tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.GlobalNPC Class Reference

This class allows you to modify and use hooks for all NPCs, including vanilla mobs. Create an instance of an overriding class then call Mod.AddGlobalNPC to use this. More...

+ Collaboration diagram for Terraria.ModLoader.GlobalNPC:

Public Member Functions

virtual void AI (NPC npc)
 Allows you to determine how any NPC behaves. This will only be called if PreAI returns true. More...
 
virtual bool Autoload (ref string name)
 Allows you to automatically load a GlobalNPC instead of using Mod.AddGlobalNPC. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name. More...
 
virtual void BossHeadRotation (NPC npc, ref float rotation)
 Allows you to customize the rotation of an NPC's boss head icon on the map. More...
 
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 stop the texture from being displayed. More...
 
virtual void BossHeadSpriteEffects (NPC npc, ref SpriteEffects spriteEffects)
 Allows you to flip an NPC's boss head icon on the map. More...
 
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 defeated, etc. More...
 
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. Return true to allow hitting the NPC, return false to block hitting the NPC, and return null to use the vanilla code for whether the NPC can be hit. Returns null by default. More...
 
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 hitting the NPC, return false to block hitting the NPC, and return null to use the vanilla code for whether the NPC can be hit. Returns null by default. More...
 
virtual ? bool CanChat (NPC npc)
 Allows you to determine whether this NPC can talk with the player. Return true to allow talking with the player, return false to block this NPC from talking with the player, and return null to use the vanilla code for whether the NPC can talk. Returns null by default. More...
 
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 the statue, return false to block this NPC from teleporting to the statue, and return null to use the vanilla code for whether the NPC can teleport to the statue. Returns null by default. More...
 
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 the target, return false to block the NPC from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default. More...
 
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 hitting the target. Returns true by default. CooldownSlot determines which of the player's cooldown counters to use (-1, 0, or 1), and defaults to -1. More...
 
virtual bool CheckActive (NPC npc)
 Whether or not to run the code for checking whether an NPC will remain active. Return false to stop the NPC from being despawned and to stop the NPC from counting towards the limit for how many NPCs can exist near a player. Returns true by default. More...
 
virtual bool CheckDead (NPC npc)
 Whether or not an NPC should be killed when it reaches 0 health. You may program extra effects in this hook (for example, how Golem's head lifts up for the second phase of its fight). Return false to stop the NPC from being killed. Returns true by default. More...
 
virtual GlobalNPC Clone ()
 Returns a clone of this GlobalNPC. By default this will return a memberwise clone; you will want to override this if your GlobalNPC contains object references. Only called if CloneNewInstances && InstancePerEntity More...
 
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 behind certain elements. Add the index to one of Main.DrawCacheNPCsMoonMoon, DrawCacheNPCsOverPlayers, DrawCacheNPCProjectiles, or DrawCacheNPCsBehindNonSolidTiles. More...
 
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 which the NPC is drawn. More...
 
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 same as Main.hbPosition; it determines whether the health bar gets drawn above or below the NPC by default. The scale parameter is the health bar's size. By default, it will be the normal 1f; most bosses set this to 1.5f. Return null to let the normal vanilla health-bar-drawing code to run. Return false to stop the health bar from being drawn. Return true to draw the health bar in the position specified by the position parameter (note that this is the world position, not screen position). More...
 
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 an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC. More...
 
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 have an attack type of 3). Item is the Texture2D instance of the item to be drawn (use Main.itemTexture[id of item]), itemSize is the width and height of the item's hitbox (the same values for TownNPCAttackSwing), scale is the multiplier for the item's drawing size, and offset is the offset from which to draw the item from its normal position. More...
 
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 maps NPC types to their spawning weights (likelihood to spawn compared to other NPCs). A type of 0 in the pool represents the default vanilla NPC spawning. More...
 
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 determine that maximum distance NPCs can spawn from the player, and the safeRanges determine the minimum distance. More...
 
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 NPCs that can spawn around the player. Lower spawnRates mean a higher chance for NPCs to spawn. More...
 
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 animate NPCs. More...
 
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 default color (normally light and buff color). Returns null by default. More...
 
virtual void GetChat (NPC npc, ref string chat)
 Allows you to modify the chat message of any NPC that the player can talk to. More...
 
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. This hook is client side. Usually when something happens when an npc dies such as item spawning, you use NPCLoot, but you can use HitEffect paired with a check for if (npc.life <= 0) to do client-side death effects, such as spawning dust, gore, or death sounds. More...
 
GlobalNPC Instance (NPC npc)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual GlobalNPC NewInstance (NPC npc)
 Create a new instance of this GlobalNPC for an NPC instance. Called at the end of NPC.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields More...
 
virtual void NPCLoot (NPC npc)
 Allows you to make things happen when an NPC dies (for example, dropping items and setting ModWorld fields). This hook runs on the server/single player. For client-side effects, such as dust, gore, and sounds, see HitEffect More...
 
virtual void OnCatchNPC (NPC npc, Player player, Item item)
 Allows you to make things happen when an NPC is caught. Ran Serverside. More...
 
virtual void OnChatButtonClicked (NPC npc, bool firstButton)
 Allows you to make something happen whenever a button is clicked on this NPC's chat window. The firstButton parameter tells whether the first button or second button (button and button2 from SetChatButtons) was clicked. More...
 
virtual void OnGoToStatue (NPC npc, bool toKingStatue)
 Allows you to make things happen when this NPC teleports to a King or Queen statue. This method is only called server side. More...
 
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. More...
 
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. More...
 
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. More...
 
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). More...
 
