tAPI Getting Started with Modding

Status
Not open for further replies.
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?
 
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