Standalone [1.3] tModLoader - A Modding API

I want to trigger an event in the mod which is basically like what happens when you defeat the WoF for the first time. How do I do so?

Biomes are not yet supported. But you can set Main.hardMode = true, but that's about it.

This is not working

Here is the log :
c:\Users\Zane McGinn\Documents\My Games\Terraria\ModLoader\Mod Sources\ExampleMod\Items\HealingSword.cs(32,30) : error CS0103: The name 'ItemID' does not exist in the current context
Please help :)
Either add 'using Terraria.ID' in your file or use Terraria.ID.ItemID instead of just ItemID

I probably need FiresparkBoots.png and FiresparkBoots_Shoes.png right?
I believe so, yes. I don't have a clue what the _shoes.png would look like though.

There is still something causing the problem, I tried UpdateAccessory and UpdateEquip and also changed item.toolTip2

Maybe in this part of the code?
Code:
               player.moveSpeed *= 1.12f;
                player.iceSkate = true;
                player.waterWalk = true;
                player.waterWalk2 = true;
                player.lavaTime = 7;
                player.fireWalk = true;
                player.rocketBoots = 5;
                player.maxRunSpeed *= 1.12f;
There's nothing wrong with this code when I look at it. At least nothing that could cause a problem. Are you sure all types are correct? (you pass a bool to a bool, int to an int and float to a float)

If u wanted an accessory to have immune to knockback what would the code be ?
I think this, but I'm not sure ^^
Code:
player.noKnockback = true;
 
Biomes are not yet supported. But you can set Main.hardMode = true, but that's about it.


Either add 'using Terraria.ID' in your file or use Terraria.ID.ItemID instead of just ItemID


I believe so, yes. I don't have a clue what the _shoes.png would look like though.


There's nothing wrong with this code when I look at it. At least nothing that could cause a problem. Are you sure all types are correct? (you pass a bool to a bool, int to an int and float to a float)


I think this, but I'm not sure ^^
Code:
player.noKnockback = true;
It works, but I dont know what I did.
Next problem:
Wearing a modded balloon accessoir displays the player wearing my balloon accessory and frostspark boots im not wearing.
1o8je.png
 
It works, but I dont know what I did.
Next problem:
Wearing a modded balloon accessoir displays the player wearing my balloon accessory and frostspark boots im not wearing.
Try to restart Terraria, if not fixed can i see code?
 
How would I go about editing/removing certain drops from NPCs or looting bags? I would like to change the drop rates of a few items and remove some drops from some monsters (to be made available elsewhere).
 
Is it be possible to make a mod that can load TerrariaPatcher plugins? Compatiblity between the two would be great, I think.
At the moment, I would assume it's not easily possible. I haven't really looked into how Terraria Patcher works yet, and this mod installs by binary difference.

@bluemagic123 In future, it will be possible to create new type of damage?
That should be possible once I add support for ModPlayer classes (although it will require more programming experience then other stuff on the part of the modder).

How would I go about editing/removing certain drops from NPCs or looting bags? I would like to change the drop rates of a few items and remove some drops from some monsters (to be made available elsewhere).
I haven't really started working on NPCs in-depth yet, so at the moment the only way would be to remove all drops from the NPC and then add back just the ones you want in the way you want.
 
How to check accessory and world time with if?
if(player. ?wears? = 123)
player.AddBuff(62, 5, true);
 
How to check accessory and world time with if?
if(player. ?wears? = 123)
player.AddBuff(62, 5, true);
You can check for accessories by looping through player.equip and checking the types of the items (a future update will add an easier way). You can check the world time with Main.dayTime and Main.time.
 
You can check for accessories by looping through player.equip and checking the types of the items (a future update will add an easier way). You can check the world time with Main.dayTime and Main.time.
where do i have to use player.equip ? It says im missing an using reference
 
How to check accessory and world time with if?
if(player. ?wears? = 123)
player.AddBuff(62, 5, true);
If you have a GlobalItem instance you can do:
Code:
public override void UpdateEquip(Item item, Player player)
        {
            foreach (Item i in player.miscEquips)
            {
                if (i.name == "Name of the item" && Main.dayTime)
                {
                    player.AddBuff(62, 5, true);
                }
            }
            base.UpdateEquip(item, player);
        }
You may replace the "Name of the item" with the name of the item you wanna check, I think there is another way to check for ids but it should be harder, also time in terraria works from 0 to 24000 and then it switches Main.dayTime so if you wanna check if it is at night you can use Main.daytime.
That should work.
 
If you have a GlobalItem instance you can do:
Code:
public override void UpdateEquip(Item item, Player player)
        {
            foreach (Item i in player.miscEquips)
            {
                if (i.name == "Name of the item" && Main.dayTime)
                {
                    player.AddBuff(62, 5, true);
                }
            }
            base.UpdateEquip(item, player);
        }
You may replace the "Name of the item" with the name of the item you wanna check, I think there is another way to check for ids but it should be harder, also time in terraria works from 0 to 24000 and then it switches Main.dayTime so if you wanna check if it is at night you can use Main.daytime.
That should work.
The problem with player.miscEquips is that it's the things like pet slots, grappling slots, mount slots, etc.
 
When you get around to requests, can you please add hooks for the players inventory(OnCreation,OnDeath, OnPvpDeath) and a hook for Killing A player in Pvp.
 
The problem with player.miscEquips is that it's the things like pet slots, grappling slots, mount slots, etc.
Well im trying to make a combination of Paladin's Shield and the Frozen Turtle Shell:
zQcMg.png

