Standalone [1.3] tModLoader - A Modding API

I still have no clue if the reason I cant get tmodloader to run anymore has to do with me making steam steam2 after reinstalling
 
Guys, I have a very annoying problem. Whenever I try to give an NPC a Cursed Skull AI, it just stays on the ground. Same for all the other floating AIs, such as the Demon Eye AI, ect. I feel like this might be the sprite, but im not sure. Here's the code of my NPC.

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Drakus.NPCs
{
    public class ForestSkull : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Skull of the Forest";
            npc.displayName = "Skull of the Forest";
            npc.width = 26;
            npc.height = 28;
            npc.damage = 35;
            npc.defense = 12;
            npc.lifeMax = 250;
            npc.HitSound = SoundID.NPCHit2;
            npc.DeathSound = SoundID.NPCDeath3;
            npc.value = 37f;
            npc.knockBackResist = 0.6f;
            npc.aiStyle = 10;
            Main.npcFrameCount[npc.type] = 3;
            aiType = 10;
            animationType = 10;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            if(NPC.downedBoss1);
            return SpawnCondition.OverworldNightMonster.Chance * 1.5f;
        }

        public override void HitEffect(int hitDirection, double damage)
        {
            if (npc.life <= 0)          //this make so when the npc has 0 life(dead) he will spawn this
            {
                Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ForestSkullGore1"), 1f);   //make sure you put the right folder name where your gores is located and the right name of gores
                Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ForestSkullGore2"), 1f);     // 1f is the gore sprite size, you can change it but i suggest to keep it to 1f
            }
        }

        public override void NPCLoot()
        {
            if (Main.rand.Next(5) == 0)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Bone, Main.rand.Next(1, 2));
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Vine, Main.rand.Next(0, 1));
            }
        }      
    }
}

All help would be appriciated!
 
i am unable to load up a multiplayer game whenever i try to it gets stuck at "Starting server" any fix? on a mac btw
 
Last edited:
Guys, I have a very annoying problem. Whenever I try to give an NPC a Cursed Skull AI, it just stays on the ground. Same for all the other floating AIs, such as the Demon Eye AI, ect. I feel like this might be the sprite, but im not sure. Here's the code of my NPC.

Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Drakus.NPCs
{
    public class ForestSkull : ModNPC
    {
        public override void SetDefaults()
        {
            npc.name = "Skull of the Forest";
            npc.displayName = "Skull of the Forest";
            npc.width = 26;
            npc.height = 28;
            npc.damage = 35;
            npc.defense = 12;
            npc.lifeMax = 250;
            npc.HitSound = SoundID.NPCHit2;
            npc.DeathSound = SoundID.NPCDeath3;
            npc.value = 37f;
            npc.knockBackResist = 0.6f;
            npc.aiStyle = 10;
            Main.npcFrameCount[npc.type] = 3;
            aiType = 10;
            animationType = 10;
        }

        public override float CanSpawn(NPCSpawnInfo spawnInfo)
        {
            if(NPC.downedBoss1);
            return SpawnCondition.OverworldNightMonster.Chance * 1.5f;
        }

        public override void HitEffect(int hitDirection, double damage)
        {
            if (npc.life <= 0)          //this make so when the npc has 0 life(dead) he will spawn this
            {
                Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ForestSkullGore1"), 1f);   //make sure you put the right folder name where your gores is located and the right name of gores
                Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/ForestSkullGore2"), 1f);     // 1f is the gore sprite size, you can change it but i suggest to keep it to 1f
            }
        }

        public override void NPCLoot()
        {
            if (Main.rand.Next(5) == 0)
            {
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Bone, Main.rand.Next(1, 2));
                Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, ItemID.Vine, Main.rand.Next(0, 1));
            }
        }     
    }
}

All help would be appriciated!
You probably want to add 'npc.noGravity = true;' to set defaults. You may also want 'npc.noTileCollide = true;' if you want it to pass through the landscape.
 
