tModLoader v2022.09
A mod to make and play Terraria mods
Terraria.ModLoader.NPCLoader Class Reference

This serves as the central class from which NPC-related functions are carried out. It also stores a list of mod NPCs by ID. More...

Static Public Member Functions

static T AddModHook< T > (T hook)
 
static void AI (NPC npc)
 
static void BossHeadRotation (NPC npc, ref float rotation)
 
static void BossHeadSlot (NPC npc, ref int index)
 
static void BossHeadSpriteEffects (NPC npc, ref SpriteEffects spriteEffects)
 
static void BossLoot (NPC npc, ref string name, ref int potionType)
 
static void BuffTownNPC (ref float damageMult, ref int defense)
 
static ? bool CanBeCaughtBy (NPC npc, Item item, Player player)
 
static ? bool CanBeHitByItem (NPC npc, Player player, Item item)
 
static ? bool CanBeHitByProjectile (NPC npc, Projectile projectile)
 
static bool CanChat (NPC npc, bool vanillaCanChat)
 
static ? bool CanFallThroughPlatforms (NPC npc)
 
static bool CanGoToStatue (NPC npc, bool toKingStatue, bool vanillaCanGo)
 
static ? bool CanHitNPC (NPC npc, NPC target)
 
static bool CanHitPlayer (NPC npc, Player target, ref int cooldownSlot)
 
static void CanTownNPCSpawn (int numTownNPCs, int money)
 
static bool CheckActive (NPC npc)
 
static bool CheckConditions (int type)
 
static bool CheckDead (NPC npc)
 
static ? int ChooseSpawn (NPCSpawnInfo spawnInfo)
 
static void DrawEffects (NPC npc, ref Color drawColor)
 
static bool DrawHealthBar (NPC npc, ref float scale)
 
static void DrawTownAttackGun (NPC npc, ref float scale, ref int item, ref int closeness)
 
static void DrawTownAttackSwing (NPC npc, ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
 
static void EditSpawnRange (Player player, ref int spawnRangeX, ref int spawnRangeY, ref int safeRangeX, ref int safeRangeY)
 
static void EditSpawnRate (Player player, ref int spawnRate, ref int maxSpawns)
 
static void FindFrame (NPC npc, int frameHeight)
 
static ? Color GetAlpha (NPC npc, Color lightColor)
 
static void GetChat (NPC npc, ref string chat)
 
static ModNPC GetNPC (int type)
 Gets the ModNPC instance corresponding to the specified type. More...
 
static void HitEffect (NPC npc, int hitDirection, double damage)
 
static void ModifyGlobalLoot (GlobalLoot globalLoot)
 
static void ModifyHitByItem (NPC npc, Player player, Item item, ref int damage, ref float knockback, ref bool crit)
 
static void ModifyHitByProjectile (NPC npc, Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 
static void ModifyHitNPC (NPC npc, NPC target, ref int damage, ref float knockback, ref bool crit)
 
static void ModifyHitPlayer (NPC npc, Player target, ref int damage, ref bool crit)
 
static void ModifyHoverBoundingBox (NPC npc, ref Rectangle boundingBox)
 
static void ModifyNPCLoot (NPC npc, NPCLoot npcLoot)
 
static List< string > ModifyNPCNameList (NPC npc, List< string > nameList)
 
static void ModifyTownNPCProfile (NPC npc, ref ITownNPCProfile profile)
 
static void ModifyTypeName (NPC npc, ref string typeName)
 
static void NPCAI (NPC npc)
 
static void OnCaughtBy (NPC npc, Player player, Item item, bool failed)
 
static void OnChatButtonClicked (bool firstButton)
 
static void OnGoToStatue (NPC npc, bool toKingStatue)
 
static void OnHitByItem (NPC npc, Player player, Item item, int damage, float knockback, bool crit)
 
static void OnHitByProjectile (NPC npc, Projectile projectile, int damage, float knockback, bool crit)
 
static void OnHitNPC (NPC npc, NPC target, int damage, float knockback, bool crit)
 
static void OnHitPlayer (NPC npc, Player target, int damage, bool crit)
 
static void OnKill (NPC npc)
 
static void PostAI (NPC npc)
 
static void PostDraw (NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
 
static bool PreAI (NPC npc)
 
static bool PreChatButtonClicked (bool firstButton)
 
static bool PreDraw (NPC npc, SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
 
static bool PreKill (NPC npc)
 
static byte[] ReadExtraAI (BinaryReader reader)
 
static void ReceiveExtraAI (NPC npc, byte[] extraAI)
 
static void ResetEffects (NPC npc)
 
static bool SavesAndLoads (NPC npc)
 
static void ScaleExpertStats (NPC npc, int numPlayers, float bossLifeScale)
 
static void SendExtraAI (BinaryWriter writer, byte[] extraAI)
 
static void SetBestiary (NPC npc, BestiaryDatabase database, BestiaryEntry bestiaryEntry)
 
static void SetChatButtons (ref string button, ref string button2)
 
static void SetupShop (int type, Chest shop, ref int nextSlot)
 
static void SetupTravelShop (int[] shop, ref int nextSlot)
 
static int SpawnNPC (int type, int tileX, int tileY)
 
static bool SpecialOnKill (NPC npc)
 
static bool StrikeNPC (NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
 
static void TownNPCAttackCooldown (NPC npc, ref int cooldown, ref int randExtraCooldown)
 
static void TownNPCAttackMagic (NPC npc, ref float auraLightMultiplier)
 
static void TownNPCAttackProj (NPC npc, ref int projType, ref int attackDelay)
 
static void TownNPCAttackProjSpeed (NPC npc, ref float multiplier, ref float gravityCorrection, ref float randomOffset)
 
static void TownNPCAttackShoot (NPC npc, ref bool inBetweenShots)
 
static void TownNPCAttackStrength (NPC npc, ref int damage, ref float knockback)
 
static void TownNPCAttackSwing (NPC npc, ref int itemWidth, ref int itemHeight)
 
static void UpdateLifeRegen (NPC npc, ref int damage)
 
static bool UsesPartyHat (NPC npc)
 
static byte[] WriteExtraAI (NPC npc)
 

Static Public Attributes

static readonly IList< int > blockLoot = new List<int>()
 Allows you to stop an NPC from dropping loot by adding item IDs to this list. This list will be cleared whenever NPCLoot ends. Useful for either removing an item or change the drop rate of an item in the NPC's loot table. To change the drop rate of an item, use the PreNPCLoot hook, spawn the item yourself, then add the item's ID to this list.
 

Properties

static int NPCCount [get]
 

Detailed Description

This serves as the central class from which NPC-related functions are carried out. It also stores a list of mod NPCs by ID.

Member Function Documentation

◆ AddModHook< T >()

static T Terraria.ModLoader.NPCLoader.AddModHook< T > ( hook)
static
Type Constraints
T :HookList 

◆ GetNPC()

static ModNPC Terraria.ModLoader.NPCLoader.GetNPC ( int  type)
static

Gets the ModNPC instance corresponding to the specified type.

Parameters
typeThe type of the npc
Returns
The ModNPC instance in the npcs array, null if not found.