TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ checkDead()

void Terraria.NPC.checkDead ( )
inline

Definition at line 83653 of file NPC.cs.

83654 {
83655 //IL_0044: Unknown result type (might be due to invalid IL or missing references)
83656 //IL_00c0: Unknown result type (might be due to invalid IL or missing references)
83657 //IL_00cc: Unknown result type (might be due to invalid IL or missing references)
83658 //IL_0298: Unknown result type (might be due to invalid IL or missing references)
83659 //IL_0620: Unknown result type (might be due to invalid IL or missing references)
83660 //IL_0331: Unknown result type (might be due to invalid IL or missing references)
83661 //IL_0354: Unknown result type (might be due to invalid IL or missing references)
83662 //IL_07a9: Unknown result type (might be due to invalid IL or missing references)
83663 //IL_07ae: Unknown result type (might be due to invalid IL or missing references)
83664 //IL_0676: Unknown result type (might be due to invalid IL or missing references)
83665 //IL_067b: Unknown result type (might be due to invalid IL or missing references)
83666 //IL_0689: Unknown result type (might be due to invalid IL or missing references)
83667 //IL_068e: Unknown result type (might be due to invalid IL or missing references)
83668 //IL_0698: Unknown result type (might be due to invalid IL or missing references)
83669 //IL_069d: Unknown result type (might be due to invalid IL or missing references)
83670 //IL_054b: Unknown result type (might be due to invalid IL or missing references)
83671 //IL_0762: Unknown result type (might be due to invalid IL or missing references)
83672 //IL_0764: Unknown result type (might be due to invalid IL or missing references)
83673 //IL_0770: Unknown result type (might be due to invalid IL or missing references)
83674 //IL_0772: Unknown result type (might be due to invalid IL or missing references)
83675 //IL_06fd: Unknown result type (might be due to invalid IL or missing references)
83676 //IL_0707: Unknown result type (might be due to invalid IL or missing references)
83677 //IL_071c: Unknown result type (might be due to invalid IL or missing references)
83678 //IL_0726: Unknown result type (might be due to invalid IL or missing references)
83679 //IL_0748: Unknown result type (might be due to invalid IL or missing references)
83680 //IL_074d: Unknown result type (might be due to invalid IL or missing references)
83681 if (!active || (realLife >= 0 && realLife != whoAmI) || life > 0)
83682 {
83683 return;
83684 }
83685 if (type == 604 || type == 605)
83686 {
83687 LadyBugKilled(base.Center, type == 605);
83688 }
83689 if (type == 397 || type == 396)
83690 {
83691 if (ai[0] != -2f)
83692 {
83693 ai[0] = -2f;
83694 life = lifeMax;
83695 netUpdate = true;
83696 dontTakeDamage = true;
83697 if (Main.netMode != 1)
83698 {
83699 int num = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)base.Center.X, (int)base.Center.Y, 400);
83700 Main.npc[num].ai[3] = ai[3];
83701 Main.npc[num].netUpdate = true;
83702 }
83703 }
83704 return;
83705 }
83706 if (type == 398 && ai[0] != 2f)
83707 {
83708 ai[0] = 2f;
83709 life = lifeMax;
83710 netUpdate = true;
83711 dontTakeDamage = true;
83712 return;
83713 }
83714 if ((type == 517 || type == 422 || type == 507 || type == 493) && ai[2] != 1f)
83715 {
83716 ai[2] = 1f;
83717 ai[1] = 0f;
83718 life = lifeMax;
83719 dontTakeDamage = true;
83720 netUpdate = true;
83721 return;
83722 }
83723 if (type == 548 && ai[1] != 1f)
83724 {
83725 ai[1] = 1f;
83726 ai[0] = 0f;
83727 life = lifeMax;
83729 netUpdate = true;
83730 return;
83731 }
83732 if (Main.netMode != 1 && Main.getGoodWorld && (type == 42 || type == 176 || (type >= 231 && type <= 235)))
83733 {
83735 }
83736 if (Main.netMode != 1 && Main.getGoodWorld)
83737 {
83738 if (type == 13)
83739 {
83740 int num3 = NewNPC(GetSpawnSourceForNaturalSpawn(), (int)base.Center.X, (int)(position.Y + (float)height), -12);
83741 if (Main.netMode == 2 && num3 < 200)
83742 {
83743 NetMessage.SendData(23, -1, -1, null, num3);
83744 }
83745 }
83746 if (type == 36)
83747 {
83748 int num4 = 3;
83749 for (int i = 0; i < num4; i++)
83750 {
83751 int num5 = 1000;
83752 for (int j = 0; j < num5; j++)
83753 {
83754 int num6 = (int)(base.Center.X / 16f) + Main.rand.Next(-50, 51);
83755 int k;
83756 for (k = (int)(base.Center.Y / 16f) + Main.rand.Next(-50, 51); k < Main.maxTilesY - 200 && !WorldGen.SolidTile(num6, k); k++)
83757 {
83758 }
83759 k--;
83760 if (!WorldGen.SolidTile(num6, k))
83761 {
83762 int num7 = NewNPC(GetSpawnSourceForNaturalSpawn(), num6 * 16 + 8, k * 16, 32);
83763 if (Main.netMode == 2 && num7 < 200)
83764 {
83765 NetMessage.SendData(23, -1, -1, null, num7);
83766 }
83767 break;
83768 }
83769 }
83770 }
83771 }
83772 }
83773 if (!NPCLoader.CheckDead(this))
83774 {
83775 return;
83776 }
83777 noSpawnCycle = true;
83778 if (townNPC && type != 37 && type != 453)
83779 {
83780 if (Main.netMode != 2)
83781 {
83782 NPCLuck();
83783 }
83784 bool flag = true;
83786 int num8 = 19;
83787 if (type == 369 || type == 663 || NPCID.Sets.IsTownPet[type])
83788 {
83789 num8 = 36;
83790 flag = false;
83791 }
83793 if (flag)
83794 {
83795 for (int l = 0; l < 255; l++)
83796 {
83797 Player player = Main.player[l];
83798 if (player != null && player.active && player.difficulty != 2)
83799 {
83800 flag = false;
83801 break;
83802 }
83803 }
83804 }
83805 if (flag)
83806 {
83808 }
83809 if (Main.netMode == 0)
83810 {
83811 Main.NewText(networkText.ToString(), byte.MaxValue, 25, 25);
83812 }
83813 else if (Main.netMode == 2)
83814 {
83815 ChatHelper.BroadcastChatMessage(networkText, new Color(255, 25, 25));
83816 }
83817 }
83818 if (Main.netMode != 1 && !Main.IsItDay() && type == 54 && !AnyNPCs(35))
83819 {
83820 for (int m = 0; m < 255; m++)
83821 {
83822 if (Main.player[m].active && !Main.player[m].dead && Main.player[m].killClothier)
83823 {
83825 break;
83826 }
83827 }
83828 }
83829 if (townNPC && Main.netMode != 1 && homeless && WorldGen.prioritizedTownNPCType == type)
83830 {
83831 WorldGen.prioritizedTownNPCType = 0;
83832 }
83834 if (type == 229 && IsShimmerVariant)
83835 {
83837 }
83838 if (legacySoundStyle.HasValue)
83839 {
83841 }
83842 if (!NPCLoader.SpecialOnKill(this))
83843 {
83844 if (type == 13 || type == 14 || type == 15)
83845 {
83846 DropEoWLoot();
83847 }
83848 else if (type == 134)
83849 {
83850 Vector2 vector = position;
83851 Vector2 center = Main.player[target].Center;
83852 float num9 = 100000000f;
83853 Vector2 vector2 = position;
83854 for (int n = 0; n < 200; n++)
83855 {
83856 if (Main.npc[n].active && (Main.npc[n].type == 134 || Main.npc[n].type == 135 || Main.npc[n].type == 136))
83857 {
83858 float num10 = Math.Abs(Main.npc[n].Center.X - center.X) + Math.Abs(Main.npc[n].Center.Y - center.Y);
83859 if (num10 < num9)
83860 {
83861 num9 = num10;
83862 vector2 = Main.npc[n].position;
83863 }
83864 }
83865 }
83866 position = vector2;
83867 NPCLoot();
83868 position = vector;
83869 }
83870 else
83871 {
83872 NPCLoot();
83873 }
83874 }
83875 active = false;
83876 if (Main.getGoodWorld && Main.netMode != 1 && type == 631)
83877 {
83878 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center, Vector2.Zero, 99, 70, 10f, Main.myPlayer);
83879 }
83884 if (nPCInvasionGroup <= 0 || nPCInvasionGroup != Main.invasionType)
83885 {
83886 return;
83887 }
83888 int num2 = 1;
83889 switch (type)
83890 {
83891 case 216:
83892 num2 = 5;
83893 break;
83894 case 395:
83895 num2 = 10;
83896 break;
83897 case 491:
83898 num2 = 10;
83899 break;
83900 case 471:
83901 num2 = 10;
83902 break;
83903 case 472:
83904 num2 = 0;
83905 break;
83906 case 387:
83907 num2 = 0;
83908 break;
83909 }
83911 if (num2 > 0)
83912 {
83913 Main.invasionSize -= num2;
83914 if (Main.invasionSize < 0)
83915 {
83916 Main.invasionSize = 0;
83917 }
83918 if (Main.netMode != 1)
83919 {
83920 Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, Main.invasionSizeStart, nPCInvasionGroup + 3, 0);
83921 }
83922 if (Main.netMode == 2)
83923 {
83924 NetMessage.SendData(78, -1, -1, null, Main.invasionProgress, Main.invasionProgressMax, Main.invasionProgressIcon);
83925 }
83926 }
83927 }
static SlotId PlaySound(in SoundStyle? style, Vector2? position=null, SoundUpdateCallback? updateCallback=null)
Attempts to play a sound style with the provided sound style (if it's not null), and returns a valid ...
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:51
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static void CheckProgress(int slainMonsterID)
Definition DD2Event.cs:340
static bool[] IsTownPet
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is categorized as a town pet....
Definition NPCID.cs:224
static int[] InvasionSlotCount
If above 0 for a given NPC type (F:Terraria.NPC.type), and its associated invasion is NOT a wave-base...
Definition NPCID.cs:731
static readonly SoundStyle NPCDeath6
Definition SoundID.cs:555
static NetworkText FromKey(string key, params object[] substitutions)
Creates a NetworkText object from a localization key and optional substitutions. The receiving client...
Represents text that will be sent over the network in multiplayer and displayed to the receiving user...
static bool CheckDead(NPC npc)
Definition NPCLoader.cs:713
static bool SpecialOnKill(NPC npc)
Definition NPCLoader.cs:729
This serves as the central class from which NPC-related functions are carried out....
Definition NPCLoader.cs:26
static bool noSpawnCycle
Definition NPC.cs:635
void NPCLoot()
Definition NPC.cs:84474
void CheckProgressPumpkinMoon()
Definition NPC.cs:84247
int lifeMax
The maximum life of this NPC.
Definition NPC.cs:1077
NetworkText GetFullNetName()
Definition NPC.cs:2311
void DropTombstoneTownNPC(NetworkText deathText)
Definition NPC.cs:83929
bool dontTakeDamageFromHostiles
Definition NPC.cs:718
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
Definition NPC.cs:997
void CheckProgressFrostMoon()
Definition NPC.cs:84096
static int GetNPCInvasionGroup(int npcID)
Gets the T:Terraria.ID.InvasionID associated with the given NPC type (F:Terraria.NPC....
Definition NPC.cs:83966
bool dontTakeDamage
Definition NPC.cs:1160
static bool AnyNPCs(int Type)
Returns true if there are any active NPC in the world of the given NPC type (F:Terraria....
Definition NPC.cs:106615
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 void SpawnSkeletron(int onWho)
Definition NPC.cs:90659
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:107568
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
static void LadyBugKilled(Vector2 Position, bool GoldLadyBug=false)
Definition NPC.cs:92092
bool homeless
Definition NPC.cs:1178
bool IsShimmerVariant
Definition NPC.cs:1405
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
Definition NPC.cs:1072
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:107558
void DropEoWLoot(bool fromCheckDead=true)
Definition NPC.cs:84061
void NPCLuck()
Definition NPC.cs:92165
static IEntitySource GetSpawnSourceForNaturalSpawn()
Definition NPC.cs:107538
SoundStyle? DeathSound
The sound that plays when this npc dies. Set this to an existing T:Terraria.ID.SoundID entry or assig...
Definition NPC.cs:1067
int realLife
Stores the index (the F:Terraria.Entity.whoAmI) of a single NPC. This NPC will then share a health po...
Definition NPC.cs:604
bool netUpdate
Definition NPC.cs:1130
int target
Definition NPC.cs:1019
void StingerExplosion()
Definition NPC.cs:56003
bool townNPC
Definition NPC.cs:1174
This data type describes in detail how a sound should be played. Passable to the M:Terraria....
Definition SoundStyle.cs:19

References Terraria.Entity.active, Terraria.NPC.ai, Terraria.NPC.AnyNPCs(), Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.ModLoader.NPCLoader.CheckDead(), Terraria.GameContent.Events.DD2Event.CheckProgress(), Terraria.NPC.CheckProgressFrostMoon(), Terraria.NPC.CheckProgressPumpkinMoon(), Terraria.NPC.DeathSound, Terraria.Player.difficulty, Terraria.NPC.dontTakeDamage, Terraria.NPC.dontTakeDamageFromHostiles, Terraria.NPC.DropEoWLoot(), Terraria.NPC.DropTombstoneTownNPC(), Terraria.Localization.NetworkText.FromKey(), Terraria.NPC.GetFullNetName(), Terraria.Main.getGoodWorld, Terraria.NPC.GetNPCInvasionGroup(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSpawnSourceForNaturalSpawn(), Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.Entity.height, Terraria.NPC.homeless, Terraria.Main.invasionProgress, Terraria.Main.invasionProgressIcon, Terraria.Main.invasionProgressMax, Terraria.Main.invasionSize, Terraria.Main.invasionSizeStart, Terraria.ID.NPCID.Sets.InvasionSlotCount, Terraria.Main.invasionType, Terraria.Main.IsItDay(), Terraria.NPC.IsShimmerVariant, Terraria.ID.NPCID.Sets.IsTownPet, Terraria.NPC.LadyBugKilled(), Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.Lang.misc, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.NPC.NewNPC(), Terraria.Projectile.NewProjectile(), Terraria.Main.NewText(), Terraria.NPC.noSpawnCycle, Terraria.Main.npc, Terraria.ID.SoundID.NPCDeath6, Terraria.NPC.NPCLoot(), Terraria.NPC.NPCLuck(), Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.WorldGen.prioritizedTownNPCType, Terraria.Main.rand, Terraria.NPC.realLife, Terraria.Main.ReportInvasionProgress(), Terraria.NetMessage.SendData(), Terraria.WorldGen.SolidTile(), Terraria.NPC.SpawnSkeletron(), Terraria.ModLoader.NPCLoader.SpecialOnKill(), Terraria.NPC.StingerExplosion(), Terraria.NPC.target, Terraria.NPC.townNPC, Terraria.NPC.type, and Terraria.Entity.whoAmI.

Referenced by Terraria.NPC.AI_006_Worms(), Terraria.NPC.AI_037_Destroyer(), and Terraria.NPC.VanillaAI_Inner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: