Terraria ModLoader  0.10.1.5
A framework for 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...

+ Collaboration diagram for Terraria.ModLoader.NPCLoader:

Classes

class  HookList
 

Static Public Member Functions

static void AI (NPC npc)
 
static void BossBag (NPC npc, ref int bagType)
 
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 CanBeHitByItem (NPC npc, Player player, Item item)
 
static bool CanBeHitByProjectile (NPC npc, Projectile projectile)
 
static bool CanChat (NPC npc)
 
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 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 NPCAI (NPC npc)
 
static void NPCLoot (NPC npc)
 
static void OnChatButtonClicked (bool firstButton)
 
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 PostAI (NPC npc)
 
static void PostDraw (NPC npc, SpriteBatch spriteBatch, Color drawColor)
 
static bool PreAI (NPC npc)
 
static bool PreChatButtonClicked (bool firstButton)
 
static bool PreDraw (NPC npc, SpriteBatch spriteBatch, Color drawColor)
 
static bool PreNPCLoot (NPC npc)
 
static void ReceiveExtraAI (NPC npc, BinaryReader reader)
 
static void ResetEffects (NPC npc)
 
static void ScaleExpertStats (NPC npc, int numPlayers, float bossLifeScale)
 
static void SendExtraAI (NPC npc, BinaryWriter writer)
 
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 SpecialNPCLoot (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 string TownNPCName (int type)
 
static void UpdateLifeRegen (NPC npc, ref int damage)
 
static bool UsesPartyHat (NPC npc)
 
static bool VanillaCanChat (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. More...
 
static int NPCCount => nextNPC
 

Private Member Functions

delegate void DelegateBossHeadRotation (NPC npc, ref float rotation)
 
delegate void DelegateBossHeadSlot (NPC npc, ref int index)
 
delegate void DelegateBossHeadSpriteEffects (NPC npc, ref SpriteEffects spriteEffects)
 
delegate void DelegateBuffTownNPC (ref float damageMult, ref int defense)
 
delegate bool DelegateCanHitPlayer (NPC npc, Player target, ref int cooldownSlot)
 
delegate void DelegateDrawEffects (NPC npc, ref Color drawColor)
 
delegate bool DelegateDrawHealthBar (NPC npc, byte bhPosition, ref float scale, ref Vector2 position)
 
delegate void DelegateDrawTownAttackGun (NPC npc, ref float scale, ref int item, ref int closeness)
 
delegate void DelegateDrawTownAttackSwing (NPC npc, ref Texture2D item, ref int itemSize, ref float scale, ref Vector2 offset)
 
delegate void DelegateEditSpawnRange (Player player, ref int spawnRangeX, ref int spawnRangeY, ref int safeRangeX, ref int safeRangeY)
 
delegate void DelegateEditSpawnRate (Player player, ref int spawnRate, ref int maxSpawns)
 
delegate void DelegateGetChat (NPC npc, ref string chat)
 
delegate void DelegateModifyHitByItem (NPC npc, Player player, Item item, ref int damage, ref float knockback, ref bool crit)
 
delegate void DelegateModifyHitByProjectile (NPC npc, Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
 
delegate void DelegateModifyHitNPC (NPC npc, NPC target, ref int damage, ref float knockback, ref bool crit)
 
delegate void DelegateModifyHitPlayer (NPC npc, Player target, ref int damage, ref bool crit)
 
delegate void DelegateOnChatButtonClicked (NPC npc, bool firstButton)
 
delegate void DelegateSetupShop (int type, Chest shop, ref int nextSlot)
 
delegate void DelegateSetupTravelShop (int[] shop, ref int nextSlot)
 
delegate bool DelegateStrikeNPC (NPC npc, ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit)
 
delegate void DelegateTownNPCAttackCooldown (NPC npc, ref int cooldown, ref int randExtraCooldown)
 
delegate void DelegateTownNPCAttackMagic (NPC npc, ref float auraLightMultiplier)
 
delegate void DelegateTownNPCAttackProj (NPC npc, ref int projType, ref int attackDelay)
 
delegate void DelegateTownNPCAttackProjSpeed (NPC npc, ref float multiplier, ref float gravityCorrection, ref float randomOffset)
 
delegate void DelegateTownNPCAttackShoot (NPC npc, ref bool inBetweenShots)
 
delegate void DelegateTownNPCAttackStrength (NPC npc, ref int damage, ref float knockback)
 
delegate void DelegateTownNPCAttackSwing (NPC npc, ref int itemWidth, ref int itemHeight)
 
delegate void DelegateUpdateLifeRegen (NPC npc, ref int damage)
 

Static Private Member Functions

static NPCLoader ()
 
static HookList AddHook< F > (Expression< Func< GlobalNPC, F >> func)
 
static void DrawHealthBar (NPC npc, Vector2 position, float scale)
 
static bool HasMethod (Type t, string method, params Type[] args)
 

Static Private Attributes

static HookList HookAI = AddHook<Action<NPC>>(g => g.AI)
 
static HookList HookBossHeadRotation = AddHook<DelegateBossHeadRotation>(g => g.BossHeadRotation)
 
static HookList HookBossHeadSlot = AddHook<DelegateBossHeadSlot>(g => g.BossHeadSlot)
 
static HookList HookBossHeadSpriteEffects = AddHook<DelegateBossHeadSpriteEffects>(g => g.BossHeadSpriteEffects)
 
static HookList HookBuffTownNPC = AddHook<DelegateBuffTownNPC>(g => g.BuffTownNPC)
 
static HookList HookCanBeHitByItem = AddHook<Func<NPC, Player, Item, bool?>>(g => g.CanBeHitByItem)
 
static HookList HookCanBeHitByProjectile = AddHook<Func<NPC, Projectile, bool?>>(g => g.CanBeHitByProjectile)
 
static HookList HookCanChat = AddHook<Func<NPC, bool?>>(g => g.CanChat)
 
static HookList HookCanHitNPC = AddHook<Func<NPC, NPC, bool?>>(g => g.CanHitNPC)
 
static HookList HookCanHitPlayer = AddHook<DelegateCanHitPlayer>(g => g.CanHitPlayer)
 
static HookList HookCheckActive = AddHook<Func<NPC, bool>>(g => g.CheckActive)
 
static HookList HookCheckDead = AddHook<Func<NPC, bool>>(g => g.CheckDead)
 
static HookList HookDrawEffects = AddHook<DelegateDrawEffects>(g => g.DrawEffects)
 
static HookList HookDrawHealthBar = AddHook<DelegateDrawHealthBar>(g => g.DrawHealthBar)
 
static HookList HookDrawTownAttackGun = AddHook<DelegateDrawTownAttackGun>(g => g.DrawTownAttackGun)
 
static HookList HookDrawTownAttackSwing = AddHook<DelegateDrawTownAttackSwing>(g => g.DrawTownAttackSwing)
 
static HookList HookEditSpawnPool = AddHook<Action<Dictionary<int, float>, NPCSpawnInfo>>(g => g.EditSpawnPool)
 
static HookList HookEditSpawnRange = AddHook<DelegateEditSpawnRange>(g => g.EditSpawnRange)
 
static HookList HookEditSpawnRate = AddHook<DelegateEditSpawnRate>(g => g.EditSpawnRate)
 
static HookList HookFindFrame = AddHook<Action<NPC, int>>(g => g.FindFrame)
 
static HookList HookGetAlpha = AddHook<Func<NPC, Color, Color?>>(g => g.GetAlpha)
 
static HookList HookGetChat = AddHook<DelegateGetChat>(g => g.GetChat)
 
static HookList HookHitEffect = AddHook<Action<NPC, int, double>>(g => g.HitEffect)
 
static HookList HookModifyHitByItem = AddHook<DelegateModifyHitByItem>(g => g.ModifyHitByItem)
 
static HookList HookModifyHitByProjectile = AddHook<DelegateModifyHitByProjectile>(g => g.ModifyHitByProjectile)
 
static HookList HookModifyHitNPC = AddHook<DelegateModifyHitNPC>(g => g.ModifyHitNPC)
 
static HookList HookModifyHitPlayer = AddHook<DelegateModifyHitPlayer>(g => g.ModifyHitPlayer)
 
static HookList HookNPCLoot = AddHook<Action<NPC>>(g => g.NPCLoot)
 
static HookList HookOnChatButtonClicked = AddHook<DelegateOnChatButtonClicked>(g => g.OnChatButtonClicked)
 
static HookList HookOnHitByItem = AddHook<Action<NPC, Player, Item, int, float, bool>>(g => g.OnHitByItem)
 
static HookList HookOnHitByProjectile = AddHook<Action<NPC, Projectile, int, float, bool>>(g => g.OnHitByProjectile)
 
static HookList HookOnHitNPC = AddHook<Action<NPC, NPC, int, float, bool>>(g => g.OnHitNPC)
 
static HookList HookOnHitPlayer = AddHook<Action<NPC, Player, int, bool>>(g => g.OnHitPlayer)
 
static HookList HookPostAI = AddHook<Action<NPC>>(g => g.PostAI)
 
static HookList HookPostDraw = AddHook<Action<NPC, SpriteBatch, Color>>(g => g.PostDraw)
 
static HookList HookPreAI = AddHook<Func<NPC, bool>>(g => g.PreAI)
 
static HookList HookPreChatButtonClicked = AddHook<Func<NPC, bool, bool>>(g => g.PreChatButtonClicked)
 
static HookList HookPreDraw = AddHook<Func<NPC, SpriteBatch, Color, bool>>(g => g.PreDraw)
 
static HookList HookPreNPCLoot = AddHook<Func<NPC, bool>>(g => g.PreNPCLoot)
 
static HookList HookResetEffects = AddHook<Action<NPC>>(g => g.ResetEffects)
 
static List< HookListhooks = new List<HookList>()
 
static HookList HookScaleExpertStats = AddHook<Action<NPC, int, float>>(g => g.ScaleExpertStats)
 
static HookList HookSetDefaults = AddHook<Action<NPC>>(g => g.SetDefaults)
 
static HookList HookSetupShop = AddHook<DelegateSetupShop>(g => g.SetupShop)
 
static HookList HookSetupTravelShop = AddHook<DelegateSetupTravelShop>(g => g.SetupTravelShop)
 
static HookList HookSpawnNPC = AddHook<Action<int, int, int>>(g => g.SpawnNPC)
 
static HookList HookSpecialNPCLoot = AddHook<Func<NPC, bool>>(g => g.SpecialNPCLoot)
 
static HookList HookStrikeNPC = AddHook<DelegateStrikeNPC>(g => g.StrikeNPC)
 
static HookList HookTownNPCAttackCooldown = AddHook<DelegateTownNPCAttackCooldown>(g => g.TownNPCAttackCooldown)
 
static HookList HookTownNPCAttackMagic = AddHook<DelegateTownNPCAttackMagic>(g => g.TownNPCAttackMagic)
 
static HookList HookTownNPCAttackProj = AddHook<DelegateTownNPCAttackProj>(g => g.TownNPCAttackProj)
 
static HookList HookTownNPCAttackProjSpeed = AddHook<DelegateTownNPCAttackProjSpeed>(g => g.TownNPCAttackProjSpeed)
 
static HookList HookTownNPCAttackShoot = AddHook<DelegateTownNPCAttackShoot>(g => g.TownNPCAttackShoot)
 
static HookList HookTownNPCAttackStrength = AddHook<DelegateTownNPCAttackStrength>(g => g.TownNPCAttackStrength)
 
static HookList HookTownNPCAttackSwing = AddHook<DelegateTownNPCAttackSwing>(g => g.TownNPCAttackSwing)
 
static HookList HookUpdateLifeRegen = AddHook<DelegateUpdateLifeRegen>(g => g.UpdateLifeRegen)
 
static int nextNPC = NPCID.Count
 
static readonly int[] shopToNPC = new int[Main.MaxShopIDs - 1]
 
static int vanillaSkeletonCount = NPCID.Sets.Skeletons.Count
 

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.

Definition at line 19 of file NPCLoader.cs.

Constructor & Destructor Documentation

static Terraria.ModLoader.NPCLoader.NPCLoader ( )
staticprivate

Definition at line 54 of file NPCLoader.cs.

References Terraria.ModLoader.ModNet.AllowVanillaClients.

54  {
55  shopToNPC[1] = NPCID.Merchant;
56  shopToNPC[2] = NPCID.ArmsDealer;
57  shopToNPC[3] = NPCID.Dryad;
58  shopToNPC[4] = NPCID.Demolitionist;
59  shopToNPC[5] = NPCID.Clothier;
60  shopToNPC[6] = NPCID.GoblinTinkerer;
61  shopToNPC[7] = NPCID.Wizard;
62  shopToNPC[8] = NPCID.Mechanic;
63  shopToNPC[9] = NPCID.SantaClaus;
64  shopToNPC[10] = NPCID.Truffle;
65  shopToNPC[11] = NPCID.Steampunker;
66  shopToNPC[12] = NPCID.DyeTrader;
67  shopToNPC[13] = NPCID.PartyGirl;
68  shopToNPC[14] = NPCID.Cyborg;
69  shopToNPC[15] = NPCID.Painter;
70  shopToNPC[16] = NPCID.WitchDoctor;
71  shopToNPC[17] = NPCID.Pirate;
72  shopToNPC[18] = NPCID.Stylist;
73  shopToNPC[19] = NPCID.TravellingMerchant;
74  shopToNPC[20] = NPCID.SkeletonMerchant;
75  shopToNPC[21] = NPCID.DD2Bartender;
76  }
static readonly int[] shopToNPC
Definition: NPCLoader.cs:30

Member Function Documentation

static HookList Terraria.ModLoader.NPCLoader.AddHook< F > ( Expression< Func< GlobalNPC, F >>  func)
staticprivate

Definition at line 48 of file NPCLoader.cs.

48  {
49  var hook = new HookList(ModLoader.Method(func));
50  hooks.Add(hook);
51  return hook;
52  }
static List< HookList > hooks
Definition: NPCLoader.cs:46
static void Terraria.ModLoader.NPCLoader.AI ( NPC  npc)
static

Definition at line 271 of file NPCLoader.cs.

References Terraria.ModLoader.GlobalNPC.AI(), Terraria.ModLoader.NPCLoader.HookList.arr, and Terraria.ModLoader.GlobalNPC.Instance().

271  {
272  npc.modNPC?.AI();
273 
274  foreach (GlobalNPC g in HookAI.arr) {
275  g.Instance(npc).AI(npc);
276  }
277  }
static HookList HookAI
Definition: NPCLoader.cs:269

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.BossBag ( NPC  npc,
ref int  bagType 
)
static

Definition at line 430 of file NPCLoader.cs.

430  {
431  if (npc.modNPC != null) {
432  bagType = npc.modNPC.bossBag;
433  }
434  }
static void Terraria.ModLoader.NPCLoader.BossHeadRotation ( NPC  npc,
ref float  rotation 
)
static

Definition at line 639 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.BossHeadRotation(), and Terraria.ModLoader.GlobalNPC.Instance().

639  {
640  npc.modNPC?.BossHeadRotation(ref rotation);
641 
642  foreach (GlobalNPC g in HookBossHeadRotation.arr) {
643  g.Instance(npc).BossHeadRotation(npc, ref rotation);
644  }
645  }
static HookList HookBossHeadRotation
Definition: NPCLoader.cs:637

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.BossHeadSlot ( NPC  npc,
ref int  index 
)
static

Definition at line 628 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.BossHeadSlot(), and Terraria.ModLoader.GlobalNPC.Instance().

628  {
629  npc.modNPC?.BossHeadSlot(ref index);
630 
631  foreach (GlobalNPC g in HookBossHeadSlot.arr) {
632  g.Instance(npc).BossHeadSlot(npc, ref index);
633  }
634  }
static HookList HookBossHeadSlot
Definition: NPCLoader.cs:626

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.BossHeadSpriteEffects ( NPC  npc,
ref SpriteEffects  spriteEffects 
)
static

Definition at line 650 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.BossHeadSpriteEffects(), and Terraria.ModLoader.GlobalNPC.Instance().

650  {
651  npc.modNPC?.BossHeadSpriteEffects(ref spriteEffects);
652 
653  foreach (GlobalNPC g in HookBossHeadSpriteEffects.arr) {
654  g.Instance(npc).BossHeadSpriteEffects(npc, ref spriteEffects);
655  }
656  }
static HookList HookBossHeadSpriteEffects
Definition: NPCLoader.cs:648

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.BossLoot ( NPC  npc,
ref string  name,
ref int  potionType 
)
static

Definition at line 426 of file NPCLoader.cs.

426  {
427  npc.modNPC?.BossLoot(ref name, ref potionType);
428  }
static void Terraria.ModLoader.NPCLoader.BuffTownNPC ( ref float  damageMult,
ref int  defense 
)
static

Definition at line 952 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, and Terraria.ModLoader.GlobalNPC.BuffTownNPC().

952  {
953  foreach (GlobalNPC g in HookBuffTownNPC.arr) {
954  g.BuffTownNPC(ref damageMult, ref defense);
955  }
956  }
static HookList HookBuffTownNPC
Definition: NPCLoader.cs:950

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CanBeHitByItem ( NPC  npc,
Player  player,
Item  item 
)
static

Definition at line 519 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CanBeHitByItem(), Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.Item.

519  {
520  bool? flag = null;
521  foreach (GlobalNPC g in HookCanBeHitByItem.arr) {
522  bool? canHit = g.Instance(npc).CanBeHitByItem(npc, player, item);
523  if (canHit.HasValue && !canHit.Value) {
524  return false;
525  }
526  if (canHit.HasValue) {
527  flag = canHit.Value;
528  }
529  }
530  if (npc.modNPC != null) {
531  bool? canHit = npc.modNPC.CanBeHitByItem(player, item);
532  if (canHit.HasValue && !canHit.Value) {
533  return false;
534  }
535  if (canHit.HasValue) {
536  flag = canHit.Value;
537  }
538  }
539  return flag;
540  }
static HookList HookCanBeHitByItem
Definition: NPCLoader.cs:517

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CanBeHitByProjectile ( NPC  npc,
Projectile  projectile 
)
static

Definition at line 565 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CanBeHitByProjectile(), and Terraria.ModLoader.GlobalNPC.Instance().

565  {
566  bool? flag = null;
567  foreach (GlobalNPC g in HookCanBeHitByProjectile.arr) {
568  bool? canHit = g.Instance(npc).CanBeHitByProjectile(npc, projectile);
569  if (canHit.HasValue && !canHit.Value) {
570  return false;
571  }
572  if (canHit.HasValue) {
573  flag = canHit.Value;
574  }
575  }
576  if (npc.modNPC != null) {
577  bool? canHit = npc.modNPC.CanBeHitByProjectile(projectile);
578  if (canHit.HasValue && !canHit.Value) {
579  return false;
580  }
581  if (canHit.HasValue) {
582  flag = canHit.Value;
583  }
584  }
585  return flag;
586  }
static HookList HookCanBeHitByProjectile
Definition: NPCLoader.cs:563

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CanChat ( NPC  npc)
static

Definition at line 851 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CanChat(), and Terraria.ModLoader.GlobalNPC.Instance().

851  {
852  bool defaultCanChat = npc.modNPC?.CanChat() ?? VanillaCanChat(npc);
853 
854  foreach (GlobalNPC g in HookCanChat.arr) {
855  bool? canChat = g.Instance(npc).CanChat(npc);
856  if (canChat.HasValue) {
857  if (!canChat.Value) {
858  return false;
859  }
860  defaultCanChat = true;
861  }
862  }
863 
864  return defaultCanChat;
865  }
static HookList HookCanChat
Definition: NPCLoader.cs:849
static bool VanillaCanChat(NPC npc)
Definition: NPCLoader.cs:834

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CanHitNPC ( NPC  npc,
NPC  target 
)
static

Definition at line 474 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CanHitNPC(), and Terraria.ModLoader.GlobalNPC.Instance().

474  {
475  bool? flag = null;
476  foreach (GlobalNPC g in HookCanHitNPC.arr) {
477  bool? canHit = g.Instance(npc).CanHitNPC(npc, target);
478  if (canHit.HasValue && !canHit.Value) {
479  return false;
480  }
481  if (canHit.HasValue) {
482  flag = canHit.Value;
483  }
484  }
485  if (npc.modNPC != null) {
486  bool? canHit = npc.modNPC.CanHitNPC(target);
487  if (canHit.HasValue && !canHit.Value) {
488  return false;
489  }
490  if (canHit.HasValue) {
491  flag = canHit.Value;
492  }
493  }
494  return flag;
495  }
static HookList HookCanHitNPC
Definition: NPCLoader.cs:472

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CanHitPlayer ( NPC  npc,
Player  target,
ref int  cooldownSlot 
)
static

Definition at line 439 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CanHitPlayer(), and Terraria.ModLoader.GlobalNPC.Instance().

439  {
440  foreach (GlobalNPC g in HookCanHitPlayer.arr) {
441  if (!g.Instance(npc).CanHitPlayer(npc, target, ref cooldownSlot)) {
442  return false;
443  }
444  }
445  if (npc.modNPC != null) {
446  return npc.modNPC.CanHitPlayer(target, ref cooldownSlot);
447  }
448  return true;
449  }
static HookList HookCanHitPlayer
Definition: NPCLoader.cs:437

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.CanTownNPCSpawn ( int  numTownNPCs,
int  money 
)
static

Definition at line 810 of file NPCLoader.cs.

References Terraria.ModLoader.ModNPC.CanTownNPCSpawn(), and Terraria.ModLoader.ModNPC.npc.

810  {
811  foreach (ModNPC npc in npcs) {
812  if (npc.npc.townNPC && NPC.TypeToHeadIndex(npc.npc.type) >= 0 && !NPC.AnyNPCs(npc.npc.type) &&
813  npc.CanTownNPCSpawn(numTownNPCs, money)) {
814  Main.townNPCCanSpawn[npc.npc.type] = true;
815  if (WorldGen.prioritizedTownNPC == 0) {
816  WorldGen.prioritizedTownNPC = npc.npc.type;
817  }
818  }
819  }
820  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CheckActive ( NPC  npc)
static

Definition at line 359 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CheckActive(), and Terraria.ModLoader.GlobalNPC.Instance().

359  {
360  if (npc.modNPC != null && !npc.modNPC.CheckActive()) {
361  return false;
362  }
363  foreach (GlobalNPC g in HookCheckActive.arr) {
364  if (!g.Instance(npc).CheckActive(npc)) {
365  return false;
366  }
367  }
368  return true;
369  }
static HookList HookCheckActive
Definition: NPCLoader.cs:357

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CheckConditions ( int  type)
static

Definition at line 822 of file NPCLoader.cs.

822  {
823  return GetNPC(type)?.CheckConditions(WorldGen.roomX1, WorldGen.roomX2, WorldGen.roomY1, WorldGen.roomY2) ?? true;
824  }
virtual bool CheckConditions(int left, int right, int top, int bottom)
Allows you to define special conditions required for this town NPC&#39;s house. For example, Truffle requires the house to be in an aboveground mushroom biome.
Definition: ModNPC.cs:571
static ModNPC GetNPC(int type)
Gets the ModNPC instance corresponding to the specified type.
Definition: NPCLoader.cs:93
static bool Terraria.ModLoader.NPCLoader.CheckDead ( NPC  npc)
static

Definition at line 373 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.CheckDead(), and Terraria.ModLoader.GlobalNPC.Instance().

373  {
374  if (npc.modNPC != null && !npc.modNPC.CheckDead()) {
375  return false;
376  }
377  foreach (GlobalNPC g in HookCheckDead.arr) {
378  if (!g.Instance(npc).CheckDead(npc)) {
379  return false;
380  }
381  }
382  return true;
383  }
static HookList HookCheckDead
Definition: NPCLoader.cs:371

+ Here is the call graph for this function:

static int Terraria.ModLoader.NPCLoader.ChooseSpawn ( NPCSpawnInfo  spawnInfo)
static

Definition at line 764 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.EditSpawnPool(), Terraria.ModLoader.ModNPC.npc, and Terraria.ModLoader.ModNPC.SpawnChance().

764  {
765  NPCSpawnHelper.Reset();
766  NPCSpawnHelper.DoChecks(spawnInfo);
767  IDictionary<int, float> pool = new Dictionary<int, float>();
768  pool[0] = 1f;
769  foreach (ModNPC npc in npcs) {
770  float weight = npc.SpawnChance(spawnInfo);
771  if (weight > 0f) {
772  pool[npc.npc.type] = weight;
773  }
774  }
775  foreach (GlobalNPC g in HookEditSpawnPool.arr) {
776  g.EditSpawnPool(pool, spawnInfo);
777  }
778  float totalWeight = 0f;
779  foreach (int type in pool.Keys) {
780  if (pool[type] < 0f) {
781  pool[type] = 0f;
782  }
783  totalWeight += pool[type];
784  }
785  float choice = (float)Main.rand.NextDouble() * totalWeight;
786  foreach (int type in pool.Keys) {
787  float weight = pool[type];
788  if (choice < weight) {
789  return type;
790  }
791  choice -= weight;
792  }
793  return null;
794  }
static HookList HookEditSpawnPool
Definition: NPCLoader.cs:762

+ Here is the call graph for this function:

delegate void Terraria.ModLoader.NPCLoader.DelegateBossHeadRotation ( NPC  npc,
ref float  rotation 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateBossHeadSlot ( NPC  npc,
ref int  index 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateBossHeadSpriteEffects ( NPC  npc,
ref SpriteEffects  spriteEffects 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateBuffTownNPC ( ref float  damageMult,
ref int  defense 
)
private
delegate bool Terraria.ModLoader.NPCLoader.DelegateCanHitPlayer ( NPC  npc,
Player  target,
ref int  cooldownSlot 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateDrawEffects ( NPC  npc,
ref Color  drawColor 
)
private
delegate bool Terraria.ModLoader.NPCLoader.DelegateDrawHealthBar ( NPC  npc,
byte  bhPosition,
ref float  scale,
ref Vector2  position 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateDrawTownAttackGun ( NPC  npc,
ref float  scale,
ref int  item,
ref int  closeness 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateDrawTownAttackSwing ( NPC  npc,
ref Texture2D  item,
ref int  itemSize,
ref float  scale,
ref Vector2  offset 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateEditSpawnRange ( Player  player,
ref int  spawnRangeX,
ref int  spawnRangeY,
ref int  safeRangeX,
ref int  safeRangeY 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateEditSpawnRate ( Player  player,
ref int  spawnRate,
ref int  maxSpawns 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateGetChat ( NPC  npc,
ref string  chat 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateModifyHitByItem ( NPC  npc,
Player  player,
Item  item,
ref int  damage,
ref float  knockback,
ref bool  crit 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateModifyHitByProjectile ( NPC  npc,
Projectile  projectile,
ref int  damage,
ref float  knockback,
ref bool  crit,
ref int  hitDirection 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateModifyHitNPC ( NPC  npc,
NPC  target,
ref int  damage,
ref float  knockback,
ref bool  crit 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateModifyHitPlayer ( NPC  npc,
Player  target,
ref int  damage,
ref bool  crit 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateOnChatButtonClicked ( NPC  npc,
bool  firstButton 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateSetupShop ( int  type,
Chest  shop,
ref int  nextSlot 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateSetupTravelShop ( int[]  shop,
ref int  nextSlot 
)
private
delegate bool Terraria.ModLoader.NPCLoader.DelegateStrikeNPC ( NPC  npc,
ref double  damage,
int  defense,
ref float  knockback,
int  hitDirection,
ref bool  crit 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackCooldown ( NPC  npc,
ref int  cooldown,
ref int  randExtraCooldown 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackMagic ( NPC  npc,
ref float  auraLightMultiplier 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackProj ( NPC  npc,
ref int  projType,
ref int  attackDelay 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackProjSpeed ( NPC  npc,
ref float  multiplier,
ref float  gravityCorrection,
ref float  randomOffset 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackShoot ( NPC  npc,
ref bool  inBetweenShots 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackStrength ( NPC  npc,
ref int  damage,
ref float  knockback 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateTownNPCAttackSwing ( NPC  npc,
ref int  itemWidth,
ref int  itemHeight 
)
private
delegate void Terraria.ModLoader.NPCLoader.DelegateUpdateLifeRegen ( NPC  npc,
ref int  damage 
)
private
static void Terraria.ModLoader.NPCLoader.DrawEffects ( NPC  npc,
ref Color  drawColor 
)
static

Definition at line 673 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.DrawEffects(), and Terraria.ModLoader.GlobalNPC.Instance().

673  {
674  npc.modNPC?.DrawEffects(ref drawColor);
675 
676  foreach (GlobalNPC g in HookDrawEffects.arr) {
677  g.Instance(npc).DrawEffects(npc, ref drawColor);
678  }
679  }
static HookList HookDrawEffects
Definition: NPCLoader.cs:671

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.DrawHealthBar ( NPC  npc,
ref float  scale 
)
static

Definition at line 708 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.DrawHealthBar(), and Terraria.ModLoader.GlobalNPC.Instance().

708  {
709  Vector2 position = new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.gfxOffY);
710  if (Main.HealthBarDrawSettings == 1) {
711  position.Y += npc.height + 10f + Main.NPCAddHeight(npc.whoAmI);
712  }
713  else if (Main.HealthBarDrawSettings == 2) {
714  position.Y -= 24f + Main.NPCAddHeight(npc.whoAmI) / 2f;
715  }
716  foreach (GlobalNPC g in HookDrawHealthBar.arr) {
717  bool? result = g.Instance(npc).DrawHealthBar(npc, Main.HealthBarDrawSettings, ref scale, ref position);
718  if (result.HasValue) {
719  if (result.Value) {
720  DrawHealthBar(npc, position, scale);
721  }
722  return false;
723  }
724  }
725  if (NPCLoader.IsModNPC(npc)) {
726  bool? result = npc.modNPC.DrawHealthBar(Main.HealthBarDrawSettings, ref scale, ref position);
727  if (result.HasValue) {
728  if (result.Value) {
729  DrawHealthBar(npc, position, scale);
730  }
731  return false;
732  }
733  }
734  return true;
735  }
static HookList HookDrawHealthBar
Definition: NPCLoader.cs:706
static bool DrawHealthBar(NPC npc, ref float scale)
Definition: NPCLoader.cs:708

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.DrawHealthBar ( NPC  npc,
Vector2  position,
float  scale 
)
staticprivate

Definition at line 737 of file NPCLoader.cs.

737  {
738  float alpha = Lighting.Brightness((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f));
739  Main.instance.DrawHealthBar(position.X, position.Y, npc.life, npc.lifeMax, alpha, scale);
740  }
static void Terraria.ModLoader.NPCLoader.DrawTownAttackGun ( NPC  npc,
ref float  scale,
ref int  item,
ref int  closeness 
)
static

Definition at line 1055 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.DrawTownAttackGun(), and Terraria.ModLoader.GlobalNPC.Instance().

1055  {
1056  npc.modNPC?.DrawTownAttackGun(ref scale, ref item, ref closeness);
1057 
1058  foreach (GlobalNPC g in HookDrawTownAttackGun.arr) {
1059  g.Instance(npc).DrawTownAttackGun(npc, ref scale, ref item, ref closeness);
1060  }
1061  }
static HookList HookDrawTownAttackGun
Definition: NPCLoader.cs:1053

+ Here is the call graph for this function:

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

Definition at line 1066 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.DrawTownAttackSwing(), and Terraria.ModLoader.GlobalNPC.Instance().

1066  {
1067  npc.modNPC?.DrawTownAttackSwing(ref item, ref itemSize, ref scale, ref offset);
1068 
1069  foreach (GlobalNPC g in HookDrawTownAttackSwing.arr) {
1070  g.Instance(npc).DrawTownAttackSwing(npc, ref item, ref itemSize, ref scale, ref offset);
1071  }
1072  }
static HookList HookDrawTownAttackSwing
Definition: NPCLoader.cs:1064

+ Here is the call graph for this function:

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

Definition at line 755 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, and Terraria.ModLoader.GlobalNPC.EditSpawnRange().

756  {
757  foreach (GlobalNPC g in HookEditSpawnRange.arr) {
758  g.EditSpawnRange(player, ref spawnRangeX, ref spawnRangeY, ref safeRangeX, ref safeRangeY);
759  }
760  }
static HookList HookEditSpawnRange
Definition: NPCLoader.cs:753

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.EditSpawnRate ( Player  player,
ref int  spawnRate,
ref int  maxSpawns 
)
static

Definition at line 745 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, and Terraria.ModLoader.GlobalNPC.EditSpawnRate().

745  {
746  foreach (GlobalNPC g in HookEditSpawnRate.arr) {
747  g.EditSpawnRate(player, ref spawnRate, ref maxSpawns);
748  }
749  }
static HookList HookEditSpawnRate
Definition: NPCLoader.cs:743

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.FindFrame ( NPC  npc,
int  frameHeight 
)
static

Definition at line 321 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.FindFrame(), and Terraria.ModLoader.GlobalNPC.Instance().

321  {
322  int type = npc.type;
323  if (npc.modNPC != null && npc.modNPC.animationType > 0) {
324  npc.type = npc.modNPC.animationType;
325  }
326  npc.VanillaFindFrame(frameHeight);
327  npc.type = type;
328  npc.modNPC?.FindFrame(frameHeight);
329 
330  foreach (GlobalNPC g in HookFindFrame.arr) {
331  g.Instance(npc).FindFrame(npc, frameHeight);
332  }
333  }
static HookList HookFindFrame
Definition: NPCLoader.cs:319

+ Here is the call graph for this function:

static Color Terraria.ModLoader.NPCLoader.GetAlpha ( NPC  npc,
Color  lightColor 
)
static

Definition at line 660 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.GetAlpha(), and Terraria.ModLoader.GlobalNPC.Instance().

660  {
661  foreach (GlobalNPC g in HookGetAlpha.arr) {
662  Color? color = g.Instance(npc).GetAlpha(npc, lightColor);
663  if (color.HasValue) {
664  return color.Value;
665  }
666  }
667  return npc.modNPC?.GetAlpha(lightColor);
668  }
static HookList HookGetAlpha
Definition: NPCLoader.cs:658

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.GetChat ( NPC  npc,
ref string  chat 
)
static

Definition at line 870 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.GetChat(), and Terraria.ModLoader.GlobalNPC.Instance().

870  {
871  if (npc.modNPC != null) {
872  chat = npc.modNPC.GetChat();
873  }
874  else if (chat.Equals("")) {
875  chat = Language.GetTextValue("tModLoader.DefaultTownNPCChat");
876  }
877  foreach (GlobalNPC g in HookGetChat.arr) {
878  g.Instance(npc).GetChat(npc, ref chat);
879  }
880  }
static HookList HookGetChat
Definition: NPCLoader.cs:868

+ Here is the call graph for this function:

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.

Definition at line 93 of file NPCLoader.cs.

93  {
94  return type >= NPCID.Count && type < NPCCount ? npcs[type - NPCID.Count] : null;
95  }
static bool Terraria.ModLoader.NPCLoader.HasMethod ( Type  t,
string  method,
params Type[]  args 
)
staticprivate

Definition at line 1074 of file NPCLoader.cs.

References Terraria.ModLoader.GlobalNPC.InstancePerEntity.

1074  {
1075  return t.GetMethod(method, args).DeclaringType != typeof(GlobalNPC);
1076  }
static void Terraria.ModLoader.NPCLoader.HitEffect ( NPC  npc,
int  hitDirection,
double  damage 
)
static

Definition at line 337 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.HitEffect(), and Terraria.ModLoader.GlobalNPC.Instance().

337  {
338  npc.VanillaHitEffect(hitDirection, damage);
339  npc.modNPC?.HitEffect(hitDirection, damage);
340 
341  foreach (GlobalNPC g in HookHitEffect.arr) {
342  g.Instance(npc).HitEffect(npc, hitDirection, damage);
343  }
344  }
static HookList HookHitEffect
Definition: NPCLoader.cs:335

+ Here is the call graph for this function:

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

Definition at line 545 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.ModifyHitByItem().

545  {
546  npc.modNPC?.ModifyHitByItem(player, item, ref damage, ref knockback, ref crit);
547 
548  foreach (GlobalNPC g in HookModifyHitByItem.arr) {
549  g.Instance(npc).ModifyHitByItem(npc, player, item, ref damage, ref knockback, ref crit);
550  }
551  }
static HookList HookModifyHitByItem
Definition: NPCLoader.cs:543

+ Here is the call graph for this function:

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

Definition at line 591 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.ModifyHitByProjectile().

591  {
592  npc.modNPC?.ModifyHitByProjectile(projectile, ref damage, ref knockback, ref crit, ref hitDirection);
593 
594  foreach (GlobalNPC g in HookModifyHitByProjectile.arr) {
595  g.Instance(npc).ModifyHitByProjectile(npc, projectile, ref damage, ref knockback, ref crit, ref hitDirection);
596  }
597  }
static HookList HookModifyHitByProjectile
Definition: NPCLoader.cs:589

+ Here is the call graph for this function:

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

Definition at line 500 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.ModifyHitNPC().

500  {
501  npc.modNPC?.ModifyHitNPC(target, ref damage, ref knockback, ref crit);
502 
503  foreach (GlobalNPC g in HookModifyHitNPC.arr) {
504  g.Instance(npc).ModifyHitNPC(npc, target, ref damage, ref knockback, ref crit);
505  }
506  }
static HookList HookModifyHitNPC
Definition: NPCLoader.cs:498

+ Here is the call graph for this function:

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

Definition at line 454 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.ModifyHitPlayer().

454  {
455  npc.modNPC?.ModifyHitPlayer(target, ref damage, ref crit);
456 
457  foreach (GlobalNPC g in HookModifyHitPlayer.arr) {
458  g.Instance(npc).ModifyHitPlayer(npc, target, ref damage, ref crit);
459  }
460  }
static HookList HookModifyHitPlayer
Definition: NPCLoader.cs:452

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.NPCAI ( NPC  npc)
static

Definition at line 239 of file NPCLoader.cs.

239  {
240  if (PreAI(npc)) {
241  int type = npc.type;
242  bool useAiType = npc.modNPC != null && npc.modNPC.aiType > 0;
243  if (useAiType) {
244  npc.type = npc.modNPC.aiType;
245  }
246  npc.VanillaAI();
247  if (useAiType) {
248  npc.type = type;
249  }
250  AI(npc);
251  }
252  PostAI(npc);
253  }
static void AI(NPC npc)
Definition: NPCLoader.cs:271
static void PostAI(NPC npc)
Definition: NPCLoader.cs:281
static bool PreAI(NPC npc)
Definition: NPCLoader.cs:257
static void Terraria.ModLoader.NPCLoader.NPCLoot ( NPC  npc)
static

Definition at line 417 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.NPCLoot().

417  {
418  npc.modNPC?.NPCLoot();
419 
420  foreach (GlobalNPC g in HookNPCLoot.arr) {
421  g.Instance(npc).NPCLoot(npc);
422  }
423  blockLoot.Clear();
424  }
static HookList HookNPCLoot
Definition: NPCLoader.cs:415
static readonly IList< int > blockLoot
Allows you to stop an NPC from dropping loot by adding item IDs to this list. This list will be clear...
Definition: NPCLoader.cs:34

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.OnChatButtonClicked ( bool  firstButton)
static

Definition at line 906 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.OnChatButtonClicked().

906  {
907  NPC npc = Main.npc[Main.LocalPlayer.talkNPC];
908  bool shop = false;
909 
910  if (npc.modNPC != null) {
911  npc.modNPC.OnChatButtonClicked(firstButton, ref shop);
912  Main.PlaySound(SoundID.MenuTick);
913  if (shop) {
914  Main.playerInventory = true;
915  Main.npcChatText = "";
916  Main.npcShop = Main.MaxShopIDs - 1;
917  Main.instance.shop[Main.npcShop].SetupShop(npc.type);
918  }
919  }
920  foreach (GlobalNPC g in HookOnChatButtonClicked.arr) {
921  g.Instance(npc).OnChatButtonClicked(npc, firstButton);
922  }
923  }
static HookList HookOnChatButtonClicked
Definition: NPCLoader.cs:904

+ Here is the call graph for this function:

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

Definition at line 555 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.OnHitByItem().

555  {
556  npc.modNPC?.OnHitByItem(player, item, damage, knockback, crit);
557 
558  foreach (GlobalNPC g in HookOnHitByItem.arr) {
559  g.Instance(npc).OnHitByItem(npc, player, item, damage, knockback, crit);
560  }
561  }
static HookList HookOnHitByItem
Definition: NPCLoader.cs:553

+ Here is the call graph for this function:

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

Definition at line 601 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.OnHitByProjectile().

601  {
602  npc.modNPC?.OnHitByProjectile(projectile, damage, knockback, crit);
603 
604  foreach (GlobalNPC g in HookOnHitByProjectile.arr) {
605  g.Instance(npc).OnHitByProjectile(npc, projectile, damage, knockback, crit);
606  }
607  }
static HookList HookOnHitByProjectile
Definition: NPCLoader.cs:599

+ Here is the call graph for this function:

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

Definition at line 510 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.OnHitNPC().

510  {
511  npc.modNPC?.OnHitNPC(target, damage, knockback, crit);
512  foreach (GlobalNPC g in HookOnHitNPC.arr) {
513  g.Instance(npc).OnHitNPC(npc, target, damage, knockback, crit);
514  }
515  }
static HookList HookOnHitNPC
Definition: NPCLoader.cs:508

+ Here is the call graph for this function:

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

Definition at line 464 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.OnHitPlayer().

464  {
465  npc.modNPC?.OnHitPlayer(target, damage, crit);
466 
467  foreach (GlobalNPC g in HookOnHitPlayer.arr) {
468  g.Instance(npc).OnHitPlayer(npc, target, damage, crit);
469  }
470  }
static HookList HookOnHitPlayer
Definition: NPCLoader.cs:462

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.PostAI ( NPC  npc)
static

Definition at line 281 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.PostAI().

281  {
282  npc.modNPC?.PostAI();
283 
284  foreach (GlobalNPC g in HookPostAI.arr) {
285  g.Instance(npc).PostAI(npc);
286  }
287  }
static HookList HookPostAI
Definition: NPCLoader.cs:279

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.PostDraw ( NPC  npc,
SpriteBatch  spriteBatch,
Color  drawColor 
)
static

Definition at line 697 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.PostDraw().

697  {
698  npc.modNPC?.PostDraw(spriteBatch, drawColor);
699 
700  foreach (GlobalNPC g in HookPostDraw.arr) {
701  g.Instance(npc).PostDraw(npc, spriteBatch, drawColor);
702  }
703  }
static HookList HookPostDraw
Definition: NPCLoader.cs:695

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.PreAI ( NPC  npc)
static

Definition at line 257 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.PreAI().

257  {
258  foreach (GlobalNPC g in HookPreAI.arr) {
259  if (!g.Instance(npc).PreAI(npc)) {
260  return false;
261  }
262  }
263  if (npc.modNPC != null) {
264  return npc.modNPC.PreAI();
265  }
266  return true;
267  }
static HookList HookPreAI
Definition: NPCLoader.cs:255

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.PreChatButtonClicked ( bool  firstButton)
static

Definition at line 891 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.PreChatButtonClicked().

891  {
892  NPC npc = Main.npc[Main.LocalPlayer.talkNPC];
893 
894  foreach (GlobalNPC g in HookPreChatButtonClicked.arr) {
895  if (!g.Instance(npc).PreChatButtonClicked(npc, firstButton)) {
896  Main.PlaySound(SoundID.MenuTick);
897  return false;
898  }
899  }
900  return true;
901  }
static HookList HookPreChatButtonClicked
Definition: NPCLoader.cs:889

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.PreDraw ( NPC  npc,
SpriteBatch  spriteBatch,
Color  drawColor 
)
static

Definition at line 683 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.PreDraw().

683  {
684  foreach (GlobalNPC g in HookPreDraw.arr) {
685  if (!g.Instance(npc).PreDraw(npc, spriteBatch, drawColor)) {
686  return false;
687  }
688  }
689  if (npc.modNPC != null) {
690  return npc.modNPC.PreDraw(spriteBatch, drawColor);
691  }
692  return true;
693  }
static HookList HookPreDraw
Definition: NPCLoader.cs:681

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.PreNPCLoot ( NPC  npc)
static

Definition at line 401 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.PreNPCLoot().

401  {
402  foreach (GlobalNPC g in HookPreNPCLoot.arr) {
403  if (!g.Instance(npc).PreNPCLoot(npc)) {
404  blockLoot.Clear();
405  return false;
406  }
407  }
408  if (npc.modNPC != null && !npc.modNPC.PreNPCLoot()) {
409  blockLoot.Clear();
410  return false;
411  }
412  return true;
413  }
static HookList HookPreNPCLoot
Definition: NPCLoader.cs:399
static readonly IList< int > blockLoot
Allows you to stop an NPC from dropping loot by adding item IDs to this list. This list will be clear...
Definition: NPCLoader.cs:34

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.ReceiveExtraAI ( NPC  npc,
BinaryReader  reader 
)
static

Definition at line 306 of file NPCLoader.cs.

306  {
307  if (npc.modNPC != null) {
308  byte[] extraAI = reader.ReadBytes(reader.ReadByte());
309  if (extraAI.Length > 0) {
310  using (MemoryStream stream = new MemoryStream(extraAI)) {
311  using (BinaryReader modReader = new BinaryReader(stream)) {
312  npc.modNPC.ReceiveExtraAI(modReader);
313  }
314  }
315  }
316  }
317  }
static void Terraria.ModLoader.NPCLoader.ResetEffects ( NPC  npc)
static

Definition at line 231 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.ResetEffects().

231  {
232  npc.modNPC?.ResetEffects();
233 
234  foreach (GlobalNPC g in HookResetEffects.arr) {
235  g.Instance(npc).ResetEffects(npc);
236  }
237  }
static HookList HookResetEffects
Definition: NPCLoader.cs:229

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.ScaleExpertStats ( NPC  npc,
int  numPlayers,
float  bossLifeScale 
)
static

Definition at line 221 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.ScaleExpertStats().

221  {
222  npc.modNPC?.ScaleExpertStats(numPlayers, bossLifeScale);
223 
224  foreach (GlobalNPC g in HookScaleExpertStats.arr) {
225  g.Instance(npc).ScaleExpertStats(npc, numPlayers, bossLifeScale);
226  }
227  }
static HookList HookScaleExpertStats
Definition: NPCLoader.cs:219

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.SendExtraAI ( NPC  npc,
BinaryWriter  writer 
)
static

Definition at line 289 of file NPCLoader.cs.

289  {
290  if (npc.modNPC != null) {
291  byte[] data;
292  using (MemoryStream stream = new MemoryStream()) {
293  using (BinaryWriter modWriter = new BinaryWriter(stream)) {
294  npc.modNPC.SendExtraAI(modWriter);
295  modWriter.Flush();
296  data = stream.ToArray();
297  }
298  }
299  writer.Write((byte)data.Length);
300  if (data.Length > 0) {
301  writer.Write(data);
302  }
303  }
304  }
static void Terraria.ModLoader.NPCLoader.SetChatButtons ( ref string  button,
ref string  button2 
)
static

Definition at line 882 of file NPCLoader.cs.

882  {
883  if (Main.player[Main.myPlayer].talkNPC >= 0) {
884  NPC npc = Main.npc[Main.player[Main.myPlayer].talkNPC];
885  npc.modNPC?.SetChatButtons(ref button, ref button2);
886  }
887  }
static void Terraria.ModLoader.NPCLoader.SetupShop ( int  type,
Chest  shop,
ref int  nextSlot 
)
static

Definition at line 928 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, and Terraria.ModLoader.GlobalNPC.SetupShop().

928  {
929  if (type < shopToNPC.Length) {
930  type = shopToNPC[type];
931  }
932  else {
933  GetNPC(type)?.SetupShop(shop, ref nextSlot);
934  }
935  foreach (GlobalNPC g in HookSetupShop.arr) {
936  g.SetupShop(type, shop, ref nextSlot);
937  }
938  }
static readonly int[] shopToNPC
Definition: NPCLoader.cs:30
virtual void SetupShop(Chest shop, ref int nextSlot)
Allows you to add items to this NPC&#39;s shop. Add an item by setting the defaults of shop...
Definition: ModNPC.cs:628
static HookList HookSetupShop
Definition: NPCLoader.cs:926
static ModNPC GetNPC(int type)
Gets the ModNPC instance corresponding to the specified type.
Definition: NPCLoader.cs:93

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.SetupTravelShop ( int[]  shop,
ref int  nextSlot 
)
static

Definition at line 943 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, and Terraria.ModLoader.GlobalNPC.SetupTravelShop().

943  {
944  foreach (GlobalNPC g in HookSetupTravelShop.arr) {
945  g.SetupTravelShop(shop, ref nextSlot);
946  }
947  }
static HookList HookSetupTravelShop
Definition: NPCLoader.cs:941

+ Here is the call graph for this function:

static int Terraria.ModLoader.NPCLoader.SpawnNPC ( int  type,
int  tileX,
int  tileY 
)
static

Definition at line 798 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), Terraria.ModLoader.GlobalNPC.SpawnNPC(), and Terraria.ModLoader.ModNPC.SpawnNPC().

798  {
799  var npc = type >= NPCID.Count ?
800  GetNPC(type).SpawnNPC(tileX, tileY) :
801  NPC.NewNPC(tileX * 16 + 8, tileY * 16, type);
802 
803  foreach (GlobalNPC g in HookSpawnNPC.arr) {
804  g.Instance(Main.npc[npc]).SpawnNPC(npc, tileX, tileY);
805  }
806 
807  return npc;
808  }
virtual int SpawnNPC(int tileX, int tileY)
Allows you to customize how this NPC is created when it naturally spawns (for example, its position or ai array). Return the return value of NPC.NewNPC. By default this method spawns this NPC on top of the tile at the given coordinates.
Definition: ModNPC.cs:549
static ModNPC GetNPC(int type)
Gets the ModNPC instance corresponding to the specified type.
Definition: NPCLoader.cs:93
static HookList HookSpawnNPC
Definition: NPCLoader.cs:796

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.SpecialNPCLoot ( NPC  npc)
static

Definition at line 387 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.SpecialNPCLoot().

387  {
388  foreach (GlobalNPC g in HookSpecialNPCLoot.arr) {
389  if (g.Instance(npc).SpecialNPCLoot(npc)) {
390  return true;
391  }
392  }
393  if (npc.modNPC != null) {
394  return npc.modNPC.SpecialNPCLoot();
395  }
396  return false;
397  }
static HookList HookSpecialNPCLoot
Definition: NPCLoader.cs:385

+ Here is the call graph for this function:

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

Definition at line 612 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.StrikeNPC().

612  {
613  bool flag = true;
614  if (npc.modNPC != null) {
615  flag = npc.modNPC.StrikeNPC(ref damage, defense, ref knockback, hitDirection, ref crit);
616  }
617  foreach (GlobalNPC g in HookStrikeNPC.arr) {
618  if (!g.Instance(npc).StrikeNPC(npc, ref damage, defense, ref knockback, hitDirection, ref crit)) {
619  flag = false;
620  }
621  }
622  return flag;
623  }
static HookList HookStrikeNPC
Definition: NPCLoader.cs:610

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackCooldown ( NPC  npc,
ref int  cooldown,
ref int  randExtraCooldown 
)
static

Definition at line 987 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackCooldown().

987  {
988  npc.modNPC?.TownNPCAttackCooldown(ref cooldown, ref randExtraCooldown);
989 
990  foreach (GlobalNPC g in HookTownNPCAttackCooldown.arr) {
991  g.Instance(npc).TownNPCAttackCooldown(npc, ref cooldown, ref randExtraCooldown);
992  }
993  }
static HookList HookTownNPCAttackCooldown
Definition: NPCLoader.cs:985

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackMagic ( NPC  npc,
ref float  auraLightMultiplier 
)
static

Definition at line 1033 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackMagic().

1033  {
1034  npc.modNPC?.TownNPCAttackMagic(ref auraLightMultiplier);
1035 
1036  foreach (GlobalNPC g in HookTownNPCAttackMagic.arr) {
1037  g.Instance(npc).TownNPCAttackMagic(npc, ref auraLightMultiplier);
1038  }
1039  }
static HookList HookTownNPCAttackMagic
Definition: NPCLoader.cs:1031

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackProj ( NPC  npc,
ref int  projType,
ref int  attackDelay 
)
static

Definition at line 998 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackProj().

998  {
999  npc.modNPC?.TownNPCAttackProj(ref projType, ref attackDelay);
1000 
1001  foreach (GlobalNPC g in HookTownNPCAttackProj.arr) {
1002  g.Instance(npc).TownNPCAttackProj(npc, ref projType, ref attackDelay);
1003  }
1004  }
static HookList HookTownNPCAttackProj
Definition: NPCLoader.cs:996

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackProjSpeed ( NPC  npc,
ref float  multiplier,
ref float  gravityCorrection,
ref float  randomOffset 
)
static

Definition at line 1010 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackProjSpeed().

1011  {
1012  npc.modNPC?.TownNPCAttackProjSpeed(ref multiplier, ref gravityCorrection, ref randomOffset);
1013 
1014  foreach (GlobalNPC g in HookTownNPCAttackProjSpeed.arr) {
1015  g.Instance(npc).TownNPCAttackProjSpeed(npc, ref multiplier, ref gravityCorrection, ref randomOffset);
1016  }
1017  }
static HookList HookTownNPCAttackProjSpeed
Definition: NPCLoader.cs:1008

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackShoot ( NPC  npc,
ref bool  inBetweenShots 
)
static

Definition at line 1022 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackShoot().

1022  {
1023  npc.modNPC?.TownNPCAttackShoot(ref inBetweenShots);
1024 
1025  foreach (GlobalNPC g in HookTownNPCAttackShoot.arr) {
1026  g.Instance(npc).TownNPCAttackShoot(npc, ref inBetweenShots);
1027  }
1028  }
static HookList HookTownNPCAttackShoot
Definition: NPCLoader.cs:1020

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackStrength ( NPC  npc,
ref int  damage,
ref float  knockback 
)
static

Definition at line 976 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackStrength().

976  {
977  npc.modNPC?.TownNPCAttackStrength(ref damage, ref knockback);
978 
979  foreach (GlobalNPC g in HookTownNPCAttackStrength.arr) {
980  g.Instance(npc).TownNPCAttackStrength(npc, ref damage, ref knockback);
981  }
982  }
static HookList HookTownNPCAttackStrength
Definition: NPCLoader.cs:974

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.TownNPCAttackSwing ( NPC  npc,
ref int  itemWidth,
ref int  itemHeight 
)
static

Definition at line 1044 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.TownNPCAttackSwing().

1044  {
1045  npc.modNPC?.TownNPCAttackSwing(ref itemWidth, ref itemHeight);
1046 
1047  foreach (GlobalNPC g in HookTownNPCAttackSwing.arr) {
1048  g.Instance(npc).TownNPCAttackSwing(npc, ref itemWidth, ref itemHeight);
1049  }
1050  }
static HookList HookTownNPCAttackSwing
Definition: NPCLoader.cs:1042

+ Here is the call graph for this function:

static string Terraria.ModLoader.NPCLoader.TownNPCName ( int  type)
static

Definition at line 826 of file NPCLoader.cs.

826  {
827  return GetNPC(type)?.TownNPCName() ?? "";
828  }
static ModNPC GetNPC(int type)
Gets the ModNPC instance corresponding to the specified type.
Definition: NPCLoader.cs:93
virtual string TownNPCName()
Allows you to give this town NPC any name when it spawns. By default returns something embarrassing...
Definition: ModNPC.cs:579
static void Terraria.ModLoader.NPCLoader.UpdateLifeRegen ( NPC  npc,
ref int  damage 
)
static

Definition at line 349 of file NPCLoader.cs.

References Terraria.ModLoader.NPCLoader.HookList.arr, Terraria.ModLoader.GlobalNPC.Instance(), and Terraria.ModLoader.GlobalNPC.UpdateLifeRegen().

349  {
350  npc.modNPC?.UpdateLifeRegen(ref damage);
351 
352  foreach (GlobalNPC g in HookUpdateLifeRegen.arr) {
353  g.Instance(npc).UpdateLifeRegen(npc, ref damage);
354  }
355  }
static HookList HookUpdateLifeRegen
Definition: NPCLoader.cs:347

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.UsesPartyHat ( NPC  npc)
static

Definition at line 830 of file NPCLoader.cs.

830  {
831  return npc.modNPC?.UsesPartyHat() ?? true;
832  }
static bool Terraria.ModLoader.NPCLoader.VanillaCanChat ( NPC  npc)
static

Definition at line 834 of file NPCLoader.cs.

834  {
835  switch (npc.type) {
836  case NPCID.BoundGoblin:
837  case NPCID.BoundWizard:
838  case NPCID.BoundMechanic:
839  case NPCID.WebbedStylist:
840  case NPCID.SleepingAngler:
841  case NPCID.BartenderUnconscious:
842  case NPCID.SkeletonMerchant:
843  return true;
844  default:
845  return npc.townNPC;
846  }
847  }

Member Data Documentation

readonly IList<int> Terraria.ModLoader.NPCLoader.blockLoot = new List<int>()
static

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.

Definition at line 34 of file NPCLoader.cs.

Referenced by Terraria.ModLoader.ItemLoader.PreOpenVanillaBag().

HookList Terraria.ModLoader.NPCLoader.HookAI = AddHook<Action<NPC>>(g => g.AI)
staticprivate

Definition at line 269 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookBossHeadRotation = AddHook<DelegateBossHeadRotation>(g => g.BossHeadRotation)
staticprivate

Definition at line 637 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookBossHeadSlot = AddHook<DelegateBossHeadSlot>(g => g.BossHeadSlot)
staticprivate

Definition at line 626 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookBossHeadSpriteEffects = AddHook<DelegateBossHeadSpriteEffects>(g => g.BossHeadSpriteEffects)
staticprivate

Definition at line 648 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookBuffTownNPC = AddHook<DelegateBuffTownNPC>(g => g.BuffTownNPC)
staticprivate

Definition at line 950 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCanBeHitByItem = AddHook<Func<NPC, Player, Item, bool?>>(g => g.CanBeHitByItem)
staticprivate

Definition at line 517 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCanBeHitByProjectile = AddHook<Func<NPC, Projectile, bool?>>(g => g.CanBeHitByProjectile)
staticprivate

Definition at line 563 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCanChat = AddHook<Func<NPC, bool?>>(g => g.CanChat)
staticprivate

Definition at line 849 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCanHitNPC = AddHook<Func<NPC, NPC, bool?>>(g => g.CanHitNPC)
staticprivate

Definition at line 472 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCanHitPlayer = AddHook<DelegateCanHitPlayer>(g => g.CanHitPlayer)
staticprivate

Definition at line 437 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCheckActive = AddHook<Func<NPC, bool>>(g => g.CheckActive)
staticprivate

Definition at line 357 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookCheckDead = AddHook<Func<NPC, bool>>(g => g.CheckDead)
staticprivate

Definition at line 371 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookDrawEffects = AddHook<DelegateDrawEffects>(g => g.DrawEffects)
staticprivate

Definition at line 671 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookDrawHealthBar = AddHook<DelegateDrawHealthBar>(g => g.DrawHealthBar)
staticprivate

Definition at line 706 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookDrawTownAttackGun = AddHook<DelegateDrawTownAttackGun>(g => g.DrawTownAttackGun)
staticprivate

Definition at line 1053 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookDrawTownAttackSwing = AddHook<DelegateDrawTownAttackSwing>(g => g.DrawTownAttackSwing)
staticprivate

Definition at line 1064 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookEditSpawnPool = AddHook<Action<Dictionary<int, float>, NPCSpawnInfo>>(g => g.EditSpawnPool)
staticprivate

Definition at line 762 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookEditSpawnRange = AddHook<DelegateEditSpawnRange>(g => g.EditSpawnRange)
staticprivate

Definition at line 753 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookEditSpawnRate = AddHook<DelegateEditSpawnRate>(g => g.EditSpawnRate)
staticprivate

Definition at line 743 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookFindFrame = AddHook<Action<NPC, int>>(g => g.FindFrame)
staticprivate

Definition at line 319 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookGetAlpha = AddHook<Func<NPC, Color, Color?>>(g => g.GetAlpha)
staticprivate

Definition at line 658 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookGetChat = AddHook<DelegateGetChat>(g => g.GetChat)
staticprivate

Definition at line 868 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookHitEffect = AddHook<Action<NPC, int, double>>(g => g.HitEffect)
staticprivate

Definition at line 335 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookModifyHitByItem = AddHook<DelegateModifyHitByItem>(g => g.ModifyHitByItem)
staticprivate

Definition at line 543 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookModifyHitByProjectile = AddHook<DelegateModifyHitByProjectile>(g => g.ModifyHitByProjectile)
staticprivate

Definition at line 589 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookModifyHitNPC = AddHook<DelegateModifyHitNPC>(g => g.ModifyHitNPC)
staticprivate

Definition at line 498 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookModifyHitPlayer = AddHook<DelegateModifyHitPlayer>(g => g.ModifyHitPlayer)
staticprivate

Definition at line 452 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookNPCLoot = AddHook<Action<NPC>>(g => g.NPCLoot)
staticprivate

Definition at line 415 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnChatButtonClicked = AddHook<DelegateOnChatButtonClicked>(g => g.OnChatButtonClicked)
staticprivate

Definition at line 904 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnHitByItem = AddHook<Action<NPC, Player, Item, int, float, bool>>(g => g.OnHitByItem)
staticprivate

Definition at line 553 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnHitByProjectile = AddHook<Action<NPC, Projectile, int, float, bool>>(g => g.OnHitByProjectile)
staticprivate

Definition at line 599 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnHitNPC = AddHook<Action<NPC, NPC, int, float, bool>>(g => g.OnHitNPC)
staticprivate

Definition at line 508 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnHitPlayer = AddHook<Action<NPC, Player, int, bool>>(g => g.OnHitPlayer)
staticprivate

Definition at line 462 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookPostAI = AddHook<Action<NPC>>(g => g.PostAI)
staticprivate

Definition at line 279 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookPostDraw = AddHook<Action<NPC, SpriteBatch, Color>>(g => g.PostDraw)
staticprivate

Definition at line 695 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookPreAI = AddHook<Func<NPC, bool>>(g => g.PreAI)
staticprivate

Definition at line 255 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookPreChatButtonClicked = AddHook<Func<NPC, bool, bool>>(g => g.PreChatButtonClicked)
staticprivate

Definition at line 889 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookPreDraw = AddHook<Func<NPC, SpriteBatch, Color, bool>>(g => g.PreDraw)
staticprivate

Definition at line 681 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookPreNPCLoot = AddHook<Func<NPC, bool>>(g => g.PreNPCLoot)
staticprivate

Definition at line 399 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookResetEffects = AddHook<Action<NPC>>(g => g.ResetEffects)
staticprivate

Definition at line 229 of file NPCLoader.cs.

List<HookList> Terraria.ModLoader.NPCLoader.hooks = new List<HookList>()
staticprivate

Definition at line 46 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookScaleExpertStats = AddHook<Action<NPC, int, float>>(g => g.ScaleExpertStats)
staticprivate

Definition at line 219 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookSetDefaults = AddHook<Action<NPC>>(g => g.SetDefaults)
staticprivate

Definition at line 190 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookSetupShop = AddHook<DelegateSetupShop>(g => g.SetupShop)
staticprivate

Definition at line 926 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookSetupTravelShop = AddHook<DelegateSetupTravelShop>(g => g.SetupTravelShop)
staticprivate

Definition at line 941 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookSpawnNPC = AddHook<Action<int, int, int>>(g => g.SpawnNPC)
staticprivate

Definition at line 796 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookSpecialNPCLoot = AddHook<Func<NPC, bool>>(g => g.SpecialNPCLoot)
staticprivate

Definition at line 385 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookStrikeNPC = AddHook<DelegateStrikeNPC>(g => g.StrikeNPC)
staticprivate

Definition at line 610 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackCooldown = AddHook<DelegateTownNPCAttackCooldown>(g => g.TownNPCAttackCooldown)
staticprivate

Definition at line 985 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackMagic = AddHook<DelegateTownNPCAttackMagic>(g => g.TownNPCAttackMagic)
staticprivate

Definition at line 1031 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackProj = AddHook<DelegateTownNPCAttackProj>(g => g.TownNPCAttackProj)
staticprivate

Definition at line 996 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackProjSpeed = AddHook<DelegateTownNPCAttackProjSpeed>(g => g.TownNPCAttackProjSpeed)
staticprivate

Definition at line 1008 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackShoot = AddHook<DelegateTownNPCAttackShoot>(g => g.TownNPCAttackShoot)
staticprivate

Definition at line 1020 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackStrength = AddHook<DelegateTownNPCAttackStrength>(g => g.TownNPCAttackStrength)
staticprivate

Definition at line 974 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookTownNPCAttackSwing = AddHook<DelegateTownNPCAttackSwing>(g => g.TownNPCAttackSwing)
staticprivate

Definition at line 1042 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookUpdateLifeRegen = AddHook<DelegateUpdateLifeRegen>(g => g.UpdateLifeRegen)
staticprivate

Definition at line 347 of file NPCLoader.cs.

int Terraria.ModLoader.NPCLoader.nextNPC = NPCID.Count
staticprivate

Definition at line 22 of file NPCLoader.cs.

int Terraria.ModLoader.NPCLoader.NPCCount => nextNPC
static

Definition at line 86 of file NPCLoader.cs.

readonly int [] Terraria.ModLoader.NPCLoader.shopToNPC = new int[Main.MaxShopIDs - 1]
staticprivate

Definition at line 30 of file NPCLoader.cs.

int Terraria.ModLoader.NPCLoader.vanillaSkeletonCount = NPCID.Sets.Skeletons.Count
staticprivate

Definition at line 29 of file NPCLoader.cs.