virtual void PostAI (NPC npc)
 Allows you to determine how any NPC behaves. This will be called regardless of what PreAI returns. More...
 
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. More...
 
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 being run. Returns true by default. More...
 
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 window. The firstButton parameter tells whether the first button or second button (button and button2 from SetChatButtons) was clicked. Return false to prevent the normal code for this button from running. Returns true by default. More...
 
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 the game from drawing the NPC (useful if you're manually drawing the NPC). Returns true by default. More...
 
virtual bool PreNPCLoot (NPC npc)
 Allows you to determine whether or not the NPC will drop anything at all. Return false to stop the NPC from dropping anything. Returns true by default. More...
 
virtual void ResetEffects (NPC npc)
 This is where you reset any fields you add to your subclass to their default states. This is necessary in order to reset your fields if they are conditionally set by a tick update but the condition is no longer satisfied. More...
 
virtual void ScaleExpertStats (NPC npc, int numPlayers, float bossLifeScale)
 Allows you to customize an NPC's stats in expert mode. More...
 
virtual void SetDefaults (NPC npc)
 Allows you to set the properties of any and every NPC that gets created. More...
 
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 belongs to. Add an item by setting the defaults of shop.item[nextSlot] then incrementing nextSlot. In the end, nextSlot must have a value of 1 greater than the highest index in shop.item that contains an item. If you want to remove an item, you will have to be familiar with programming. More...
 
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 the ID of the item you are adding then incrementing nextSlot. In the end, nextSlot must have a value of 1 greater than the highest index in shop that represents an item ID. If you want to remove an item, you will have to be familiar with programming. More...
 
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 before it is synced between servers and clients. As of right now, this only works for modded NPCs. More...
 
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 own. Useful for things like dropping loot from the nearest segment of a worm boss. Returns false by default. More...
 
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. For example, you can change the way defense works or use a different crit multiplier. Return false to stop the game from running the vanilla damage formula; returns true by default. More...
 
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 number greater than or equal to the first parameter, and less then the sum of the two parameters. More...
 
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 magic attack. Only used when the town NPC has an attack type of 2 (magic) More...
 
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 projectile to actually appear. This hook is only used when the town NPC has an attack type of 0 (throwing), 1 (shooting), or 2 (magic). More...
 
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. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity. This hook is only used when the town NPC has an attack type of 0 (throwing), 1 (shooting), or 2 (magic). More...
 
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 more projectiles as part of a single attack so that the game can animate the NPC's attack properly. Only used when the town NPC has an attack type of 1 (shooting). More...
 
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. (More information on scaling in GlobalNPC.BuffTownNPCs.) More...
 
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, which controls the range of the NPC's swung weapon. Only used when the town NPC has an attack type of 3 (swinging). More...
 
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.lifeRegen. Regeneration or damage will occur at a rate of half of npc.lifeRegen per second. The damage parameter is the number that appears above the NPC's head if it takes damage over time. More...
 

Properties

virtual bool CloneNewInstances [get]
 Whether instances of this GlobalNPC are created through Clone or constructor (by default implementations of NewInstance and Clone()). Defaults to false (using default constructor). More...
 
virtual bool InstancePerEntity [get]
 Whether to create a new GlobalNPC instance for every NPC that exists. Useful for storing information on an npc. Defaults to false. Return true if you need to store information (have non-static fields). More...
 
Mod mod [get, set]
 The mod to which this GlobalNPC belongs. More...
 
string Name [get, set]
 The name of this GlobalNPC instance. More...
 

Detailed Description

This class allows you to modify and use hooks for all NPCs, including vanilla mobs. Create an instance of an overriding class then call Mod.AddGlobalNPC to use this.

Definition at line 11 of file GlobalNPC.cs.

Member Function Documentation

◆ AI()

virtual void Terraria.ModLoader.GlobalNPC.AI ( NPC  npc)
virtual

Allows you to determine how any NPC behaves. This will only be called if PreAI returns true.

Parameters
npc

Definition at line 117 of file GlobalNPC.cs.

117 {
118 }

Referenced by Terraria.ModLoader.NPCLoader.AI().

+ Here is the caller graph for this function:

◆ Autoload()

virtual bool Terraria.ModLoader.GlobalNPC.Autoload ( ref string  name)
virtual

Allows you to automatically load a GlobalNPC instead of using Mod.AddGlobalNPC. Return true to allow autoloading; by default returns the mod's autoload property. Name is initialized to the overriding class name. Use this method to either force or stop an autoload or to control the internal name.

Parameters
name
Returns

Definition at line 37 of file GlobalNPC.cs.

37 {
38 return mod.Properties.Autoload;
39 }
Mod mod
The mod to which this GlobalNPC belongs.
Definition: GlobalNPC.cs:16
ModProperties Properties
Definition: Mod.cs:52
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.GlobalNPC.mod, and Terraria.ModLoader.Mod.Properties.

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalNPC().

+ Here is the caller graph for this function:

◆ BossHeadRotation()

virtual void Terraria.ModLoader.GlobalNPC.BossHeadRotation ( NPC  npc,
ref float  rotation 
)
virtual

Allows you to customize the rotation of an NPC's boss head icon on the map.

Parameters
npc
rotation

Definition at line 361 of file GlobalNPC.cs.

361 {
362 }

Referenced by Terraria.ModLoader.NPCLoader.BossHeadRotation().

+ Here is the caller graph for this function:

◆ BossHeadSlot()

virtual void Terraria.ModLoader.GlobalNPC.BossHeadSlot ( NPC  npc,
ref int  index 
)
virtual

Allows you to customize the boss head texture used by an NPC based on its state. Set index to -1 to stop the texture from being displayed.

Parameters
npc
indexThe index for NPCID.Sets.BossHeadTextures

Definition at line 353 of file GlobalNPC.cs.

353 {
354 }

Referenced by Terraria.ModLoader.NPCLoader.BossHeadSlot().

+ Here is the caller graph for this function:

◆ BossHeadSpriteEffects()

virtual void Terraria.ModLoader.GlobalNPC.BossHeadSpriteEffects ( NPC  npc,
ref SpriteEffects  spriteEffects 
)
virtual

Allows you to flip an NPC's boss head icon on the map.

Parameters
npc
spriteEffects

Definition at line 369 of file GlobalNPC.cs.

369 {
370 }

Referenced by Terraria.ModLoader.NPCLoader.BossHeadSpriteEffects().

+ Here is the caller graph for this function:

◆ BuffTownNPC()

virtual void Terraria.ModLoader.GlobalNPC.BuffTownNPC ( ref float  damageMult,
ref int  defense 
)
virtual

Allows you to modify the stats of town NPCs. Useful for buffing town NPCs when certain bosses are defeated, etc.

Parameters
damageMult
defense

Definition at line 544 of file GlobalNPC.cs.

544 {
545 }

Referenced by Terraria.ModLoader.NPCLoader.BuffTownNPC().

+ Here is the caller graph for this function:

◆ CanBeHitByItem()

virtual ? bool Terraria.ModLoader.GlobalNPC.CanBeHitByItem ( NPC  npc,
Player  player,
Item  item 
)
virtual

Allows you to determine whether an NPC can be hit by the given melee weapon when swung. Return true to allow hitting the NPC, return false to block hitting the NPC, and return null to use the vanilla code for whether the NPC can be hit. Returns null by default.

Parameters
npc
player
item
Returns

Definition at line 273 of file GlobalNPC.cs.

273 {
274 return null;
275 }

Referenced by Terraria.ModLoader.NPCLoader.CanBeHitByItem().

+ Here is the caller graph for this function:

◆ CanBeHitByProjectile()

virtual ? bool Terraria.ModLoader.GlobalNPC.CanBeHitByProjectile ( NPC  npc,
Projectile  projectile 
)
virtual

Allows you to determine whether an NPC can be hit by the given projectile. Return true to allow hitting the NPC, return false to block hitting the NPC, and return null to use the vanilla code for whether the NPC can be hit. Returns null by default.

Parameters
npc
projectile
Returns

Definition at line 307 of file GlobalNPC.cs.

307 {
308 return null;
309 }

Referenced by Terraria.ModLoader.NPCLoader.CanBeHitByProjectile().

+ Here is the caller graph for this function:

◆ CanChat()

virtual ? bool Terraria.ModLoader.GlobalNPC.CanChat ( NPC  npc)
virtual

Allows you to determine whether this NPC can talk with the player. Return true to allow talking with the player, return false to block this NPC from talking with the player, and return null to use the vanilla code for whether the NPC can talk. Returns null by default.

Parameters
npc
Returns

Definition at line 474 of file GlobalNPC.cs.

474 {
475 return null;
476 }

Referenced by Terraria.ModLoader.NPCLoader.CanChat().

+ Here is the caller graph for this function:

◆ CanGoToStatue()

virtual ? bool Terraria.ModLoader.GlobalNPC.CanGoToStatue ( NPC  npc,
bool  toKingStatue 
)
virtual

Whether this NPC can be telported a King or Queen statue. Return true to allow the NPC to teleport to the statue, return false to block this NPC from teleporting to the statue, and return null to use the vanilla code for whether the NPC can teleport to the statue. Returns null by default.

Parameters
npcThe NPC
toKingStatueWhether the NPC is being teleported to a King or Queen statue.

Definition at line 526 of file GlobalNPC.cs.

526 {
527 return null;
528 }

Referenced by Terraria.ModLoader.NPCLoader.CanGoToStatue().

+ Here is the caller graph for this function:

◆ CanHitNPC()

virtual ? bool Terraria.ModLoader.GlobalNPC.CanHitNPC ( NPC  npc,
NPC  target 
)
virtual

Allows you to determine whether an NPC can hit the given friendly NPC. Return true to allow hitting the target, return false to block the NPC from hitting the target, and return null to use the vanilla code for whether the target can be hit. Returns null by default.

Parameters
npc
target
Returns

Definition at line 240 of file GlobalNPC.cs.

240 {
241 return null;
242 }

Referenced by Terraria.ModLoader.NPCLoader.CanHitNPC().

+ Here is the caller graph for this function:

◆ CanHitPlayer()

virtual bool Terraria.ModLoader.GlobalNPC.CanHitPlayer ( NPC  npc,
Player  target,
ref int  cooldownSlot 
)
virtual

Allows you to determine whether an NPC can hit the given player. Return false to block the NPC from hitting the target. Returns true by default. CooldownSlot determines which of the player's cooldown counters to use (-1, 0, or 1), and defaults to -1.

Parameters
npc
target
cooldownSlot
Returns

Definition at line 210 of file GlobalNPC.cs.

210 {
211 return true;
212 }

Referenced by Terraria.ModLoader.NPCLoader.CanHitPlayer().

+ Here is the caller graph for this function:

◆ CheckActive()

virtual bool Terraria.ModLoader.GlobalNPC.CheckActive ( NPC  npc)
virtual

Whether or not to run the code for checking whether an NPC will remain active. Return false to stop the NPC from being despawned and to stop the NPC from counting towards the limit for how many NPCs can exist near a player. Returns true by default.

Parameters
npc
Returns

Definition at line 157 of file GlobalNPC.cs.

157 {
158 return true;
159 }

Referenced by Terraria.ModLoader.NPCLoader.CheckActive().

+ Here is the caller graph for this function:

◆ CheckDead()

virtual bool Terraria.ModLoader.GlobalNPC.CheckDead ( NPC  npc)
virtual

Whether or not an NPC should be killed when it reaches 0 health. You may program extra effects in this hook (for example, how Golem's head lifts up for the second phase of its fight). Return false to stop the NPC from being killed. Returns true by default.

Parameters
npc
Returns

Definition at line 166 of file GlobalNPC.cs.

166 {
167 return true;
168 }

Referenced by Terraria.ModLoader.NPCLoader.CheckDead().

+ Here is the caller graph for this function:

◆ Clone()

virtual GlobalNPC Terraria.ModLoader.GlobalNPC.Clone ( )
virtual

Returns a clone of this GlobalNPC. By default this will return a memberwise clone; you will want to override this if your GlobalNPC contains object references. Only called if CloneNewInstances && InstancePerEntity

Referenced by Terraria.ModLoader.GlobalNPC.NewInstance().

+ Here is the caller graph for this function:

◆ DrawBehind()

virtual void Terraria.ModLoader.GlobalNPC.DrawBehind ( NPC  npc,
int  index 
)
virtual

When used in conjunction with "npc.hide = true", allows you to specify that this npc should be drawn behind certain elements. Add the index to one of Main.DrawCacheNPCsMoonMoon, DrawCacheNPCsOverPlayers, DrawCacheNPCProjectiles, or DrawCacheNPCsBehindNonSolidTiles.

Parameters
npc
index

Definition at line 415 of file GlobalNPC.cs.

416 {
417 }

◆ DrawEffects()

virtual void Terraria.ModLoader.GlobalNPC.DrawEffects ( NPC  npc,
ref Color  drawColor 
)
virtual

Allows you to add special visual effects to an NPC (such as creating dust), and modify the color in which the NPC is drawn.

Parameters
npc
drawColor

Definition at line 387 of file GlobalNPC.cs.

387 {
388 }

Referenced by Terraria.ModLoader.NPCLoader.DrawEffects().

+ Here is the caller graph for this function:

◆ DrawHealthBar()

virtual ? bool Terraria.ModLoader.GlobalNPC.DrawHealthBar ( NPC  npc,
byte  hbPosition,
ref float  scale,
ref Vector2  position 
)
virtual

Allows you to control how the health bar for the given NPC is drawn. The hbPosition parameter is the same as Main.hbPosition; it determines whether the health bar gets drawn above or below the NPC by default. The scale parameter is the health bar's size. By default, it will be the normal 1f; most bosses set this to 1.5f. Return null to let the normal vanilla health-bar-drawing code to run. Return false to stop the health bar from being drawn. Return true to draw the health bar in the position specified by the position parameter (note that this is the world position, not screen position).

Parameters
npc
hbPosition
scale
position
Returns

Definition at line 427 of file GlobalNPC.cs.

427 {
428 return null;
429 }

Referenced by Terraria.ModLoader.NPCLoader.DrawHealthBar().

+ Here is the caller graph for this function:

◆ DrawTownAttackGun()

virtual void Terraria.ModLoader.GlobalNPC.DrawTownAttackGun ( NPC  npc,
ref float  scale,
ref int  item,
ref int  closeness 
)
virtual

Allows you to customize how a town NPC's weapon is drawn when the NPC is shooting (the NPC must have an attack type of 1). Scale is a multiplier for the item's drawing size, item is the ID of the item to be drawn, and closeness is how close the item should be drawn to the NPC.

Parameters
npc
scale
item
closeness

Definition at line 617 of file GlobalNPC.cs.

617 {
618 }

Referenced by Terraria.ModLoader.NPCLoader.DrawTownAttackGun().

+ Here is the caller graph for this function:

◆ DrawTownAttackSwing()

virtual void Terraria.ModLoader.GlobalNPC.DrawTownAttackSwing ( NPC  npc,
ref Texture2D  item,
ref int  itemSize,
ref float  scale,
ref Vector2  offset 
)
virtual

Allows you to customize how a town NPC's weapon is drawn when the NPC is swinging it (the NPC must have an attack type of 3). Item is the Texture2D instance of the item to be drawn (use Main.itemTexture[id of item]), itemSize is the width and height of the item's hitbox (the same values for TownNPCAttackSwing), scale is the multiplier for the item's drawing size, and offset is the offset from which to draw the item from its normal position.

Parameters
npc
item
itemSize
scale
offset

Definition at line 628 of file GlobalNPC.cs.

628 {
629 }

Referenced by Terraria.ModLoader.NPCLoader.DrawTownAttackSwing().

+ Here is the caller graph for this function:

◆ EditSpawnPool()

virtual void Terraria.ModLoader.GlobalNPC.EditSpawnPool ( IDictionary< int, float >  pool,
NPCSpawnInfo  spawnInfo 
)
virtual

Allows you to control which NPCs can spawn and how likely each one is to spawn. The pool parameter maps NPC types to their spawning weights (likelihood to spawn compared to other NPCs). A type of 0 in the pool represents the default vanilla NPC spawning.

Parameters
pool
spawnInfo

Definition at line 457 of file GlobalNPC.cs.

457 {
458 }

Referenced by Terraria.ModLoader.NPCLoader.ChooseSpawn().

+ Here is the caller graph for this function:

◆ EditSpawnRange()

virtual void Terraria.ModLoader.GlobalNPC.EditSpawnRange ( Player  player,
ref int  spawnRangeX,
ref int  spawnRangeY,
ref int  safeRangeX,
ref int  safeRangeY 
)
virtual

Allows you to modify the range at which NPCs can spawn around the given player. The spawnRanges determine that maximum distance NPCs can spawn from the player, and the safeRanges determine the minimum distance.

Parameters
player
spawnRangeX
spawnRangeY
safeRangeX
safeRangeY

Definition at line 448 of file GlobalNPC.cs.

449 {
450 }

Referenced by Terraria.ModLoader.NPCLoader.EditSpawnRange().

+ Here is the caller graph for this function:

◆ EditSpawnRate()

virtual void Terraria.ModLoader.GlobalNPC.EditSpawnRate ( Player  player,
ref int  spawnRate,
ref int  maxSpawns 
)
virtual

Allows you to modify the chance of NPCs spawning around the given player and the maximum number of NPCs that can spawn around the player. Lower spawnRates mean a higher chance for NPCs to spawn.

Parameters
player
spawnRate
maxSpawns

Definition at line 437 of file GlobalNPC.cs.

437 {
438 }

Referenced by Terraria.ModLoader.NPCLoader.EditSpawnRate().

+ Here is the caller graph for this function:

◆ FindFrame()

virtual void Terraria.ModLoader.GlobalNPC.FindFrame ( NPC  npc,
int  frameHeight 
)
virtual

Allows you to modify the frame from an NPC's texture that is drawn, which is necessary in order to animate NPCs.

Parameters
npc
frameHeight

Definition at line 132 of file GlobalNPC.cs.

132 {
133 }

Referenced by Terraria.ModLoader.NPCLoader.FindFrame().

+ Here is the caller graph for this function:

◆ GetAlpha()

virtual ? Color Terraria.ModLoader.GlobalNPC.GetAlpha ( NPC  npc,
Color  drawColor 
)
virtual

Allows you to determine the color and transparency in which an NPC is drawn. Return null to use the default color (normally light and buff color). Returns null by default.

Parameters
npc
drawColor
Returns

Definition at line 378 of file GlobalNPC.cs.

378 {
379 return null;
380 }

Referenced by Terraria.ModLoader.NPCLoader.GetAlpha().

+ Here is the caller graph for this function:

◆ GetChat()

virtual void Terraria.ModLoader.GlobalNPC.GetChat ( NPC  npc,
ref string  chat 
)
virtual

Allows you to modify the chat message of any NPC that the player can talk to.

Parameters
npc
chat

Definition at line 483 of file GlobalNPC.cs.

483 {
484 }

Referenced by Terraria.ModLoader.NPCLoader.GetChat().

+ Here is the caller graph for this function:

◆ HitEffect()

virtual void Terraria.ModLoader.GlobalNPC.HitEffect ( NPC  npc,
int  hitDirection,
double  damage 
)
virtual

Allows you to make things happen whenever an NPC is hit, such as creating dust or gores. This hook is client side. Usually when something happens when an npc dies such as item spawning, you use NPCLoot, but you can use HitEffect paired with a check for if (npc.life <= 0) to do client-side death effects, such as spawning dust, gore, or death sounds.

Parameters
npc
hitDirection
damage

Definition at line 141 of file GlobalNPC.cs.

141 {
142 }

Referenced by Terraria.ModLoader.NPCLoader.HitEffect().

+ Here is the caller graph for this function:

◆ Instance()

GlobalNPC Terraria.ModLoader.GlobalNPC.Instance ( NPC  npc)

Referenced by Terraria.ModLoader.NPCLoader.AI(), Terraria.ModLoader.NPCLoader.BossHeadRotation(), Terraria.ModLoader.NPCLoader.BossHeadSlot(), Terraria.ModLoader.NPCLoader.BossHeadSpriteEffects(), Terraria.ModLoader.NPCLoader.CanBeHitByItem(), Terraria.ModLoader.NPCLoader.CanBeHitByProjectile(), Terraria.ModLoader.NPCLoader.CanChat(), Terraria.ModLoader.NPCLoader.CanGoToStatue(), Terraria.ModLoader.NPCLoader.CanHitNPC(), Terraria.ModLoader.NPCLoader.CanHitPlayer(), Terraria.ModLoader.NPCLoader.CheckActive(), Terraria.ModLoader.NPCLoader.CheckDead(), Terraria.ModLoader.NPCLoader.DrawEffects(), Terraria.ModLoader.NPCLoader.DrawHealthBar(), Terraria.ModLoader.NPCLoader.DrawTownAttackGun(), Terraria.ModLoader.NPCLoader.DrawTownAttackSwing(), Terraria.ModLoader.NPCLoader.FindFrame(), Terraria.ModLoader.NPCLoader.GetAlpha(), Terraria.ModLoader.NPCLoader.GetChat(), Terraria.ModLoader.NPCLoader.HitEffect(), Terraria.ModLoader.NPCLoader.ModifyHitByItem(), Terraria.ModLoader.NPCLoader.ModifyHitByProjectile(), Terraria.ModLoader.NPCLoader.ModifyHitNPC(), Terraria.ModLoader.NPCLoader.ModifyHitPlayer(), Terraria.ModLoader.NPCLoader.NPCLoot(), Terraria.ModLoader.NPCLoader.OnCatchNPC(), Terraria.ModLoader.NPCLoader.OnChatButtonClicked(), Terraria.ModLoader.NPCLoader.OnHitByItem(), Terraria.ModLoader.NPCLoader.OnHitByProjectile(), Terraria.ModLoader.NPCLoader.OnHitNPC(), Terraria.ModLoader.NPCLoader.OnHitPlayer(), Terraria.ModLoader.NPCLoader.PostAI(), Terraria.ModLoader.NPCLoader.PostDraw(), Terraria.ModLoader.NPCLoader.PreAI(), Terraria.ModLoader.NPCLoader.PreChatButtonClicked(), Terraria.ModLoader.NPCLoader.PreDraw(), Terraria.ModLoader.NPCLoader.PreNPCLoot(), Terraria.ModLoader.NPCLoader.ResetEffects(), Terraria.ModLoader.NPCLoader.ScaleExpertStats(), Terraria.ModLoader.NPCLoader.SpawnNPC(), Terraria.ModLoader.NPCLoader.SpecialNPCLoot(), Terraria.ModLoader.NPCLoader.StrikeNPC(), Terraria.ModLoader.NPCLoader.TownNPCAttackCooldown(), Terraria.ModLoader.NPCLoader.TownNPCAttackMagic(), Terraria.ModLoader.NPCLoader.TownNPCAttackProj(), Terraria.ModLoader.NPCLoader.TownNPCAttackProjSpeed(), Terraria.ModLoader.NPCLoader.TownNPCAttackShoot(), Terraria.ModLoader.NPCLoader.TownNPCAttackStrength(), Terraria.ModLoader.NPCLoader.TownNPCAttackSwing(), and Terraria.ModLoader.NPCLoader.UpdateLifeRegen().

◆ ModifyHitByItem()

virtual void Terraria.ModLoader.GlobalNPC.ModifyHitByItem ( NPC  npc,
Player  player,
Item  item,
ref int  damage,
ref float  knockback,
ref bool  crit 
)
virtual

Allows you to modify the damage, knockback, etc., that an NPC takes from a melee weapon.

Parameters
npc
player
item
damage
knockback
crit

Definition at line 286 of file GlobalNPC.cs.

286 {
287 }

Referenced by Terraria.ModLoader.NPCLoader.ModifyHitByItem().

+ Here is the caller graph for this function:

◆ ModifyHitByProjectile()

virtual void Terraria.ModLoader.GlobalNPC.ModifyHitByProjectile ( NPC  npc,
Projectile  projectile,
ref int  damage,
ref float  knockback,
ref bool  crit,
ref int  hitDirection 
)
virtual

Allows you to modify the damage, knockback, etc., that an NPC takes from a projectile.

Parameters
npc
projectile
damage
knockback
crit
hitDirection

Definition at line 320 of file GlobalNPC.cs.

320 {
321 }

Referenced by Terraria.ModLoader.NPCLoader.ModifyHitByProjectile().

+ Here is the caller graph for this function:

◆ ModifyHitNPC()

virtual void Terraria.ModLoader.GlobalNPC.ModifyHitNPC ( NPC  npc,
NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit 
)
virtual

Allows you to modify the damage, knockback, etc., that an NPC does to a friendly NPC.

Parameters
npc
target
damage
knockback
crit

Definition at line 252 of file GlobalNPC.cs.

252 {
253 }

Referenced by Terraria.ModLoader.NPCLoader.ModifyHitNPC().

+ Here is the caller graph for this function:

◆ ModifyHitPlayer()

virtual void Terraria.ModLoader.GlobalNPC.ModifyHitPlayer ( NPC  npc,
Player  target,
ref int  damage,
ref bool  crit 
)
virtual

Allows you to modify the damage, etc., that an NPC does to a player.

Parameters
npc
target
damage
crit

Definition at line 221 of file GlobalNPC.cs.

221 {
222 }

Referenced by Terraria.ModLoader.NPCLoader.ModifyHitPlayer().

+ Here is the caller graph for this function:

◆ NewInstance()

virtual GlobalNPC Terraria.ModLoader.GlobalNPC.NewInstance ( NPC  npc)
virtual

Create a new instance of this GlobalNPC for an NPC instance. Called at the end of NPC.SetDefaults. If CloneNewInstances is true, just calls Clone() Otherwise calls the default constructor and copies fields

Definition at line 69 of file GlobalNPC.cs.

69 {
71 return Clone();
72 }
73 GlobalNPC copy = (GlobalNPC)Activator.CreateInstance(GetType());
74 copy.mod = mod;
75 copy.Name = Name;
76 copy.index = index;
77 copy.instanceIndex = instanceIndex;
78 return copy;
79 }
virtual GlobalNPC Clone()
Returns a clone of this GlobalNPC. By default this will return a memberwise clone; you will want to o...
string Name
The name of this GlobalNPC instance.
Definition: GlobalNPC.cs:24
virtual bool CloneNewInstances
Whether instances of this GlobalNPC are created through Clone or constructor (by default implementati...
Definition: GlobalNPC.cs:54

References Terraria.ModLoader.GlobalNPC.Clone(), Terraria.ModLoader.GlobalNPC.CloneNewInstances, Terraria.ModLoader.GlobalNPC.mod, and Terraria.ModLoader.GlobalNPC.Name.

+ Here is the call graph for this function:

◆ NPCLoot()

virtual void Terraria.ModLoader.GlobalNPC.NPCLoot ( NPC  npc)
virtual

Allows you to make things happen when an NPC dies (for example, dropping items and setting ModWorld fields). This hook runs on the server/single player. For client-side effects, such as dust, gore, and sounds, see HitEffect

Parameters
npc

Definition at line 191 of file GlobalNPC.cs.

191 {
192 }

Referenced by Terraria.ModLoader.NPCLoader.NPCLoot().

+ Here is the caller graph for this function:

◆ OnCatchNPC()

virtual void Terraria.ModLoader.GlobalNPC.OnCatchNPC ( NPC  npc,
Player  player,
Item  item 
)
virtual

Allows you to make things happen when an NPC is caught. Ran Serverside.

Parameters
npcThe caught NPC
playerThe player catching the NPC
itemThe item that will be spawned

Definition at line 200 of file GlobalNPC.cs.

200 {
201 }

Referenced by Terraria.ModLoader.NPCLoader.OnCatchNPC().

+ Here is the caller graph for this function:

◆ OnChatButtonClicked()

virtual void Terraria.ModLoader.GlobalNPC.OnChatButtonClicked ( NPC  npc,
bool  firstButton 
)
virtual

Allows you to make something happen whenever a button is clicked on this NPC's chat window. The firstButton parameter tells whether the first button or second button (button and button2 from SetChatButtons) was clicked.

Parameters
npc
firstButton

Definition at line 501 of file GlobalNPC.cs.

501 {
502 }

Referenced by Terraria.ModLoader.NPCLoader.OnChatButtonClicked().

+ Here is the caller graph for this function:

◆ OnGoToStatue()

virtual void Terraria.ModLoader.GlobalNPC.OnGoToStatue ( NPC  npc,
bool  toKingStatue 
)
virtual

Allows you to make things happen when this NPC teleports to a King or Queen statue. This method is only called server side.

Parameters
npcThe NPC
toKingStatueWhether the NPC was teleported to a King or Queen statue.

Definition at line 536 of file GlobalNPC.cs.

536 {
537 }

Referenced by Terraria.ModLoader.NPCLoader.OnGoToStatue().

+ Here is the caller graph for this function:

◆ OnHitByItem()

virtual void Terraria.ModLoader.GlobalNPC.OnHitByItem ( NPC  npc,
Player  player,
Item  item,
int  damage,
float  knockback,
bool  crit 
)
virtual

Allows you to create special effects when an NPC is hit by a melee weapon.

Parameters
npc
player
item
damage
knockback
crit

Definition at line 298 of file GlobalNPC.cs.

298 {
299 }

Referenced by Terraria.ModLoader.NPCLoader.OnHitByItem().

+ Here is the caller graph for this function:

◆ OnHitByProjectile()

virtual void Terraria.ModLoader.GlobalNPC.OnHitByProjectile ( NPC  npc,
Projectile  projectile,
int  damage,
float  knockback,
bool  crit 
)
virtual

Allows you to create special effects when an NPC is hit by a projectile.

Parameters
npc
projectile
damage
knockback
crit

Definition at line 331 of file GlobalNPC.cs.

331 {
332 }

Referenced by Terraria.ModLoader.NPCLoader.OnHitByProjectile().

+ Here is the caller graph for this function:

◆ OnHitNPC()

virtual void Terraria.ModLoader.GlobalNPC.OnHitNPC ( NPC  npc,
NPC  target,
int  damage,
float  knockback,
bool  crit 
)
virtual

Allows you to create special effects when an NPC hits a friendly NPC.

Parameters
npc
target
damage
knockback
crit

Definition at line 263 of file GlobalNPC.cs.

263 {
264 }

Referenced by Terraria.ModLoader.NPCLoader.OnHitNPC().

+ Here is the caller graph for this function:

◆ OnHitPlayer()

virtual void Terraria.ModLoader.GlobalNPC.OnHitPlayer ( NPC  npc,
Player  target,
int  damage,
bool  crit 
)
virtual

Allows you to create special effects when an NPC hits a player (for example, inflicting debuffs).

Parameters
npc
target
damage
crit

Definition at line 231 of file GlobalNPC.cs.

231 {
232 }

Referenced by Terraria.ModLoader.NPCLoader.OnHitPlayer().

+ Here is the caller graph for this function:

◆ PostAI()

virtual void Terraria.ModLoader.GlobalNPC.PostAI ( NPC  npc)
virtual

Allows you to determine how any NPC behaves. This will be called regardless of what PreAI returns.

Parameters
npc

Definition at line 124 of file GlobalNPC.cs.

124 {
125 }

Referenced by Terraria.ModLoader.NPCLoader.PostAI().

+ Here is the caller graph for this function:

◆ PostDraw()

virtual void Terraria.ModLoader.GlobalNPC.PostDraw ( NPC  npc,
SpriteBatch  spriteBatch,
Color  drawColor 
)
virtual

Allows you to draw things in front of this NPC. This method is called even if PreDraw returns false.

Parameters
npc
spriteBatch
drawColor

Definition at line 407 of file GlobalNPC.cs.

407 {
408 }

Referenced by Terraria.ModLoader.NPCLoader.PostDraw().

+ Here is the caller graph for this function:

◆ PreAI()

virtual bool Terraria.ModLoader.GlobalNPC.PreAI ( NPC  npc)
virtual

Allows you to determine how any NPC behaves. Return false to stop the vanilla AI and the AI hook from being run. Returns true by default.

Parameters
npc
Returns

Definition at line 109 of file GlobalNPC.cs.

109 {
110 return true;
111 }

Referenced by Terraria.ModLoader.NPCLoader.PreAI().

+ Here is the caller graph for this function:

◆ PreChatButtonClicked()

virtual bool Terraria.ModLoader.GlobalNPC.PreChatButtonClicked ( NPC  npc,
bool  firstButton 
)
virtual

Allows you to determine if something can happen whenever a button is clicked on this NPC's chat window. The firstButton parameter tells whether the first button or second button (button and button2 from SetChatButtons) was clicked. Return false to prevent the normal code for this button from running. Returns true by default.

Parameters
npc
firstButton
Returns

Definition at line 492 of file GlobalNPC.cs.

492 {
493 return true;
494 }

Referenced by Terraria.ModLoader.NPCLoader.PreChatButtonClicked().

+ Here is the caller graph for this function:

◆ PreDraw()

virtual bool Terraria.ModLoader.GlobalNPC.PreDraw ( NPC  npc,
SpriteBatch  spriteBatch,
Color  drawColor 
)
virtual

Allows you to draw things behind an NPC, or to modify the way the NPC is drawn. Return false to stop the game from drawing the NPC (useful if you're manually drawing the NPC). Returns true by default.

Parameters
npc
spriteBatch
drawColor
Returns

Definition at line 397 of file GlobalNPC.cs.

397 {
398 return true;
399 }

Referenced by Terraria.ModLoader.NPCLoader.PreDraw().

+ Here is the caller graph for this function:

◆ PreNPCLoot()

virtual bool Terraria.ModLoader.GlobalNPC.PreNPCLoot ( NPC  npc)
virtual

Allows you to determine whether or not the NPC will drop anything at all. Return false to stop the NPC from dropping anything. Returns true by default.

Parameters
npc
Returns

Definition at line 183 of file GlobalNPC.cs.

183 {
184 return true;
185 }

Referenced by Terraria.ModLoader.NPCLoader.PreNPCLoot().

+ Here is the caller graph for this function:

◆ ResetEffects()

virtual void Terraria.ModLoader.GlobalNPC.ResetEffects ( NPC  npc)
virtual

This is where you reset any fields you add to your subclass to their default states. This is necessary in order to reset your fields if they are conditionally set by a tick update but the condition is no longer satisfied.

Parameters
npc

Definition at line 101 of file GlobalNPC.cs.

101 {
102 }

Referenced by Terraria.ModLoader.NPCLoader.ResetEffects().

+ Here is the caller graph for this function:

◆ ScaleExpertStats()

virtual void Terraria.ModLoader.GlobalNPC.ScaleExpertStats ( NPC  npc,
int  numPlayers,
float  bossLifeScale 
)
virtual

Allows you to customize an NPC's stats in expert mode.

Parameters
npc
numPlayers
bossLifeScale

Definition at line 94 of file GlobalNPC.cs.

94 {
95 }

Referenced by Terraria.ModLoader.NPCLoader.ScaleExpertStats().

+ Here is the caller graph for this function:

◆ SetDefaults()

virtual void Terraria.ModLoader.GlobalNPC.SetDefaults ( NPC  npc)
virtual

Allows you to set the properties of any and every NPC that gets created.

Parameters
npc

Definition at line 85 of file GlobalNPC.cs.

85 {
86 }

◆ SetupShop()

virtual void Terraria.ModLoader.GlobalNPC.SetupShop ( int  type,
Chest  shop,
ref int  nextSlot 
)
virtual

Allows you to add items to an NPC's shop. The type parameter is the type of the NPC that this shop belongs to. Add an item by setting the defaults of shop.item[nextSlot] then incrementing nextSlot. In the end, nextSlot must have a value of 1 greater than the highest index in shop.item that contains an item. If you want to remove an item, you will have to be familiar with programming.

Parameters
type
shop
nextSlot

Definition at line 510 of file GlobalNPC.cs.

510 {
511 }

Referenced by Terraria.ModLoader.NPCLoader.SetupShop().

+ Here is the caller graph for this function:

◆ SetupTravelShop()

virtual void Terraria.ModLoader.GlobalNPC.SetupTravelShop ( int[]  shop,
ref int  nextSlot 
)
virtual

Allows you to add items to the traveling merchant's shop. Add an item by setting shop[nextSlot] to the ID of the item you are adding then incrementing nextSlot. In the end, nextSlot must have a value of 1 greater than the highest index in shop that represents an item ID. If you want to remove an item, you will have to be familiar with programming.

Parameters
shop
nextSlot

Definition at line 518 of file GlobalNPC.cs.

518 {
519 }

Referenced by Terraria.ModLoader.NPCLoader.SetupTravelShop().

+ Here is the caller graph for this function:

◆ SpawnNPC()

virtual void Terraria.ModLoader.GlobalNPC.SpawnNPC ( int  npc,
int  tileX,
int  tileY 
)
virtual

Allows you to customize an NPC (for example, its position or ai array) after it naturally spawns and before it is synced between servers and clients. As of right now, this only works for modded NPCs.

Parameters
npc
tileX
tileY

Definition at line 466 of file GlobalNPC.cs.

466 {
467 }

Referenced by Terraria.ModLoader.NPCLoader.SpawnNPC().

+ Here is the caller graph for this function:

◆ SpecialNPCLoot()

virtual bool Terraria.ModLoader.GlobalNPC.SpecialNPCLoot ( NPC  npc)
virtual

Allows you to call NPCLoot on your own when the NPC dies, rather then letting vanilla call it on its own. Useful for things like dropping loot from the nearest segment of a worm boss. Returns false by default.

Returns
Return true to stop vanilla from calling NPCLoot on its own. Do this if you call NPCLoot yourself.

Definition at line 174 of file GlobalNPC.cs.

174 {
175 return false;
176 }

Referenced by Terraria.ModLoader.NPCLoader.SpecialNPCLoot().

+ Here is the caller graph for this function:

◆ StrikeNPC()

virtual bool Terraria.ModLoader.GlobalNPC.StrikeNPC ( NPC  npc,
ref double  damage,
int  defense,
ref float  knockback,
int  hitDirection,
ref bool  crit 
)
virtual

Allows you to use a custom damage formula for when an NPC takes damage from any source. For example, you can change the way defense works or use a different crit multiplier. Return false to stop the game from running the vanilla damage formula; returns true by default.

Parameters
npc
damage
defense
knockback
hitDirection
crit
Returns

Definition at line 344 of file GlobalNPC.cs.

344 {
345 return true;
346 }

Referenced by Terraria.ModLoader.NPCLoader.StrikeNPC().

+ Here is the caller graph for this function:

◆ TownNPCAttackCooldown()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackCooldown ( NPC  npc,
ref int  cooldown,
ref int  randExtraCooldown 
)
virtual

Allows you to determine the cooldown between each of a town NPC's attack. The cooldown will be a number greater than or equal to the first parameter, and less then the sum of the two parameters.

Parameters
npc
cooldown
randExtraCooldown

Definition at line 562 of file GlobalNPC.cs.

562 {
563 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackCooldown().

+ Here is the caller graph for this function:

◆ TownNPCAttackMagic()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackMagic ( NPC  npc,
ref float  auraLightMultiplier 
)
virtual

Allows you to control the brightness of the light emitted by a town NPC's aura when it performs a magic attack. Only used when the town NPC has an attack type of 2 (magic)

Parameters
npc
auraLightMultiplier

Definition at line 598 of file GlobalNPC.cs.

598 {
599 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackMagic().

+ Here is the caller graph for this function:

◆ TownNPCAttackProj()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackProj ( NPC  npc,
ref int  projType,
ref int  attackDelay 
)
virtual

Allows you to determine the projectile type of a town NPC's attack, and how long it takes for the projectile to actually appear. This hook is only used when the town NPC has an attack type of 0 (throwing), 1 (shooting), or 2 (magic).

Parameters
npc
projType
attackDelay

Definition at line 571 of file GlobalNPC.cs.

571 {
572 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackProj().

+ Here is the caller graph for this function:

◆ TownNPCAttackProjSpeed()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackProjSpeed ( NPC  npc,
ref float  multiplier,
ref float  gravityCorrection,
ref float  randomOffset 
)
virtual

Allows you to determine the speed at which a town NPC throws a projectile when it attacks. Multiplier is the speed of the projectile, gravityCorrection is how much extra the projectile gets thrown upwards, and randomOffset allows you to randomize the projectile's velocity in a square centered around the original velocity. This hook is only used when the town NPC has an attack type of 0 (throwing), 1 (shooting), or 2 (magic).

Parameters
npc
multiplier
gravityCorrection
randomOffset

Definition at line 581 of file GlobalNPC.cs.

582 {
583 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackProjSpeed().

+ Here is the caller graph for this function:

◆ TownNPCAttackShoot()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackShoot ( NPC  npc,
ref bool  inBetweenShots 
)
virtual

Allows you to tell the game that a town NPC has already created a projectile and will still create more projectiles as part of a single attack so that the game can animate the NPC's attack properly. Only used when the town NPC has an attack type of 1 (shooting).

Parameters
npc
inBetweenShots

Definition at line 590 of file GlobalNPC.cs.

590 {
591 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackShoot().

+ Here is the caller graph for this function:

◆ TownNPCAttackStrength()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackStrength ( NPC  npc,
ref int  damage,
ref float  knockback 
)
virtual

Allows you to determine the damage and knockback of a town NPC's attack before the damage is scaled. (More information on scaling in GlobalNPC.BuffTownNPCs.)

Parameters
npc
damage
knockback

Definition at line 553 of file GlobalNPC.cs.

553 {
554 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackStrength().

+ Here is the caller graph for this function:

◆ TownNPCAttackSwing()

virtual void Terraria.ModLoader.GlobalNPC.TownNPCAttackSwing ( NPC  npc,
ref int  itemWidth,
ref int  itemHeight 
)
virtual

Allows you to determine the width and height of the item a town NPC swings when it attacks, which controls the range of the NPC's swung weapon. Only used when the town NPC has an attack type of 3 (swinging).

Parameters
npc
itemWidth
itemHeight

Definition at line 607 of file GlobalNPC.cs.

607 {
608 }

Referenced by Terraria.ModLoader.NPCLoader.TownNPCAttackSwing().

+ Here is the caller graph for this function:

◆ UpdateLifeRegen()

virtual void Terraria.ModLoader.GlobalNPC.UpdateLifeRegen ( NPC  npc,
ref int  damage 
)
virtual

Allows you to make the NPC either regenerate health or take damage over time by setting npc.lifeRegen. Regeneration or damage will occur at a rate of half of npc.lifeRegen per second. The damage parameter is the number that appears above the NPC's head if it takes damage over time.

Parameters
npc
damage

Definition at line 149 of file GlobalNPC.cs.

149 {
150 }

Referenced by Terraria.ModLoader.NPCLoader.UpdateLifeRegen().

+ Here is the caller graph for this function:

Property Documentation

◆ CloneNewInstances

virtual bool Terraria.ModLoader.GlobalNPC.CloneNewInstances
get

Whether instances of this GlobalNPC are created through Clone or constructor (by default implementations of NewInstance and Clone()). Defaults to false (using default constructor).

Definition at line 54 of file GlobalNPC.cs.

Referenced by Terraria.ModLoader.GlobalNPC.NewInstance().

◆ InstancePerEntity

virtual bool Terraria.ModLoader.GlobalNPC.InstancePerEntity
get

Whether to create a new GlobalNPC instance for every NPC that exists. Useful for storing information on an npc. Defaults to false. Return true if you need to store information (have non-static fields).

Definition at line 46 of file GlobalNPC.cs.

◆ mod

Mod Terraria.ModLoader.GlobalNPC.mod
getset

The mod to which this GlobalNPC belongs.

Definition at line 16 of file GlobalNPC.cs.

16 {
17 get;
18 internal set;
19 }

Referenced by Terraria.ModLoader.GlobalNPC.Autoload(), and Terraria.ModLoader.GlobalNPC.NewInstance().

◆ Name

string Terraria.ModLoader.GlobalNPC.Name
getset

The name of this GlobalNPC instance.

Definition at line 24 of file GlobalNPC.cs.

24 {
25 get;
26 internal set;
27 }

Referenced by Terraria.ModLoader.Mod.AutoloadGlobalNPC(), and Terraria.ModLoader.GlobalNPC.NewInstance().