tModLoader Beginner modder needing help

natee_99

Terrarian
Hi, I have recently got into coding and modding Terraria, and have gone through basic tutorials using Mods such as Example Mod, editing items in that. I want to change vanilla items/NPCs but I can't figure out or find how to do that. To give an example, one thing I would like to do is make Pumpking drop Spooky Wood on death. I have heard of things like GlobalNPC in forums but don't know where to find that/edit it. Any help would be super appreciated!
 
This is a bit of a late response, but oh well.
the GlobalNPC from my understanding is basically like the file for any normal NPC, except it runs for every NPC. If you don't already have a GlobalNPC file in your mod, you'd have to create one.
So to edit a specific NPC you'd just need to include an if (type == NPCID.name) statement.

Here's an example that I think would work for your example. (I haven't actually tested the code tho)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
//I have absolutely no idea how many of the above are actually needed.

namespace YourMod.NPCs //Or whatever the namespace is
{
    public class ExampleGlobalNPC : GlobalNPC
    {
        public override void NPCLoot()
        {
            if (type == NPCID.Pumpking)
            {
                Item.NewItem(npc.getRect(), ItemID.SpookyWood, Main.rand.Next(20, 100));
            }
        }
    }
}
 
Back
Top Bottom