so I am having trouble with my new sword and I am getting these errors
\Documents\My Games\Terraria\ModLoader\Mod Sources\NewEvils\Items\DarkBlade.cs(1,15) : error CS1002: ; expected
Documents\My Games\Terraria\ModLoader\Mod Sources\NewEvils\Items\DarkBlade.cs(37,9) : error CS1585: Member modifier 'override' must precede the member type and name
I don't get what is wrong heres my code (I know about the comments)
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace NewEvils.Items         //The directory for your .cs and .png; Example: Mod Sources/TutorialMOD/Items
{
    public class DarkBlade : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Dark Blade";     //the name displayed when hovering over the Weapon ingame.
            item.damage = 124;     //The damage stat for the Weapon.
            item.melee = true;      //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
            item.width = 85;   //The size of the width of the hitbox in pixels.
            item.height = 85;  //The size of the height of the hitbox in pixels.
            item.toolTip = "The power of dakrness";    //The description of the Weapon shown when hovering over the Weapon ingame.
            item.useTime = 20;   //How fast the Weapon is used.
            item.useAnimation = 20;     //How long the Weapon is used for.
            item.useStyle = 1;            //The way your Weapon will be used, 1 is the regular sword swing for example
            item.knockBack = 6;  //The knockback stat of your Weapon.
            item.value = Item.buyPrice(0, 0, 25, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
            item.rare = 5;    //The color the title of your Weapon when hovering over it ingame
            item.UseSound = SoundID.Item1;   //The sound played when using your Weapon
            item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
        }
        public override void AddRecipes()
        {                                        //this is how to craft this item
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);      //this is how to add an ingredient from Terraria,  so for crafting this item you need 10 Dirt Block       
            recipe.AddTile(TileID.WorkBenches);  //this is where to craft the item ,WorkBenches = all WorkBenches    Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
 
so I am having trouble with my new sword and I am getting these errors
\Documents\My Games\Terraria\ModLoader\Mod Sources\NewEvils\Items\DarkBlade.cs(1,15) : error CS1002: ; expected
Documents\My Games\Terraria\ModLoader\Mod Sources\NewEvils\Items\DarkBlade.cs(37,9) : error CS1585: Member modifier 'override' must precede the member type and name
I don't get what is wrong heres my code (I know about the comments)
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace NewEvils.Items         //The directory for your .cs and .png; Example: Mod Sources/TutorialMOD/Items
{
    public class DarkBlade : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Dark Blade";     //the name displayed when hovering over the Weapon ingame.
            item.damage = 124;     //The damage stat for the Weapon.
            item.melee = true;      //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
            item.width = 85;   //The size of the width of the hitbox in pixels.
            item.height = 85;  //The size of the height of the hitbox in pixels.
            item.toolTip = "The power of dakrness";    //The description of the Weapon shown when hovering over the Weapon ingame.
            item.useTime = 20;   //How fast the Weapon is used.
            item.useAnimation = 20;     //How long the Weapon is used for.
            item.useStyle = 1;            //The way your Weapon will be used, 1 is the regular sword swing for example
            item.knockBack = 6;  //The knockback stat of your Weapon.
            item.value = Item.buyPrice(0, 0, 25, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
            item.rare = 5;    //The color the title of your Weapon when hovering over it ingame
            item.UseSound = SoundID.Item1;   //The sound played when using your Weapon
            item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
        }
        public override void AddRecipes()
        {                                        //this is how to craft this item
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);      //this is how to add an ingredient from Terraria,  so for crafting this item you need 10 Dirt Block      
            recipe.AddTile(TileID.WorkBenches);  //this is where to craft the item ,WorkBenches = all WorkBenches    Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
This is all fine, you sure this is the exact file it is complaining about?
 
so I am having trouble with my new sword and I am getting these errors
\Documents\My Games\Terraria\ModLoader\Mod Sources\NewEvils\Items\DarkBlade.cs(1,15) : error CS1002: ; expected
Documents\My Games\Terraria\ModLoader\Mod Sources\NewEvils\Items\DarkBlade.cs(37,9) : error CS1585: Member modifier 'override' must precede the member type and name
I don't get what is wrong heres my code (I know about the comments)
Code:
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace NewEvils.Items         //The directory for your .cs and .png; Example: Mod Sources/TutorialMOD/Items
{
    public class DarkBlade : ModItem
    {
        public override void SetDefaults()
        {
            item.name = "Dark Blade";     //the name displayed when hovering over the Weapon ingame.
            item.damage = 124;     //The damage stat for the Weapon.
            item.melee = true;      //This defines if it does Melee damage and if its effected by Melee increasing Armor/Accessories.
            item.width = 85;   //The size of the width of the hitbox in pixels.
            item.height = 85;  //The size of the height of the hitbox in pixels.
            item.toolTip = "The power of dakrness";    //The description of the Weapon shown when hovering over the Weapon ingame.
            item.useTime = 20;   //How fast the Weapon is used.
            item.useAnimation = 20;     //How long the Weapon is used for.
            item.useStyle = 1;            //The way your Weapon will be used, 1 is the regular sword swing for example
            item.knockBack = 6;  //The knockback stat of your Weapon.
            item.value = Item.buyPrice(0, 0, 25, 0); // How much the item is worth, in copper coins, when you sell it to a merchant. It costs 1/5th of this to buy it back from them. An easy way to remember the value is platinum, gold, silver, copper or PPGGSSCC (so this item price is 10gold)
            item.rare = 5;    //The color the title of your Weapon when hovering over it ingame
            item.UseSound = SoundID.Item1;   //The sound played when using your Weapon
            item.autoReuse = true; //Weather your Weapon will be used again after use while holding down, if false you will need to click again after use to use it again.
        }
        public override void AddRecipes()
        {                                        //this is how to craft this item
            ModRecipe recipe = new ModRecipe(mod);
            recipe.AddIngredient(ItemID.DirtBlock, 10);      //this is how to add an ingredient from Terraria,  so for crafting this item you need 10 Dirt Block      
            recipe.AddTile(TileID.WorkBenches);  //this is where to craft the item ,WorkBenches = all WorkBenches    Anvils = all anvils , MythrilAnvil = Mythril Anvil and Orichalcum Anvil, Furnaces = all furnaces , DemonAltar = Demon Altar and Crimson Altar , TinkerersWorkbench = Tinkerer's Workbench
            recipe.SetResult(this);
            recipe.AddRecipe();
        }
    }
}
Yes this is the file its complaining about. I tried removing the item from items but it kept complaining about it.
 
I've got a small bug. When I'm not in a world, I consistently get small lag spikes around every second. I don't know how else to explain it. Any ideas? I've confirmed it's not a mod problem and I'm using 0.9.2.3. This bug was also present in 0.9.2.2.
EDIT: I've found that this is a bug with my Terraria, not tModLoader (or so I assume). Sorry to bother you!
 
Last edited:
Guys i have a problem.
I just logged in my world and all of my modded items are gone. My inventory still has the modded items but everything modded in my world is gone. Is there a fix for this?
 
I may've found two bugs.

1. Buying stacks of multiple items (which were sold to NPCs) will only decrease the stack quantity by one.
2. When build/reloading all, you can get dependency errors from mods which aren't loaded.

These may be caused by the mods I'm using.
 
1. Buying stacks of multiple items (which were sold to NPCs) will only decrease the stack quantity by one.
That's not a tModLoader bug, it isn't even a bug at all, it's intentionally made to be that way by Terraria developers. Left-click to buy one item; right-click to buy many.
 
That's not a tModLoader bug, it isn't even a bug at all, it's intentionally made to be that way by Terraria developers. Left-click to buy one item; right-click to buy many.

I get what you're saying. I mean if you buy a whole stack at once, it'll only reduce the shop amount by one.

I.e. if you sell 7 dirt to the merchant, and then buy it all at once, there will still be 6 dirt in the shop.
 
Hey, I'm currently working on a mod that adds more NPCs with my friend. I am adding an NPC called the Miner that sells ores. I want to include hardmode ores that can only be purchased during hardmode. I don't know whether I should make the NPC move in during hardmode (which I can easily do) or make it sell hardmode ores during hardmode, which I have no idea how to do. If you know how to make hardmode-only items could you please send me a script of a shop with hardmode-only items? It would be appreciated. Thanks.

Edit: I decided to go with the NPC moving in during hardmode as it ruins the fun of exploring the underground and searching for ores. However, I am having an issue with my sprite. I used a guide sprite to start out with, which has 26 frames, and because its based off the guide sprite, the attack frames are meant for a bow. How do I make my NPC hold a bow instead of a sword? I tried changing the attack type to shooting, but all my NPC does is hold out his hands as if he is carrying an invisible bow, yet he doesn't do any damage.
 
how do you make it so your mob/NPC uses a separate frame/sprite when shooting a projectile? I just need to see an code example.
 
Back
Top Bottom