1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
4using System.Collections.Generic;
30 internal int instanceIndex;
37 public virtual bool Autoload(ref
string name) {
77 copy.instanceIndex = instanceIndex;
109 public virtual bool PreAI(NPC npc) {
117 public virtual void AI(NPC npc) {
132 public virtual void FindFrame(NPC npc,
int frameHeight) {
141 public virtual void HitEffect(NPC npc,
int hitDirection,
double damage) {
200 public virtual void OnCatchNPC(NPC npc, Player player, Item item) {
210 public virtual bool CanHitPlayer(NPC npc, Player target, ref
int cooldownSlot) {
221 public virtual void ModifyHitPlayer(NPC npc, Player target, ref
int damage, ref
bool crit) {
231 public virtual void OnHitPlayer(NPC npc, Player target,
int damage,
bool crit) {
252 public virtual void ModifyHitNPC(NPC npc, NPC target, ref
int damage, ref
float knockback, ref
bool crit) {
263 public virtual void OnHitNPC(NPC npc, NPC target,
int damage,
float knockback,
bool crit) {
286 public virtual void ModifyHitByItem(NPC npc, Player player, Item item, ref
int damage, ref
float knockback, ref
bool crit) {
298 public virtual void OnHitByItem(NPC npc, Player player, Item item,
int damage,
float knockback,
bool crit) {
320 public virtual void ModifyHitByProjectile(NPC npc, Projectile projectile, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection) {
331 public virtual void OnHitByProjectile(NPC npc, Projectile projectile,
int damage,
float knockback,
bool crit) {
344 public virtual bool StrikeNPC(NPC npc, ref
double damage,
int defense, ref
float knockback,
int hitDirection, ref
bool crit) {
378 public virtual Color?
GetAlpha(NPC npc, Color drawColor) {
397 public virtual bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor) {
407 public virtual void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor) {
427 public virtual bool?
DrawHealthBar(NPC npc,
byte hbPosition, ref
float scale, ref Vector2 position) {
437 public virtual void EditSpawnRate(Player player, ref
int spawnRate, ref
int maxSpawns) {
448 public virtual void EditSpawnRange(Player player, ref
int spawnRangeX, ref
int spawnRangeY,
449 ref
int safeRangeX, ref
int safeRangeY) {
466 public virtual void SpawnNPC(
int npc,
int tileX,
int tileY) {
483 public virtual void GetChat(NPC npc, ref
string chat) {
510 public virtual void SetupShop(
int type, Chest shop, ref
int nextSlot) {
544 public virtual void BuffTownNPC(ref
float damageMult, ref
int defense) {
582 ref
float randomOffset) {
617 public virtual void DrawTownAttackGun(NPC npc, ref
float scale, ref
int item, ref
int closeness) {
628 public virtual void DrawTownAttackSwing(NPC npc, ref Texture2D item, ref
int itemSize, ref
float scale, ref Vector2 offset) {
This class allows you to modify and use hooks for all NPCs, including vanilla mobs....
virtual GlobalNPC Clone()
Returns a clone of this GlobalNPC. By default this will return a memberwise clone; you will want to o...
virtual void TownNPCAttackMagic(NPC npc, ref float auraLightMultiplier)
Allows you to control the brightness of the light emitted by a town NPC's aura when it performs a mag...
virtual bool CanHitPlayer(NPC npc, Player target, ref int cooldownSlot)
Allows you to determine whether an NPC can hit the given player. Return false to block the NPC from h...
virtual ? bool CanBeHitByItem(NPC npc, Player player, Item item)
Allows you to determine whether an NPC can be hit by the given melee weapon when swung....
virtual void DrawBehind(NPC npc, int index)
When used in conjunction with "npc.hide = true", allows you to specify that this npc should be drawn ...
virtual ? bool DrawHealthBar(NPC npc, byte hbPosition, ref float scale, ref Vector2 position)
Allows you to control how the health bar for the given NPC is drawn. The hbPosition parameter is the ...
virtual void BossHeadRotation(NPC npc, ref float rotation)
Allows you to customize the rotation of an NPC's boss head icon on the map.
virtual void OnHitByItem(NPC npc, Player player, Item item, int damage, float knockback, bool crit)
Allows you to create special effects when an NPC is hit by a melee weapon.
virtual ? Color GetAlpha(NPC npc, Color drawColor)
Allows you to determine the color and transparency in which an NPC is drawn. Return null to use the d...
virtual void BossHeadSlot(NPC npc, ref int index)
Allows you to customize the boss head texture used by an NPC based on its state. Set index to -1 to s...
virtual void TownNPCAttackStrength(NPC npc, ref int damage, ref float knockback)
Allows you to determine the damage and knockback of a town NPC's attack before the damage is scaled....
virtual void SetupTravelShop(int[] shop, ref int nextSlot)
Allows you to add items to the traveling merchant's shop. Add an item by setting shop[nextSlot] to th...
virtual bool StrikeNPC(NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
Allows you to use a custom damage formula for when an NPC takes damage from any source....
virtual ? bool CanChat(NPC npc)
Allows you to determine whether this NPC can talk with the player. Return true to allow talking with ...
virtual void OnHitPlayer(NPC npc, Player target, int damage, bool crit)
Allows you to create special effects when an NPC hits a player (for example, inflicting debuffs).
virtual void TownNPCAttackSwing(NPC npc, ref int itemWidth, ref int itemHeight)
Allows you to determine the width and height of the item a town NPC swings when it attacks,...
virtual void SetupShop(int type, Chest shop, ref int nextSlot)
Allows you to add items to an NPC's shop. The type parameter is the type of the NPC that this shop be...
virtual bool PreDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
Allows you to draw things behind an NPC, or to modify the way the NPC is drawn. Return false to stop ...
virtual void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
Allows you to modify the chance of NPCs spawning around the given player and the maximum number of NP...
virtual bool CheckActive(NPC npc)
Whether or not to run the code for checking whether an NPC will remain active. Return false to stop t...
virtual void GetChat(NPC npc, ref string chat)
Allows you to modify the chat message of any NPC that the player can talk to.
virtual void UpdateLifeRegen(NPC npc, ref int damage)
Allows you to make the NPC either regenerate health or take damage over time by setting npc....
Mod mod
The mod to which this GlobalNPC belongs.
virtual bool Autoload(ref string name)
Allows you to automatically load a GlobalNPC instead of using Mod.AddGlobalNPC. Return true to allow ...
virtual void PostAI(NPC npc)
Allows you to determine how any NPC behaves. This will be called regardless of what PreAI returns.
virtual void ResetEffects(NPC npc)
This is where you reset any fields you add to your subclass to their default states....
virtual void OnChatButtonClicked(NPC npc, bool firstButton)
Allows you to make something happen whenever a button is clicked on this NPC's chat window....
virtual bool InstancePerEntity
Whether to create a new GlobalNPC instance for every NPC that exists. Useful for storing information ...
virtual void TownNPCAttackProjSpeed(NPC npc, ref float multiplier, ref float gravityCorrection, ref float randomOffset)
Allows you to determine the speed at which a town NPC throws a projectile when it attacks....
GlobalNPC Instance(NPC npc)
virtual void SpawnNPC(int npc, int tileX, int tileY)
Allows you to customize an NPC (for example, its position or ai array) after it naturally spawns and ...
virtual void ModifyHitPlayer(NPC npc, Player target, ref int damage, ref bool crit)
Allows you to modify the damage, etc., that an NPC does to a player.
virtual void ModifyHitByItem(NPC npc, Player player, Item item, ref int damage, ref float knockback, ref bool crit)
Allows you to modify the damage, knockback, etc., that an NPC takes from a melee weapon.
virtual ? bool CanHitNPC(NPC npc, NPC target)
Allows you to determine whether an NPC can hit the given friendly NPC. Return true to allow hitting t...
virtual bool PreNPCLoot(NPC npc)
Allows you to determine whether or not the NPC will drop anything at all. Return false to stop the NP...
virtual void PostDraw(NPC npc, SpriteBatch spriteBatch, Color drawColor)
Allows you to draw things in front of this NPC. This method is called even if PreDraw returns false.
virtual void TownNPCAttackShoot(NPC npc, ref bool inBetweenShots)
Allows you to tell the game that a town NPC has already created a projectile and will still create mo...
virtual void EditSpawnRange(Player player, ref int spawnRangeX, ref int spawnRangeY, ref int safeRangeX, ref int safeRangeY)
Allows you to modify the range at which NPCs can spawn around the given player. The spawnRanges deter...
virtual bool PreChatButtonClicked(NPC npc, bool firstButton)
Allows you to determine if something can happen whenever a button is clicked on this NPC's chat windo...
virtual void BossHeadSpriteEffects(NPC npc, ref SpriteEffects spriteEffects)
Allows you to flip an NPC's boss head icon on the map.
virtual void OnHitByProjectile(NPC npc, Projectile projectile, int damage, float knockback, bool crit)
Allows you to create special effects when an NPC is hit by a projectile.
virtual void ScaleExpertStats(NPC npc, int numPlayers, float bossLifeScale)
Allows you to customize an NPC's stats in expert mode.
virtual void DrawTownAttackSwing(NPC npc, ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
Allows you to customize how a town NPC's weapon is drawn when the NPC is swinging it (the NPC must ha...
string Name
The name of this GlobalNPC instance.
virtual void AI(NPC npc)
Allows you to determine how any NPC behaves. This will only be called if PreAI returns true.
virtual void OnCatchNPC(NPC npc, Player player, Item item)
Allows you to make things happen when an NPC is caught. Ran Serverside.
virtual void ModifyHitByProjectile(NPC npc, Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
Allows you to modify the damage, knockback, etc., that an NPC takes from a projectile.
virtual void DrawEffects(NPC npc, ref Color drawColor)
Allows you to add special visual effects to an NPC (such as creating dust), and modify the color in w...
virtual ? bool CanBeHitByProjectile(NPC npc, Projectile projectile)
Allows you to determine whether an NPC can be hit by the given projectile. Return true to allow hitti...
virtual void ModifyHitNPC(NPC npc, NPC target, ref int damage, ref float knockback, ref bool crit)
Allows you to modify the damage, knockback, etc., that an NPC does to a friendly NPC.
virtual void BuffTownNPC(ref float damageMult, ref int defense)
Allows you to modify the stats of town NPCs. Useful for buffing town NPCs when certain bosses are def...
virtual void SetDefaults(NPC npc)
Allows you to set the properties of any and every NPC that gets created.
virtual void DrawTownAttackGun(NPC npc, ref float scale, ref int item, ref int closeness)
Allows you to customize how a town NPC's weapon is drawn when the NPC is shooting (the NPC must have ...
virtual bool CloneNewInstances
Whether instances of this GlobalNPC are created through Clone or constructor (by default implementati...
virtual void OnGoToStatue(NPC npc, bool toKingStatue)
Allows you to make things happen when this NPC teleports to a King or Queen statue....
virtual GlobalNPC NewInstance(NPC npc)
Create a new instance of this GlobalNPC for an NPC instance. Called at the end of NPC....
virtual bool PreAI(NPC npc)
Allows you to determine how any NPC behaves. Return false to stop the vanilla AI and the AI hook from...
virtual void NPCLoot(NPC npc)
Allows you to make things happen when an NPC dies (for example, dropping items and setting ModWorld f...
virtual void EditSpawnPool(IDictionary< int, float > pool, NPCSpawnInfo spawnInfo)
Allows you to control which NPCs can spawn and how likely each one is to spawn. The pool parameter ma...
virtual bool SpecialNPCLoot(NPC npc)
Allows you to call NPCLoot on your own when the NPC dies, rather then letting vanilla call it on its ...
virtual void TownNPCAttackCooldown(NPC npc, ref int cooldown, ref int randExtraCooldown)
Allows you to determine the cooldown between each of a town NPC's attack. The cooldown will be a numb...
virtual ? bool CanGoToStatue(NPC npc, bool toKingStatue)
Whether this NPC can be telported a King or Queen statue. Return true to allow the NPC to teleport to...
virtual void FindFrame(NPC npc, int frameHeight)
Allows you to modify the frame from an NPC's texture that is drawn, which is necessary in order to an...
virtual void HitEffect(NPC npc, int hitDirection, double damage)
Allows you to make things happen whenever an NPC is hit, such as creating dust or gores....
virtual void TownNPCAttackProj(NPC npc, ref int projType, ref int attackDelay)
Allows you to determine the projectile type of a town NPC's attack, and how long it takes for the pro...
virtual bool CheckDead(NPC npc)
Whether or not an NPC should be killed when it reaches 0 health. You may program extra effects in thi...
virtual void OnHitNPC(NPC npc, NPC target, int damage, float knockback, bool crit)
Allows you to create special effects when an NPC hits a friendly NPC.
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...
A struct that stores information regarding where an NPC is naturally spawning and the player it is sp...