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

◆ AI_007_TownEntities()

void Terraria.NPC.AI_007_TownEntities ( )
inlineprivate

Definition at line 46226 of file NPC.cs.

46227 {
46229 if (type == 441 && GivenName == "Andrew")
46230 {
46231 defDefense = 200;
46232 }
46233 int num = 300;
46234 if (type == 638 || type == 656 || NPCID.Sets.IsTownSlime[type])
46235 {
46236 num = 0;
46237 }
46238 bool flag = Main.raining;
46239 if (!Main.dayTime)
46240 {
46241 flag = true;
46242 }
46243 if (Main.eclipse)
46244 {
46245 flag = true;
46246 }
46247 if (Main.slimeRain)
46248 {
46249 flag = true;
46250 }
46251 float num2 = 1f;
46252 if (Main.masterMode)
46253 {
46254 defense = (dryadWard ? (defDefense + 14) : defDefense);
46255 }
46256 else if (Main.expertMode)
46257 {
46258 defense = (dryadWard ? (defDefense + 10) : defDefense);
46259 }
46260 else
46261 {
46262 defense = (dryadWard ? (defDefense + 6) : defDefense);
46263 }
46264 if (isLikeATownNPC)
46265 {
46267 {
46268 num2 += 0.2f;
46269 defense += 6;
46270 }
46272 {
46273 num2 += 0.2f;
46274 defense += 6;
46275 }
46276 if (downedBoss1)
46277 {
46278 num2 += 0.1f;
46279 defense += 3;
46280 }
46281 if (downedBoss2)
46282 {
46283 num2 += 0.1f;
46284 defense += 3;
46285 }
46286 if (downedBoss3)
46287 {
46288 num2 += 0.1f;
46289 defense += 3;
46290 }
46291 if (downedQueenBee)
46292 {
46293 num2 += 0.1f;
46294 defense += 3;
46295 }
46296 if (Main.hardMode)
46297 {
46298 num2 += 0.4f;
46299 defense += 12;
46300 }
46301 if (downedQueenSlime)
46302 {
46303 num2 += 0.15f;
46304 defense += 6;
46305 }
46306 if (downedMechBoss1)
46307 {
46308 num2 += 0.15f;
46309 defense += 6;
46310 }
46311 if (downedMechBoss2)
46312 {
46313 num2 += 0.15f;
46314 defense += 6;
46315 }
46316 if (downedMechBoss3)
46317 {
46318 num2 += 0.15f;
46319 defense += 6;
46320 }
46321 if (downedPlantBoss)
46322 {
46323 num2 += 0.15f;
46324 defense += 8;
46325 }
46327 {
46328 num2 += 0.15f;
46329 defense += 8;
46330 }
46331 if (downedGolemBoss)
46332 {
46333 num2 += 0.15f;
46334 defense += 8;
46335 }
46337 {
46338 num2 += 0.15f;
46339 defense += 8;
46340 }
46341 }
46342 if (type == 142 && Main.netMode != 1 && !Main.xMas)
46343 {
46344 StrikeNPCNoInteraction(9999, 0f, 0);
46345 if (Main.netMode == 2)
46346 {
46347 NetMessage.SendData(28, -1, -1, null, whoAmI, 9999f);
46348 }
46349 }
46350 if ((type == 148 || type == 149) && localAI[0] == 0f)
46351 {
46352 localAI[0] = Main.rand.Next(1, 5);
46353 }
46354 if (type == 124)
46355 {
46357 bool flag2 = false;
46358 if (Main.projectile.IndexInRange(num3))
46359 {
46360 Projectile projectile = Main.projectile[num3];
46361 if (projectile.active && projectile.type == 582 && projectile.ai[1] == (float)whoAmI)
46362 {
46363 flag2 = true;
46364 }
46365 }
46366 localAI[0] = flag2.ToInt();
46367 }
46368 if ((type == 362 || type == 364 || type == 602 || type == 608) && Main.netMode != 1 && (velocity.Y > 4f || velocity.Y < -4f || wet))
46369 {
46370 int num4 = direction;
46371 Transform(type + 1);
46372 TargetClosest();
46373 direction = num4;
46374 netUpdate = true;
46375 return;
46376 }
46377 switch (type)
46378 {
46379 case 588:
46380 savedGolfer = true;
46381 break;
46382 case 441:
46383 savedTaxCollector = true;
46384 break;
46385 case 107:
46386 savedGoblin = true;
46387 break;
46388 case 108:
46389 savedWizard = true;
46390 break;
46391 case 124:
46392 savedMech = true;
46393 break;
46394 case 353:
46395 savedStylist = true;
46396 break;
46397 case 369:
46398 savedAngler = true;
46399 break;
46400 case 550:
46401 savedBartender = true;
46402 break;
46403 }
46404 dontTakeDamage = false;
46405 if (ai[0] == 25f)
46406 {
46407 dontTakeDamage = true;
46408 if (ai[1] == 0f)
46409 {
46410 velocity.X = 0f;
46411 }
46412 shimmerWet = false;
46413 wet = false;
46414 lavaWet = false;
46415 honeyWet = false;
46416 if (ai[1] == 0f && Main.netMode == 1)
46417 {
46418 return;
46419 }
46420 if (ai[1] == 0f && ai[2] < 1f)
46421 {
46423 }
46424 if (ai[2] > 0f)
46425 {
46426 ai[2] -= 1f;
46427 if (ai[2] <= 0f)
46428 {
46429 ai[1] = 1f;
46430 }
46431 return;
46432 }
46433 ai[1] += 1f;
46434 if (ai[1] >= 30f)
46435 {
46436 if (!Collision.WetCollision(position, width, height))
46437 {
46439 }
46440 else
46441 {
46442 ai[1] = 30f;
46443 }
46444 velocity = new Vector2(0f, -4f * shimmerTransparency);
46445 }
46446 Rectangle hitbox = base.Hitbox;
46447 hitbox.Y += 20;
46448 hitbox.Height -= 20;
46449 float num5 = Main.rand.NextFloatDirection();
46450 Lighting.AddLight(base.Center, Main.hslToRgb((float)Main.timeForVisualEffects / 360f % 1f, 0.6f, 0.65f).ToVector3() * Utils.Remap(ai[1], 30f, 90f, 0f, 0.7f));
46451 if (Main.rand.NextFloat() > Utils.Remap(ai[1], 30f, 60f, 1f, 0.5f))
46452 {
46453 Dust.NewDustPerfect(Main.rand.NextVector2FromRectangle(hitbox) + Main.rand.NextVector2Circular(8f, 0f) + new Vector2(0f, 4f), 309, new Vector2(0f, -2f).RotatedBy(num5 * ((float)Math.PI * 2f) * 0.11f), 0, default(Color), 1.7f - Math.Abs(num5) * 1.3f);
46454 }
46455 if (ai[1] > 60f && Main.rand.Next(15) == 0)
46456 {
46457 for (int i = 0; i < 3; i++)
46458 {
46459 Vector2 vector = Main.rand.NextVector2FromRectangle(base.Hitbox);
46461 {
46462 PositionInWorld = vector,
46463 MovementVector = DirectionTo(vector).RotatedBy((float)Math.PI * 9f / 20f * (float)(Main.rand.Next(2) * 2 - 1)) * Main.rand.NextFloat()
46464 });
46465 }
46466 }
46467 TargetClosest();
46469 if (ai[1] >= 75f && shimmerTransparency <= 0f && Main.netMode != 1)
46470 {
46471 ai[0] = 0f;
46472 ai[1] = 0f;
46473 ai[2] = 0f;
46474 ai[3] = 0f;
46475 Math.Sign(targetData.Center.X - base.Center.X);
46476 velocity = new Vector2(0f, -4f);
46477 localAI[0] = 0f;
46478 localAI[1] = 0f;
46479 localAI[2] = 0f;
46480 localAI[3] = 0f;
46481 netUpdate = true;
46483 NetMessage.SendData(56, -1, -1, null, whoAmI);
46484 Teleport(position, 12);
46486 {
46487 PositionInWorld = base.Center
46488 });
46489 }
46490 return;
46491 }
46492 if (type >= 0 && type < NPCID.Count && NPCID.Sets.TownCritter[type] && target == 255)
46493 {
46494 TargetClosest();
46495 if (position.X < Main.player[target].position.X)
46496 {
46497 direction = 1;
46499 }
46500 if (position.X > Main.player[target].position.X)
46501 {
46502 direction = -1;
46504 }
46505 if (homeTileX == -1)
46506 {
46507 UpdateHomeTileState(homeless, (int)((position.X + (float)(width / 2)) / 16f), homeTileY);
46508 }
46509 }
46510 else if (homeTileX == -1 && homeTileY == -1 && velocity.Y == 0f && !shimmering)
46511 {
46512 UpdateHomeTileState(homeless, (int)base.Center.X / 16, (int)(position.Y + (float)height + 4f) / 16);
46513 }
46514 bool flag3 = false;
46515 int num6 = (int)(position.X + (float)(width / 2)) / 16;
46516 int num7 = (int)(position.Y + (float)height + 1f) / 16;
46518 if (type == 441)
46519 {
46520 taxCollector = true;
46521 }
46522 directionY = -1;
46523 if (direction == 0)
46524 {
46525 direction = 1;
46526 }
46527 if (ai[0] != 24f)
46528 {
46529 for (int j = 0; j < 255; j++)
46530 {
46531 if (Main.player[j].active && Main.player[j].talkNPC == whoAmI)
46532 {
46533 flag3 = true;
46534 if (ai[0] != 0f)
46535 {
46536 netUpdate = true;
46537 }
46538 ai[0] = 0f;
46539 ai[1] = 300f;
46540 localAI[3] = 100f;
46541 if (Main.player[j].position.X + (float)(Main.player[j].width / 2) < position.X + (float)(width / 2))
46542 {
46543 direction = -1;
46544 }
46545 else
46546 {
46547 direction = 1;
46548 }
46549 }
46550 }
46551 }
46552 if (ai[3] == 1f)
46553 {
46554 life = -1;
46555 HitEffect();
46556 active = false;
46557 netUpdate = true;
46558 if (type == 37)
46559 {
46560 SoundEngine.PlaySound(15, (int)position.X, (int)position.Y, 0);
46561 }
46562 return;
46563 }
46564 if (type == 37 && Main.netMode != 1)
46565 {
46566 UpdateHomeTileState(homeless: false, Main.dungeonX, Main.dungeonY);
46567 if (downedBoss3)
46568 {
46569 ai[3] = 1f;
46570 netUpdate = true;
46571 }
46572 }
46573 if (type == 368)
46574 {
46575 homeless = true;
46576 if (!Main.dayTime)
46577 {
46578 if (!shimmering)
46579 {
46580 UpdateHomeTileState(homeless, (int)(base.Center.X / 16f), (int)(position.Y + (float)height + 2f) / 16);
46581 }
46582 if (!flag3 && ai[0] == 0f)
46583 {
46584 ai[0] = 1f;
46585 ai[1] = 200f;
46586 }
46587 flag = false;
46588 }
46589 }
46590 if (type == 369 && homeless && wet)
46591 {
46592 if (base.Center.X / 16f < 380f || base.Center.X / 16f > (float)(Main.maxTilesX - 380))
46593 {
46594 UpdateHomeTileState(homeless, Main.spawnTileX, Main.spawnTileY);
46595 ai[0] = 1f;
46596 ai[1] = 200f;
46597 }
46598 if (position.X / 16f < 300f)
46599 {
46600 direction = 1;
46601 }
46602 else if (position.X / 16f > (float)(Main.maxTilesX - 300))
46603 {
46604 direction = -1;
46605 }
46606 }
46607 if (!WorldGen.InWorld(num6, num7) || Main.tile[num6, num7] == null)
46608 {
46609 return;
46610 }
46611 if (!homeless && Main.netMode != 1 && townNPC && (flag || (type == 37 && Main.tileDungeon[Main.tile[num6, num7].type])) && !AI_007_TownEntities_IsInAGoodRestingSpot(num6, num7, floorX, floorY))
46612 {
46613 bool flag4 = true;
46614 for (int k = 0; k < 2; k++)
46615 {
46616 if (!flag4)
46617 {
46618 break;
46619 }
46620 Rectangle rectangle = new Rectangle((int)(position.X + (float)(width / 2) - (float)(sWidth / 2) - (float)safeRangeX), (int)(position.Y + (float)(height / 2) - (float)(sHeight / 2) - (float)safeRangeY), sWidth + safeRangeX * 2, sHeight + safeRangeY * 2);
46621 if (k == 1)
46622 {
46623 rectangle = new Rectangle(floorX * 16 + 8 - sWidth / 2 - safeRangeX, floorY * 16 + 8 - sHeight / 2 - safeRangeY, sWidth + safeRangeX * 2, sHeight + safeRangeY * 2);
46624 }
46625 for (int l = 0; l < 255; l++)
46626 {
46627 if (Main.player[l].active && new Rectangle((int)Main.player[l].position.X, (int)Main.player[l].position.Y, Main.player[l].width, Main.player[l].height).Intersects(rectangle))
46628 {
46629 flag4 = false;
46630 break;
46631 }
46632 }
46633 }
46634 if (flag4)
46635 {
46637 }
46638 }
46639 bool flag5 = type == 300 || type == 447 || type == 610;
46640 bool flag6 = type == 616 || type == 617 || type == 625;
46641 bool flag7 = type == 361 || type == 445 || type == 687;
46644 bool flag9 = flag6 || flag7;
46645 bool flag10 = flag6 || flag7;
46646 bool flag11 = flag8;
46647 bool flag12 = flag8;
46648 float num8 = 200f;
46649 if (NPCID.Sets.DangerDetectRange[type] != -1)
46650 {
46652 }
46653 bool flag13 = false;
46654 bool flag14 = false;
46655 float num9 = -1f;
46656 float num10 = -1f;
46657 int num11 = 0;
46658 int num12 = -1;
46659 int num13 = -1;
46660 if (!flag6 && Main.netMode != 1 && !flag3)
46661 {
46662 for (int m = 0; m < 200; m++)
46663 {
46664 if (!Main.npc[m].active || Main.npc[m].friendly || Main.npc[m].damage <= 0 || !(Main.npc[m].Distance(base.Center) < num8) || (type == 453 && NPCID.Sets.Skeletons[Main.npc[m].type]) || (!Main.npc[m].noTileCollide && !Collision.CanHit(base.Center, 0, 0, Main.npc[m].Center, 0, 0)))
46665 {
46666 continue;
46667 }
46668 bool flag15 = Main.npc[m].CanBeChasedBy(this);
46669 flag13 = true;
46670 float num14 = Main.npc[m].Center.X - base.Center.X;
46671 if (type == 614)
46672 {
46673 if (num14 < 0f && (num9 == -1f || num14 > num9))
46674 {
46675 num10 = num14;
46676 num13 = m;
46677 }
46678 if (num14 > 0f && (num10 == -1f || num14 < num10))
46679 {
46680 num9 = num14;
46681 num12 = m;
46682 }
46683 continue;
46684 }
46685 if (num14 < 0f && (num9 == -1f || num14 > num9))
46686 {
46687 num9 = num14;
46688 if (flag15)
46689 {
46690 num12 = m;
46691 }
46692 }
46693 if (num14 > 0f && (num10 == -1f || num14 < num10))
46694 {
46695 num10 = num14;
46696 if (flag15)
46697 {
46698 num13 = m;
46699 }
46700 }
46701 }
46702 if (flag13)
46703 {
46704 num11 = ((num9 == -1f) ? 1 : ((num10 != -1f) ? (num10 < 0f - num9).ToDirectionInt() : (-1)));
46705 float num15 = 0f;
46706 if (num9 != -1f)
46707 {
46708 num15 = 0f - num9;
46709 }
46710 if (num15 == 0f || (num10 < num15 && num10 > 0f))
46711 {
46712 num15 = num10;
46713 }
46714 if (ai[0] == 8f)
46715 {
46716 if (direction == -num11)
46717 {
46718 ai[0] = 1f;
46719 ai[1] = 300 + Main.rand.Next(300);
46720 ai[2] = 0f;
46721 localAI[3] = 0f;
46722 netUpdate = true;
46723 }
46724 }
46725 else if (ai[0] != 10f && ai[0] != 12f && ai[0] != 13f && ai[0] != 14f && ai[0] != 15f)
46726 {
46727 if (NPCID.Sets.PrettySafe[type] != -1 && (float)NPCID.Sets.PrettySafe[type] < num15)
46728 {
46729 flag13 = false;
46731 }
46732 else if (ai[0] != 1f)
46733 {
46734 int tileX = (int)((position.X + (float)(width / 2) + (float)(15 * direction)) / 16f);
46735 int tileY = (int)((position.Y + (float)height - 16f) / 16f);
46736 bool currentlyDrowning = wet && !flag9;
46738 if (!avoidFalling)
46739 {
46740 if (ai[0] == 3f || ai[0] == 4f || ai[0] == 16f || ai[0] == 17f)
46741 {
46742 NPC nPC = Main.npc[(int)ai[2]];
46743 if (nPC.active)
46744 {
46745 nPC.ai[0] = 1f;
46746 nPC.ai[1] = 120 + Main.rand.Next(120);
46747 nPC.ai[2] = 0f;
46748 nPC.localAI[3] = 0f;
46749 nPC.direction = -num11;
46750 nPC.netUpdate = true;
46751 }
46752 }
46753 ai[0] = 1f;
46754 ai[1] = 120 + Main.rand.Next(120);
46755 ai[2] = 0f;
46756 localAI[3] = 0f;
46757 direction = -num11;
46758 netUpdate = true;
46759 }
46760 }
46761 else if (ai[0] == 1f && direction != -num11)
46762 {
46763 direction = -num11;
46764 netUpdate = true;
46765 }
46766 }
46767 }
46768 }
46769 if (ai[0] == 0f)
46770 {
46771 if (localAI[3] > 0f)
46772 {
46773 localAI[3] -= 1f;
46774 }
46775 int num16 = 120;
46776 if (type == 638)
46777 {
46778 num16 = 60;
46779 }
46780 if ((flag7 || flag8) && wet)
46781 {
46782 ai[0] = 1f;
46783 ai[1] = 200 + Main.rand.Next(500, 700);
46784 ai[2] = 0f;
46785 localAI[3] = 0f;
46786 netUpdate = true;
46787 }
46788 else if (flag && !flag3 && !NPCID.Sets.TownCritter[type])
46789 {
46790 if (Main.netMode != 1)
46791 {
46792 if (num6 == floorX && num7 == floorY)
46793 {
46794 if (velocity.X != 0f)
46795 {
46796 netUpdate = true;
46797 }
46798 if (velocity.X > 0.1f)
46799 {
46800 velocity.X -= 0.1f;
46801 }
46802 else if (velocity.X < -0.1f)
46803 {
46804 velocity.X += 0.1f;
46805 }
46806 else
46807 {
46808 velocity.X = 0f;
46810 }
46811 if (NPCID.Sets.IsTownPet[type])
46812 {
46814 }
46815 }
46816 else
46817 {
46818 if (num6 > floorX)
46819 {
46820 direction = -1;
46821 }
46822 else
46823 {
46824 direction = 1;
46825 }
46826 ai[0] = 1f;
46827 ai[1] = 200 + Main.rand.Next(200);
46828 ai[2] = 0f;
46829 localAI[3] = 0f;
46830 netUpdate = true;
46831 }
46832 }
46833 }
46834 else
46835 {
46836 if (flag5)
46837 {
46838 velocity.X *= 0.5f;
46839 }
46840 if (velocity.X > 0.1f)
46841 {
46842 velocity.X -= 0.1f;
46843 }
46844 else if (velocity.X < -0.1f)
46845 {
46846 velocity.X += 0.1f;
46847 }
46848 else
46849 {
46850 velocity.X = 0f;
46851 }
46852 if (Main.netMode != 1)
46853 {
46854 if (!flag3 && NPCID.Sets.IsTownPet[type] && ai[1] >= 100f && ai[1] <= 150f)
46855 {
46857 }
46858 if (ai[1] > 0f)
46859 {
46860 ai[1] -= 1f;
46861 }
46862 bool flag16 = true;
46863 int tileX2 = (int)((position.X + (float)(width / 2) + (float)(15 * direction)) / 16f);
46864 int tileY2 = (int)((position.Y + (float)height - 16f) / 16f);
46865 bool currentlyDrowning2 = wet && !flag9;
46867 if (wet && !flag9)
46868 {
46869 bool currentlyDrowning3 = Collision.DrownCollision(position, width, height, 1f, includeSlopes: true);
46871 {
46872 ai[0] = 1f;
46873 ai[1] = 200 + Main.rand.Next(300);
46874 ai[2] = 0f;
46876 {
46877 ai[1] += Main.rand.Next(200, 400);
46878 }
46879 localAI[3] = 0f;
46880 netUpdate = true;
46881 }
46882 }
46883 if (avoidFalling2)
46884 {
46885 flag16 = false;
46886 }
46887 if (ai[1] <= 0f)
46888 {
46889 if (flag16 && !avoidFalling2)
46890 {
46891 ai[0] = 1f;
46892 ai[1] = 200 + Main.rand.Next(300);
46893 ai[2] = 0f;
46895 {
46896 ai[1] += Main.rand.Next(200, 400);
46897 }
46898 localAI[3] = 0f;
46899 netUpdate = true;
46900 }
46901 else
46902 {
46903 direction *= -1;
46904 ai[1] = 60 + Main.rand.Next(120);
46905 netUpdate = true;
46906 }
46907 }
46908 }
46909 }
46910 if (Main.netMode != 1 && (!flag || AI_007_TownEntities_IsInAGoodRestingSpot(num6, num7, floorX, floorY)))
46911 {
46913 {
46914 if (localAI[3] == 0f)
46915 {
46916 if (num6 < floorX - 50 && direction == -1)
46917 {
46918 direction = 1;
46919 netUpdate = true;
46920 }
46921 else if (num6 > floorX + 50 && direction == 1)
46922 {
46923 direction = -1;
46924 netUpdate = true;
46925 }
46926 }
46927 }
46928 else if (Main.rand.Next(80) == 0 && localAI[3] == 0f)
46929 {
46930 localAI[3] = 200f;
46931 direction *= -1;
46932 netUpdate = true;
46933 }
46934 }
46935 }
46936 else if (ai[0] == 1f)
46937 {
46938 if (Main.netMode != 1 && flag && AI_007_TownEntities_IsInAGoodRestingSpot(num6, num7, floorX, floorY) && !NPCID.Sets.TownCritter[type])
46939 {
46940 ai[0] = 0f;
46941 ai[1] = 200 + Main.rand.Next(200);
46942 localAI[3] = 60f;
46943 netUpdate = true;
46944 }
46945 else
46946 {
46947 bool flag17 = !flag9 && Collision.DrownCollision(position, width, height, 1f, includeSlopes: true);
46948 if (!flag17)
46949 {
46950 if (Main.netMode != 1 && !homeless && !Main.tileDungeon[Main.tile[num6, num7].type] && (num6 < floorX - 35 || num6 > floorX + 35))
46951 {
46952 if (position.X < (float)(floorX * 16) && direction == -1)
46953 {
46954 ai[1] -= 5f;
46955 }
46956 else if (position.X > (float)(floorX * 16) && direction == 1)
46957 {
46958 ai[1] -= 5f;
46959 }
46960 }
46961 ai[1] -= 1f;
46962 }
46963 if (ai[1] <= 0f)
46964 {
46965 ai[0] = 0f;
46966 ai[1] = 300 + Main.rand.Next(300);
46967 ai[2] = 0f;
46969 {
46970 ai[1] -= Main.rand.Next(100);
46971 }
46972 else
46973 {
46974 ai[1] += Main.rand.Next(900);
46975 }
46976 localAI[3] = 60f;
46977 netUpdate = true;
46978 }
46979 if (closeDoor && ((position.X + (float)(width / 2)) / 16f > (float)(doorX + 2) || (position.X + (float)(width / 2)) / 16f < (float)(doorX - 2)))
46980 {
46981 Tile tileSafely = Framing.GetTileSafely(doorX, doorY);
46982 if (tileSafely.type == 11)
46983 {
46984 if (WorldGen.CloseDoor(doorX, doorY))
46985 {
46986 closeDoor = false;
46987 NetMessage.SendData(19, -1, -1, null, 1, doorX, doorY, direction);
46988 }
46989 if ((position.X + (float)(width / 2)) / 16f > (float)(doorX + 4) || (position.X + (float)(width / 2)) / 16f < (float)(doorX - 4) || (position.Y + (float)(height / 2)) / 16f > (float)(doorY + 4) || (position.Y + (float)(height / 2)) / 16f < (float)(doorY - 4))
46990 {
46991 closeDoor = false;
46992 }
46993 }
46994 else if (tileSafely.type == 389)
46995 {
46996 if (WorldGen.ShiftTallGate(doorX, doorY, closing: true))
46997 {
46998 closeDoor = false;
46999 NetMessage.SendData(19, -1, -1, null, 5, doorX, doorY);
47000 }
47001 if ((position.X + (float)(width / 2)) / 16f > (float)(doorX + 4) || (position.X + (float)(width / 2)) / 16f < (float)(doorX - 4) || (position.Y + (float)(height / 2)) / 16f > (float)(doorY + 4) || (position.Y + (float)(height / 2)) / 16f < (float)(doorY - 4))
47002 {
47003 closeDoor = false;
47004 }
47005 }
47006 else
47007 {
47008 closeDoor = false;
47009 }
47010 }
47011 float num17 = 1f;
47012 float num18 = 0.07f;
47013 if (type == 614 && flag13)
47014 {
47015 num17 = 1.5f;
47016 num18 = 0.1f;
47017 }
47018 else if (type == 299 || type == 539 || type == 538 || (type >= 639 && type <= 645))
47019 {
47020 num17 = 1.5f;
47021 }
47022 else if (flag6)
47023 {
47024 if (wet)
47025 {
47026 num18 = 1f;
47027 num17 = 2f;
47028 }
47029 else
47030 {
47031 num18 = 0.07f;
47032 num17 = 0.5f;
47033 }
47034 }
47035 if (type == 625)
47036 {
47037 if (wet)
47038 {
47039 num18 = 1f;
47040 num17 = 2.5f;
47041 }
47042 else
47043 {
47044 num18 = 0.07f;
47045 num17 = 0.2f;
47046 }
47047 }
47048 if (flag5)
47049 {
47050 num17 = 2f;
47051 num18 = 1f;
47052 }
47053 if (friendly && (flag13 || flag17))
47054 {
47055 num17 = 1.5f;
47056 float num19 = 1f - (float)life / (float)lifeMax;
47057 num17 += num19 * 0.9f;
47058 num18 = 0.1f;
47059 }
47060 if (flag11 && wet)
47061 {
47062 num17 = 2f;
47063 num18 = 0.2f;
47064 }
47065 if (flag7 && wet)
47066 {
47067 if (Math.Abs(velocity.X) < 0.05f && Math.Abs(velocity.Y) < 0.05f)
47068 {
47069 velocity.X += num17 * 10f * (float)direction;
47070 }
47071 else
47072 {
47073 velocity.X *= 0.9f;
47074 }
47075 }
47076 else if (velocity.X < 0f - num17 || velocity.X > num17)
47077 {
47078 if (velocity.Y == 0f)
47079 {
47080 velocity *= 0.8f;
47081 }
47082 }
47083 else if (velocity.X < num17 && direction == 1)
47084 {
47085 velocity.X += num18;
47086 if (velocity.X > num17)
47087 {
47088 velocity.X = num17;
47089 }
47090 }
47091 else if (velocity.X > 0f - num17 && direction == -1)
47092 {
47093 velocity.X -= num18;
47094 if (velocity.X > num17)
47095 {
47096 velocity.X = num17;
47097 }
47098 }
47099 bool flag18 = true;
47100 if ((float)(homeTileY * 16 - 32) > position.Y)
47101 {
47102 flag18 = false;
47103 }
47104 if (!flag18 && velocity.Y == 0f)
47105 {
47106 Collision.StepDown(ref position, ref velocity, width, height, ref stepSpeed, ref gfxOffY);
47107 }
47108 if (velocity.Y >= 0f)
47109 {
47110 Collision.StepUp(ref position, ref velocity, width, height, ref stepSpeed, ref gfxOffY, 1, flag18, 1);
47111 }
47112 if (velocity.Y == 0f)
47113 {
47114 int num20 = (int)((position.X + (float)(width / 2) + (float)(15 * direction)) / 16f);
47115 int num21 = (int)((position.Y + (float)height - 16f) / 16f);
47116 int num22 = 180;
47118 bool flag19 = false;
47119 bool flag20 = false;
47121 {
47122 avoidFalling3 = true;
47123 localAI[3] = num22;
47124 int num23 = 0;
47125 for (int n = 0; n <= 10 && Framing.GetTileSafely(num20 - direction, num21 - n).liquid != 0; n++)
47126 {
47127 num23++;
47128 }
47129 float num24 = 0.3f;
47130 float num25 = (float)Math.Sqrt((float)(num23 * 16 + 16) * 2f * num24);
47131 if (num25 > 26f)
47132 {
47133 num25 = 26f;
47134 }
47135 velocity.Y = 0f - num25;
47136 localAI[3] = position.X;
47137 flag19 = true;
47138 }
47139 if (avoidFalling3 && !flag19)
47140 {
47141 int num26 = (int)((position.X + (float)(width / 2)) / 16f);
47142 int num27 = 0;
47143 for (int num28 = -1; num28 <= 1; num28++)
47144 {
47145 Tile tileSafely2 = Framing.GetTileSafely(num26 + num28, num21 + 1);
47146 if (tileSafely2.nactive() && Main.tileSolid[tileSafely2.type])
47147 {
47148 num27++;
47149 }
47150 }
47151 if (num27 <= 2)
47152 {
47153 if (velocity.X != 0f)
47154 {
47155 netUpdate = true;
47156 }
47157 keepwalking3 = (avoidFalling3 = false);
47158 ai[0] = 0f;
47159 ai[1] = 50 + Main.rand.Next(50);
47160 ai[2] = 0f;
47161 localAI[3] = 40f;
47162 }
47163 }
47164 if (position.X == localAI[3] && !flag19)
47165 {
47166 direction *= -1;
47167 netUpdate = true;
47168 localAI[3] = num22;
47169 }
47170 if (flag17 && !flag19)
47171 {
47172 if (localAI[3] > (float)num22)
47173 {
47174 localAI[3] = num22;
47175 }
47176 if (localAI[3] > 0f)
47177 {
47178 localAI[3] -= 1f;
47179 }
47180 }
47181 else
47182 {
47183 localAI[3] = -1f;
47184 }
47185 Tile tileSafely3 = Framing.GetTileSafely(num20, num21);
47186 Tile tileSafely4 = Framing.GetTileSafely(num20, num21 - 1);
47187 Tile tileSafely5 = Framing.GetTileSafely(num20, num21 - 2);
47188 bool flag21 = height / 16 < 3;
47189 if (townNPC && tileSafely5.nactive() && (tileSafely5.type == 10 || tileSafely5.type == 388) && (Main.rand.Next(10) == 0 || flag))
47190 {
47191 if (Main.netMode != 1)
47192 {
47193 if (WorldGen.OpenDoor(num20, num21 - 2, direction))
47194 {
47195 closeDoor = true;
47196 doorX = num20;
47197 doorY = num21 - 2;
47198 NetMessage.SendData(19, -1, -1, null, 0, num20, num21 - 2, direction);
47199 netUpdate = true;
47200 ai[1] += 80f;
47201 }
47202 else if (WorldGen.OpenDoor(num20, num21 - 2, -direction))
47203 {
47204 closeDoor = true;
47205 doorX = num20;
47206 doorY = num21 - 2;
47207 NetMessage.SendData(19, -1, -1, null, 0, num20, num21 - 2, -direction);
47208 netUpdate = true;
47209 ai[1] += 80f;
47210 }
47211 else if (WorldGen.ShiftTallGate(num20, num21 - 2, closing: false))
47212 {
47213 closeDoor = true;
47214 doorX = num20;
47215 doorY = num21 - 2;
47216 NetMessage.SendData(19, -1, -1, null, 4, num20, num21 - 2);
47217 netUpdate = true;
47218 ai[1] += 80f;
47219 }
47220 else
47221 {
47222 direction *= -1;
47223 netUpdate = true;
47224 }
47225 }
47226 }
47227 else
47228 {
47229 if ((velocity.X < 0f && direction == -1) || (velocity.X > 0f && direction == 1))
47230 {
47231 bool flag22 = false;
47232 bool flag23 = false;
47233 if (tileSafely5.nactive() && Main.tileSolid[tileSafely5.type] && !Main.tileSolidTop[tileSafely5.type] && (!flag21 || (tileSafely4.nactive() && Main.tileSolid[tileSafely4.type] && !Main.tileSolidTop[tileSafely4.type])))
47234 {
47235 if (!Collision.SolidTilesVersatile(num20 - direction * 2, num20 - direction, num21 - 5, num21 - 1) && !Collision.SolidTiles(num20, num20, num21 - 5, num21 - 3))
47236 {
47237 velocity.Y = -6f;
47238 netUpdate = true;
47239 }
47240 else if (flag5)
47241 {
47242 if (WorldGen.SolidTile((int)(base.Center.X / 16f) + direction, (int)(base.Center.Y / 16f)))
47243 {
47244 direction *= -1;
47245 velocity.X *= 0f;
47246 netUpdate = true;
47247 }
47248 }
47249 else if (flag13)
47250 {
47251 flag23 = true;
47252 flag22 = true;
47253 }
47254 else if (!flag20)
47255 {
47256 flag22 = true;
47257 }
47258 }
47259 else if (tileSafely4.nactive() && Main.tileSolid[tileSafely4.type] && !Main.tileSolidTop[tileSafely4.type])
47260 {
47261 if (!Collision.SolidTilesVersatile(num20 - direction * 2, num20 - direction, num21 - 4, num21 - 1) && !Collision.SolidTiles(num20, num20, num21 - 4, num21 - 2))
47262 {
47263 velocity.Y = -5f;
47264 netUpdate = true;
47265 }
47266 else if (flag13)
47267 {
47268 flag23 = true;
47269 flag22 = true;
47270 }
47271 else
47272 {
47273 flag22 = true;
47274 }
47275 }
47276 else if (position.Y + (float)height - (float)(num21 * 16) > 20f && tileSafely3.nactive() && Main.tileSolid[tileSafely3.type] && !tileSafely3.topSlope())
47277 {
47278 if (!Collision.SolidTilesVersatile(num20 - direction * 2, num20, num21 - 3, num21 - 1))
47279 {
47280 velocity.Y = -4.4f;
47281 netUpdate = true;
47282 }
47283 else if (flag13)
47284 {
47285 flag23 = true;
47286 flag22 = true;
47287 }
47288 else
47289 {
47290 flag22 = true;
47291 }
47292 }
47293 else if (avoidFalling3)
47294 {
47295 if (!flag20)
47296 {
47297 flag22 = true;
47298 }
47299 if (flag13)
47300 {
47301 flag23 = true;
47302 }
47303 }
47304 else if (flag12 && !Collision.SolidTilesVersatile(num20 - direction * 2, num20 - direction, num21 - 2, num21 - 1))
47305 {
47306 velocity.Y = -5f;
47307 netUpdate = true;
47308 }
47309 if (flag23)
47310 {
47311 keepwalking3 = false;
47312 velocity.X = 0f;
47313 ai[0] = 8f;
47314 ai[1] = 240f;
47315 netUpdate = true;
47316 }
47317 if (flag22)
47318 {
47319 direction *= -1;
47320 velocity.X *= -1f;
47321 netUpdate = true;
47322 }
47323 if (keepwalking3)
47324 {
47325 ai[1] = 90f;
47326 netUpdate = true;
47327 }
47328 if (velocity.Y < 0f)
47329 {
47330 localAI[3] = position.X;
47331 }
47332 }
47333 if (velocity.Y < 0f && wet)
47334 {
47335 velocity.Y *= 1.2f;
47336 }
47337 if (velocity.Y < 0f && NPCID.Sets.TownCritter[type] && !flag5)
47338 {
47339 velocity.Y *= 1.2f;
47340 }
47341 }
47342 }
47343 else if (flag12 && !wet)
47344 {
47345 int num29 = (int)(base.Center.X / 16f);
47346 int num30 = (int)((position.Y + (float)height - 16f) / 16f);
47347 int num31 = 0;
47348 for (int num32 = -1; num32 <= 1; num32++)
47349 {
47350 for (int num33 = 1; num33 <= 6; num33++)
47351 {
47352 Tile tileSafely6 = Framing.GetTileSafely(num29 + num32, num30 + num33);
47353 if (tileSafely6.liquid > 0 || (tileSafely6.nactive() && Main.tileSolid[tileSafely6.type]))
47354 {
47355 num31++;
47356 }
47357 }
47358 }
47359 if (num31 <= 2)
47360 {
47361 if (velocity.X != 0f)
47362 {
47363 netUpdate = true;
47364 }
47365 velocity.X *= 0.2f;
47366 ai[0] = 0f;
47367 ai[1] = 50 + Main.rand.Next(50);
47368 ai[2] = 0f;
47369 localAI[3] = 40f;
47370 }
47371 }
47372 }
47373 }
47374 else if (ai[0] == 2f || ai[0] == 11f)
47375 {
47376 if (Main.netMode != 1)
47377 {
47378 localAI[3] -= 1f;
47379 if (Main.rand.Next(60) == 0 && localAI[3] == 0f)
47380 {
47381 localAI[3] = 60f;
47382 direction *= -1;
47383 netUpdate = true;
47384 }
47385 }
47386 ai[1] -= 1f;
47387 velocity.X *= 0.8f;
47388 if (ai[1] <= 0f)
47389 {
47390 localAI[3] = 40f;
47391 ai[0] = 0f;
47392 ai[1] = 60 + Main.rand.Next(60);
47393 netUpdate = true;
47394 }
47395 }
47396 else if (ai[0] == 3f || ai[0] == 4f || ai[0] == 5f || ai[0] == 8f || ai[0] == 9f || ai[0] == 16f || ai[0] == 17f || ai[0] == 20f || ai[0] == 21f || ai[0] == 22f || ai[0] == 23f)
47397 {
47398 velocity.X *= 0.8f;
47399 ai[1] -= 1f;
47400 if (ai[0] == 8f && ai[1] < 60f && flag13)
47401 {
47402 ai[1] = 180f;
47403 netUpdate = true;
47404 }
47405 if (ai[0] == 5f)
47406 {
47407 Point coords = (base.Bottom + Vector2.UnitY * -2f).ToTileCoordinates();
47408 Tile tile = Main.tile[coords.X, coords.Y];
47409 if (tile.type != 15 && tile.type != 497)
47410 {
47411 ai[1] = 0f;
47412 }
47413 else
47414 {
47415 Main.sittingManager.AddNPC(whoAmI, coords);
47416 }
47417 }
47418 if (ai[1] <= 0f)
47419 {
47420 ai[0] = 0f;
47421 ai[1] = 60 + Main.rand.Next(60);
47422 ai[2] = 0f;
47423 localAI[3] = 30 + Main.rand.Next(60);
47424 netUpdate = true;
47425 }
47426 }
47427 else if (ai[0] == 6f || ai[0] == 7f || ai[0] == 18f || ai[0] == 19f)
47428 {
47429 if (ai[0] == 18f && (localAI[3] < 1f || localAI[3] > 2f))
47430 {
47431 localAI[3] = 2f;
47432 }
47433 velocity.X *= 0.8f;
47434 ai[1] -= 1f;
47435 int num34 = (int)ai[2];
47436 if (num34 < 0 || num34 > 255 || !Main.player[num34].CanBeTalkedTo || Main.player[num34].Distance(base.Center) > 200f || !Collision.CanHitLine(base.Top, 0, 0, Main.player[num34].Top, 0, 0))
47437 {
47438 ai[1] = 0f;
47439 }
47440 if (ai[1] > 0f)
47441 {
47442 int num35 = ((base.Center.X < Main.player[num34].Center.X) ? 1 : (-1));
47443 if (num35 != direction)
47444 {
47445 netUpdate = true;
47446 }
47447 direction = num35;
47448 }
47449 else
47450 {
47451 ai[0] = 0f;
47452 ai[1] = 60 + Main.rand.Next(60);
47453 ai[2] = 0f;
47454 localAI[3] = 30 + Main.rand.Next(60);
47455 netUpdate = true;
47456 }
47457 }
47458 else if (ai[0] == 10f)
47459 {
47460 int num36 = 0;
47461 int num37 = 0;
47462 float knockBack = 0f;
47463 float num38 = 0f;
47464 int num39 = 0;
47465 int num40 = 0;
47466 int maxValue = 0;
47467 float num41 = 0f;
47469 float num43 = 0f;
47470 if ((float)NPCID.Sets.AttackTime[type] == ai[1])
47471 {
47472 frameCounter = 0.0;
47473 localAI[3] = 0f;
47474 }
47475 if (type == 38)
47476 {
47477 num36 = 30;
47478 num38 = 6f;
47479 num37 = 20;
47480 num39 = 10;
47481 num40 = 180;
47482 maxValue = 120;
47483 num41 = 16f;
47484 knockBack = 7f;
47485 }
47486 else if (type == 633)
47487 {
47488 num36 = 880;
47489 num38 = 24f;
47490 num37 = 15;
47491 num39 = 1;
47492 num41 = 0f;
47493 knockBack = 7f;
47494 num40 = 15;
47495 maxValue = 10;
47497 {
47498 num36 = 929;
47499 num37 = (int)((float)num37 * 1.5f);
47500 }
47501 }
47502 else if (type == 550)
47503 {
47504 num36 = 669;
47505 num38 = 6f;
47506 num37 = 24;
47507 num39 = 10;
47508 num40 = 120;
47509 maxValue = 60;
47510 num41 = 16f;
47511 knockBack = 9f;
47512 }
47513 else if (type == 588)
47514 {
47515 num36 = 721;
47516 num38 = 8f;
47517 num37 = 15;
47518 num39 = 5;
47519 num40 = 20;
47520 maxValue = 10;
47521 num41 = 16f;
47522 knockBack = 9f;
47523 }
47524 else if (type == 208)
47525 {
47526 num36 = 588;
47527 num38 = 6f;
47528 num37 = 30;
47529 num39 = 10;
47530 num40 = 60;
47531 maxValue = 120;
47532 num41 = 16f;
47533 knockBack = 6f;
47534 }
47535 else if (type == 17)
47536 {
47537 num36 = 48;
47538 num38 = 9f;
47539 num37 = 12;
47540 num39 = 10;
47541 num40 = 60;
47542 maxValue = 60;
47543 num41 = 16f;
47544 knockBack = 1.5f;
47545 }
47546 else if (type == 369)
47547 {
47548 num36 = 520;
47549 num38 = 12f;
47550 num37 = 10;
47551 num39 = 10;
47552 num40 = 0;
47553 maxValue = 1;
47554 num41 = 16f;
47555 knockBack = 3f;
47556 }
47557 else if (type == 453)
47558 {
47559 num36 = 21;
47560 num38 = 14f;
47561 num37 = 14;
47562 num39 = 10;
47563 num40 = 0;
47564 maxValue = 1;
47565 num41 = 16f;
47566 knockBack = 3f;
47567 }
47568 else if (type == 107)
47569 {
47570 num36 = 24;
47571 num38 = 5f;
47572 num37 = 15;
47573 num39 = 10;
47574 num40 = 60;
47575 maxValue = 60;
47576 num41 = 16f;
47577 knockBack = 1f;
47578 }
47579 else if (type == 124)
47580 {
47581 num36 = 582;
47582 num38 = 10f;
47583 num37 = 11;
47584 num39 = 1;
47585 num40 = 30;
47586 maxValue = 30;
47587 knockBack = 3.5f;
47588 }
47589 else if (type == 18)
47590 {
47591 num36 = 583;
47592 num38 = 8f;
47593 num37 = 8;
47594 num39 = 1;
47595 num40 = 15;
47596 maxValue = 10;
47597 knockBack = 2f;
47598 num41 = 10f;
47599 }
47600 else if (type == 142)
47601 {
47602 num36 = 589;
47603 num38 = 7f;
47604 num37 = 22;
47605 num39 = 1;
47606 num40 = 10;
47607 maxValue = 1;
47608 knockBack = 2f;
47609 num41 = 10f;
47610 }
47611 if (Main.expertMode)
47612 {
47613 num37 = (int)((float)num37 * Main.GameModeInfo.TownNPCDamageMultiplier);
47614 }
47615 num37 = (int)((float)num37 * num2);
47616 velocity.X *= 0.8f;
47617 ai[1] -= 1f;
47618 localAI[3] += 1f;
47619 if (localAI[3] == (float)num39 && Main.netMode != 1)
47620 {
47622 if (num11 == 1 && spriteDirection == 1 && num13 != -1)
47623 {
47624 vec = DirectionTo(Main.npc[num13].Center + new Vector2(0f, (0f - num41) * MathHelper.Clamp(Distance(Main.npc[num13].Center) / num42, 0f, 1f)));
47625 }
47626 if (num11 == -1 && spriteDirection == -1 && num12 != -1)
47627 {
47628 vec = DirectionTo(Main.npc[num12].Center + new Vector2(0f, (0f - num41) * MathHelper.Clamp(Distance(Main.npc[num12].Center) / num42, 0f, 1f)));
47629 }
47630 if (vec.HasNaNs() || Math.Sign(vec.X) != spriteDirection)
47631 {
47632 vec = new Vector2(spriteDirection, -1f);
47633 }
47634 vec *= num38;
47635 vec += Utils.RandomVector2(Main.rand, 0f - num43, num43);
47636 int num44 = 1000;
47637 num44 = ((type == 124) ? Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec.X, vec.Y, num36, num37, knockBack, Main.myPlayer, 0f, whoAmI, townNpcVariationIndex) : ((type != 142) ? Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec.X, vec.Y, num36, num37, knockBack, Main.myPlayer) : Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec.X, vec.Y, num36, num37, knockBack, Main.myPlayer, 0f, Main.rand.Next(5))));
47638 Main.projectile[num44].npcProj = true;
47639 Main.projectile[num44].noDropItem = true;
47640 if (type == 588)
47641 {
47642 Main.projectile[num44].timeLeft = 480;
47643 }
47644 }
47645 if (ai[1] <= 0f && 0 == 0)
47646 {
47647 ai[0] = ((localAI[2] == 8f && flag13) ? 8 : 0);
47648 ai[1] = num40 + Main.rand.Next(maxValue);
47649 ai[2] = 0f;
47650 localAI[1] = (localAI[3] = num40 / 2 + Main.rand.Next(maxValue));
47651 netUpdate = true;
47652 }
47653 }
47654 else if (ai[0] == 12f)
47655 {
47656 int num45 = 0;
47657 int num46 = 0;
47658 float num47 = 0f;
47659 int num48 = 0;
47660 int num49 = 0;
47661 int maxValue2 = 0;
47662 float knockBack2 = 0f;
47663 int num50 = 0;
47664 bool flag24 = false;
47665 float num51 = 0f;
47666 if ((float)NPCID.Sets.AttackTime[type] == ai[1])
47667 {
47668 frameCounter = 0.0;
47669 localAI[3] = 0f;
47670 }
47671 int num52 = -1;
47672 if (num11 == 1 && spriteDirection == 1)
47673 {
47674 num52 = num13;
47675 }
47676 if (num11 == -1 && spriteDirection == -1)
47677 {
47678 num52 = num12;
47679 }
47680 if (type == 19)
47681 {
47682 num45 = 14;
47683 num47 = 13f;
47684 num46 = 24;
47685 num49 = 14;
47686 maxValue2 = 4;
47687 knockBack2 = 3f;
47688 num48 = 1;
47689 num51 = 0.5f;
47690 if ((float)NPCID.Sets.AttackTime[type] == ai[1])
47691 {
47692 frameCounter = 0.0;
47693 localAI[3] = 0f;
47694 }
47695 if (Main.hardMode)
47696 {
47697 num46 = 15;
47698 if (localAI[3] > (float)num48)
47699 {
47700 num48 = 10;
47701 flag24 = true;
47702 }
47703 if (localAI[3] > (float)num48)
47704 {
47705 num48 = 20;
47706 flag24 = true;
47707 }
47708 if (localAI[3] > (float)num48)
47709 {
47710 num48 = 30;
47711 flag24 = true;
47712 }
47713 }
47714 }
47715 else if (type == 227)
47716 {
47717 num45 = 587;
47718 num47 = 10f;
47719 num46 = 8;
47720 num49 = 10;
47721 maxValue2 = 1;
47722 knockBack2 = 1.75f;
47723 num48 = 1;
47724 num51 = 0.5f;
47725 if (localAI[3] > (float)num48)
47726 {
47727 num48 = 12;
47728 flag24 = true;
47729 }
47730 if (localAI[3] > (float)num48)
47731 {
47732 num48 = 24;
47733 flag24 = true;
47734 }
47735 if (Main.hardMode)
47736 {
47737 num46 += 2;
47738 }
47739 }
47740 else if (type == 368)
47741 {
47742 num45 = 14;
47743 num47 = 13f;
47744 num46 = 24;
47745 num49 = 12;
47746 maxValue2 = 5;
47747 knockBack2 = 2f;
47748 num48 = 1;
47749 num51 = 0.2f;
47750 if (Main.hardMode)
47751 {
47752 num46 = 30;
47753 num45 = 357;
47754 }
47755 }
47756 else if (type == 22)
47757 {
47758 num47 = 10f;
47759 num46 = 8;
47760 num48 = 1;
47761 if (Main.hardMode)
47762 {
47763 num45 = 2;
47764 num49 = 15;
47765 maxValue2 = 10;
47766 num46 += 6;
47767 }
47768 else
47769 {
47770 num45 = 1;
47771 num49 = 30;
47772 maxValue2 = 20;
47773 }
47774 knockBack2 = 2.75f;
47775 num50 = 4;
47776 num51 = 0.7f;
47777 }
47778 else if (type == 228)
47779 {
47780 num45 = 267;
47781 num47 = 14f;
47782 num46 = 20;
47783 num48 = 1;
47784 num49 = 10;
47785 maxValue2 = 1;
47786 knockBack2 = 3f;
47787 num50 = 6;
47788 num51 = 0.4f;
47789 }
47790 else if (type == 178)
47791 {
47792 num45 = 242;
47793 num47 = 13f;
47794 num46 = ((!Main.hardMode) ? 11 : 15);
47795 num49 = 10;
47796 maxValue2 = 1;
47797 knockBack2 = 2f;
47798 num48 = 1;
47799 if (localAI[3] > (float)num48)
47800 {
47801 num48 = 8;
47802 flag24 = true;
47803 }
47804 if (localAI[3] > (float)num48)
47805 {
47806 num48 = 16;
47807 flag24 = true;
47808 }
47809 num51 = 0.3f;
47810 }
47811 else if (type == 229)
47812 {
47813 num45 = 14;
47814 num47 = 14f;
47815 num46 = 24;
47816 num49 = 10;
47817 maxValue2 = 1;
47818 knockBack2 = 2f;
47819 num48 = 1;
47820 num51 = 0.7f;
47821 if (localAI[3] > (float)num48)
47822 {
47823 num48 = 16;
47824 flag24 = true;
47825 }
47826 if (localAI[3] > (float)num48)
47827 {
47828 num48 = 24;
47829 flag24 = true;
47830 }
47831 if (localAI[3] > (float)num48)
47832 {
47833 num48 = 32;
47834 flag24 = true;
47835 }
47836 if (localAI[3] > (float)num48)
47837 {
47838 num48 = 40;
47839 flag24 = true;
47840 }
47841 if (localAI[3] > (float)num48)
47842 {
47843 num48 = 48;
47844 flag24 = true;
47845 }
47846 if (localAI[3] == 0f && num52 != -1 && Distance(Main.npc[num52].Center) < (float)NPCID.Sets.PrettySafe[type])
47847 {
47848 num51 = 0.1f;
47849 num45 = 162;
47850 num46 = 50;
47851 knockBack2 = 10f;
47852 num47 = 24f;
47853 }
47854 }
47855 else if (type == 209)
47856 {
47857 num45 = Utils.SelectRandom<int>(Main.rand, 134, 133, 135);
47858 num48 = 1;
47859 switch (num45)
47860 {
47861 case 135:
47862 num47 = 12f;
47863 num46 = 30;
47864 num49 = 30;
47865 maxValue2 = 10;
47866 knockBack2 = 7f;
47867 num51 = 0.2f;
47868 break;
47869 case 133:
47870 num47 = 10f;
47871 num46 = 25;
47872 num49 = 10;
47873 maxValue2 = 1;
47874 knockBack2 = 6f;
47875 num51 = 0.2f;
47876 break;
47877 case 134:
47878 num47 = 13f;
47879 num46 = 20;
47880 num49 = 20;
47881 maxValue2 = 10;
47882 knockBack2 = 4f;
47883 num51 = 0.1f;
47884 break;
47885 }
47886 }
47887 if (Main.expertMode)
47888 {
47889 num46 = (int)((float)num46 * Main.GameModeInfo.TownNPCDamageMultiplier);
47890 }
47891 num46 = (int)((float)num46 * num2);
47892 velocity.X *= 0.8f;
47893 ai[1] -= 1f;
47894 localAI[3] += 1f;
47895 if (localAI[3] == (float)num48 && Main.netMode != 1)
47896 {
47898 if (num52 != -1)
47899 {
47900 vec2 = DirectionTo(Main.npc[num52].Center + new Vector2(0f, -num50));
47901 }
47902 if (vec2.HasNaNs() || Math.Sign(vec2.X) != spriteDirection)
47903 {
47904 vec2 = new Vector2(spriteDirection, 0f);
47905 }
47906 vec2 *= num47;
47907 vec2 += Utils.RandomVector2(Main.rand, 0f - num51, num51);
47908 int num53 = 1000;
47909 num53 = ((type != 227) ? Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec2.X, vec2.Y, num45, num46, knockBack2, Main.myPlayer) : Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec2.X, vec2.Y, num45, num46, knockBack2, Main.myPlayer, 0f, (float)Main.rand.Next(12) / 6f));
47910 Main.projectile[num53].npcProj = true;
47911 Main.projectile[num53].noDropItem = true;
47912 }
47913 if (localAI[3] == (float)num48 && flag24 && num52 != -1)
47914 {
47915 Vector2 vector2 = DirectionTo(Main.npc[num52].Center);
47916 if (vector2.Y <= 0.5f && vector2.Y >= -0.5f)
47917 {
47918 ai[2] = vector2.Y;
47919 }
47920 }
47921 if (ai[1] <= 0f && 0 == 0)
47922 {
47923 ai[0] = ((localAI[2] == 8f && flag13) ? 8 : 0);
47924 ai[1] = num49 + Main.rand.Next(maxValue2);
47925 ai[2] = 0f;
47926 localAI[1] = (localAI[3] = num49 / 2 + Main.rand.Next(maxValue2));
47927 netUpdate = true;
47928 }
47929 }
47930 else if (ai[0] == 13f)
47931 {
47932 velocity.X *= 0.8f;
47933 if ((float)NPCID.Sets.AttackTime[type] == ai[1])
47934 {
47935 frameCounter = 0.0;
47936 }
47937 ai[1] -= 1f;
47938 localAI[3] += 1f;
47939 if (localAI[3] == 1f && Main.netMode != 1)
47940 {
47941 Vector2 vec3 = DirectionTo(Main.npc[(int)ai[2]].Center + new Vector2(0f, -20f));
47942 if (vec3.HasNaNs() || Math.Sign(vec3.X) == -spriteDirection)
47943 {
47944 vec3 = new Vector2(spriteDirection, -1f);
47945 }
47946 vec3 *= 8f;
47947 int num54 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec3.X, vec3.Y, 584, 0, 0f, Main.myPlayer, ai[2]);
47948 Main.projectile[num54].npcProj = true;
47949 Main.projectile[num54].noDropItem = true;
47950 }
47951 if (ai[1] <= 0f)
47952 {
47953 ai[0] = 0f;
47954 ai[1] = 10 + Main.rand.Next(10);
47955 ai[2] = 0f;
47956 localAI[3] = 5 + Main.rand.Next(10);
47957 netUpdate = true;
47958 }
47959 }
47960 else if (ai[0] == 14f)
47961 {
47962 int num55 = 0;
47963 int num56 = 0;
47964 float num57 = 0f;
47965 int num58 = 0;
47966 int num59 = 0;
47967 int maxValue3 = 0;
47968 float knockBack3 = 0f;
47969 float num60 = 0f;
47971 float num62 = 1f;
47972 float num63 = 0f;
47973 if ((float)NPCID.Sets.AttackTime[type] == ai[1])
47974 {
47975 frameCounter = 0.0;
47976 localAI[3] = 0f;
47977 }
47978 int num64 = -1;
47979 if (num11 == 1 && spriteDirection == 1)
47980 {
47981 num64 = num13;
47982 }
47983 if (num11 == -1 && spriteDirection == -1)
47984 {
47985 num64 = num12;
47986 }
47987 if (type == 54)
47988 {
47989 num55 = 585;
47990 num57 = 10f;
47991 num56 = 16;
47992 num58 = 30;
47993 num59 = 20;
47994 maxValue3 = 15;
47995 knockBack3 = 2f;
47996 num63 = 1f;
47997 }
47998 else if (type == 108)
47999 {
48000 num55 = 15;
48001 num57 = 6f;
48002 num56 = 18;
48003 num58 = 15;
48004 num59 = 15;
48005 maxValue3 = 5;
48006 knockBack3 = 3f;
48007 num60 = 20f;
48008 }
48009 else if (type == 160)
48010 {
48011 num55 = 590;
48012 num56 = 40;
48013 num58 = 15;
48014 num59 = 10;
48015 maxValue3 = 1;
48016 knockBack3 = 3f;
48017 for (; localAI[3] > (float)num58; num58 += 15)
48018 {
48019 }
48020 }
48021 else if (type == 663)
48022 {
48023 num55 = 950;
48024 num56 = ((!Main.hardMode) ? 15 : 20);
48025 num58 = 15;
48026 num59 = 0;
48027 maxValue3 = 0;
48028 knockBack3 = 3f;
48029 for (; localAI[3] > (float)num58; num58 += 10)
48030 {
48031 }
48032 }
48033 else if (type == 20)
48034 {
48035 num55 = 586;
48036 num58 = 24;
48037 num59 = 10;
48038 maxValue3 = 1;
48039 knockBack3 = 3f;
48040 }
48041 if (Main.expertMode)
48042 {
48043 num56 = (int)((float)num56 * Main.GameModeInfo.TownNPCDamageMultiplier);
48044 }
48045 num56 = (int)((float)num56 * num2);
48046 velocity.X *= 0.8f;
48047 ai[1] -= 1f;
48048 localAI[3] += 1f;
48049 if (localAI[3] == (float)num58 && Main.netMode != 1)
48050 {
48052 if (num64 != -1)
48053 {
48054 vec4 = DirectionTo(Main.npc[num64].Center + new Vector2(0f, (0f - num60) * MathHelper.Clamp(Distance(Main.npc[num64].Center) / num61, 0f, 1f)));
48055 }
48056 if (vec4.HasNaNs() || Math.Sign(vec4.X) != spriteDirection)
48057 {
48058 vec4 = new Vector2(spriteDirection, 0f);
48059 }
48060 vec4 *= num57;
48061 vec4 += Utils.RandomVector2(Main.rand, 0f - num63, num63);
48062 if (type == 108)
48063 {
48064 int num65 = Utils.SelectRandom<int>(Main.rand, 1, 1, 1, 1, 2, 2, 3);
48065 for (int num66 = 0; num66 < num65; num66++)
48066 {
48067 Vector2 vector3 = Utils.RandomVector2(Main.rand, -3.4f, 3.4f);
48068 int num67 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec4.X + vector3.X, vec4.Y + vector3.Y, num55, num56, knockBack3, Main.myPlayer, 0f, 0f, townNpcVariationIndex);
48069 Main.projectile[num67].npcProj = true;
48070 Main.projectile[num67].noDropItem = true;
48071 }
48072 }
48073 else if (type == 160)
48074 {
48075 if (num64 != -1)
48076 {
48077 Vector2 vector4 = Main.npc[num64].position - Main.npc[num64].Size * 2f + Main.npc[num64].Size * Utils.RandomVector2(Main.rand, 0f, 1f) * 5f;
48078 int num68 = 10;
48079 while (num68 > 0 && WorldGen.SolidTile(Framing.GetTileSafely((int)vector4.X / 16, (int)vector4.Y / 16)))
48080 {
48081 num68--;
48082 vector4 = Main.npc[num64].position - Main.npc[num64].Size * 2f + Main.npc[num64].Size * Utils.RandomVector2(Main.rand, 0f, 1f) * 5f;
48083 }
48084 int num69 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector4.X, vector4.Y, 0f, 0f, num55, num56, knockBack3, Main.myPlayer, 0f, 0f, townNpcVariationIndex);
48085 Main.projectile[num69].npcProj = true;
48086 Main.projectile[num69].noDropItem = true;
48087 }
48088 }
48089 else if (type == 663)
48090 {
48091 if (num64 != -1)
48092 {
48093 Vector2 vector5 = Main.npc[num64].position + Main.npc[num64].Size * Utils.RandomVector2(Main.rand, 0f, 1f) * 1f;
48094 int num70 = 5;
48095 while (num70 > 0 && WorldGen.SolidTile(Framing.GetTileSafely((int)vector5.X / 16, (int)vector5.Y / 16)))
48096 {
48097 num70--;
48098 vector5 = Main.npc[num64].position + Main.npc[num64].Size * Utils.RandomVector2(Main.rand, 0f, 1f) * 1f;
48099 }
48100 int num71 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector5.X, vector5.Y, 0f, 0f, num55, num56, knockBack3, Main.myPlayer, 0f, 0f, townNpcVariationIndex);
48101 Main.projectile[num71].npcProj = true;
48102 Main.projectile[num71].noDropItem = true;
48103 }
48104 }
48105 else if (type == 20)
48106 {
48107 int num72 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec4.X, vec4.Y, num55, num56, knockBack3, Main.myPlayer, 0f, whoAmI, townNpcVariationIndex);
48108 Main.projectile[num72].npcProj = true;
48109 Main.projectile[num72].noDropItem = true;
48110 }
48111 else
48112 {
48113 int num73 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X + (float)(spriteDirection * 16), base.Center.Y - 2f, vec4.X, vec4.Y, num55, num56, knockBack3, Main.myPlayer);
48114 Main.projectile[num73].npcProj = true;
48115 Main.projectile[num73].noDropItem = true;
48116 }
48117 }
48118 if (num62 > 0f)
48119 {
48121 Lighting.AddLight(base.Center, vector6.X, vector6.Y, vector6.Z);
48122 }
48123 if (ai[1] <= 0f && 0 == 0)
48124 {
48125 ai[0] = ((localAI[2] == 8f && flag13) ? 8 : 0);
48126 ai[1] = num59 + Main.rand.Next(maxValue3);
48127 ai[2] = 0f;
48128 localAI[1] = (localAI[3] = num59 / 2 + Main.rand.Next(maxValue3));
48129 netUpdate = true;
48130 }
48131 }
48132 else if (ai[0] == 15f)
48133 {
48134 int num74 = 0;
48135 int maxValue4 = 0;
48136 if ((float)NPCID.Sets.AttackTime[type] == ai[1])
48137 {
48138 frameCounter = 0.0;
48139 localAI[3] = 0f;
48140 }
48141 int num75 = 0;
48142 float num76 = 0f;
48143 int num77 = 0;
48144 int num78 = 0;
48145 if (num11 == 1)
48146 {
48148 _ = 1;
48149 }
48150 if (num11 == -1)
48151 {
48153 _ = -1;
48154 }
48155 if (type == 207)
48156 {
48157 num75 = 11;
48158 num77 = (num78 = 32);
48159 num74 = 12;
48160 maxValue4 = 6;
48161 num76 = 4.25f;
48162 }
48163 else if (type == 441)
48164 {
48165 num75 = 9;
48166 num77 = (num78 = 28);
48167 num74 = 9;
48168 maxValue4 = 3;
48169 num76 = 3.5f;
48170 if (GivenName == "Andrew")
48171 {
48172 num75 *= 2;
48173 num76 *= 2f;
48174 }
48175 }
48176 else if (type == 353)
48177 {
48178 num75 = 10;
48179 num77 = (num78 = 32);
48180 num74 = 15;
48181 maxValue4 = 8;
48182 num76 = 5f;
48183 }
48184 else if (NPCID.Sets.IsTownPet[type])
48185 {
48186 num75 = 10;
48187 num77 = (num78 = 32);
48188 num74 = 15;
48189 maxValue4 = 8;
48190 num76 = 3f;
48191 }
48192 if (Main.expertMode)
48193 {
48194 num75 = (int)((float)num75 * Main.GameModeInfo.TownNPCDamageMultiplier);
48195 }
48196 num75 = (int)((float)num75 * num2);
48197 velocity.X *= 0.8f;
48198 ai[1] -= 1f;
48199 if (Main.netMode != 1)
48200 {
48202 Rectangle itemRectangle = new Rectangle((int)swingStats.Item1.X, (int)swingStats.Item1.Y, num77, num78);
48203 if (spriteDirection == -1)
48204 {
48205 itemRectangle.X -= num77;
48206 }
48207 itemRectangle.Y -= num78;
48209 int myPlayer = Main.myPlayer;
48210 for (int num79 = 0; num79 < 200; num79++)
48211 {
48212 NPC nPC2 = Main.npc[num79];
48213 if (nPC2.active && nPC2.immune[myPlayer] == 0 && !nPC2.dontTakeDamage && !nPC2.friendly && nPC2.damage > 0 && itemRectangle.Intersects(nPC2.Hitbox) && (nPC2.noTileCollide || Collision.CanHit(position, width, height, nPC2.position, nPC2.width, nPC2.height)))
48214 {
48215 nPC2.StrikeNPCNoInteraction(num75, num76, spriteDirection);
48216 if (Main.netMode != 0)
48217 {
48218 NetMessage.SendData(28, -1, -1, null, num79, num75, num76, spriteDirection);
48219 }
48220 nPC2.netUpdate = true;
48221 nPC2.immune[myPlayer] = (int)ai[1] + 2;
48222 }
48223 }
48224 }
48225 if (ai[1] <= 0f)
48226 {
48227 bool flag25 = false;
48228 if (flag13)
48229 {
48230 int num80 = -num11;
48231 if (!Collision.CanHit(base.Center, 0, 0, base.Center + Vector2.UnitX * num80 * 32f, 0, 0) || localAI[2] == 8f)
48232 {
48233 flag25 = true;
48234 }
48235 if (flag25)
48236 {
48238 int num82 = ((num11 == 1) ? num13 : num12);
48239 int num83 = ((num11 == 1) ? num12 : num13);
48240 if (num82 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num82].Center, 0, 0))
48241 {
48242 num82 = ((num83 == -1 || !Collision.CanHit(base.Center, 0, 0, Main.npc[num83].Center, 0, 0)) ? (-1) : num83);
48243 }
48244 if (num82 != -1)
48245 {
48246 ai[0] = 15f;
48247 ai[1] = num81;
48248 ai[2] = 0f;
48249 localAI[3] = 0f;
48250 direction = ((position.X < Main.npc[num82].position.X) ? 1 : (-1));
48251 netUpdate = true;
48252 }
48253 else
48254 {
48255 flag25 = false;
48256 }
48257 }
48258 }
48259 if (!flag25)
48260 {
48261 ai[0] = ((localAI[2] == 8f && flag13) ? 8 : 0);
48262 ai[1] = num74 + Main.rand.Next(maxValue4);
48263 ai[2] = 0f;
48264 localAI[1] = (localAI[3] = num74 / 2 + Main.rand.Next(maxValue4));
48265 netUpdate = true;
48266 }
48267 }
48268 }
48269 else if (ai[0] == 24f)
48270 {
48271 velocity.X *= 0.8f;
48272 ai[1] -= 1f;
48273 localAI[3] += 1f;
48274 direction = 1;
48275 spriteDirection = 1;
48277 Lighting.AddLight(base.Center, vector7.X, vector7.Y, vector7.Z);
48278 if (ai[1] <= 0f)
48279 {
48280 ai[0] = 0f;
48281 ai[1] = 480f;
48282 ai[2] = 0f;
48283 localAI[1] = 480f;
48284 netUpdate = true;
48285 }
48286 }
48287 if (flag11 && wet)
48288 {
48289 int num84 = (int)(base.Center.X / 16f);
48290 int num85 = 5;
48291 if (collideX || (num84 < num85 && direction == -1) || (num84 > Main.maxTilesX - num85 && direction == 1))
48292 {
48293 direction *= -1;
48294 velocity.X *= -0.25f;
48295 netUpdate = true;
48296 }
48297 velocity.Y *= 0.9f;
48298 velocity.Y -= 0.5f;
48299 if (velocity.Y < -15f)
48300 {
48301 velocity.Y = -15f;
48302 }
48303 }
48304 if (flag10 && wet)
48305 {
48306 if (flag7)
48307 {
48308 ai[1] = 50f;
48309 }
48310 int num86 = (int)(base.Center.X / 16f);
48311 int num87 = 5;
48312 if (collideX || (num86 < num87 && direction == -1) || (num86 > Main.maxTilesX - num87 && direction == 1))
48313 {
48314 direction *= -1;
48315 velocity.X *= -0.25f;
48316 netUpdate = true;
48317 }
48318 if (Collision.GetWaterLine(base.Center.ToTileCoordinates(), out var waterLineHeight))
48319 {
48320 float num88 = base.Center.Y + 1f;
48321 if (base.Center.Y > waterLineHeight)
48322 {
48323 velocity.Y -= 0.8f;
48324 if (velocity.Y < -4f)
48325 {
48326 velocity.Y = -4f;
48327 }
48329 {
48330 velocity.Y = waterLineHeight - num88;
48331 }
48332 }
48333 else
48334 {
48335 velocity.Y = MathHelper.Min(velocity.Y, waterLineHeight - num88);
48336 }
48337 }
48338 else
48339 {
48340 velocity.Y -= 0.2f;
48341 }
48342 }
48343 if (Main.netMode != 1 && isLikeATownNPC && !flag3)
48344 {
48345 bool flag26 = ai[0] < 2f && !flag13 && !wet;
48346 bool flag27 = (ai[0] < 2f || ai[0] == 8f) && (flag13 || flag14);
48347 if (localAI[1] > 0f)
48348 {
48349 localAI[1] -= 1f;
48350 }
48351 if (localAI[1] > 0f)
48352 {
48353 flag27 = false;
48354 }
48355 if (flag27 && type == 124 && localAI[0] == 1f)
48356 {
48357 flag27 = false;
48358 }
48359 if (flag27 && type == 20)
48360 {
48361 flag27 = false;
48362 for (int num89 = 0; num89 < 200; num89++)
48363 {
48364 NPC nPC3 = Main.npc[num89];
48365 if (nPC3.active && nPC3.townNPC && !(Distance(nPC3.Center) > 1200f) && nPC3.FindBuffIndex(165) == -1)
48366 {
48367 flag27 = true;
48368 break;
48369 }
48370 }
48371 }
48372 if (CanTalk && flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(300) == 0)
48373 {
48374 int num90 = 420;
48375 num90 = ((Main.rand.Next(2) != 0) ? (num90 * Main.rand.Next(1, 3)) : (num90 * Main.rand.Next(1, 4)));
48376 int num91 = 100;
48377 int num92 = 20;
48378 for (int num93 = 0; num93 < 200; num93++)
48379 {
48380 NPC nPC4 = Main.npc[num93];
48381 bool flag28 = (nPC4.ai[0] == 1f && nPC4.closeDoor) || (nPC4.ai[0] == 1f && nPC4.ai[1] > 200f) || nPC4.ai[0] > 1f || nPC4.wet;
48382 if (nPC4 != this && nPC4.active && nPC4.CanBeTalkedTo && !flag28 && nPC4.Distance(base.Center) < (float)num91 && nPC4.Distance(base.Center) > (float)num92 && Collision.CanHit(base.Center, 0, 0, nPC4.Center, 0, 0))
48383 {
48384 int num94 = (position.X < nPC4.position.X).ToDirectionInt();
48385 ai[0] = 3f;
48386 ai[1] = num90;
48387 ai[2] = num93;
48388 direction = num94;
48389 netUpdate = true;
48390 nPC4.ai[0] = 4f;
48391 nPC4.ai[1] = num90;
48392 nPC4.ai[2] = whoAmI;
48393 nPC4.direction = -num94;
48394 nPC4.netUpdate = true;
48395 break;
48396 }
48397 }
48398 }
48399 else if (CanTalk && flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(1800) == 0)
48400 {
48401 int num95 = 420;
48402 num95 = ((Main.rand.Next(2) != 0) ? (num95 * Main.rand.Next(1, 3)) : (num95 * Main.rand.Next(1, 4)));
48403 int num96 = 100;
48404 int num97 = 20;
48405 for (int num98 = 0; num98 < 200; num98++)
48406 {
48407 NPC nPC5 = Main.npc[num98];
48408 bool flag29 = (nPC5.ai[0] == 1f && nPC5.closeDoor) || (nPC5.ai[0] == 1f && nPC5.ai[1] > 200f) || nPC5.ai[0] > 1f || nPC5.wet;
48409 if (nPC5 != this && nPC5.active && nPC5.CanBeTalkedTo && !NPCID.Sets.IsTownPet[nPC5.type] && !flag29 && nPC5.Distance(base.Center) < (float)num96 && nPC5.Distance(base.Center) > (float)num97 && Collision.CanHit(base.Center, 0, 0, nPC5.Center, 0, 0))
48410 {
48411 int num99 = (position.X < nPC5.position.X).ToDirectionInt();
48412 ai[0] = 16f;
48413 ai[1] = num95;
48414 ai[2] = num98;
48415 localAI[2] = Main.rand.Next(4);
48416 localAI[3] = Main.rand.Next(3 - (int)localAI[2]);
48417 direction = num99;
48418 netUpdate = true;
48419 nPC5.ai[0] = 17f;
48420 nPC5.ai[1] = num95;
48421 nPC5.ai[2] = whoAmI;
48422 nPC5.localAI[2] = 0f;
48423 nPC5.localAI[3] = 0f;
48424 nPC5.direction = -num99;
48425 nPC5.netUpdate = true;
48426 break;
48427 }
48428 }
48429 }
48430 else if (!NPCID.Sets.IsTownPet[type] && flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(1200) == 0 && (type == 208 || (BirthdayParty.PartyIsUp && NPCID.Sets.AttackType[type] == NPCID.Sets.AttackType[208])))
48431 {
48432 int num100 = 300;
48433 int num101 = 150;
48434 for (int num102 = 0; num102 < 255; num102++)
48435 {
48436 Player player = Main.player[num102];
48437 if (player.active && !player.dead && player.Distance(base.Center) < (float)num101 && Collision.CanHitLine(base.Top, 0, 0, player.Top, 0, 0))
48438 {
48439 int num103 = (position.X < player.position.X).ToDirectionInt();
48440 ai[0] = 6f;
48441 ai[1] = num100;
48442 ai[2] = num102;
48443 direction = num103;
48444 netUpdate = true;
48445 break;
48446 }
48447 }
48448 }
48449 else if (flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(600) == 0 && type == 550)
48450 {
48451 int num104 = 300;
48452 int num105 = 150;
48453 for (int num106 = 0; num106 < 255; num106++)
48454 {
48455 Player player2 = Main.player[num106];
48456 if (player2.active && !player2.dead && player2.Distance(base.Center) < (float)num105 && Collision.CanHitLine(base.Top, 0, 0, player2.Top, 0, 0))
48457 {
48458 int num107 = (position.X < player2.position.X).ToDirectionInt();
48459 ai[0] = 18f;
48460 ai[1] = num104;
48461 ai[2] = num106;
48462 direction = num107;
48463 netUpdate = true;
48464 break;
48465 }
48466 }
48467 }
48468 else if (!NPCID.Sets.IsTownPet[type] && flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(1800) == 0)
48469 {
48470 ai[0] = 2f;
48471 ai[1] = 45 * Main.rand.Next(1, 2);
48472 netUpdate = true;
48473 }
48474 else if (flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(600) == 0 && type == 229 && !flag14)
48475 {
48476 ai[0] = 11f;
48477 ai[1] = 30 * Main.rand.Next(1, 4);
48478 netUpdate = true;
48479 }
48480 else if (flag26 && ai[0] == 0f && velocity.Y == 0f && Main.rand.Next(1200) == 0)
48481 {
48482 int num108 = 220;
48483 int num109 = 150;
48484 for (int num110 = 0; num110 < 255; num110++)
48485 {
48486 Player player3 = Main.player[num110];
48487 if (player3.CanBeTalkedTo && player3.Distance(base.Center) < (float)num109 && Collision.CanHitLine(base.Top, 0, 0, player3.Top, 0, 0))
48488 {
48489 int num111 = (position.X < player3.position.X).ToDirectionInt();
48490 ai[0] = 7f;
48491 ai[1] = num108;
48492 ai[2] = num110;
48493 direction = num111;
48494 netUpdate = true;
48495 break;
48496 }
48497 }
48498 }
48499 else if (flag26 && ai[0] == 1f && velocity.Y == 0f && num > 0 && Main.rand.Next(num) == 0)
48500 {
48501 Point point = (base.Bottom + Vector2.UnitY * -2f).ToTileCoordinates();
48502 bool flag30 = WorldGen.InWorld(point.X, point.Y, 1);
48503 if (flag30)
48504 {
48505 for (int num112 = 0; num112 < 200; num112++)
48506 {
48507 if (Main.npc[num112].active && Main.npc[num112].aiStyle == 7 && Main.npc[num112].townNPC && Main.npc[num112].ai[0] == 5f && (Main.npc[num112].Bottom + Vector2.UnitY * -2f).ToTileCoordinates() == point)
48508 {
48509 flag30 = false;
48510 break;
48511 }
48512 }
48513 for (int num113 = 0; num113 < 255; num113++)
48514 {
48515 if (Main.player[num113].active && Main.player[num113].sitting.isSitting && Main.player[num113].Center.ToTileCoordinates() == point)
48516 {
48517 flag30 = false;
48518 break;
48519 }
48520 }
48521 }
48522 if (flag30)
48523 {
48524 Tile tile2 = Main.tile[point.X, point.Y];
48525 flag30 = tile2.type == 15 || tile2.type == 497;
48526 if (flag30 && tile2.type == 15 && tile2.frameY >= 1080 && tile2.frameY <= 1098)
48527 {
48528 flag30 = false;
48529 }
48530 if (flag30)
48531 {
48532 ai[0] = 5f;
48533 ai[1] = 900 + Main.rand.Next(10800);
48534 direction = ((tile2.frameX != 0) ? 1 : (-1));
48535 base.Bottom = new Vector2(point.X * 16 + 8 + 2 * direction, point.Y * 16 + 16);
48537 localAI[3] = 0f;
48538 netUpdate = true;
48539 }
48540 }
48541 }
48542 else if (flag26 && ai[0] == 1f && velocity.Y == 0f && Main.rand.Next(600) == 0 && Utils.PlotTileLine(base.Top, base.Bottom, width, DelegateMethods.SearchAvoidedByNPCs))
48543 {
48544 Point point2 = (base.Center + new Vector2(direction * 10, 0f)).ToTileCoordinates();
48545 bool flag31 = WorldGen.InWorld(point2.X, point2.Y, 1);
48546 if (flag31)
48547 {
48548 Tile tileSafely7 = Framing.GetTileSafely(point2.X, point2.Y);
48549 if (!tileSafely7.nactive() || !TileID.Sets.InteractibleByNPCs[tileSafely7.type])
48550 {
48551 flag31 = false;
48552 }
48553 }
48554 if (flag31)
48555 {
48556 ai[0] = 9f;
48557 ai[1] = 40 + Main.rand.Next(90);
48559 localAI[3] = 0f;
48560 netUpdate = true;
48561 }
48562 }
48563 if (Main.netMode != 1 && ai[0] < 2f && velocity.Y == 0f && type == 18 && breath > 0)
48564 {
48565 int num114 = -1;
48566 for (int num115 = 0; num115 < 200; num115++)
48567 {
48568 NPC nPC6 = Main.npc[num115];
48569 if (nPC6.active && nPC6.townNPC && nPC6.life != nPC6.lifeMax && (num114 == -1 || nPC6.lifeMax - nPC6.life > Main.npc[num114].lifeMax - Main.npc[num114].life) && Collision.CanHitLine(position, width, height, nPC6.position, nPC6.width, nPC6.height) && Distance(nPC6.Center) < 500f)
48570 {
48571 num114 = num115;
48572 }
48573 }
48574 if (num114 != -1)
48575 {
48576 ai[0] = 13f;
48577 ai[1] = 34f;
48578 ai[2] = num114;
48579 localAI[3] = 0f;
48580 direction = ((position.X < Main.npc[num114].position.X) ? 1 : (-1));
48581 netUpdate = true;
48582 }
48583 }
48584 if (flag27 && velocity.Y == 0f && NPCID.Sets.AttackType[type] == 0 && NPCID.Sets.AttackAverageChance[type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[type] * 2) == 0)
48585 {
48587 int num117 = ((num11 == 1) ? num13 : num12);
48588 int num118 = ((num11 == 1) ? num12 : num13);
48589 if (num117 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num117].Center, 0, 0))
48590 {
48591 num117 = ((num118 == -1 || !Collision.CanHit(base.Center, 0, 0, Main.npc[num118].Center, 0, 0)) ? (-1) : num118);
48592 }
48593 bool flag32 = num117 != -1;
48594 if (flag32 && type == 633)
48595 {
48596 flag32 = Vector2.Distance(base.Center, Main.npc[num117].Center) <= 50f;
48597 }
48598 if (flag32)
48599 {
48600 localAI[2] = ai[0];
48601 ai[0] = 10f;
48602 ai[1] = num116;
48603 ai[2] = 0f;
48604 localAI[3] = 0f;
48605 direction = ((position.X < Main.npc[num117].position.X) ? 1 : (-1));
48606 netUpdate = true;
48607 }
48608 }
48609 else if (flag27 && velocity.Y == 0f && NPCID.Sets.AttackType[type] == 1 && NPCID.Sets.AttackAverageChance[type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[type] * 2) == 0)
48610 {
48612 int num120 = ((num11 == 1) ? num13 : num12);
48613 int num121 = ((num11 == 1) ? num12 : num13);
48614 if (num120 != -1 && !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num120].Center, 0, 0))
48615 {
48616 num120 = ((num121 == -1 || !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num121].Center, 0, 0)) ? (-1) : num121);
48617 }
48618 if (num120 != -1)
48619 {
48620 Vector2 vector8 = DirectionTo(Main.npc[num120].Center);
48621 if (vector8.Y <= 0.5f && vector8.Y >= -0.5f)
48622 {
48623 localAI[2] = ai[0];
48624 ai[0] = 12f;
48625 ai[1] = num119;
48626 ai[2] = vector8.Y;
48627 localAI[3] = 0f;
48628 direction = ((position.X < Main.npc[num120].position.X) ? 1 : (-1));
48629 netUpdate = true;
48630 }
48631 }
48632 }
48633 if (flag27 && velocity.Y == 0f && NPCID.Sets.AttackType[type] == 2 && NPCID.Sets.AttackAverageChance[type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[type] * 2) == 0)
48634 {
48636 int num123 = ((num11 == 1) ? num13 : num12);
48637 int num124 = ((num11 == 1) ? num12 : num13);
48638 if (num123 != -1 && !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num123].Center, 0, 0))
48639 {
48640 num123 = ((num124 == -1 || !Collision.CanHitLine(base.Center, 0, 0, Main.npc[num124].Center, 0, 0)) ? (-1) : num124);
48641 }
48642 if (num123 != -1)
48643 {
48644 localAI[2] = ai[0];
48645 ai[0] = 14f;
48646 ai[1] = num122;
48647 ai[2] = 0f;
48648 localAI[3] = 0f;
48649 direction = ((position.X < Main.npc[num123].position.X) ? 1 : (-1));
48650 netUpdate = true;
48651 }
48652 else if (type == 20)
48653 {
48654 localAI[2] = ai[0];
48655 ai[0] = 14f;
48656 ai[1] = num122;
48657 ai[2] = 0f;
48658 localAI[3] = 0f;
48659 netUpdate = true;
48660 }
48661 }
48662 if (flag27 && velocity.Y == 0f && NPCID.Sets.AttackType[type] == 3 && NPCID.Sets.AttackAverageChance[type] > 0 && Main.rand.Next(NPCID.Sets.AttackAverageChance[type] * 2) == 0)
48663 {
48665 int num126 = ((num11 == 1) ? num13 : num12);
48666 int num127 = ((num11 == 1) ? num12 : num13);
48667 if (num126 != -1 && !Collision.CanHit(base.Center, 0, 0, Main.npc[num126].Center, 0, 0))
48668 {
48669 num126 = ((num127 == -1 || !Collision.CanHit(base.Center, 0, 0, Main.npc[num127].Center, 0, 0)) ? (-1) : num127);
48670 }
48671 if (num126 != -1)
48672 {
48673 localAI[2] = ai[0];
48674 ai[0] = 15f;
48675 ai[1] = num125;
48676 ai[2] = 0f;
48677 localAI[3] = 0f;
48678 direction = ((position.X < Main.npc[num126].position.X) ? 1 : (-1));
48679 netUpdate = true;
48680 }
48681 }
48682 }
48683 if (type == 681)
48684 {
48685 float R = 0f;
48686 float G = 0f;
48687 float B = 0f;
48688 TorchID.TorchColor(23, out R, out G, out B);
48689 float num128 = 0.35f;
48690 R *= num128;
48691 G *= num128;
48692 B *= num128;
48693 Lighting.AddLight(base.Center, R, G, B);
48694 }
48695 if (type == 683 || type == 687)
48696 {
48697 float num129 = Utils.WrappedLerp(0.75f, 1f, (float)Main.timeForVisualEffects % 120f / 120f);
48698 Lighting.AddLight(base.Center, 0.25f * num129, 0.25f * num129, 0.1f * num129);
48699 }
48700 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static float Min(float value1, float value2)
Definition MathHelper.cs:36
static double Sqrt(double d)
static double Abs(double value)
const double PI
Definition Math.cs:16
static int Sign(decimal value)
Definition Math.cs:1202
static void PlaySound(int type, Vector2 position, int style=1)
bool honeyWet
Definition Entity.cs:34
Vector2 Center
Definition Entity.cs:43
bool shimmerWet
Definition Entity.cs:32
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static void BroadcastParticleSpawn(ParticleOrchestraType type, ParticleOrchestraSettings settings)
static void RequestParticleSpawn(bool clientOnly, ParticleOrchestraType type, ParticleOrchestraSettings settings, int? overrideInvokingPlayerIndex=null)
static int[] PrettySafe
Definition NPCID.cs:4230
static bool[] Skeletons
Definition NPCID.cs:4238
static bool[] TownCritter
Definition NPCID.cs:4200
static bool[] IsTownPet
Definition NPCID.cs:4099
static int[] AttackTime
Definition NPCID.cs:4224
static bool[] IsTownSlime
Definition NPCID.cs:4101
static int[] AttackType
Definition NPCID.cs:4228
static int[] AttackAverageChance
Definition NPCID.cs:4226
static int[] DangerDetectRange
Definition NPCID.cs:4214
static readonly short Count
Definition NPCID.cs:11744
static bool[] InteractibleByNPCs
Definition TileID.cs:273
static void TorchColor(int torchID, out float R, out float G, out float B)
Definition TorchID.cs:164
int breath
Definition NPC.cs:565
bool CanTalk
Definition NPC.cs:641
static bool savedAngler
Definition NPC.cs:293
int defense
Definition NPC.cs:463
Color GetMagicAuraColor()
Definition NPC.cs:46208
bool ShouldBestiaryGirlBeLycantrope()
Definition NPC.cs:90417
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
static bool downedMechBoss2
Definition NPC.cs:425
void Teleport(Vector2 newPos, int Style=0, int extraInfo=0)
Definition NPC.cs:77888
bool AI_007_TownEntities_CheckIfWillDrown(bool currentlyDrowning)
Definition NPC.cs:48887
static bool savedTaxCollector
Definition NPC.cs:285
static bool downedBoss2
Definition NPC.cs:347
void TweakSwingStats(int swingMax, int swingCurrent, int aimDir, ref Rectangle itemRectangle)
Definition NPC.cs:58967
static bool savedGolfer
Definition NPC.cs:299
int lifeMax
Definition NPC.cs:479
bool dryadWard
Definition NPC.cs:259
string GivenName
Definition NPC.cs:761
bool closeDoor
Definition NPC.cs:557
float gfxOffY
Definition NPC.cs:125
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
static int safeRangeY
Definition NPC.cs:187
static bool savedMech
Definition NPC.cs:291
bool isLikeATownNPC
Definition NPC.cs:822
static bool downedEmpressOfLight
Definition NPC.cs:393
int townNpcVariationIndex
Definition NPC.cs:101
void UpdateHomeTileState(bool homeless, int x, int y)
Definition NPC.cs:46195
static bool savedWizard
Definition NPC.cs:289
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
Definition NPC.cs:864
static bool downedBoss1
Definition NPC.cs:345
int defDefense
Definition NPC.cs:467
float[] ai
Definition NPC.cs:447
static bool savedGoblin
Definition NPC.cs:287
int doorX
Definition NPC.cs:559
bool AI_007_TownEntities_IsInAGoodRestingSpot(int tileX, int tileY, int idealRestX, int idealRestY)
Definition NPC.cs:46069
static int sWidth
Definition NPC.cs:177
static bool taxCollector
Definition NPC.cs:111
static bool combatBookWasUsed
Definition NPC.cs:339
static bool[] ShimmeredTownNPCs
Definition NPC.cs:97
int homeTileX
Definition NPC.cs:543
int doorY
Definition NPC.cs:561
bool dontTakeDamage
Definition NPC.cs:527
static bool downedMechBoss3
Definition NPC.cs:427
bool friendly
Definition NPC.cs:555
float stepSpeed
Definition NPC.cs:127
void AI_007_TownEntities_Shimmer_TeleportToLandingSpot()
Definition NPC.cs:48702
void AI_007_TownEntities_GetWalkPrediction(int myTileX, int homeFloorX, bool canBreathUnderWater, bool currentlyDrowning, int tileX, int tileY, out bool keepwalking, out bool avoidFalling)
Definition NPC.cs:48813
bool collideX
Definition NPC.cs:511
int type
Definition NPC.cs:445
static int safeRangeX
Definition NPC.cs:185
static bool downedQueenBee
Definition NPC.cs:351
double StrikeNPCNoInteraction(int Damage, float knockBack, int hitDirection, bool crit=false, bool noEffect=false, bool fromNet=false)
Definition NPC.cs:78015
double frameCounter
Definition NPC.cs:483
float shimmerTransparency
Definition NPC.cs:207
bool shimmering
Definition NPC.cs:245
void AI_007_FindGoodRestingSpot(int myTileX, int myTileY, out int floorX, out int floorY)
Definition NPC.cs:46090
void AI_007_AttemptToPlayIdleAnimationsForPets(int petIdleChance)
Definition NPC.cs:48892
static int[] lazyNPCOwnedProjectileSearchArray
Definition NPC.cs:431
static bool combatBookVolumeTwoWasUsed
Definition NPC.cs:341
void HitEffect(int hitDirection=0, double dmg=10.0)
Definition NPC.cs:78386
Tuple< Vector2, float > GetSwingStats(int swingMax, int swingCurrent, int aimDir, int itemWidth, int itemHeight)
Definition NPC.cs:58864
static bool downedGolemBoss
Definition NPC.cs:365
bool homeless
Definition NPC.cs:541
static bool downedAncientCultist
Definition NPC.cs:381
bool IsShimmerVariant
Definition NPC.cs:721
static bool downedBoss3
Definition NPC.cs:349
void Transform(int newType)
Definition NPC.cs:77913
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
static bool downedPlantBoss
Definition NPC.cs:363
static bool savedBartender
Definition NPC.cs:297
void AI_007_TownEntities_TeleportToHome(int homeFloorX, int homeFloorY)
Definition NPC.cs:48783
int directionY
Definition NPC.cs:443
static bool downedMechBoss1
Definition NPC.cs:423
bool netUpdate
Definition NPC.cs:507
void AI_007_TryForcingSitting(int homeFloorX, int homeFloorY)
Definition NPC.cs:46159
int target
Definition NPC.cs:459
bool townNPC
Definition NPC.cs:537
static bool downedQueenSlime
Definition NPC.cs:395
int homeTileY
Definition NPC.cs:545
static bool savedStylist
Definition NPC.cs:295
static int sHeight
Definition NPC.cs:179
bool Intersects(Rectangle value)
Definition Rectangle.cs:129
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References System.Math.Abs(), Terraria.Entity.active, Terraria.Lighting.AddLight(), Terraria.NPC.ai, Terraria.Projectile.ai, Terraria.NPC.AI_007_AttemptToPlayIdleAnimationsForPets(), Terraria.NPC.AI_007_FindGoodRestingSpot(), Terraria.NPC.AI_007_TownEntities_CheckIfWillDrown(), Terraria.NPC.AI_007_TownEntities_GetWalkPrediction(), Terraria.NPC.AI_007_TownEntities_IsInAGoodRestingSpot(), Terraria.NPC.AI_007_TownEntities_Shimmer_TeleportToLandingSpot(), Terraria.NPC.AI_007_TownEntities_TeleportToHome(), Terraria.NPC.AI_007_TryForcingSitting(), Terraria.ID.NPCID.Sets.AttackAverageChance, Terraria.ID.NPCID.Sets.AttackTime, Terraria.ID.NPCID.Sets.AttackType, System.B, Terraria.NPC.breath, Terraria.GameContent.Drawing.ParticleOrchestrator.BroadcastParticleSpawn(), Terraria.Collision.CanHit(), Terraria.Collision.CanHitLine(), Terraria.NPC.CanTalk, Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.NPC.closeDoor, Terraria.WorldGen.CloseDoor(), Terraria.NPC.collideX, Terraria.NPC.combatBookVolumeTwoWasUsed, Terraria.NPC.combatBookWasUsed, Terraria.ID.NPCID.Count, Terraria.ID.NPCID.Sets.DangerDetectRange, Terraria.Main.dayTime, Terraria.Player.dead, Terraria.NPC.defDefense, Terraria.NPC.defense, Terraria.Entity.direction, Terraria.Entity.DirectionTo(), Terraria.NPC.directionY, Terraria.Entity.Distance(), Microsoft.Xna.Framework.Vector2.Distance(), Terraria.NPC.dontTakeDamage, Terraria.NPC.doorX, Terraria.NPC.doorY, Terraria.NPC.downedAncientCultist, Terraria.NPC.downedBoss1, Terraria.NPC.downedBoss2, Terraria.NPC.downedBoss3, Terraria.NPC.downedEmpressOfLight, Terraria.NPC.downedGolemBoss, Terraria.NPC.downedMechBoss1, Terraria.NPC.downedMechBoss2, Terraria.NPC.downedMechBoss3, Terraria.NPC.downedPlantBoss, Terraria.NPC.downedQueenBee, Terraria.NPC.downedQueenSlime, Terraria.Collision.DrownCollision(), Terraria.NPC.dryadWard, Terraria.Main.dungeonX, Terraria.Main.dungeonY, Terraria.Main.eclipse, Terraria.Main.expertMode, Terraria.NPC.frameCounter, Terraria.NPC.friendly, System.G, Terraria.Main.GameModeInfo, Terraria.NPC.GetMagicAuraColor(), Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSwingStats(), Terraria.NPC.GetTargetData(), Terraria.Framing.GetTileSafely(), Terraria.Collision.GetWaterLine(), Terraria.NPC.gfxOffY, Terraria.NPC.GivenName, Terraria.Main.hardMode, Terraria.Entity.height, Terraria.NPC.HitEffect(), Terraria.NPC.homeless, Terraria.NPC.homeTileX, Terraria.NPC.homeTileY, Terraria.Entity.honeyWet, Terraria.Main.hslToRgb(), Terraria.ID.TileID.Sets.InteractibleByNPCs, Microsoft.Xna.Framework.Rectangle.Intersects(), Terraria.WorldGen.InWorld(), Terraria.NPC.isLikeATownNPC, Terraria.NPC.IsShimmerVariant, Terraria.ID.NPCID.Sets.IsTownPet, Terraria.ID.NPCID.Sets.IsTownSlime, Terraria.Entity.lavaWet, Terraria.NPC.lazyNPCOwnedProjectileSearchArray, Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.NPC.localAI, Terraria.Main.masterMode, Terraria.Main.maxTilesX, Microsoft.Xna.Framework.MathHelper.Min(), Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Dust.NewDustPerfect(), Terraria.Projectile.NewProjectile(), Terraria.Main.npc, Terraria.WorldGen.OpenDoor(), System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Utils.PlotTileLine(), Terraria.Entity.position, Terraria.ID.NPCID.Sets.PrettySafe, Terraria.Main.projectile, System.R, Terraria.Main.raining, Terraria.Main.rand, Terraria.Utils.RandomVector2(), Terraria.Utils.Remap(), Terraria.GameContent.Drawing.ParticleOrchestrator.RequestParticleSpawn(), Terraria.NPC.safeRangeX, Terraria.NPC.safeRangeY, Terraria.NPC.savedAngler, Terraria.NPC.savedBartender, Terraria.NPC.savedGoblin, Terraria.NPC.savedGolfer, Terraria.NPC.savedMech, Terraria.NPC.savedStylist, Terraria.NPC.savedTaxCollector, Terraria.NPC.savedWizard, Terraria.DelegateMethods.SearchAvoidedByNPCs(), Terraria.NetMessage.SendData(), Terraria.NPC.sHeight, Terraria.WorldGen.ShiftTallGate(), Terraria.NPC.ShimmeredTownNPCs, Terraria.NPC.shimmering, Terraria.NPC.shimmerTransparency, Terraria.Entity.shimmerWet, Terraria.NPC.ShouldBestiaryGirlBeLycantrope(), System.Math.Sign(), Terraria.Main.sittingManager, Terraria.ID.NPCID.Sets.Skeletons, Terraria.Main.slimeRain, Terraria.WorldGen.SolidTile(), Terraria.Collision.SolidTiles(), Terraria.Collision.SolidTilesVersatile(), Terraria.Main.spawnTileX, Terraria.Main.spawnTileY, Terraria.NPC.spriteDirection, System.Math.Sqrt(), Terraria.Collision.StepDown(), Terraria.NPC.stepSpeed, Terraria.Collision.StepUp(), Terraria.NPC.StrikeNPCNoInteraction(), Terraria.NPC.sWidth, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.NPC.taxCollector, Terraria.NPC.Teleport(), Terraria.Main.tile, Terraria.Main.tileDungeon, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, Terraria.Main.timeForVisualEffects, Terraria.Entity.Top, Terraria.ID.TorchID.TorchColor(), Microsoft.Xna.Framework.Color.ToVector3(), Terraria.ID.NPCID.Sets.TownCritter, Terraria.NPC.townNPC, Terraria.NPC.townNpcVariationIndex, Terraria.NPC.Transform(), Terraria.NPC.TweakSwingStats(), Terraria.NPC.type, Terraria.Projectile.type, Terraria.Tile.type, Microsoft.Xna.Framework.Vector2.UnitX, Microsoft.Xna.Framework.Vector2.UnitY, Terraria.NPC.UpdateHomeTileState(), Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.wet, Terraria.Collision.WetCollision(), Terraria.Entity.whoAmI, Terraria.Entity.width, Terraria.Utils.WrappedLerp(), Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Terraria.Main.xMas, Microsoft.Xna.Framework.Point.Y, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().