Code:
using System;
using Terraria;
using Terraria.ModLoader;
using Terranova.Items;
using Terraria.ID;
using Terranova;
//using Terranova.Items.Armor;
using Terranova.NPCs;

namespace Terranova.Items
{
    public class GlobalItems : GlobalItem
    {
        public override void SetDefaults(Item item)
        {
            if (item.type == ItemID.KingSlimeMask)
            {             
                item.vanity = false;
                item.value = 10000;
                item.rare = 1;
                item.defense = 2;
                item.maxStack = 1;
            }
        }
        public override void UpdateEquip(Item item, Player player)
        {
            foreach (Item i in player.armor)
            {
                if (i.name == "PaladinsShell" && (double)player.statLife <= (double)player.statLifeMax2 * 0.5)
                {
                    player.AddBuff(62, 5, true);
                    if ((double)player.statLife > (double)player.statLifeMax2 * 0.25)
                {
                    if (i == Main.myPlayer)
                    {
                        player.paladinGive = true;
                    }
                    else if (player.miscCounter % 5 == 0)
                    {
                        int myPlayer = Main.myPlayer;
                        if (Main.player[myPlayer].team == player.team && player.team != 0)
                        {
                            float num3 = player.position.X - Main.player[myPlayer].position.X;
                            float num4 = player.position.Y - Main.player[myPlayer].position.Y;
                            float num5 = (float)Math.Sqrt((double)(num3 * num3 + num4 * num4));
                            if (num5 < 800f)
                            {
                                Main.player[myPlayer].AddBuff(43, 10, true);
                            }
                        }
                    }
                }
                player.noKnockback = true;
              
                }
            }
            base.UpdateEquip(item, player);
        }
    }
}
 
I don't necasarily want a new biome I just want to make a new mode: PreHardmode - Hardmode - Ultra Hardmode
That should be easy to do once I add support for NPCs and world hooks.

It has a size of 34, i'm sure it handles accesories, am I wrong?
Huh, according to the source code it has a size of 5. And all the accessories effects come from player.armor.

When you get around to requests, can you please add hooks for the players inventory(OnCreation,OnDeath, OnPvpDeath) and a hook for Killing A player in Pvp.
Sure, those hooks are all planned once I start making ModPlayer.

Well im trying to make a combination of Paladin's Shield and the Frozen Turtle Shell:
zQcMg.png

Code:
using System;
using Terraria;
using Terraria.ModLoader;
using Terranova.Items;
using Terraria.ID;
using Terranova;
//using Terranova.Items.Armor;
using Terranova.NPCs;

namespace Terranova.Items
{
    public class GlobalItems : GlobalItem
    {
        public override void SetDefaults(Item item)
        {
            if (item.type == ItemID.KingSlimeMask)
            {            
                item.vanity = false;
                item.value = 10000;
                item.rare = 1;
                item.defense = 2;
                item.maxStack = 1;
            }
        }
        public override void UpdateEquip(Item item, Player player)
        {
            foreach (Item i in player.armor)
            {
                if (i.name == "PaladinsShell" && (double)player.statLife <= (double)player.statLifeMax2 * 0.5)
                {
                    player.AddBuff(62, 5, true);
                    if ((double)player.statLife > (double)player.statLifeMax2 * 0.25)
                {
                    if (i == Main.myPlayer)
                    {
                        player.paladinGive = true;
                    }
                    else if (player.miscCounter % 5 == 0)
                    {
                        int myPlayer = Main.myPlayer;
                        if (Main.player[myPlayer].team == player.team && player.team != 0)
                        {
                            float num3 = player.position.X - Main.player[myPlayer].position.X;
                            float num4 = player.position.Y - Main.player[myPlayer].position.Y;
                            float num5 = (float)Math.Sqrt((double)(num3 * num3 + num4 * num4));
                            if (num5 < 800f)
                            {
                                Main.player[myPlayer].AddBuff(43, 10, true);
                            }
                        }
                    }
                }
                player.noKnockback = true;
             
                }
            }
            base.UpdateEquip(item, player);
        }
    }
}
If you're trying to give your own item effects, you don't need to use a GlobalItem class, just use your ModItem class and you won't need to check to see if the player is wearing it since tModLoader does that for you.
 
That should be easy to do once I add support for NPCs and world hooks.


Huh, according to the source code it has a size of 5. And all the accessories effects come from player.armor.


Sure, those hooks are all planned once I start making ModPlayer.


If you're trying to give your own item effects, you don't need to use a GlobalItem class, just use your ModItem class and you won't need to check to see if the player is wearing it since tModLoader does that for you.
Ok, but how do I fix this, ' i ' is not available in this context
Code:
if (i == Main.myPlayer)
                {
                    player.paladinGive = true;
                }
                else if (player.miscCounter % 5 == 0)
                {
                    int myPlayer = Main.myPlayer;
                    if (Main.player[myPlayer].team == player.team && player.team != 0)
                    {
                        float num3 = player.position.X - Main.player[myPlayer].position.X;
                        float num4 = player.position.Y - Main.player[myPlayer].position.Y;
                        float num5 = (float)Math.Sqrt((double)(num3 * num3 + num4 * num4));
                        if (num5 < 800f)
                        {
                            Main.player[myPlayer].AddBuff(43, 10, true);
                        }
                    }
                }
[DOUBLEPOST=1438554618,1438554255][/DOUBLEPOST]I could also post the whole item code, if needed
 
Back
Top Bottom