In a GlobalNPC, use the NPCLoot hook and check npc.type against the NPCID of the npc you want to add a drop to: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/NPCs/ExampleGlobalNPC.cs#L66How do I make NPCs, modded and vanilla (primarily vanilla), drop modded items?
Awesome! Thanks.In a GlobalNPC, use the NPCLoot hook and check npc.type against the NPCID of the npc you want to add a drop to: https://github.com/bluemagic123/tModLoader/blob/master/ExampleMod/NPCs/ExampleGlobalNPC.cs#L66
If it is a ModNPC, you don't need to check against npc.type since the code is only executing for your npc.
For the ItemID, use the ItemID.??? for vanilla (check the wiki or autocomplete with Visual Studio) and mod.ItemType("?????") for modItems.
mod is a member variable of ModNPC and GlobalNPC, so they should be there unless you forgot to extend those classes.Ok, I came across a bit of a problem:
ANewBeginning.cs(22,83) : error CS0103: The name 'mod' does not exist in the current context
referencing this line of code:
Item.NewItem((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height, mod.ItemType("MasamuneBlade"), Main.rand.Next(1, 19));
I've cross-referenced it to what you linked, and the code looks the same (except item, of course). I'm not sure why it's saying this.
... oh. I did. Accidentally skipped that part. Sorry for bothering you about it, I'm still very new to C#.mod is a member variable of ModNPC and GlobalNPC, so they should be there unless you forgot to extend those classes.