huntermangus70
Terrarian
Hi I'm new if you couldn't tell by the question. I'm wondering how to add a drop to an npc already in Terraria. Any help is appreciated.
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace <modname>
{
public class ModGlobalNPC : GlobalNPC
{
public override void NPCLoot(NPC npc)
{
//The if (Main.rand.Next(x) == 0) determines how rare the drop is. To find the percent of a drop, divide 100 by your desired percent, minus the percent sign. Ex: A 2% chance would be 100% / 2%, or 50. This is what you put in place of x.
if (Main.rand.Next(50) == 0) //2% chance
{
if (<npc.type(<npcname>)
{
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, <If using a Vanilla item, ItemID.<itemid>. If using a modded item, mod.ItemType("mod item id")>);
}
}
}
}
}
if (<npc.type(<npcname>)
Actually this line doesn't doesn't make sense could you make a working example of this one line... (I can't get it to work because I'm not really understanding what you want me to put in place of the <> statements)
P.S. the parenthesis () are not balanced in it either.
if (npc.type == NPCID.BlackRecluse)
So if you wanted to modify multiple Vanilla NPC's world you just keep adding to this code or would you make a different class every timeI messed up on the main post, sorry.Code:if (npc.type == NPCID.BlackRecluse)
You would keep adding if statements into NPCLoot, one for each enemy.So if you wanted to modify multiple Vanilla NPC's world you just keep adding to this code or would you make a different class every time