Terraria ModLoader  0.11.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, bool vanillaCanChat)
 
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 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 OnCatchNPC (NPC npc, Player player, Item item)
 
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 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 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 HookCanGoToStatue = AddHook<Func<NPC, bool, bool?>>(g => g.CanGoToStatue)
 
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 HookOnCatchNPC = AddHook<Action<NPC, Player, Item>>(g => g.OnCatchNPC)
 
static HookList HookOnChatButtonClicked = AddHook<DelegateOnChatButtonClicked>(g => g.OnChatButtonClicked)
 
static HookList HookOnGoToStatue = AddHook<Action<NPC, bool>>(g => g.OnGoToStatue)
 
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 270 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 435 of file NPCLoader.cs.

435  {
436  if (npc.modNPC != null) {
437  bagType = npc.modNPC.bossBag;
438  }
439  }
static void Terraria.ModLoader.NPCLoader.BossHeadRotation ( NPC  npc,
ref float  rotation 
)
static

Definition at line 654 of file NPCLoader.cs.

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

654  {
655  npc.modNPC?.BossHeadRotation(ref rotation);
656 
657  foreach (GlobalNPC g in HookBossHeadRotation.arr) {
658  g.Instance(npc).BossHeadRotation(npc, ref rotation);
659  }
660  }
static HookList HookBossHeadRotation
Definition: NPCLoader.cs:652

+ Here is the call graph for this function:

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

Definition at line 643 of file NPCLoader.cs.

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

643  {
644  npc.modNPC?.BossHeadSlot(ref index);
645 
646  foreach (GlobalNPC g in HookBossHeadSlot.arr) {
647  g.Instance(npc).BossHeadSlot(npc, ref index);
648  }
649  }
static HookList HookBossHeadSlot
Definition: NPCLoader.cs:641

+ Here is the call graph for this function:

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

Definition at line 665 of file NPCLoader.cs.

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

665  {
666  npc.modNPC?.BossHeadSpriteEffects(ref spriteEffects);
667 
668  foreach (GlobalNPC g in HookBossHeadSpriteEffects.arr) {
669  g.Instance(npc).BossHeadSpriteEffects(npc, ref spriteEffects);
670  }
671  }
static HookList HookBossHeadSpriteEffects
Definition: NPCLoader.cs:663

+ 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 431 of file NPCLoader.cs.

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

Definition at line 983 of file NPCLoader.cs.

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

983  {
984  foreach (GlobalNPC g in HookBuffTownNPC.arr) {
985  g.BuffTownNPC(ref damageMult, ref defense);
986  }
987  }
static HookList HookBuffTownNPC
Definition: NPCLoader.cs:981

+ Here is the call graph for this function:

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

Definition at line 534 of file NPCLoader.cs.

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

534  {
535  bool? flag = null;
536  foreach (GlobalNPC g in HookCanBeHitByItem.arr) {
537  bool? canHit = g.Instance(npc).CanBeHitByItem(npc, player, item);
538  if (canHit.HasValue && !canHit.Value) {
539  return false;
540  }
541  if (canHit.HasValue) {
542  flag = canHit.Value;
543  }
544  }
545  if (npc.modNPC != null) {
546  bool? canHit = npc.modNPC.CanBeHitByItem(player, item);
547  if (canHit.HasValue && !canHit.Value) {
548  return false;
549  }
550  if (canHit.HasValue) {
551  flag = canHit.Value;
552  }
553  }
554  return flag;
555  }
static HookList HookCanBeHitByItem
Definition: NPCLoader.cs:532

+ Here is the call graph for this function:

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

Definition at line 580 of file NPCLoader.cs.

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

580  {
581  bool? flag = null;
582  foreach (GlobalNPC g in HookCanBeHitByProjectile.arr) {
583  bool? canHit = g.Instance(npc).CanBeHitByProjectile(npc, projectile);
584  if (canHit.HasValue && !canHit.Value) {
585  return false;
586  }
587  if (canHit.HasValue) {
588  flag = canHit.Value;
589  }
590  }
591  if (npc.modNPC != null) {
592  bool? canHit = npc.modNPC.CanBeHitByProjectile(projectile);
593  if (canHit.HasValue && !canHit.Value) {
594  return false;
595  }
596  if (canHit.HasValue) {
597  flag = canHit.Value;
598  }
599  }
600  return flag;
601  }
static HookList HookCanBeHitByProjectile
Definition: NPCLoader.cs:578

