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

◆ checkDead()

void Terraria.NPC.checkDead ( )
inline

Definition at line 70326 of file NPC.cs.

70327 {
70328 if (!active || (realLife >= 0 && realLife != whoAmI) || life > 0)
70329 {
70330 return;
70331 }
70332 if (type == 604 || type == 605)
70333 {
70334 LadyBugKilled(base.Center, type == 605);
70335 }
70336 if (type == 397 || type == 396)
70337 {
70338 if (ai[0] != -2f)
70339 {
70340 ai[0] = -2f;
70341 life = lifeMax;
70342 netUpdate = true;
70343 dontTakeDamage = true;
70344 if (Main.netMode != 1)
70345 {
70346 int num = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)base.Center.X, (int)base.Center.Y, 400);
70347 Main.npc[num].ai[3] = ai[3];
70348 Main.npc[num].netUpdate = true;
70349 }
70350 }
70351 return;
70352 }
70353 if (type == 398 && ai[0] != 2f)
70354 {
70355 ai[0] = 2f;
70356 life = lifeMax;
70357 netUpdate = true;
70358 dontTakeDamage = true;
70359 return;
70360 }
70361 if ((type == 517 || type == 422 || type == 507 || type == 493) && ai[2] != 1f)
70362 {
70363 ai[2] = 1f;
70364 ai[1] = 0f;
70365 life = lifeMax;
70366 dontTakeDamage = true;
70367 netUpdate = true;
70368 return;
70369 }
70370 if (type == 548 && ai[1] != 1f)
70371 {
70372 ai[1] = 1f;
70373 ai[0] = 0f;
70374 life = lifeMax;
70376 netUpdate = true;
70377 return;
70378 }
70379 if (Main.netMode != 1 && Main.getGoodWorld && (type == 42 || type == 176 || (type >= 231 && type <= 235)))
70380 {
70382 }
70383 if (Main.netMode != 1 && Main.getGoodWorld)
70384 {
70385 if (type == 13)
70386 {
70387 int num2 = NewNPC(GetSpawnSourceForNaturalSpawn(), (int)base.Center.X, (int)(position.Y + (float)height), -12);
70388 if (Main.netMode == 2 && num2 < 200)
70389 {
70390 NetMessage.SendData(23, -1, -1, null, num2);
70391 }
70392 }
70393 if (type == 36)
70394 {
70395 int num3 = 3;
70396 for (int i = 0; i < num3; i++)
70397 {
70398 int num4 = 1000;
70399 for (int j = 0; j < num4; j++)
70400 {
70401 int num5 = (int)(base.Center.X / 16f) + Main.rand.Next(-50, 51);
70402 int k;
70403 for (k = (int)(base.Center.Y / 16f) + Main.rand.Next(-50, 51); k < Main.maxTilesY - 200 && !WorldGen.SolidTile(num5, k); k++)
70404 {
70405 }
70406 k--;
70407 if (!WorldGen.SolidTile(num5, k))
70408 {
70409 int num6 = NewNPC(GetSpawnSourceForNaturalSpawn(), num5 * 16 + 8, k * 16, 32);
70410 if (Main.netMode == 2 && num6 < 200)
70411 {
70412 NetMessage.SendData(23, -1, -1, null, num6);
70413 }
70414 break;
70415 }
70416 }
70417 }
70418 }
70419 }
70420 noSpawnCycle = true;
70421 if (townNPC && type != 37 && type != 453)
70422 {
70423 if (Main.netMode != 2)
70424 {
70425 NPCLuck();
70426 }
70427 bool flag = true;
70429 int num7 = 19;
70430 if (type == 369 || type == 663 || NPCID.Sets.IsTownPet[type])
70431 {
70432 num7 = 36;
70433 flag = false;
70434 }
70436 if (flag)
70437 {
70438 for (int l = 0; l < 255; l++)
70439 {
70440 Player player = Main.player[l];
70441 if (player != null && player.active && player.difficulty != 2)
70442 {
70443 flag = false;
70444 break;
70445 }
70446 }
70447 }
70448 if (flag)
70449 {
70451 }
70452 if (Main.netMode == 0)
70453 {
70454 Main.NewText(networkText.ToString(), byte.MaxValue, 25, 25);
70455 }
70456 else if (Main.netMode == 2)
70457 {
70459 }
70460 }
70461 if (Main.netMode != 1 && !Main.IsItDay() && type == 54 && !AnyNPCs(35))
70462 {
70463 for (int m = 0; m < 255; m++)
70464 {
70465 if (Main.player[m].active && !Main.player[m].dead && Main.player[m].killClothier)
70466 {
70468 break;
70469 }
70470 }
70471 }
70472 if (townNPC && Main.netMode != 1 && homeless && WorldGen.prioritizedTownNPCType == type)
70473 {
70474 WorldGen.prioritizedTownNPCType = 0;
70475 }
70477 if (type == 229 && IsShimmerVariant)
70478 {
70480 }
70481 if (legacySoundStyle != null)
70482 {
70484 }
70485 if (type == 13 || type == 14 || type == 15)
70486 {
70487 DropEoWLoot();
70488 }
70489 else if (type == 134)
70490 {
70492 Vector2 center = Main.player[target].Center;
70493 float num8 = 100000000f;
70495 for (int n = 0; n < 200; n++)
70496 {
70497 if (Main.npc[n].active && (Main.npc[n].type == 134 || Main.npc[n].type == 135 || Main.npc[n].type == 136))
70498 {
70499 float num9 = Math.Abs(Main.npc[n].Center.X - center.X) + Math.Abs(Main.npc[n].Center.Y - center.Y);
70500 if (num9 < num8)
70501 {
70502 num8 = num9;
70503 vector2 = Main.npc[n].position;
70504 }
70505 }
70506 }
70507 position = vector2;
70508 NPCLoot();
70509 position = vector;
70510 }
70511 else
70512 {
70513 NPCLoot();
70514 }
70515 active = false;
70516 if (Main.getGoodWorld && Main.netMode != 1 && type == 631)
70517 {
70518 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center, Vector2.Zero, 99, 70, 10f, Main.myPlayer);
70519 }
70524 if (nPCInvasionGroup <= 0 || nPCInvasionGroup != Main.invasionType)
70525 {
70526 return;
70527 }
70528 int num10 = 1;
70529 switch (type)
70530 {
70531 case 216:
70532 num10 = 5;
70533 break;
70534 case 395:
70535 num10 = 10;
70536 break;
70537 case 491:
70538 num10 = 10;
70539 break;
70540 case 471:
70541 num10 = 10;
70542 break;
70543 case 472:
70544 num10 = 0;
70545 break;
70546 case 387:
70547 num10 = 0;
70548 break;
70549 }
70550 if (num10 > 0)
70551 {
70552 Main.invasionSize -= num10;
70553 if (Main.invasionSize < 0)
70554 {
70555 Main.invasionSize = 0;
70556 }
70557 if (Main.netMode != 1)
70558 {
70559 Main.ReportInvasionProgress(Main.invasionSizeStart - Main.invasionSize, Main.invasionSizeStart, nPCInvasionGroup + 3, 0);
70560 }
70561 if (Main.netMode == 2)
70562 {
70563 NetMessage.SendData(78, -1, -1, null, Main.invasionProgress, Main.invasionProgressMax, Main.invasionProgressIcon);
70564 }
70565 }
70566 }
static double Abs(double value)
static void PlaySound(int type, Vector2 position, int style=1)
static void BroadcastChatMessage(NetworkText text, Color color, int excludedPlayer=-1)
Definition ChatHelper.cs:46
Vector2 position
Definition Entity.cs:14
static void CheckProgress(int slainMonsterID)
Definition DD2Event.cs:338
static bool[] IsTownPet
Definition NPCID.cs:4099
static readonly LegacySoundStyle NPCDeath6
Definition SoundID.cs:292
static NetworkText FromKey(string key, params object[] substitutions)
static bool noSpawnCycle
Definition NPC.cs:199
void NPCLoot()
Definition NPC.cs:71114
void CheckProgressPumpkinMoon()
Definition NPC.cs:70892
int lifeMax
Definition NPC.cs:479
NetworkText GetFullNetName()
Definition NPC.cs:1490
void DropTombstoneTownNPC(NetworkText deathText)
Definition NPC.cs:70568
bool dontTakeDamageFromHostiles
Definition NPC.cs:279
float[] ai
Definition NPC.cs:447
void CheckProgressFrostMoon()
Definition NPC.cs:70742
static int GetNPCInvasionGroup(int npcID)
Definition NPC.cs:70596
bool dontTakeDamage
Definition NPC.cs:527
static bool AnyNPCs(int Type)
Definition NPC.cs:86689
int type
Definition NPC.cs:445
LegacySoundStyle DeathSound
Definition NPC.cs:475
static void SpawnSkeletron(int onWho)
Definition NPC.cs:77174
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:87546
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)
Definition NPC.cs:77654
static void LadyBugKilled(Vector2 Position, bool GoldLadyBug=false)
Definition NPC.cs:78297
bool homeless
Definition NPC.cs:541
bool IsShimmerVariant
Definition NPC.cs:721
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
void DropEoWLoot(bool fromCheckDead=true)
Definition NPC.cs:70707
void NPCLuck()
Definition NPC.cs:78360
static IEntitySource GetSpawnSourceForNaturalSpawn()
Definition NPC.cs:87536
int realLife
Definition NPC.cs:173
bool netUpdate
Definition NPC.cs:507
int target
Definition NPC.cs:459
void StingerExplosion()
Definition NPC.cs:46036
bool townNPC
Definition NPC.cs:537

References System.Math.Abs(), Terraria.Entity.active, Terraria.NPC.ai, Terraria.NPC.AnyNPCs(), Terraria.Chat.ChatHelper.BroadcastChatMessage(), Terraria.GameContent.Events.DD2Event.CheckProgress(), Terraria.NPC.CheckProgressFrostMoon(), Terraria.NPC.CheckProgressPumpkinMoon(), Microsoft.Xna.Framework.Graphics.Color, 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.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.NPC.StingerExplosion(), Terraria.NPC.target, Terraria.NPC.townNPC, Terraria.NPC.type, Terraria.Entity.whoAmI, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

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