public virtual void UpdateSpawnRate(Player player)
Allows you to change the spawn rate and spawn cap. I recommend using this only for a class with the GlobalMod attribute.
public virtual System.Collections.Generic.List<int> EditSpawnPool(int x, int y, System.Collections.Generic.List<int> pool, Player player)
You can modify the "pool" list to determine the possible NPCs that can spawn. Again, I only recommend this for a GlobalMod class.
public virtual bool CanSpawn(int x, int y, int type, Player spawnedOn)
Lets you determine the conditions under which an NPC can spawn. "type" is the type of the NPC that this method is getting called for.
public virtual bool CanTownNPCSpawn()
Lets you determine the conditions required for a town NPC to spawn.
public virtual void OnSpawn()
If you want your mod to be server-compatible, I don't recommend using this.
public virtual string CheckConditions(int minX, int maxX, int minY, int maxY)
I've never actually used this yet, so I don't know what it does.
public virtual bool PreAI()
Lets you do AI stuff before the main AI is called. Also lets you determine whether the AI should run at all; if you return false then the normal AI will not run. By default it will return true.
public virtual void AI()
This is where you put all your main AI stuff. Not called if PreAI returns false.
public virtual void PostAI()
This is where you put AI stuff that happens after the main AI. Note that this will always run no matter what PreAI returns.
public virtual void SetupLootRules(NPC npc)
Allows you to determine what will happen when the NPC dies. For a full explanation you'll need to see the TAPI.LootRule class in the source code.
public virtual bool PreNPCLoot()
An alternative to determine what happens when the NPC dies. It's easier to learn than LootRules but more tedious to use. Returns true if NPCLoot should be called, return false to stop NPCLoot from running.
public virtual void NPCLoot()
This gets called when the NPC dies and PreNPCLoot returns true. To make items drop you'll have to use Item.NewItem.
public virtual void PostNPCLoot()
This gets called when the NPC dies after everything else gets called, regardless of what PreNPCLoot returns.
public virtual void ItemsDropped(System.Collections.Generic.List<Item> items)
Huh, I never actually new this existed. It sounds way easier than the alternatives listed above. Not as much freedom though.
public virtual void SelectFrame(int frameSize)
Modify npc.frame.Y here to run your NPC's animations.
public virtual void HitEffect(int hitDirection, double damage, bool isDead)
This gets called whenever the NPC gets damaged. It's normally used to make dust and gores.
public virtual void DamagePlayer(Player player, int hitDir, ref int damage, ref bool crit, ref float critChance)
This lets you modify the damage dealt to a player and the crit chance against a player. It also lets you set 100% crits under certain conditions.
public virtual void DealtPlayer(Player player, int hitDir, int dmgDealt, bool crit)
This gets called when the NPC actually damages the player. I personally use it for things like inflicting debuffs.
public virtual void DamageNPC(Player player, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
You can use this to modify the damage a player does to this NPC. You can also modify the knockback and the critical hit multiplier, and change whether or not it's a critical hit.
public virtual void DealtNPC(Player player, int hitDir, int dmgDealt, float knockback, bool crit)
This gets called whenever a player damages this NPC.
public virtual void DamageNPC(Projectile projectile, int hitDir, ref int damage, ref float knockback, ref bool crit, ref float critMult)
Same as the above ones except for a projectile damaging this NPC.
public virtual void DealtNPC(Projectile projectile, int hitDir, int dmgDealt, float knocback, bool crit)
Same as the above ones except for a projectile damaging this NPC.
public virtual bool? CanHitPlayer(Player player)
Whether or not this NPC can damage the player. Return false if it can't, true if it always will, and null for to let other sources decide. (If everything returns null then it counts as true.)
public virtual bool? CanHitNPC(Player player)
Same as above, except for whether the player can damage this NPC.
public virtual bool? CanHitFriendNPC(NPC npc)
I've never actually used this; I assume it's for things like critters and town NPCs?
public virtual bool PreDraw(SpriteBatch sb)
Here you can draw stuff that is behind the NPC, such as Pumpking's cloak. If you return false, then the NPC itself will not be drawn.
public virtual void PostDraw(SpriteBatch sb)
Here you can draw stuff in front of the NPC. It will always be called even if PreDraw returns false.
public virtual void DrawMapIcon(SpriteBatch sb, Vector2 drawPosition, float scale, Color color, ref string cursorText)
I've never actually used this. I'm not sure what it does.
public virtual Color ModifyDrawColor(Color color)
Let's you determine the shade of color that the NPC should be drawn in. The parameter is a combination of the lighting color and the colors resulting from (de)buffs.
public virtual string SetName()
Returns a string that will be the town NPC's name.
public virtual string SetChat()
Returns a string which is what the town NPC will say when you talk to him/her.
public virtual string PostSetChat(string chat)
This gets called after SetChat. The parameter is what you chose for the NPC to say.
public virtual void SetupShop(Chest chest, ref int index)
I've never used anything related to shops yet, but other people know how to use it. If you need help feel free to ask.
public virtual bool ResetShop(Chest chest)
public virtual void PostSetupShop(Chest chest, ref int lastIndex)
public virtual void PostSetupTravelShop(int[] shop, ref int lastIndex)
public virtual void SetChatButtons(ref string[] buttons)
You can modify the list of strings to determine the buttons that appear in the chat window. For example, the guide has a "Crafting" button, the old man has a "Curse" button, and many people have "Shop" buttons.
public virtual void OnChatButtonClicked(string[] buttons, int buttonIndex, ref bool openShop)
This lets you determine what happens when a chat button is clicked. You can modify openShop to determine whether or not the button opens a shop.