+ Here is the call graph for this function:

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

Definition at line 850 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

static bool Terraria.ModLoader.NPCLoader.CanGoToStatue ( NPC  npc,
bool  toKingStatue,
bool  vanillaCanGo 
)
static

Definition at line 954 of file NPCLoader.cs.

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

954  {
955  bool defaultCanGo = npc.modNPC?.CanGoToStatue(toKingStatue) ?? vanillaCanGo;
956 
957  foreach (GlobalNPC g in HookCanGoToStatue.arr) {
958  bool? canGo = g.Instance(npc).CanGoToStatue(npc, toKingStatue);
959  if (canGo.HasValue) {
960  if (!canGo.Value) {
961  return false;
962  }
963  defaultCanGo = true;
964  }
965  }
966 
967  return defaultCanGo;
968  }
static HookList HookCanGoToStatue
Definition: NPCLoader.cs:952

+ Here is the call graph for this function:

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

Definition at line 489 of file NPCLoader.cs.

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

489  {
490  bool? flag = null;
491  foreach (GlobalNPC g in HookCanHitNPC.arr) {
492  bool? canHit = g.Instance(npc).CanHitNPC(npc, target);
493  if (canHit.HasValue && !canHit.Value) {
494  return false;
495  }
496  if (canHit.HasValue) {
497  flag = canHit.Value;
498  }
499  }
500  if (npc.modNPC != null) {
501  bool? canHit = npc.modNPC.CanHitNPC(target);
502  if (canHit.HasValue && !canHit.Value) {
503  return false;
504  }
505  if (canHit.HasValue) {
506  flag = canHit.Value;
507  }
508  }
509  return flag;
510  }
static HookList HookCanHitNPC
Definition: NPCLoader.cs:487

+ 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 454 of file NPCLoader.cs.

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

454  {
455  foreach (GlobalNPC g in HookCanHitPlayer.arr) {
456  if (!g.Instance(npc).CanHitPlayer(npc, target, ref cooldownSlot)) {
457  return false;
458  }
459  }
460  if (npc.modNPC != null) {
461  return npc.modNPC.CanHitPlayer(target, ref cooldownSlot);
462  }
463  return true;
464  }
static HookList HookCanHitPlayer
Definition: NPCLoader.cs:452

+ Here is the call graph for this function:

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

Definition at line 824 of file NPCLoader.cs.

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

824  {
825  foreach (ModNPC npc in npcs) {
826  if (npc.npc.townNPC && NPC.TypeToHeadIndex(npc.npc.type) >= 0 && !NPC.AnyNPCs(npc.npc.type) &&
827  npc.CanTownNPCSpawn(numTownNPCs, money)) {
828  Main.townNPCCanSpawn[npc.npc.type] = true;
829  if (WorldGen.prioritizedTownNPC == 0) {
830  WorldGen.prioritizedTownNPC = npc.npc.type;
831  }
832  }
833  }
834  }

+ Here is the call graph for this function:

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

Definition at line 358 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 836 of file NPCLoader.cs.

836  {
837  return GetNPC(type)?.CheckConditions(WorldGen.roomX1, WorldGen.roomX2, WorldGen.roomY1, WorldGen.roomY2) ?? true;
838  }
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:579
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 372 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 778 of file NPCLoader.cs.

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

778  {
779  NPCSpawnHelper.Reset();
780  NPCSpawnHelper.DoChecks(spawnInfo);
781  IDictionary<int, float> pool = new Dictionary<int, float>();
782  pool[0] = 1f;
783  foreach (ModNPC npc in npcs) {
784  float weight = npc.SpawnChance(spawnInfo);
785  if (weight > 0f) {
786  pool[npc.npc.type] = weight;
787  }
788  }
789  foreach (GlobalNPC g in HookEditSpawnPool.arr) {
790  g.EditSpawnPool(pool, spawnInfo);
791  }
792  float totalWeight = 0f;
793  foreach (int type in pool.Keys) {
794  if (pool[type] < 0f) {
795  pool[type] = 0f;
796  }
797  totalWeight += pool[type];
798  }
799  float choice = (float)Main.rand.NextDouble() * totalWeight;
800  foreach (int type in pool.Keys) {
801  float weight = pool[type];
802  if (choice < weight) {
803  return type;
804  }
805  choice -= weight;
806  }
807  return null;
808  }
static HookList HookEditSpawnPool
Definition: NPCLoader.cs:776

