tAPI Getting Started with Modding

Status
Not open for further replies.
It was at that moment I realised, I had been doing everything wrong.
 
Do you now any good C# tAPI tutorials? I would also like a tutorial on how to make a Town NPC.
 
I attempted to make something, it worked in the Compiler, but... I can't craft it in game. :(
Did you make sure the folder name is "Items" other than Item?
 
Did you make sure the folder name is "Items" other than Item?

I already got everything working, and my mod is currently W(H)IP with 17 items so far (3 accessories! YAY)
 
using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using TAPI; using Terraria; namespace berberborscing.Items { public class Modbase : ModBase //Use ModBase instead of Items. { public override void OnLoad() //This will call the code when you load up the game. { Recipe.newRecipe.createItem.SetDefaults(1309, false); //This is where the item you want to add a recipe to goes. "1309" is the ID of the Slime Staff. Recipe.newRecipe.createItem.stack = 1; //This is how many are produced by this recipe. Recipe.newRecipe.requiredItem.Add(new Item().SetDefaults(9, false)); //This is the first item used in the recipe. "9" is the ID for Wood. Recipe.newRecipe.requiredItem[0].stack = 15; //This is how much Wood we need, 15. the [0] notes that this is the first material in the recipe. Recipe.newRecipe.requiredItem.Add(new Item().SetDefaults(23, false)); //This is the second item used in the recipe. "23" is the ID for Gel. Recipe.newRecipe.requiredItem[1].stack = 80; //We need 80 Gel. The [1] means it is the second material in the recipe. It goes up from there. Recipe.newRecipe.requiredItem.Add(new Item().SetDefaults(29, false)); //"29" is the ID for Life Crystal. Get it now? Recipe.newRecipe.requiredItem[2].stack = 1; //We need 1 Heart Crystal. Recipe.newRecipe.requiredTile.Add(18); //This is where the crafting station you need goes. "18" is the ID for the Work Bench. Recipe.AddRecipe(); //This tidbit of code adds the recipe into the game. } } }

Can I put multiple New Item recipes in here?
 
Can I put multiple New Item recipes in here?
I'm not completely sure, but are you using that to make the recipe for your mod items?
 
I'm not completely sure, but are you using that to make the recipe for your mod items?

No. I'm adding a new rec... holy crap, I made a terrible mistake.
 
Never mind, I thought I'd replaced the recipe for mechanical worm. Only added a new one! :D
Oh okay, but if you're using the code for a recipe for non-mod items then just copy and make a new one for each item. I guess.
 
I don't put projectiles in the Items folder, where do I put them?
 
In the "Projectiles" folder.

Which would be "next to" the Items folder (in the same folder as it), correct? Also, how do I make something drop from a mob?
 
Which would be "next to" the Items folder (in the same folder as it), correct? Also, how do I make something drop from a mob?
Yes, in the same folder the "Items" folder is on. What kind of mob? A vanilla one, or a modded one?
 
How would i go about making a boomerang that acts like the razorblaze? Meaning like i would throw it and it would bounce to enemies and return to me? And if it could have the effect like shadow armor when it moves, is that possible?
 
Save this as MNPC.cs in the same folder as "ModInfo.json"
Replace Internal Mod Name with your mod's internal name. (Can be found in ModInfo) And ItemName with the name of the item you are making it drop.
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Terraria;
using TAPI;

namespace InternalModName
{
    [GlobalMod]
    public class MNPC : ModNPC
    {
        public override void PostNPCLoot()
        {
                if(npc.type == 3) //Replace the number with the ID of the mob you are making drop from. Separate numbers with " || "
            {
                if(Main.rand.Next(1, 100) == 1) //Chance of the item dropping. In this case, 1 in 100 chance
                {
                    Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width / 2, npc.height / 2, ItemDef.byName["InternalModName:ItemName"].type, 1, false, 0);
                }
            }
    }
    }
}
Here are 2 websites with NPC IDs:
http://terraria.wiki.gg/Data_IDs#NPC_IDs
http://dev.willhuxtable.com/ids/#npc

How would i go about making a boomerang that acts like the razorblaze? Meaning like i would throw it and it would bounce to enemies and return to me? And if it could have the effect like shadow armor when it moves, is that possible?
Save this as "ItemName.cs" in the same folder as the armor.
Replace Internal Mod Name with your mod's internal name. (Can be found in ModInfo) And ItemName with the name of the chestplate.
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using TAPI;
using Terraria;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace InternalModName.Items
{
    public class ItemName : ModItem
    {
        public override void ArmorSetBonus(Player p)
        {
            p.drawAura = true; //Pulsating Effect
            p.drawAfterimage = true; //Afterimage
        }
       
    }
}
 
Status
Not open for further replies.
Back
Top Bottom