56256 {
56257
56258
56259
56260
56261
56262
56263
56264
56265
56266
56267
56268
56269
56270
56271
56272
56273
56274
56275
56276
56277
56278
56279
56280
56281
56282
56283
56284
56285
56286
56287
56288
56289
56290
56291
56292
56293
56294
56295
56296
56297
56298
56299
56300
56301
56302
56303
56304
56305
56306
56307
56308
56309
56310
56311
56312
56313
56314
56315
56316
56317
56318
56319
56320
56321
56322
56323
56324
56325
56326
56327
56328
56329
56330
56331
56332
56333
56334
56335
56336
56337
56338
56339
56340
56341
56342
56343
56344
56345
56346
56347
56348
56349
56350
56351
56352
56353
56354
56355
56356
56357
56358
56359
56360
56361
56362
56363
56364
56365
56366
56367
56368
56369
56370
56371
56372
56373
56374
56375
56376
56377
56378
56379
56380
56381
56382
56383
56384
56385
56386
56387
56388
56389
56390
56391
56392
56393
56394
56395
56396
56397
56398
56399
56400
56401
56402
56403
56404
56405
56406
56407
56408
56409
56410
56411
56412
56413
56414
56415
56416
56417
56418
56419
56420
56421
56422
56423
56424
56425
56426
56427
56428
56429
56430
56431
56432
56433
56434
56435
56436
56437
56438
56439
56440
56441
56442
56443
56444
56445
56446
56447
56448
56449
56450
56451
56452
56453
56454
56455
56456
56457
56458
56459
56460
56461
56462
56463
56464
56465
56466
56467
56468
56469
56470
56471
56472
56473
56474
56475
56476
56477
56478
56479
56480
56481
56482
56483
56484
56485
56486
56487
56488
56489
56490
56491
56492
56493
56494
56495
56496
56497
56498
56499
56500
56501
56502
56503
56504
56505
56506
56507
56508
56509
56510
56511
56512
56513
56514
56515
56516
56517
56518
56519
56520
56521
56522
56523
56524
56525
56526
56527
56528
56529
56530
56531
56532
56533
56534
56535
56536
56537
56538
56539
56540
56541
56542
56543
56544
56545
56546
56547
56548
56549
56550
56551
56552
56553
56554
56555
56556
56557
56558
56559
56560
56561
56562
56563
56564
56565
56566
56567
56568
56569
56570
56571
56572
56573
56574
56575
56576
56577
56578
56579
56580
56581
56582
56583
56584
56585
56586
56587
56588
56589
56590
56591
56592
56593
56594
56595
56596
56597
56598
56599
56600
56601
56602
56603
56604
56605
56606
56607
56608
56611 {
56613 }
56616 {
56618 }
56619 bool flag = Main.raining;
56620 if (!Main.dayTime)
56621 {
56623 }
56624 if (Main.eclipse)
56625 {
56627 }
56628 if (Main.slimeRain)
56629 {
56631 }
56633 if (Main.masterMode)
56634 {
56636 }
56637 else if (Main.expertMode)
56638 {
56640 }
56641 else
56642 {
56644 }
56646 {
56648 {
56651 }
56653 {
56656 }
56658 {
56661 }
56663 {
56666 }
56668 {
56671 }
56673 {
56676 }
56677 if (Main.hardMode)
56678 {
56681 }
56683 {
56686 }
56688 {
56691 }
56693 {
56696 }
56698 {
56701 }
56703 {
56706 }
56708 {
56711 }
56713 {
56716 }
56718 {
56721 }
56723 }
56724 if (
type == 142 && Main.netMode != 1 && !Main.xMas)
56725 {
56727 if (Main.netMode == 2)
56728 {
56729 NetMessage.SendData(28, -1, -1,
null,
whoAmI, 9999
f);
56730 }
56731 }
56733 {
56734 localAI[0] = Main.rand.Next(1, 5);
56735 }
56737 {
56740 if (Main.projectile.IndexInRange(
num53))
56741 {
56742 Projectile projectile = Main.projectile[
num53];
56743 if (projectile.active && projectile.type == 582 && projectile.ai[1] == (
float)
whoAmI)
56744 {
56746 }
56747 }
56749 }
56751 {
56757 return;
56758 }
56760 {
56761 case 588:
56763 break;
56764 case 441:
56766 break;
56767 case 107:
56769 break;
56770 case 108:
56772 break;
56773 case 124:
56775 break;
56776 case 353:
56778 break;
56779 case 369:
56781 break;
56782 case 550:
56784 break;
56785 }
56789 {
56792 {
56794 }
56799 if (
ai[1] == 0
f && Main.netMode == 1)
56800 {
56801 return;
56802 }
56803 if (
ai[1] == 0
f &&
ai[2] < 1
f)
56804 {
56806 }
56808 {
56811 {
56813 }
56814 return;
56815 }
56818 {
56820 {
56822 }
56823 else
56824 {
56826 }
56828 }
56830 hitbox.Y += 20;
56831 hitbox.Height -= 20;
56832 float num75 = Main.rand.NextFloatDirection();
56834 newColor = Main.hslToRgb((
float)Main.timeForVisualEffects / 360
f % 1
f, 0.6f, 0.65f);
56835 Lighting.AddLight(
center, ((Color)(
ref newColor)).ToVector3() * Utils.Remap(
ai[1], 30
f, 90
f, 0
f, 0.7f));
56836 if (Main.rand.NextFloat() > Utils.Remap(
ai[1], 30
f, 60
f, 1
f, 0.5f))
56837 {
56838 Vector2
val = Main.rand.NextVector2FromRectangle(
hitbox) + Main.rand.NextVector2Circular(8
f, 0
f) +
new Vector2(0
f, 4
f);
56839 Vector2?
val2 = Utils.RotatedBy(
new Vector2(0
f, -2
f),
num75 * ((
float)
Math.PI * 2
f) * 0.11f);
56842 }
56843 if (
ai[1] > 60
f && Main.rand.Next(15) == 0)
56844 {
56845 for (int i = 0; i < 3; i++)
56846 {
56847 Vector2
vector = Main.rand.NextVector2FromRectangle(
base.Hitbox);
56849 {
56850 PositionInWorld =
vector,
56851 MovementVector =
DirectionTo(
vector).RotatedBy((
float)
Math.PI * 9
f / 20
f * (
float)(Main.rand.Next(2) * 2 - 1)) * Main.rand.NextFloat()
56852 });
56853 }
56854 }
56858 {
56871 NetMessage.SendData(56, -1, -1,
null,
whoAmI);
56874 {
56875 PositionInWorld = base.Center
56876 });
56877 }
56878 return;
56879 }
56881 {
56884 {
56887 }
56889 {
56892 }
56894 {
56896 }
56897 }
56899 {
56901 }
56907 {
56909 }
56912 {
56914 }
56916 {
56917 for (
int j = 0;
j < 255;
j++)
56918 {
56919 if (Main.player[
j].active && Main.player[
j].talkNPC ==
whoAmI)
56920 {
56923 {
56925 }
56929 if (Main.player[
j].position.X + (
float)(Main.player[
j].width / 2) <
position.X + (
float)(
width / 2))
56930 {
56932 }
56933 else
56934 {
56936 }
56937 }
56938 }
56939 }
56941 {
56947 {
56949 }
56950 return;
56951 }
56952 if (
type == 37 && Main.netMode != 1)
56953 {
56956 {
56959 }
56960 }
56962 {
56964 if (!Main.dayTime)
56965 {
56967 {
56969 }
56971 {
56974 }
56976 }
56977 }
56979 {
56981 {
56985 }
56987 {
56989 }
56990 else if (
position.X / 16
f > (
float)(Main.maxTilesX - 300))
56991 {
56993 }
56994 }
56996 {
56997 return;
56998 }
57000 {
57002 Rectangle
rectangle =
default(Rectangle);
57003 for (
int k = 0;
k < 2;
k++)
57004 {
57006 {
57007 break;
57008 }
57011 {
57013 }
57014 for (
int l = 0;
l < 255;
l++)
57015 {
57016 if (Main.player[
l].active)
57017 {
57018 Rectangle
val3 =
new Rectangle((
int)Main.player[
l].position.X, (
int)Main.player[
l].position.Y, Main.player[
l].width, Main.player[
l].height);
57020 {
57022 break;
57023 }
57024 }
57025 }
57026 }
57028 {
57030 }
57031 }
57043 {
57045 }
57046 bool flag5 =
false;
57047 bool flag6 =
false;
57055 {
57056 for (
int m = 0;
m < 200;
m++)
57057 {
57058 if (!Main.npc[
m].active || Main.npc[
m].friendly || Main.npc[
m].damage <= 0 || !(Main.npc[
m].Distance(
base.Center) <
num108) || (
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)) || !
NPCLoader.
CanHitNPC(Main.npc[
m],
this))
57059 {
57060 continue;
57061 }
57062 bool flag7 = Main.npc[
m].CanBeChasedBy(
this);
57064 float num36 = Main.npc[
m].Center.X -
base.Center.X;
57066 {
57068 {
57071 }
57073 {
57076 }
57077 continue;
57078 }
57080 {
57083 {
57085 }
57086 }
57088 {
57091 {
57093 }
57094 }
57095 }
57097 {
57101 {
57103 }
57105 {
57107 }
57109 {
57111 {
57113 ai[1] = 300 + Main.rand.Next(300);
57117 }
57118 }
57119 else if (
ai[0] != 10
f &&
ai[0] != 12
f &&
ai[0] != 13
f &&
ai[0] != 14
f &&
ai[0] != 15
f)
57120 {
57122 {
57125 }
57126 else if (
ai[0] != 1
f)
57127 {
57133 {
57134 if (
ai[0] == 3
f ||
ai[0] == 4
f ||
ai[0] == 16
f ||
ai[0] == 17
f)
57135 {
57138 {
57140 nPC.ai[1] = 120 + Main.rand.Next(120);
57142 nPC.localAI[3] = 0
f;
57143 nPC.direction = -
num13;
57144 nPC.netUpdate = true;
57145 }
57146 }
57148 ai[1] = 120 + Main.rand.Next(120);
57153 }
57154 }
57156 {
57159 }
57160 }
57161 }
57162 }
57164 {
57166 {
57168 }
57171 {
57173 }
57175 {
57177 ai[1] = 200 + Main.rand.Next(500, 700);
57181 }
57183 {
57184 if (Main.netMode != 1)
57185 {
57187 {
57189 {
57191 }
57193 {
57194 velocity.X -= 0.1f;
57195 }
57197 {
57198 velocity.X += 0.1f;
57199 }
57200 else
57201 {
57204 }
57206 {
57208 }
57209 }
57210 else
57211 {
57213 {
57215 }
57216 else
57217 {
57219 }
57221 ai[1] = 200 + Main.rand.Next(200);
57225 }
57226 }
57227 }
57228 else
57229 {
57231 {
57232 velocity.X *= 0.5f;
57233 }
57235 {
57236 velocity.X -= 0.1f;
57237 }
57239 {
57240 velocity.X += 0.1f;
57241 }
57242 else
57243 {
57245 }
57246 if (Main.netMode != 1)
57247 {
57249 {
57251 }
57253 {
57255 }
57262 {
57265 {
57267 ai[1] = 200 + Main.rand.Next(300);
57270 {
57271 ai[1] += Main.rand.Next(200, 400);
57272 }
57275 }
57276 }
57278 {
57280 }
57282 {
57284 {
57286 ai[1] = 200 + Main.rand.Next(300);
57289 {
57290 ai[1] += Main.rand.Next(200, 400);
57291 }
57294 }
57295 else
57296 {
57298 ai[1] = 60 + Main.rand.Next(120);
57300 }
57301 }
57302 }
57303 }
57305 {
57307 {
57309 {
57311 {
57314 }
57316 {
57319 }
57320 }
57321 }
57322 else if (Main.rand.Next(80) == 0 &&
localAI[3] == 0
f)
57323 {
57327 }
57328 }
57329 }
57330 else if (
ai[0] == 1
f)
57331 {
57333 {
57335 ai[1] = 200 + Main.rand.Next(200);
57338 }
57339 else
57340 {
57343 {
57345 {
57347 {
57349 }
57351 {
57353 }
57354 }
57356 }
57358 {
57360 ai[1] = 300 + Main.rand.Next(300);
57363 {
57364 ai[1] -= Main.rand.Next(100);
57365 }
57366 else
57367 {
57368 ai[1] += Main.rand.Next(900);
57369 }
57372 }
57374 {
57377 {
57379 {
57382 }
57384 {
57386 }
57387 }
57389 {
57391 {
57393 NetMessage.SendData(19, -1, -1,
null, 5,
doorX,
doorY);
57394 }
57396 {
57398 }
57399 }
57400 else
57401 {
57403 }
57404 }
57406 float num40 = 0.07f;
57408 {
57411 }
57413 {
57415 }
57417 {
57419 {
57422 }
57423 else
57424 {
57427 }
57428 }
57430 {
57432 {
57435 }
57436 else
57437 {
57440 }
57441 }
57443 {
57446 }
57448 {
57453 }
57455 {
57458 }
57460 {
57462 {
57464 }
57465 else
57466 {
57467 velocity.X *= 0.9f;
57468 }
57469 }
57471 {
57473 {
57475 }
57476 }
57478 {
57479 velocity.X +=
num40;
57481 {
57482 velocity.X =
num39;
57483 }
57484 }
57486 {
57487 velocity.X -=
num40;
57489 {
57490 velocity.X =
num39;
57491 }
57492 }
57495 {
57497 }
57499 {
57501 }
57503 {
57505 }
57507 {
57515 {
57520 {
57522 }
57523 float num47 = 0.3f;
57526 {
57528 }
57529 velocity.Y = 0
f -
num48;
57532 }
57534 {
57538 {
57541 {
57543 }
57544 }
57546 {
57548 {
57550 }
57553 ai[1] = 50 + Main.rand.Next(50);
57556 }
57557 }
57559 {
57563 }
57565 {
57567 {
57569 }
57571 {
57573 }
57574 }
57575 else
57576 {
57578 }
57584 {
57585 if (Main.netMode != 1)
57586 {
57588 {
57595 }
57597 {
57604 }
57606 {
57610 NetMessage.SendData(19, -1, -1,
null, 4,
num43,
num44 - 2);
57613 }
57614 else
57615 {
57618 }
57619 }
57620 }
57621 else
57622 {
57624 {
57628 {
57630 {
57633 }
57635 {
57637 {
57641 }
57642 }
57644 {
57647 }
57649 {
57651 }
57652 }
57654 {
57656 {
57659 }
57661 {
57664 }
57665 else
57666 {
57668 }
57669 }
57671 {
57673 {
57674 velocity.Y = -4.4f;
57676 }
57678 {
57681 }
57682 else
57683 {
57685 }
57686 }
57688 {
57690 {
57692 }
57694 {
57696 }
57697 }
57699 {
57702 }
57704 {
57710 }
57712 {
57716 }
57718 {
57721 }
57723 {
57725 }
57726 }
57728 {
57729 velocity.Y *= 1.2f;
57730 }
57732 {
57733 velocity.Y *= 1.2f;
57734 }
57735 }
57736 }
57738 {
57743 {
57745 {
57748 {
57750 }
57751 }
57752 }
57754 {
57756 {
57758 }
57759 velocity.X *= 0.2f;
57761 ai[1] = 50 + Main.rand.Next(50);
57764 }
57765 }
57766 }
57767 }
57768 else if (
ai[0] == 2
f ||
ai[0] == 11
f)
57769 {
57770 if (Main.netMode != 1)
57771 {
57773 if (Main.rand.Next(60) == 0 &&
localAI[3] == 0
f)
57774 {
57778 }
57779 }
57781 velocity.X *= 0.8f;
57783 {
57786 ai[1] = 60 + Main.rand.Next(60);
57788 }
57789 }
57790 else if (
ai[0] == 3
f ||
ai[0] == 4
f ||
ai[0] == 5
f ||
ai[0] == 8
f ||
ai[0] == 9
f ||
ai[0] == 16
f ||
ai[0] == 17
f ||
ai[0] == 20
f ||
ai[0] == 21
f ||
ai[0] == 22
f ||
ai[0] == 23
f)
57791 {
57792 velocity.X *= 0.8f;
57795 {
57798 }
57800 {
57801 Point coords = (base.Bottom + Vector2.UnitY * -2
f).ToTileCoordinates();
57802 Tile tile = Main.tile[coords.X, coords.Y];
57804 {
57806 }
57807 else
57808 {
57809 Main.sittingManager.AddNPC(
whoAmI, coords);
57810 }
57811 }
57813 {
57815 ai[1] = 60 + Main.rand.Next(60);
57817 localAI[3] = 30 + Main.rand.Next(60);
57819 }
57820 }
57821 else if (
ai[0] == 6
f ||
ai[0] == 7
f ||
ai[0] == 18
f ||
ai[0] == 19
f)
57822 {
57824 {
57826 }
57827 velocity.X *= 0.8f;
57831 {
57833 }
57835 {
57836 int num59 = ((base.Center.X < Main.player[
num58].Center.X) ? 1 : (-1));
57838 {
57840 }
57842 }
57843 else
57844 {
57846 ai[1] = 60 + Main.rand.Next(60);
57848 localAI[3] = 30 + Main.rand.Next(60);
57850 }
57851 }
57852 else if (
ai[0] == 10
f)
57853 {
57856 float knockBack = 0
f;
57865 {
57868 }
57870 {
57879 }
57880 else if (
type == 633)
57881 {
57891 {
57894 }
57895 }
57896 else if (
type == 550)
57897 {
57906 }
57907 else if (
type == 588)
57908 {
57917 }
57918 else if (
type == 208)
57919 {
57928 }
57929 else if (
type == 17)
57930 {
57938 knockBack = 1.5f;
57939 }
57940 else if (
type == 369)
57941 {
57950 }
57951 else if (
type == 453)
57952 {
57961 }
57962 else if (
type == 107)
57963 {
57972 }
57973 else if (
type == 124)
57974 {
57981 knockBack = 3.5f;
57982 }
57983 else if (
type == 18)
57984 {
57993 }
57994 else if (
type == 142)
57995 {
58004 }
58009 if (Main.expertMode)
58010 {
58011 num61 = (int)((
float)
num61 * Main.GameModeInfo.TownNPCDamageMultiplier);
58012 }
58014 velocity.X *= 0.8f;
58018 {
58019 Vector2
vec = -Vector2.UnitY;
58021 {
58023 }
58025 {
58027 }
58029 {
58031 }
58035 num69 = ((
type == 124) ? Projectile.NewProjectile(
GetSpawnSource_ForProjectile(), base.Center.X + (float)(
spriteDirection * 16), base.Center.Y - 2
f,
vec.X,
vec.Y,
num60,
num61, knockBack, Main.myPlayer, 0
f,
whoAmI,
townNpcVariationIndex) : ((
type != 142) ? Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
base.
Center.X + (float)(
spriteDirection * 16),
base.
Center.Y - 2
f,
vec.X,
vec.Y,
num60,
num61, knockBack, Main.myPlayer) : Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
base.
Center.X + (float)(
spriteDirection * 16),
base.
Center.Y - 2
f,
vec.X,
vec.Y,
num60,
num61, knockBack, Main.myPlayer, 0
f, Main.rand.Next(5))));
58036 Main.projectile[
num69].npcProj =
true;
58037 Main.projectile[
num69].noDropItem =
true;
58039 {
58040 Main.projectile[
num69].timeLeft = 480;
58041 }
58042 }
58044 {
58050 }
58051 }
58052 else if (
ai[0] == 12
f)
58053 {
58065 {
58068 }
58071 {
58073 }
58075 {
58077 }
58079 {
58089 {
58092 }
58093 if (Main.hardMode)
58094 {
58097 {
58100 }
58102 {
58105 }
58107 {
58110 }
58111 }
58112 }
58113 else if (
type == 227)
58114 {
58124 {
58127 }
58129 {
58132 }
58133 if (Main.hardMode)
58134 {
58136 }
58137 }
58138 else if (
type == 368)
58139 {
58148 if (Main.hardMode)
58149 {
58152 }
58153 }
58154 else if (
type == 22)
58155 {
58159 if (Main.hardMode)
58160 {
58165 }
58166 else
58167 {
58171 }
58175 }
58176 else if (
type == 228)
58177 {
58187 }
58188 else if (
type == 178)
58189 {
58192 num71 = ((!Main.hardMode) ? 11 : 15);
58198 {
58201 }
58203 {
58206 }
58208 }
58209 else if (
type == 229)
58210 {
58220 {
58223 }
58225 {
58228 }
58230 {
58233 }
58235 {
58238 }
58240 {
58243 }
58245 {
58251 }
58252 }
58253 else if (
type == 209)
58254 {
58255 num70 = Utils.SelectRandom<
int>(Main.rand, 134, 133, 135);
58258 {
58259 case 135:
58266 break;
58267 case 133:
58274 break;
58275 case 134:
58282 break;
58283 }
58284 }
58290 if (Main.expertMode)
58291 {
58292 num71 = (int)((
float)
num71 * Main.GameModeInfo.TownNPCDamageMultiplier);
58293 }
58295 velocity.X *= 0.8f;
58299 {
58300 Vector2
vec2 = Vector2.Zero;
58302 {
58304 }
58306 {
58308 }
58312 num79 = ((
type != 227) ? Projectile.NewProjectile(
GetSpawnSource_ForProjectile(), base.Center.X + (float)(
spriteDirection * 16), base.Center.Y - 2
f,
vec2.X,
vec2.Y,
num70,
num71,
knockBack2, Main.myPlayer) : Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
base.
Center.X + (float)(
spriteDirection * 16),
base.
Center.Y - 2
f,
vec2.X,
vec2.Y,
num70,
num71,
knockBack2, Main.myPlayer, 0
f, (float)Main.rand.Next(12) / 6
f));
58313 Main.projectile[
num79].npcProj =
true;
58314 Main.projectile[
num79].noDropItem =
true;
58315 }
58317 {
58320 {
58322 }
58323 }
58325 {
58331 }
58332 }
58333 else if (
ai[0] == 13
f)
58334 {
58335 velocity.X *= 0.8f;
58337 {
58339 }
58342 if (
localAI[3] == 1
f && Main.netMode != 1)
58343 {
58346 {
58348 }
58351 Main.projectile[
num80].npcProj =
true;
58352 Main.projectile[
num80].noDropItem =
true;
58353 }
58355 {
58357 ai[1] = 10 + Main.rand.Next(10);
58359 localAI[3] = 5 + Main.rand.Next(10);
58361 }
58362 }
58363 else if (
ai[0] == 14
f)
58364 {
58377 {
58380 }
58383 {
58385 }
58387 {
58389 }
58391 {
58400 }
58401 else if (
type == 108)
58402 {
58411 }
58412 else if (
type == 160)
58413 {
58421 {
58422 }
58423 }
58424 else if (
type == 663)
58425 {
58427 num82 = ((!Main.hardMode) ? 15 : 20);
58433 {
58434 }
58435 }
58436 else if (
type == 20)
58437 {
58443 }
58449 if (Main.expertMode)
58450 {
58451 num82 = (int)((
float)
num82 * Main.GameModeInfo.TownNPCDamageMultiplier);
58452 }
58454 velocity.X *= 0.8f;
58458 {
58459 Vector2
vec4 = Vector2.Zero;
58461 {
58463 }
58465 {
58467 }
58471 {
58472 int num92 = Utils.SelectRandom<
int>(Main.rand, 1, 1, 1, 1, 2, 2, 3);
58474 {
58475 Vector2
vector3 = Utils.RandomVector2(Main.rand, -3.4f, 3.4f);
58476 int num94 = Projectile.NewProjectile(
GetSpawnSource_ForProjectile(), base.Center.X + (float)(
spriteDirection * 16), base.Center.Y - 2
f, vec4.X +
vector3.X, vec4.Y +
vector3.Y,
num81,
num82,
knockBack3, Main.myPlayer, 0
f, 0
f,
townNpcVariationIndex);
58477 Main.projectile[
num94].npcProj =
true;
58478 Main.projectile[
num94].noDropItem =
true;
58479 }
58480 }
58481 else if (
type == 160)
58482 {
58484 {
58485 Vector2
vector4 = Main.npc[
num91].position - Main.npc[
num91].Size * 2
f + Main.npc[
num91].Size * Utils.RandomVector2(Main.rand, 0
f, 1
f) * 5
f;
58487 while (
num95 > 0 &&
WorldGen.SolidTile(Framing.GetTileSafely((
int)vector4.X / 16, (int)
vector4.Y / 16)))
58488 {
58490 vector4 = Main.npc[
num91].position - Main.npc[
num91].Size * 2
f + Main.npc[
num91].Size * Utils.RandomVector2(Main.rand, 0
f, 1
f) * 5
f;
58491 }
58492 int num96 = Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
vector4.X,
vector4.Y, 0
f, 0
f,
num81,
num82,
knockBack3, Main.myPlayer, 0
f, 0
f,
townNpcVariationIndex);
58493 Main.projectile[
num96].npcProj =
true;
58494 Main.projectile[
num96].noDropItem =
true;
58495 }
58496 }
58497 else if (
type == 663)
58498 {
58500 {
58501 Vector2
vector5 = Main.npc[
num91].position + Main.npc[
num91].Size * Utils.RandomVector2(Main.rand, 0
f, 1
f) * 1
f;
58503 while (
num98 > 0 &&
WorldGen.SolidTile(Framing.GetTileSafely((
int)vector5.X / 16, (int)
vector5.Y / 16)))
58504 {
58506 vector5 = Main.npc[
num91].position + Main.npc[
num91].Size * Utils.RandomVector2(Main.rand, 0
f, 1
f) * 1
f;
58507 }
58508 int num99 = Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
vector5.X,
vector5.Y, 0
f, 0
f,
num81,
num82,
knockBack3, Main.myPlayer, 0
f, 0
f,
townNpcVariationIndex);
58509 Main.projectile[
num99].npcProj =
true;
58510 Main.projectile[
num99].noDropItem =
true;
58511 }
58512 }
58513 else if (
type == 20)
58514 {
58515 int num100 = Projectile.NewProjectile(
GetSpawnSource_ForProjectile(), base.Center.X + (float)(
spriteDirection * 16), base.Center.Y - 2
f,
vec4.X,
vec4.Y,
num81,
num82,
knockBack3, Main.myPlayer, 0
f,
whoAmI,
townNpcVariationIndex);
58516 Main.projectile[
num100].npcProj =
true;
58517 Main.projectile[
num100].noDropItem =
true;
58518 }
58519 else
58520 {
58522 Main.projectile[
num101].npcProj =
true;
58523 Main.projectile[
num101].noDropItem =
true;
58524 }
58525 }
58527 {
58531 }
58533 {
58539 }
58540 }
58541 else if (
ai[0] == 15
f)
58542 {
58546 {
58549 }
58555 {
58557 }
58559 {
58561 }
58563 {
58569 }
58570 else if (
type == 441)
58571 {
58578 {
58581 }
58582 }
58583 else if (
type == 353)
58584 {
58590 }
58592 {
58598 }
58602 if (Main.expertMode)
58603 {
58604 num103 = (int)((
float)
num103 * Main.GameModeInfo.TownNPCDamageMultiplier);
58605 }
58607 velocity.X *= 0.8f;
58609 if (Main.netMode != 1)
58610 {
58615 {
58616 itemRectangle.X -=
num105;
58617 }
58618 itemRectangle.Y -=
num106;
58620 int myPlayer = Main.myPlayer;
58622 {
58625 {
58627 if (Main.netMode != 0)
58628 {
58630 }
58631 nPC2.netUpdate = true;
58632 nPC2.immune[myPlayer] = (int)
ai[1] + 2;
58633 }
58634 }
58635 }
58637 {
58640 {
58642 if (!Collision.CanHit(
base.Center, 0, 0,
base.Center + Vector2.UnitX * (
float)
num109 * 32
f, 0, 0) ||
localAI[2] == 8
f)
58643 {
58645 }
58647 {
58651 if (
num111 != -1 && !Collision.CanHit(
base.Center, 0, 0, Main.npc[
num111].Center, 0, 0))
58652 {
58654 }
58656 {
58663 }
58664 else
58665 {
58667 }
58668 }
58669 }
58671 {
58677 }
58678 }
58679 }
58680 else if (
ai[0] == 24
f)
58681 {
58682 velocity.X *= 0.8f;
58691 {
58697 }
58698 }
58700 {
58704 {
58706 velocity.X *= -0.25f;
58708 }
58709 velocity.Y *= 0.9f;
58710 velocity.Y -= 0.5f;
58712 {
58714 }
58715 }
58717 {
58719 {
58721 }
58725 {
58727 velocity.X *= -0.25f;
58729 }
58731 {
58732 float num117 = base.Center.Y + 1
f;
58734 {
58735 velocity.Y -= 0.8f;
58737 {
58739 }
58741 {
58743 }
58744 }
58745 else
58746 {
58748 }
58749 }
58750 else
58751 {
58752 velocity.Y -= 0.2f;
58753 }
58754 }
58756 {
58760 {
58762 }
58764 {
58766 }
58768 {
58770 }
58772 {
58775 {
58778 {
58780 break;
58781 }
58782 }
58783 }
58785 {
58787 num120 = ((Main.rand.Next(2) != 0) ? (
num120 * Main.rand.Next(1, 3)) : (
num120 * Main.rand.Next(1, 4)));
58791 {
58795 {
58796 int num124 = (position.X <
nPC4.position.X).ToDirectionInt();
58805 nPC4.direction = -
num124;
58806 nPC4.netUpdate = true;
58807 break;
58808 }
58809 }
58810 }
58812 {
58814 num125 = ((Main.rand.Next(2) != 0) ? (
num125 * Main.rand.Next(1, 3)) : (
num125 * Main.rand.Next(1, 4)));
58818 {
58822 {
58823 int num129 = (position.X <
nPC5.position.X).ToDirectionInt();
58827 localAI[2] = Main.rand.Next(4);
58834 nPC5.localAI[2] = 0
f;
58835 nPC5.localAI[3] = 0
f;
58836 nPC5.direction = -
num129;
58837 nPC5.netUpdate = true;
58838 break;
58839 }
58840 }
58841 }
58843 {
58847 {
58849 if (player.active && !player.dead && player.Distance(
base.Center) < (float)
num4 && Collision.CanHitLine(
base.Top, 0, 0, player.Top, 0, 0))
58850 {
58851 int num6 = (position.X < player.position.X).ToDirectionInt();
58857 break;
58858 }
58859 }
58860 }
58862 {
58866 {
58869 {
58870 int num10 = (position.X <
player2.position.X).ToDirectionInt();
58876 break;
58877 }
58878 }
58879 }
58881 {
58883 ai[1] = 45 * Main.rand.Next(1, 2);
58885 }
58887 {
58889 ai[1] = 30 * Main.rand.Next(1, 4);
58891 }
58893 {
58897 {
58900 {
58901 int num15 = (position.X <
player3.position.X).ToDirectionInt();
58907 break;
58908 }
58909 }
58910 }
58912 {
58913 Point point = (base.Bottom + Vector2.UnitY * -2
f).ToTileCoordinates();
58916 {
58918 {
58919 if (Main.npc[
num16].active && Main.npc[
num16].aiStyle == 7 && Main.npc[
num16].townNPC && Main.npc[
num16].ai[0] == 5
f && (Main.npc[
num16].Bottom + Vector2.UnitY * -2
f).ToTileCoordinates() == point)
58920 {
58922 break;
58923 }
58924 }
58926 {
58927 if (Main.player[
num17].active && Main.player[
num17].sitting.isSitting && Main.player[
num17].Center.ToTileCoordinates() == point)
58928 {
58930 break;
58931 }
58932 }
58933 }
58935 {
58936 Tile tile2 = Main.tile[point.X, point.Y];
58939 {
58941 }
58943 {
58945 ai[1] = 900 + Main.rand.Next(10800);
58948 base.Bottom = bottom;
58952 }
58953 }
58954 }
58955 else if (
flag19 &&
ai[0] == 1
f &&
velocity.Y == 0
f && Main.rand.Next(600) == 0 && Utils.PlotTileLine(
base.Top,
base.Bottom,
width, DelegateMethods.SearchAvoidedByNPCs))
58956 {
58957 Point
point2 = (base.Center +
new Vector2((
float)(
direction * 10), 0
f)).ToTileCoordinates();
58960 {
58963 {
58965 }
58966 }
58968 {
58970 ai[1] = 40 + Main.rand.Next(90);
58974 }
58975 }
58977 {
58980 {
58983 {
58985 }
58986 }
58988 {
58993 direction = ((position.X < Main.npc[
num18].position.X) ? 1 : (-1));
58995 }
58996 }
58998 {
59002 if (
num21 != -1 && !Collision.CanHit(
base.Center, 0, 0, Main.npc[
num21].Center, 0, 0))
59003 {
59005 }
59008 {
59010 }
59012 {
59018 direction = ((position.X < Main.npc[
num21].position.X) ? 1 : (-1));
59020 }
59021 }
59023 {
59027 if (
num25 != -1 && !Collision.CanHitLine(
base.Center, 0, 0, Main.npc[
num25].Center, 0, 0))
59028 {
59030 }
59032 {
59035 {
59041 direction = ((position.X < Main.npc[
num25].position.X) ? 1 : (-1));
59043 }
59044 }
59045 }
59047 {
59051 if (
num28 != -1 && !Collision.CanHitLine(
base.Center, 0, 0, Main.npc[
num28].Center, 0, 0))
59052 {
59054 }
59056 {
59062 direction = ((position.X < Main.npc[
num28].position.X) ? 1 : (-1));
59064 }
59065 else if (
type == 20)
59066 {
59073 }
59074 }
59076 {
59080 if (
num31 != -1 && !Collision.CanHit(
base.Center, 0, 0, Main.npc[
num31].Center, 0, 0))
59081 {
59083 }
59085 {
59091 direction = ((position.X < Main.npc[
num31].position.X) ? 1 : (-1));
59093 }
59094 }
59095 }
59097 {
59102 float num33 = 0.35f;
59106 Lighting.AddLight(
base.Center, R, G, B);
59107 }
59109 {
59110 float num34 = Utils.WrappedLerp(0.75
f, 1
f, (
float)Main.timeForVisualEffects % 120
f / 120
f);
59112 }
59113 }
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 ...
bool wet
The Entity is currently in water. Projectile: Affects movement speed and some projectiles die when ...
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
float Distance(Vector2 Other)
Vector2 position
The position of this Entity in world coordinates.
int width
The width of this Entity's hitbox, in pixels.
Vector2 DirectionTo(Vector2 Destination)
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
int height
The height of this Entity's hitbox, in pixels.
static void BroadcastParticleSpawn(ParticleOrchestraType type, ParticleOrchestraSettings settings)
static void RequestParticleSpawn(bool clientOnly, ParticleOrchestraType type, ParticleOrchestraSettings settings, int? overrideInvokingPlayerIndex=null)
static int[] PrettySafe
The maximum distance in pixels that an enemy can be from this town NPC before they try to attack....
static bool[] Skeletons
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is a type of skeleton....
static bool[] TownCritter
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is a critter that can spawn in town...
static bool[] IsTownPet
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is categorized as a town pet....
static int[] AttackTime
The duration of this town NPC's attack animation in ticks. Defaults to -1.
static bool[] IsTownSlime
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is categorized as a town slime....
static int[] AttackType
Determines how a town NPC with the given NPC type (F:Terraria.NPC.type) attacks. For -1,...
static int[] AttackAverageChance
The chance that this town NPC attacks if it detects danger. The actual chance is 1 / (retrieved val...
static bool[] AllowDoorInteraction
Whether or not this NPC can still interact with doors if they use the Vanilla TownNPC aiStyle (AKA ai...
static int[] DangerDetectRange
The distance, in pixels, that this town NPC will check for enemies to attack. Any enemies beyond this...
static bool[] CanBeSatOnForNPCs
static bool[] InteractibleByNPCs
static void TorchColor(int torchID, out float R, out float G, out float B)
static void TownNPCAttackStrength(NPC npc, ref int damage, ref float knockback)
static void TownNPCAttackMagic(NPC npc, ref float auraLightMultiplier)
static void TownNPCAttackProj(NPC npc, ref int projType, ref int attackDelay)
static void TownNPCAttackShoot(NPC npc, ref bool inBetweenShots)
static void TownNPCAttackSwing(NPC npc, ref int itemWidth, ref int itemHeight)
static void TownNPCAttackProjSpeed(NPC npc, ref float multiplier, ref float gravityCorrection, ref float randomOffset)
static void TownNPCAttackCooldown(NPC npc, ref int cooldown, ref int randExtraCooldown)
static bool CanHitNPC(NPC npc, NPC target)
static void BuffTownNPC(ref float damageMult, ref int defense)
This serves as the central class from which NPC-related functions are carried out....
static int CloseDoorID(Tile tile)
static bool IsClosedDoor(Tile tile)
This serves as the central class from which tile-related functions are supported and carried out.
int defense
How resistant to damage this NPC is. The List of NPCs wiki pagecan be useful for finding appropriat...
Color GetMagicAuraColor()
bool ShouldBestiaryGirlBeLycantrope()
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
static bool downedMechBoss2
Denotes whether or not the Twins have been defeated at least once in the current world.
void Teleport(Vector2 newPos, int Style=0, int extraInfo=0)
bool AI_007_TownEntities_CheckIfWillDrown(bool currentlyDrowning)
static bool savedTaxCollector
static bool downedBoss2
Denotes whether or not the Eater of Worlds OR the Brain of Cthulhu have been defeated at least once i...
void TweakSwingStats(int swingMax, int swingCurrent, int aimDir, ref Rectangle itemRectangle)
int lifeMax
The maximum life of this NPC.
string GivenName
The GIVEN name of this NPC. Can be set directly. Given names are unique to each NPC,...
float gfxOffY
An offset from the actual position of the npc that will be added to the draw position....
void TargetClosest(bool faceTarget=true)
static bool downedEmpressOfLight
Denotes whether or not the Empress of Light has been defeated at least once in the current world.
int townNpcVariationIndex
void UpdateHomeTileState(bool homeless, int x, int y)
NPCAimedTarget GetTargetData(bool ignorePlayerTankPets=true)
static bool downedBoss1
Denotes whether or not the Eye of Cthulhu has been defeated at least once in the current world.
int defDefense
Stores the value of F:Terraria.NPC.defense at the end of SetDefaults. Useful for scaling defense in A...
float[] ai
An array with 4 slots used for any sort of data storage, which is occasionally synced from the server...
bool AI_007_TownEntities_IsInAGoodRestingSpot(int tileX, int tileY, int idealRestX, int idealRestY)
static bool combatBookWasUsed
Denotes whether or not Advanced Combat Techniques has been used in the current world.
static bool[] ShimmeredTownNPCs
void SitDown(Point anchorTilePosition, out int direction, out Vector2 bottom)
Helper method for getting the parameters for seating a town NPC. Assumes the tile at anchorTilePositi...
static bool downedMechBoss3
Denotes whether or not Skeletron Prime has been defeated at least once in the current world.
bool friendly
Indicates that an NPC is friendly to players. If true, a player won't damage the NPC and the NPC won'...
float stepSpeed
Has nothing to do with the speed that this NPC travels, that is dictated by AI code adjusting F:Terra...
void AI_007_TownEntities_Shimmer_TeleportToLandingSpot()
void AI_007_TownEntities_GetWalkPrediction(int myTileX, int homeFloorX, bool canBreathUnderWater, bool currentlyDrowning, int tileX, int tileY, out bool keepwalking, out bool avoidFalling)
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
static bool downedQueenBee
Denotes whether or not at least one Queen Bee has been defeated in the current world.
float shimmerTransparency
void AI_007_FindGoodRestingSpot(int myTileX, int myTileY, out int floorX, out int floorY)
void AI_007_AttemptToPlayIdleAnimationsForPets(int petIdleChance)
static int[] lazyNPCOwnedProjectileSearchArray
static bool combatBookVolumeTwoWasUsed
Tuple< Vector2, float > GetSwingStats(int swingMax, int swingCurrent, int aimDir, int itemWidth, int itemHeight)
static bool downedGolemBoss
Denotes whether or not Golem has been defeated at least once in the current world.
static bool downedAncientCultist
Denotes whether or not the Lunatic Cultist has been defeated at least once in the current world.
static bool downedBoss3
Denotes whether or not Skeletron has been defeated at least once in the current world.
void Transform(int newType)
int life
The current life of the NPC. Automatically set to the value of F:Terraria.NPC.lifeMax at the end of S...
IEntitySource GetSpawnSource_ForProjectile()
static bool downedPlantBoss
Denotes whether or not Plantera has been defeated at least once in the current world.
static bool savedBartender
void AI_007_TownEntities_TeleportToHome(int homeFloorX, int homeFloorY)
static bool downedMechBoss1
Denotes whether or not the Destroyer has been defeated at least once in the current world.
int StrikeNPCNoInteraction(int Damage, float knockBack, int hitDirection)
void AI_007_TryForcingSitting(int homeFloorX, int homeFloorY)
static bool downedQueenSlime
Denotes whether or not Queen Slime has been defeated at least once in the current world.
void HitEffect(int hitDirection=0, double dmg=10.0, bool? instantKill=null)