+ 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 688 of file NPCLoader.cs.

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

688  {
689  npc.modNPC?.DrawEffects(ref drawColor);
690 
691  foreach (GlobalNPC g in HookDrawEffects.arr) {
692  g.Instance(npc).DrawEffects(npc, ref drawColor);
693  }
694  }
static HookList HookDrawEffects
Definition: NPCLoader.cs:686

+ Here is the call graph for this function:

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

Definition at line 722 of file NPCLoader.cs.

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

722  {
723  Vector2 position = new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.gfxOffY);
724  if (Main.HealthBarDrawSettings == 1) {
725  position.Y += npc.height + 10f + Main.NPCAddHeight(npc.whoAmI);
726  }
727  else if (Main.HealthBarDrawSettings == 2) {
728  position.Y -= 24f + Main.NPCAddHeight(npc.whoAmI) / 2f;
729  }
730  foreach (GlobalNPC g in HookDrawHealthBar.arr) {
731  bool? result = g.Instance(npc).DrawHealthBar(npc, Main.HealthBarDrawSettings, ref scale, ref position);
732  if (result.HasValue) {
733  if (result.Value) {
734  DrawHealthBar(npc, position, scale);
735  }
736  return false;
737  }
738  }
739  if (NPCLoader.IsModNPC(npc)) {
740  bool? result = npc.modNPC.DrawHealthBar(Main.HealthBarDrawSettings, ref scale, ref position);
741  if (result.HasValue) {
742  if (result.Value) {
743  DrawHealthBar(npc, position, scale);
744  }
745  return false;
746  }
747  }
748  return true;
749  }
static HookList HookDrawHealthBar
Definition: NPCLoader.cs:720
static bool DrawHealthBar(NPC npc, ref float scale)
Definition: NPCLoader.cs:722

+ Here is the call graph for this function:

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

Definition at line 751 of file NPCLoader.cs.

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

Definition at line 1086 of file NPCLoader.cs.

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

1086  {
1087  npc.modNPC?.DrawTownAttackGun(ref scale, ref item, ref closeness);
1088 
1089  foreach (GlobalNPC g in HookDrawTownAttackGun.arr) {
1090  g.Instance(npc).DrawTownAttackGun(npc, ref scale, ref item, ref closeness);
1091  }
1092  }
static HookList HookDrawTownAttackGun
Definition: NPCLoader.cs:1084

+ 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 1097 of file NPCLoader.cs.

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

1097  {
1098  npc.modNPC?.DrawTownAttackSwing(ref item, ref itemSize, ref scale, ref offset);
1099 
1100  foreach (GlobalNPC g in HookDrawTownAttackSwing.arr) {
1101  g.Instance(npc).DrawTownAttackSwing(npc, ref item, ref itemSize, ref scale, ref offset);
1102  }
1103  }
static HookList HookDrawTownAttackSwing
Definition: NPCLoader.cs:1095

+ 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 769 of file NPCLoader.cs.

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

770  {
771  foreach (GlobalNPC g in HookEditSpawnRange.arr) {
772  g.EditSpawnRange(player, ref spawnRangeX, ref spawnRangeY, ref safeRangeX, ref safeRangeY);
773  }
774  }
static HookList HookEditSpawnRange
Definition: NPCLoader.cs:767

+ 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 759 of file NPCLoader.cs.

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

759  {
760  foreach (GlobalNPC g in HookEditSpawnRate.arr) {
761  g.EditSpawnRate(player, ref spawnRate, ref maxSpawns);
762  }
763  }
static HookList HookEditSpawnRate
Definition: NPCLoader.cs:757

+ Here is the call graph for this function:

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

Definition at line 320 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 675 of file NPCLoader.cs.

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

675  {
676  foreach (GlobalNPC g in HookGetAlpha.arr) {
677  Color? color = g.Instance(npc).GetAlpha(npc, lightColor);
678  if (color.HasValue) {
679  return color.Value;
680  }
681  }
682  return npc.modNPC?.GetAlpha(lightColor);
683  }
static HookList HookGetAlpha
Definition: NPCLoader.cs:673

+ Here is the call graph for this function:

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

Definition at line 869 of file NPCLoader.cs.

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

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

+ 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.

