TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
ModNPC.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using Microsoft.Xna.Framework;
5using Microsoft.Xna.Framework.Graphics;
6using ReLogic.Utilities;
11using Terraria.ID;
14
15namespace Terraria.ModLoader;
16
20public abstract class ModNPC : ModType<NPC, ModNPC>, ILocalizedModType, IModType
21{
23 public NPC NPC => base.Entity;
24
26 public int Type => NPC.type;
27
28 public virtual string LocalizationCategory => "NPCs";
29
31 public virtual LocalizedText DisplayName => this.GetLocalization("DisplayName", base.PrettyPrintName);
32
36 public virtual string Texture => (GetType().Namespace + "." + Name).Replace('.', '/');
37
39 public virtual string HeadTexture => Texture + "_Head";
40
42 public virtual string BossHeadTexture => Texture + "_Head_Boss";
43
45 public int AIType { get; set; }
46
53 public int AnimationType { get; set; }
54
62 public int Music { get; set; } = -1;
63
64
68
69
71 public float DrawOffsetY { get; set; }
72
74 public int Banner { get; set; }
75
77 public int BannerItem { get; set; }
78
80 public int[] SpawnModBiomes { get; set; } = new int[0];
81
82
84 public bool TownNPCStayingHomeless { get; set; }
85
86 protected override NPC CreateTemplateEntity()
87 {
88 return new NPC
89 {
90 ModNPC = this
91 };
92 }
93
94 protected sealed override void Register()
95 {
96 ModTypeLookup<ModNPC>.Register(this);
97 NPC.type = NPCLoader.Register(this);
98 Type type = GetType();
99 if (type.GetAttribute<AutoloadHead>() != null)
100 {
101 base.Mod.AddNPCHeadTexture(NPC.type, HeadTexture);
102 }
103 if (type.GetAttribute<AutoloadBossHead>() != null)
104 {
105 base.Mod.AddBossHeadTexture(BossHeadTexture, NPC.type);
106 }
107 }
108
117 {
118 return null;
119 }
120
121 public sealed override void SetupContent()
122 {
126 NPCID.Search.Add(base.FullName, Type);
127 }
128
132 public virtual void SetDefaults()
133 {
134 }
135
139 public virtual void OnSpawn(IEntitySource source)
140 {
141 }
142
146 public virtual void AutoStaticDefaults()
147 {
148 TextureAssets.Npc[NPC.type] = ModContent.Request<Texture2D>(Texture);
149 if (Banner != 0 && BannerItem != 0)
150 {
152 }
153 else if (Banner != 0 || BannerItem != 0)
154 {
155 Logging.tML.Warn((object)Language.GetTextValue("tModLoader.LoadWarningBannerOrBannerItemNotSet", base.Mod.DisplayName, Name));
156 }
157 if (NPC.lifeMax > 32767 || NPC.boss)
158 {
160 }
161 else if (NPC.lifeMax > 127)
162 {
164 }
165 else
166 {
168 }
169 }
170
183 {
184 }
185
194
198 public virtual void ModifyTypeName(ref string typeName)
199 {
200 }
201
206 public virtual void ModifyHoverBoundingBox(ref Rectangle boundingBox)
207 {
208 }
209
216 {
217 return new List<string>();
218 }
219
225 {
226 return null;
227 }
228
232 public virtual void ResetEffects()
233 {
234 }
235
240 public virtual bool PreAI()
241 {
242 return true;
243 }
244
248 public virtual void AI()
249 {
250 }
251
252 public virtual void PostAI()
253 {
254 }
255
262 public virtual void SendExtraAI(BinaryWriter writer)
263 {
264 }
265
272 public virtual void ReceiveExtraAI(BinaryReader reader)
273 {
274 }
275
280 public virtual void FindFrame(int frameHeight)
281 {
282 }
283
289 public virtual void HitEffect(NPC.HitInfo hit)
290 {
291 }
292
297 public virtual void UpdateLifeRegen(ref int damage)
298 {
299 }
300
305 public virtual bool CheckActive()
306 {
307 return true;
308 }
309
314 public virtual bool CheckDead()
315 {
316 return true;
317 }
318
323 public virtual bool SpecialOnKill()
324 {
325 return false;
326 }
327
332 public virtual bool PreKill()
333 {
334 return true;
335 }
336
340 public virtual void OnKill()
341 {
342 }
343
348 public virtual bool? CanFallThroughPlatforms()
349 {
350 return null;
351 }
352
364 public virtual bool? CanBeCaughtBy(Item item, Player player)
365 {
366 return null;
367 }
368
375 public virtual void OnCaughtBy(Player player, Item item, bool failed)
376 {
377 }
378
385 public virtual void ModifyNPCLoot(NPCLoot npcLoot)
386 {
387 }
388
394 public virtual void BossLoot(ref string name, ref int potionType)
395 {
396 }
397
404 public virtual bool CanHitPlayer(Player target, ref int cooldownSlot)
405 {
406 return true;
407 }
408
416 {
417 }
418
425 public virtual void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
426 {
427 }
428
434 public virtual bool CanHitNPC(NPC target)
435 {
436 return true;
437 }
438
444 public virtual bool CanBeHitByNPC(NPC attacker)
445 {
446 return true;
447 }
448
455 public virtual void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
456 {
457 }
458
465 public virtual void OnHitNPC(NPC target, NPC.HitInfo hit)
466 {
467 }
468
475 public virtual bool? CanBeHitByItem(Player player, Item item)
476 {
477 return null;
478 }
479
490 public virtual bool? CanCollideWithPlayerMeleeAttack(Player player, Item item, Rectangle meleeAttackHitbox)
491 {
492 return null;
493 }
494
502 public virtual void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers)
503 {
504 }
505
514 public virtual void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
515 {
516 }
517
523 public virtual bool? CanBeHitByProjectile(Projectile projectile)
524 {
525 return null;
526 }
527
534 {
535 }
536
543 public virtual void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
544 {
545 }
546
552 {
553 }
554
559 public virtual void BossHeadSlot(ref int index)
560 {
561 }
562
567 public virtual void BossHeadRotation(ref float rotation)
568 {
569 }
570
575 public virtual void BossHeadSpriteEffects(ref SpriteEffects spriteEffects)
576 {
577 }
578
584 public virtual Color? GetAlpha(Color drawColor)
585 {
586 return null;
587 }
588
593 public virtual void DrawEffects(ref Color drawColor)
594 {
595 }
596
604 public virtual bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
605 {
606 return true;
607 }
608
615 public virtual void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
616 {
617 }
618
623 public virtual void DrawBehind(int index)
624 {
625 }
626
634 public virtual bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
635 {
636 return null;
637 }
638
644 public virtual float SpawnChance(NPCSpawnInfo spawnInfo)
645 {
646 return 0f;
647 }
648
655 public virtual int SpawnNPC(int tileX, int tileY)
656 {
657 return NPC.NewNPC(null, tileX * 16 + 8, tileY * 16, NPC.type);
658 }
659
665 public virtual bool CanTownNPCSpawn(int numTownNPCs)
666 {
667 return false;
668 }
669
678 public virtual bool CheckConditions(int left, int right, int top, int bottom)
679 {
680 return true;
681 }
682
687 public virtual bool UsesPartyHat()
688 {
689 return true;
690 }
691
700 public virtual bool CanChat()
701 {
702 return NPC.townNPC;
703 }
704
709 public virtual string GetChat()
710 {
711 return Language.GetTextValue("tModLoader.DefaultTownNPCChat");
712 }
713
719 public virtual void SetChatButtons(ref string button, ref string button2)
720 {
721 }
722
728 public virtual void OnChatButtonClicked(bool firstButton, ref string shopName)
729 {
730 }
731
736 public virtual void AddShops()
737 {
738 }
739
747 public virtual void ModifyActiveShop(string shopName, Item[] items)
748 {
749 }
750
755 public virtual bool CanGoToStatue(bool toKingStatue)
756 {
757 return false;
758 }
759
765 public virtual void OnGoToStatue(bool toKingStatue)
766 {
767 }
768
774 public virtual void TownNPCAttackStrength(ref int damage, ref float knockback)
775 {
776 }
777
783 public virtual void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
784 {
785 }
786
792 public virtual void TownNPCAttackProj(ref int projType, ref int attackDelay)
793 {
794 }
795
803 {
804 }
805
810 public virtual void TownNPCAttackShoot(ref bool inBetweenShots)
811 {
812 }
813
818 public virtual void TownNPCAttackMagic(ref float auraLightMultiplier)
819 {
820 }
821
827 public virtual void TownNPCAttackSwing(ref int itemWidth, ref int itemHeight)
828 {
829 }
830
840 public virtual void DrawTownAttackGun(ref Texture2D item, ref Rectangle itemFrame, ref float scale, ref int horizontalHoldoutOffset)
841 {
842 }
843
852 public virtual void DrawTownAttackSwing(ref Texture2D item, ref Rectangle itemFrame, ref int itemSize, ref float scale, ref Vector2 offset)
853 {
854 }
855
865 {
866 return true;
867 }
868
874 public virtual bool NeedSaving()
875 {
876 return false;
877 }
878
888 public virtual void SaveData(TagCompound tag)
889 {
890 }
891
896 public virtual void LoadData(TagCompound tag)
897 {
898 }
899}
static Asset< Texture2D >[] Npc
static readonly IdDictionary Search
Definition NPCID.cs:12911
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12
Contains the localization value corresponding to a key for the current game language....
static Dictionary< int, byte > npcLifeBytes
Definition Main.cs:2154
Tag compounds contained named values, serialisable as per the NBT spec: NBT spec wiki page All primi...
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
Definition ModContent.cs:38
virtual ? Color GetAlpha(Color drawColor)
Allows you to determine the color and transparency in which this NPC is drawn. Return null to use the...
Definition ModNPC.cs:584
override NPC CreateTemplateEntity()
Definition ModNPC.cs:86
virtual void OnChatButtonClicked(bool firstButton, ref string shopName)
Allows you to make something happen whenever a button is clicked on this NPC's chat window....
Definition ModNPC.cs:728
virtual void ModifyNPCLoot(NPCLoot npcLoot)
Allows you to add and modify NPC loot tables to drop on death and to appear in the Bestiary....
Definition ModNPC.cs:385
virtual void BossHeadSlot(ref int index)
Allows you to customize the boss head texture used by an NPC based on its state. Set index to -1 to s...
Definition ModNPC.cs:559
virtual bool UsesPartyHat()
Allows you to determine whether this town NPC wears a party hat during a party. Returns true by defau...
Definition ModNPC.cs:687
virtual bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
Allows you to draw things behind this NPC, or to modify the way this NPC is drawn....
Definition ModNPC.cs:604
virtual bool NeedSaving()
Makes this ModNPC save along the world even if it's not a townNPC. Defaults to false....
Definition ModNPC.cs:874
int AIType
Determines which type of vanilla NPC this ModNPC will copy the behavior (AI) of. Leave as 0 to not co...
Definition ModNPC.cs:45
virtual bool CanHitNPC(NPC target)
Allows you to determine whether this NPC can hit the given friendly NPC. Return false to block the NP...
Definition ModNPC.cs:434
virtual void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
Allows you to set an NPC's information in the Bestiary.
Definition ModNPC.cs:191
int Banner
The type of NPC that this NPC will be considered as when determining banner drops and banner bonuses....
Definition ModNPC.cs:74
virtual void TownNPCAttackStrength(ref int damage, ref float knockback)
Allows you to determine the damage and knockback of this town NPC's attack before the damage is scale...
Definition ModNPC.cs:774
float DrawOffsetY
The vertical offset used for drawing this NPC. Defaults to 0.
Definition ModNPC.cs:71
virtual void DrawBehind(int index)
When used in conjunction with "NPC.hide = true", allows you to specify that this NPC should be drawn ...
Definition ModNPC.cs:623
virtual bool CanTownNPCSpawn(int numTownNPCs)
Whether or not the conditions have been met for this town NPC to be able to move into town....
Definition ModNPC.cs:665
virtual void TownNPCAttackCooldown(ref int cooldown, ref int randExtraCooldown)
Allows you to determine the cooldown between each of this town NPC's attack. The cooldown will be a n...
Definition ModNPC.cs:783
virtual void ModifyHitByItem(Player player, Item item, ref NPC.HitModifiers modifiers)
Allows you to modify the damage, knockback, etc., that this NPC takes from a melee weapon....
Definition ModNPC.cs:502
bool TownNPCStayingHomeless
Setting this to true will make the NPC not appear in the housing menu nor make it find an house.
Definition ModNPC.cs:84
virtual void FindFrame(int frameHeight)
Allows you to modify the frame from this NPC's texture that is drawn, which is necessary in order to ...
Definition ModNPC.cs:280
virtual void ModifyTypeName(ref string typeName)
Allows you to modify the type name of this NPC dynamically.
Definition ModNPC.cs:198
virtual bool CanHitPlayer(Player target, ref int cooldownSlot)
Allows you to determine whether this NPC can hit the given player. Return false to block this NPC fro...
Definition ModNPC.cs:404
override void Register()
Definition ModNPC.cs:94
virtual void ModifyHitByProjectile(Projectile projectile, ref NPC.HitModifiers modifiers)
Allows you to modify the damage, knockback, etc., that this NPC takes from a projectile....
Definition ModNPC.cs:533
virtual void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset)
Allows you to determine the speed at which this town NPC throws a projectile when it attacks....
Definition ModNPC.cs:802
virtual void ReceiveExtraAI(BinaryReader reader)
Use this to receive information that was sent in M:Terraria.ModLoader.ModNPC.SendExtraAI(System....
Definition ModNPC.cs:272
virtual void SaveData(TagCompound tag)
Allows you to save custom data for the given item. Allows you to save custom data for the given npc....
Definition ModNPC.cs:888
virtual ? bool CanBeHitByProjectile(Projectile projectile)
Allows you to determine whether this NPC can be hit by the given projectile. Return true to allow hit...
Definition ModNPC.cs:523
virtual void OnHitByItem(Player player, Item item, NPC.HitInfo hit, int damageDone)
Allows you to create special effects when this NPC is hit by a melee weapon. Runs on the client or ...
Definition ModNPC.cs:514
virtual void DrawEffects(ref Color drawColor)
Allows you to add special visual effects to this NPC (such as creating dust), and modify the color in...
Definition ModNPC.cs:593
virtual bool PreKill()
Allows you to determine whether or not this NPC will do anything upon death (besides dying)....
Definition ModNPC.cs:332
virtual string HeadTexture
The file name of this NPC's head texture file, to be used in autoloading.
Definition ModNPC.cs:39
virtual ITownNPCProfile TownNPCProfile()
Allows you to set the town NPC profile that this NPC uses. By default, returns null,...
Definition ModNPC.cs:224
virtual bool PreAI()
Allows you to determine how this NPC behaves. Return false to stop the vanilla AI and the AI hook fro...
Definition ModNPC.cs:240
virtual void DrawTownAttackSwing(ref Texture2D item, ref Rectangle itemFrame, ref int itemSize, ref float scale, ref Vector2 offset)
Allows you to customize how this town NPC's weapon is drawn when this NPC is swinging it (this NPC mu...
Definition ModNPC.cs:852
virtual string Texture
The file name of this type's texture file in the mod loader's file space.
Definition ModNPC.cs:36
virtual void TownNPCAttackSwing(ref int itemWidth, ref int itemHeight)
Allows you to determine the width and height of the item this town NPC swings when it attacks,...
Definition ModNPC.cs:827
virtual ? bool CanCollideWithPlayerMeleeAttack(Player player, Item item, Rectangle meleeAttackHitbox)
Allows you to determine whether an NPC can be collided with the player melee weapon when swung....
Definition ModNPC.cs:490
virtual void ResetEffects()
This is where you reset any fields you add to your subclass to their default states....
Definition ModNPC.cs:232
virtual void DrawTownAttackGun(ref Texture2D item, ref Rectangle itemFrame, ref float scale, ref int horizontalHoldoutOffset)
Allows you to customize how this town NPC's weapon is drawn when this NPC is shooting (this NPC must ...
Definition ModNPC.cs:840
virtual bool CanBeHitByNPC(NPC attacker)
Allows you to determine whether a friendly NPC can be hit by an NPC. Return false to block the attack...
Definition ModNPC.cs:444
virtual bool CheckConditions(int left, int right, int top, int bottom)
Allows you to define special conditions required for this town NPC's house. For example,...
Definition ModNPC.cs:678
virtual void PostDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
Allows you to draw things in front of this NPC. Substract screenPos from the draw position before dra...
Definition ModNPC.cs:615
int BannerItem
The type of the item this NPC drops for every 50 times it is defeated. For any ModNPC whose banner fi...
Definition ModNPC.cs:77
virtual void ModifyHitPlayer(Player target, ref Player.HurtModifiers modifiers)
Allows you to modify the damage, etc., that this NPC does to a player. Runs on the local client.
Definition ModNPC.cs:415
virtual void BossHeadSpriteEffects(ref SpriteEffects spriteEffects)
Allows you to flip this NPC's boss head icon on the map.
Definition ModNPC.cs:575
virtual void TownNPCAttackShoot(ref bool inBetweenShots)
Allows you to tell the game that this town NPC has already created a projectile and will still create...
Definition ModNPC.cs:810
virtual void OnSpawn(IEntitySource source)
Gets called when your NPC spawns in world.
Definition ModNPC.cs:139
virtual void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers)
Allows you to modify the damage, knockback, etc., that this NPC does to a friendly NPC....
Definition ModNPC.cs:455
virtual bool CanChat()
Allows you to determine whether this NPC can talk with the player. By default, returns if the NPC is ...
Definition ModNPC.cs:700
virtual void AutoStaticDefaults()
Automatically sets certain static defaults. Override this if you do not want the properties to be set...
Definition ModNPC.cs:146
virtual void OnKill()
Allows you to make things happen when this NPC dies (for example, dropping items and setting ModSyste...
Definition ModNPC.cs:340
virtual void AddShops()
Allows you to add shops to this NPC, similar to adding recipes for items. Make a new T:Terraria....
Definition ModNPC.cs:736
int Music
The ID of the music that plays when this NPC is on or near the screen. Defaults to -1,...
Definition ModNPC.cs:62
virtual void UpdateLifeRegen(ref int damage)
Allows you to make the NPC either regenerate health or take damage over time by setting NPC....
Definition ModNPC.cs:297
virtual void ModifyIncomingHit(ref NPC.HitModifiers modifiers)
Allows you to use a custom damage formula for when this NPC takes damage from any source....
Definition ModNPC.cs:551
virtual void SetDefaults()
Allows you to set all your NPC's properties, such as width, damage, aiStyle, lifeMax,...
Definition ModNPC.cs:132
virtual void OnCaughtBy(Player player, Item item, bool failed)
Allows you to make things happen when the given item attempts to catch this NPC.
Definition ModNPC.cs:375
virtual void AI()
Allows you to determine how this NPC behaves. This will only be called if PreAI returns true.
Definition ModNPC.cs:248
virtual void OnHitByProjectile(Projectile projectile, NPC.HitInfo hit, int damageDone)
Allows you to create special effects when this NPC is hit by a projectile.
Definition ModNPC.cs:543
virtual string GetChat()
Allows you to give this NPC a chat message when a player talks to it. By default returns something em...
Definition ModNPC.cs:709
virtual LocalizedText DisplayName
The translations for the display name of this NPC.
Definition ModNPC.cs:31
virtual void SetChatButtons(ref string button, ref string button2)
Allows you to set the text for the buttons that appear on this NPC's chat window. A parameter left as...
Definition ModNPC.cs:719
override void SetupContent()
If you make a new ModType, seal this override, and call M:Terraria.ModLoader.ModType....
Definition ModNPC.cs:121
virtual void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
Allows you to create special effects when this NPC hits a player (for example, inflicting debuffs)....
Definition ModNPC.cs:425
virtual ? bool CanFallThroughPlatforms()
Allows you to determine how and when this NPC can fall through platforms and similar tiles....
Definition ModNPC.cs:348
virtual ? int PickEmote(Player closestPlayer, List< int > emoteList, WorldUIAnchor otherAnchor)
Allows you to change the emote that the NPC will pick.
Definition ModNPC.cs:116
virtual ? bool DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
Allows you to control how the health bar for this NPC is drawn. The hbPosition parameter is the same ...
Definition ModNPC.cs:634
virtual string BossHeadTexture
This file name of this NPC's boss head texture file, to be used in autoloading.
Definition ModNPC.cs:42
virtual void ModifyActiveShop(string shopName, Item[] items)
Allows you to modify the contents of a shop whenever player opens it. To create a shop,...
Definition ModNPC.cs:747
virtual void BossHeadRotation(ref float rotation)
Allows you to customize the rotation of this NPC's boss head icon on the map.
Definition ModNPC.cs:567
virtual void ModifyHoverBoundingBox(ref Rectangle boundingBox)
Allows you to modify the bounding box for hovering over this NPC (affects things like whether or not ...
Definition ModNPC.cs:206
virtual void TownNPCAttackProj(ref int projType, ref int attackDelay)
Allows you to determine the projectile type of this town NPC's attack, and how long it takes for the ...
Definition ModNPC.cs:792
virtual int SpawnNPC(int tileX, int tileY)
Allows you to customize how this NPC is created when it naturally spawns (for example,...
Definition ModNPC.cs:655
virtual void TownNPCAttackMagic(ref float auraLightMultiplier)
Allows you to control the brightness of the light emitted by this town NPC's aura when it performs a ...
Definition ModNPC.cs:818
virtual bool SpecialOnKill()
Allows you to call OnKill on your own when the NPC dies, rather then letting vanilla call it on its o...
Definition ModNPC.cs:323
virtual ? bool CanBeHitByItem(Player player, Item item)
Allows you to determine whether this NPC can be hit by the given melee weapon when swung....
Definition ModNPC.cs:475
virtual void OnHitNPC(NPC target, NPC.HitInfo hit)
Allows you to create special effects when this NPC hits a friendly NPC. Runs in single player or on...
Definition ModNPC.cs:465
virtual bool ModifyCollisionData(Rectangle victimHitbox, ref int immunityCooldownSlot, ref MultipliableFloat damageMultiplier, ref Rectangle npcHitbox)
Allows you to modify the NPC's T:Terraria.ID.ImmunityCooldownID, damage multiplier,...
Definition ModNPC.cs:864
virtual void SendExtraAI(BinaryWriter writer)
If you are storing AI information outside of the NPC.ai array, use this to send that AI information b...
Definition ModNPC.cs:262
virtual List< string > SetNPCNameList()
Allows you to give a list of names this NPC can be given on spawn. By default, returns a blank list,...
Definition ModNPC.cs:215
virtual void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment)
Allows you to customize this NPC's stats when the difficulty is expert or higher. This runs after F:...
Definition ModNPC.cs:182
virtual bool CheckDead()
Whether or not this NPC should be killed when it reaches 0 health. You may program extra effects in t...
Definition ModNPC.cs:314
virtual ? bool CanBeCaughtBy(Item item, Player player)
Allows you to determine whether the given item can catch this NPC. Return true or false to say this ...
Definition ModNPC.cs:364
int AnimationType
Determines which type of vanilla NPC this ModNPC will copy the animation/framing logic of,...
Definition ModNPC.cs:53
virtual string LocalizationCategory
The category used by this modded content for use in localization keys. Localization keys follow the p...
Definition ModNPC.cs:28
virtual float SpawnChance(NPCSpawnInfo spawnInfo)
Whether or not this NPC can spawn with the given spawning conditions. Return the weight for the chanc...
Definition ModNPC.cs:644
virtual void BossLoot(ref string name, ref int potionType)
Allows you to customize what happens when this boss dies, such as which name is displayed in the defe...
Definition ModNPC.cs:394
int[] SpawnModBiomes
The ModBiome Types associated with this NPC spawning, if applicable. Used in Bestiary.
Definition ModNPC.cs:80
virtual bool CanGoToStatue(bool toKingStatue)
Whether this NPC can be teleported to a King or Queen statue. Returns false by default.
Definition ModNPC.cs:755
virtual void HitEffect(NPC.HitInfo hit)
Allows you to make things happen whenever this NPC is hit, such as creating dust or gores....
Definition ModNPC.cs:289
virtual void LoadData(TagCompound tag)
Allows you to load custom data that you have saved for this npc.
Definition ModNPC.cs:896
virtual void OnGoToStatue(bool toKingStatue)
Allows you to make things happen when this NPC teleports to a King or Queen statue....
Definition ModNPC.cs:765
virtual bool CheckActive()
Whether or not to run the code for checking whether this NPC will remain active. Return false to stop...
Definition ModNPC.cs:305
virtual void PostAI()
Definition ModNPC.cs:252
This class serves as a place for you to place all your properties and hooks for each NPC....
Definition ModNPC.cs:21
virtual void SetStaticDefaults()
Allows you to modify the properties after initial loading has completed.
Definition ModType.cs:72
The base type for most modded things.
Definition ModType.cs:114
static void SetDefaults(NPC npc, bool createModNPC=true)
Definition NPCLoader.cs:443
static readonly IDictionary< int, int > bannerToItem
Definition NPCLoader.cs:103
static int Register(ModNPC npc)
Definition NPCLoader.cs:284
This serves as the central class from which NPC-related functions are carried out....
Definition NPCLoader.cs:26
bool boss
Set to true if the NPC is a boss. Prevents off-screen despawn. Bosses also need [AutoloadBossHead] an...
Definition NPC.cs:1141
int lifeMax
The maximum life of this NPC.
Definition NPC.cs:1077
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
Definition NPC.cs:91239
bool townNPC
Definition NPC.cs:1174
This object encapsulates context information about the source of a particular spawning event of an It...
string Name
The internal name of this instance.
Definition IModType.cs:13
SceneEffectPriority
This enum dictates from low to high which SceneEffect selections take priority. Setting appropriate p...
This readonly struct is a simple shortcut to T:Terraria.GameContent.ItemDropRules....
Definition NPCLoot.cs:9
A struct that stores information regarding where an NPC is naturally spawning and the player it is sp...
Represents a finalized damage calculation for damage about to be applied to an NPC....
Definition NPC.cs:341
Represents a damage calculation in the process of being calculated for damage to be applied to an NPC...
Definition NPC.cs:55