Referenced by Terraria.ModLoader.ModContent.MusicExists().

93  {
94  return type >= NPCID.Count && type < NPCCount ? npcs[type - NPCID.Count] : null;
95  }

+ Here is the caller graph for this function:

static bool Terraria.ModLoader.NPCLoader.HasMethod ( Type  t,
string  method,
params Type[]  args 
)
staticprivate

Definition at line 1105 of file NPCLoader.cs.

References Terraria.ModLoader.GlobalNPC.InstancePerEntity.

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

Definition at line 336 of file NPCLoader.cs.

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

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

+ 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 560 of file NPCLoader.cs.

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

560  {
561  npc.modNPC?.ModifyHitByItem(player, item, ref damage, ref knockback, ref crit);
562 
563  foreach (GlobalNPC g in HookModifyHitByItem.arr) {
564  g.Instance(npc).ModifyHitByItem(npc, player, item, ref damage, ref knockback, ref crit);
565  }
566  }
static HookList HookModifyHitByItem
Definition: NPCLoader.cs:558

+ 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 606 of file NPCLoader.cs.

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

606  {
607  npc.modNPC?.ModifyHitByProjectile(projectile, ref damage, ref knockback, ref crit, ref hitDirection);
608 
609  foreach (GlobalNPC g in HookModifyHitByProjectile.arr) {
610  g.Instance(npc).ModifyHitByProjectile(npc, projectile, ref damage, ref knockback, ref crit, ref hitDirection);
611  }
612  }
static HookList HookModifyHitByProjectile
Definition: NPCLoader.cs:604

+ 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 515 of file NPCLoader.cs.

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

515  {
516  npc.modNPC?.ModifyHitNPC(target, ref damage, ref knockback, ref crit);
517 
518  foreach (GlobalNPC g in HookModifyHitNPC.arr) {
519  g.Instance(npc).ModifyHitNPC(npc, target, ref damage, ref knockback, ref crit);
520  }
521  }
static HookList HookModifyHitNPC
Definition: NPCLoader.cs:513

+ 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 469 of file NPCLoader.cs.

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

469  {
470  npc.modNPC?.ModifyHitPlayer(target, ref damage, ref crit);
471 
472  foreach (GlobalNPC g in HookModifyHitPlayer.arr) {
473  g.Instance(npc).ModifyHitPlayer(npc, target, ref damage, ref crit);
474  }
475  }
static HookList HookModifyHitPlayer
Definition: NPCLoader.cs:467

+ 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:270
static void PostAI(NPC npc)
Definition: NPCLoader.cs:280
static bool PreAI(NPC npc)
Definition: NPCLoader.cs:257
static void Terraria.ModLoader.NPCLoader.NPCLoot ( NPC  npc)
static

Definition at line 422 of file NPCLoader.cs.

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

422  {
423  npc.modNPC?.NPCLoot();
424 
425  foreach (GlobalNPC g in HookNPCLoot.arr) {
426  g.Instance(npc).NPCLoot(npc);
427  }
428  blockLoot.Clear();
429  }
static HookList HookNPCLoot
Definition: NPCLoader.cs:420
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.OnCatchNPC ( NPC  npc,
Player  player,
Item  item 
)
static

Definition at line 443 of file NPCLoader.cs.

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

443  {
444  npc.modNPC?.OnCatchNPC(player, item);
445 
446  foreach (GlobalNPC g in HookOnCatchNPC.arr) {
447  g.Instance(npc).OnCatchNPC(npc, player, item);
448  }
449  }
static HookList HookOnCatchNPC
Definition: NPCLoader.cs:441

+ Here is the call graph for this function:

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

Definition at line 909 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

static void Terraria.ModLoader.NPCLoader.OnGoToStatue ( NPC  npc,
bool  toKingStatue 
)
static

Definition at line 972 of file NPCLoader.cs.

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

972  {
973  npc.modNPC?.OnGoToStatue(toKingStatue);
974 
975  foreach (GlobalNPC g in HookOnGoToStatue.arr) {
976  g.OnGoToStatue(npc, toKingStatue);
977  }
978  }
static HookList HookOnGoToStatue
Definition: NPCLoader.cs:970

+ 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 570 of file NPCLoader.cs.

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

570  {
571  npc.modNPC?.OnHitByItem(player, item, damage, knockback, crit);
572 
573  foreach (GlobalNPC g in HookOnHitByItem.arr) {
574  g.Instance(npc).OnHitByItem(npc, player, item, damage, knockback, crit);
575  }
576  }
static HookList HookOnHitByItem
Definition: NPCLoader.cs:568

+ 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 616 of file NPCLoader.cs.

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

616  {
617  npc.modNPC?.OnHitByProjectile(projectile, damage, knockback, crit);
618 
619  foreach (GlobalNPC g in HookOnHitByProjectile.arr) {
620  g.Instance(npc).OnHitByProjectile(npc, projectile, damage, knockback, crit);
621  }
622  }
static HookList HookOnHitByProjectile
Definition: NPCLoader.cs:614

+ 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 525 of file NPCLoader.cs.

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

525  {
526  npc.modNPC?.OnHitNPC(target, damage, knockback, crit);
527  foreach (GlobalNPC g in HookOnHitNPC.arr) {
528  g.Instance(npc).OnHitNPC(npc, target, damage, knockback, crit);
529  }
530  }
static HookList HookOnHitNPC
Definition: NPCLoader.cs:523

+ 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 479 of file NPCLoader.cs.

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

479  {
480  npc.modNPC?.OnHitPlayer(target, damage, crit);
481 
482  foreach (GlobalNPC g in HookOnHitPlayer.arr) {
483  g.Instance(npc).OnHitPlayer(npc, target, damage, crit);
484  }
485  }
static HookList HookOnHitPlayer
Definition: NPCLoader.cs:477

+ Here is the call graph for this function:

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

Definition at line 280 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 711 of file NPCLoader.cs.

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

711  {
712  npc.modNPC?.PostDraw(spriteBatch, drawColor);
713 
714  foreach (GlobalNPC g in HookPostDraw.arr) {
715  g.Instance(npc).PostDraw(npc, spriteBatch, drawColor);
716  }
717  }
static HookList HookPostDraw
Definition: NPCLoader.cs:709

+ 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  bool result = true;
259  foreach (GlobalNPC g in HookPreAI.arr) {
260  result &= g.Instance(npc).PreAI(npc);
261  }
262  if (result && npc.modNPC != null) {
263  return npc.modNPC.PreAI();
264  }
265  return result;
266  }
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 890 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 698 of file NPCLoader.cs.

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

698  {
699  bool result = true;
700  foreach (GlobalNPC g in HookPreDraw.arr) {
701  result &= g.Instance(npc).PreDraw(npc, spriteBatch, drawColor);
702  }
703  if (result && npc.modNPC != null) {
704  return npc.modNPC.PreDraw(spriteBatch, drawColor);
705  }
706  return result;
707  }
static HookList HookPreDraw
Definition: NPCLoader.cs:696

+ Here is the call graph for this function:

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

Definition at line 402 of file NPCLoader.cs.

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

402  {
403  bool result = true;
404  foreach (GlobalNPC g in HookPreNPCLoot.arr) {
405  result &= g.Instance(npc).PreNPCLoot(npc);
406  }
407 
408  if (result && npc.modNPC != null) {
409  result = npc.modNPC.PreNPCLoot();
410  }
411 
412  if (!result) {
413  blockLoot.Clear();
414  return false;
415  }
416 
417  return true;
418  }
static HookList HookPreNPCLoot
Definition: NPCLoader.cs:400
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 305 of file NPCLoader.cs.

305  {
306  if (npc.modNPC != null) {
307  byte[] extraAI = reader.ReadBytes(reader.ReadByte());
308  if (extraAI.Length > 0) {
309  using (MemoryStream stream = new MemoryStream(extraAI)) {
310  using (BinaryReader modReader = new BinaryReader(stream)) {
311  npc.modNPC.ReceiveExtraAI(modReader);
312  }
313  }
314  }
315  }
316  }
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 288 of file NPCLoader.cs.

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

Definition at line 881 of file NPCLoader.cs.

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

Definition at line 931 of file NPCLoader.cs.

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

931  {
932  if (type < shopToNPC.Length) {
933  type = shopToNPC[type];
934  }
935  else {
936  GetNPC(type)?.SetupShop(shop, ref nextSlot);
937  }
938  foreach (GlobalNPC g in HookSetupShop.arr) {
939  g.SetupShop(type, shop, ref nextSlot);
940  }
941  }
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:636
static HookList HookSetupShop
Definition: NPCLoader.cs:929
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 946 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 812 of file NPCLoader.cs.

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

812  {
813  var npc = type >= NPCID.Count ?
814  GetNPC(type).SpawnNPC(tileX, tileY) :
815  NPC.NewNPC(tileX * 16 + 8, tileY * 16, type);
816 
817  foreach (GlobalNPC g in HookSpawnNPC.arr) {
818  g.Instance(Main.npc[npc]).SpawnNPC(npc, tileX, tileY);
819  }
820 
821  return npc;
822  }
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:557
static ModNPC GetNPC(int type)
Gets the ModNPC instance corresponding to the specified type.
Definition: NPCLoader.cs:93
static HookList HookSpawnNPC
Definition: NPCLoader.cs:810

+ Here is the call graph for this function:

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

Definition at line 388 of file NPCLoader.cs.

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

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

+ 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 627 of file NPCLoader.cs.

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

627  {
628  bool flag = true;
629  if (npc.modNPC != null) {
630  flag = npc.modNPC.StrikeNPC(ref damage, defense, ref knockback, hitDirection, ref crit);
631  }
632  foreach (GlobalNPC g in HookStrikeNPC.arr) {
633  if (!g.Instance(npc).StrikeNPC(npc, ref damage, defense, ref knockback, hitDirection, ref crit)) {
634  flag = false;
635  }
636  }
637  return flag;
638  }
static HookList HookStrikeNPC
Definition: NPCLoader.cs:625

+ 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 1018 of file NPCLoader.cs.

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

1018  {
1019  npc.modNPC?.TownNPCAttackCooldown(ref cooldown, ref randExtraCooldown);
1020 
1021  foreach (GlobalNPC g in HookTownNPCAttackCooldown.arr) {
1022  g.Instance(npc).TownNPCAttackCooldown(npc, ref cooldown, ref randExtraCooldown);
1023  }
1024  }
static HookList HookTownNPCAttackCooldown
Definition: NPCLoader.cs:1016

+ Here is the call graph for this function:

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

Definition at line 1064 of file NPCLoader.cs.

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

1064  {
1065  npc.modNPC?.TownNPCAttackMagic(ref auraLightMultiplier);
1066 
1067  foreach (GlobalNPC g in HookTownNPCAttackMagic.arr) {
1068  g.Instance(npc).TownNPCAttackMagic(npc, ref auraLightMultiplier);
1069  }
1070  }
static HookList HookTownNPCAttackMagic
Definition: NPCLoader.cs:1062

+ 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 1029 of file NPCLoader.cs.

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

1029  {
1030  npc.modNPC?.TownNPCAttackProj(ref projType, ref attackDelay);
1031 
1032  foreach (GlobalNPC g in HookTownNPCAttackProj.arr) {
1033  g.Instance(npc).TownNPCAttackProj(npc, ref projType, ref attackDelay);
1034  }
1035  }
static HookList HookTownNPCAttackProj
Definition: NPCLoader.cs:1027

+ 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 1041 of file NPCLoader.cs.

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

1042  {
1043  npc.modNPC?.TownNPCAttackProjSpeed(ref multiplier, ref gravityCorrection, ref randomOffset);
1044 
1045  foreach (GlobalNPC g in HookTownNPCAttackProjSpeed.arr) {
1046  g.Instance(npc).TownNPCAttackProjSpeed(npc, ref multiplier, ref gravityCorrection, ref randomOffset);
1047  }
1048  }
static HookList HookTownNPCAttackProjSpeed
Definition: NPCLoader.cs:1039

+ Here is the call graph for this function:

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

Definition at line 1053 of file NPCLoader.cs.

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

1053  {
1054  npc.modNPC?.TownNPCAttackShoot(ref inBetweenShots);
1055 
1056  foreach (GlobalNPC g in HookTownNPCAttackShoot.arr) {
1057  g.Instance(npc).TownNPCAttackShoot(npc, ref inBetweenShots);
1058  }
1059  }
static HookList HookTownNPCAttackShoot
Definition: NPCLoader.cs:1051

+ 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 1007 of file NPCLoader.cs.

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

1007  {
1008  npc.modNPC?.TownNPCAttackStrength(ref damage, ref knockback);
1009 
1010  foreach (GlobalNPC g in HookTownNPCAttackStrength.arr) {
1011  g.Instance(npc).TownNPCAttackStrength(npc, ref damage, ref knockback);
1012  }
1013  }
static HookList HookTownNPCAttackStrength
Definition: NPCLoader.cs:1005

+ 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 1075 of file NPCLoader.cs.

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

1075  {
1076  npc.modNPC?.TownNPCAttackSwing(ref itemWidth, ref itemHeight);
1077 
1078  foreach (GlobalNPC g in HookTownNPCAttackSwing.arr) {
1079  g.Instance(npc).TownNPCAttackSwing(npc, ref itemWidth, ref itemHeight);
1080  }
1081  }
static HookList HookTownNPCAttackSwing
Definition: NPCLoader.cs:1073

+ Here is the call graph for this function:

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

Definition at line 840 of file NPCLoader.cs.

840  {
841  return GetNPC(type)?.TownNPCName() ?? "";
842  }
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:587
static void Terraria.ModLoader.NPCLoader.UpdateLifeRegen ( NPC  npc,
ref int  damage 
)
static

Definition at line 348 of file NPCLoader.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 844 of file NPCLoader.cs.

844  {
845  return npc.modNPC?.UsesPartyHat() ?? true;
846  }

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 268 of file NPCLoader.cs.

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

Definition at line 652 of file NPCLoader.cs.

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

Definition at line 641 of file NPCLoader.cs.

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

Definition at line 663 of file NPCLoader.cs.

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

Definition at line 981 of file NPCLoader.cs.

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

Definition at line 532 of file NPCLoader.cs.

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

Definition at line 578 of file NPCLoader.cs.

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

Definition at line 848 of file NPCLoader.cs.

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

Definition at line 952 of file NPCLoader.cs.

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

Definition at line 487 of file NPCLoader.cs.

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

Definition at line 452 of file NPCLoader.cs.

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

Definition at line 356 of file NPCLoader.cs.

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

Definition at line 370 of file NPCLoader.cs.

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

Definition at line 686 of file NPCLoader.cs.

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

Definition at line 720 of file NPCLoader.cs.

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

Definition at line 1084 of file NPCLoader.cs.

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

Definition at line 1095 of file NPCLoader.cs.

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

Definition at line 776 of file NPCLoader.cs.

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

Definition at line 767 of file NPCLoader.cs.

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

Definition at line 757 of file NPCLoader.cs.

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

Definition at line 318 of file NPCLoader.cs.

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

Definition at line 673 of file NPCLoader.cs.

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

Definition at line 867 of file NPCLoader.cs.

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

Definition at line 334 of file NPCLoader.cs.

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

Definition at line 558 of file NPCLoader.cs.

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

Definition at line 604 of file NPCLoader.cs.

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

Definition at line 513 of file NPCLoader.cs.

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

Definition at line 467 of file NPCLoader.cs.

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

Definition at line 420 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnCatchNPC = AddHook<Action<NPC, Player, Item>>(g => g.OnCatchNPC)
staticprivate

Definition at line 441 of file NPCLoader.cs.

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

Definition at line 907 of file NPCLoader.cs.

HookList Terraria.ModLoader.NPCLoader.HookOnGoToStatue = AddHook<Action<NPC, bool>>(g => g.OnGoToStatue)
staticprivate

Definition at line 970 of file NPCLoader.cs.

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

Definition at line 568 of file NPCLoader.cs.

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

Definition at line 614 of file NPCLoader.cs.

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

Definition at line 523 of file NPCLoader.cs.

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

Definition at line 477 of file NPCLoader.cs.

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

Definition at line 278 of file NPCLoader.cs.

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

Definition at line 709 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 888 of file NPCLoader.cs.

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

Definition at line 696 of file NPCLoader.cs.

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

Definition at line 400 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 929 of file NPCLoader.cs.

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

Definition at line 944 of file NPCLoader.cs.

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

Definition at line 810 of file NPCLoader.cs.

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

Definition at line 386 of file NPCLoader.cs.

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

Definition at line 625 of file NPCLoader.cs.

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

Definition at line 1016 of file NPCLoader.cs.

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

Definition at line 1062 of file NPCLoader.cs.

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

Definition at line 1027 of file NPCLoader.cs.

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

Definition at line 1039 of file NPCLoader.cs.

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

Definition at line 1051 of file NPCLoader.cs.

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

Definition at line 1005 of file NPCLoader.cs.

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

Definition at line 1073 of file NPCLoader.cs.

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

Definition at line 346 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.