68991 {
68992
68993
68994
68995
68996
68997
68998
68999
69000
69001
69002
69003
69004
69005
69006
69007
69008
69009
69010
69011
69012
69013
69014
69015
69016
69017
69018
69019
69020
69021
69022
69023
69024
69025
69026
69027
69028
69029
69030
69031
69032
69033
69034
69035
69036
69037
69038
69039
69040
69041
69042
69043
69044
69045
69046
69047
69048
69049
69050
69051
69052
69053
69054
69055
69056
69057
69058
69059
69060
69061
69062
69063
69064
69065
69066
69067
69068
69069
69070
69071
69072
69073
69074
69075
69076
69077
69078
69079
69080
69081
69082
69083
69084
69085
69086
69087
69088
69089
69090
69091
69092
69093
69094
69095
69096
69097
69098
69099
69100
69101
69102
69103
69104
69105
69106
69107
69108
69109
69110
69111
69112
69113
69114
69115
69116
69117
69118
69119
69120
69121
69122
69123
69124
69125
69126
69127
69128
69129
69130
69131
69132
69133
69134
69135
69136
69137
69138
69139
69140
69141
69142
69143
69144
69145
69146
69147
69148
69149
69150
69151
69152
69153
69154
69155
69156
69157
69158
69159
69160
69161
69162
69163
69164
69165
69166
69167
69168
69169
69170
69171
69172
69173
69174
69175
69176
69177
69178
69179
69180
69181
69182
69183
69184
69185
69186
69187
69188
69189
69190
69191
69192
69193
69194
69195
69196
69197
69198
69199
69200
69201
69202
69203
69204
69205
69206
69207
69208
69209
69210
69211
69212
69213
69214
69215
69216
69217
69218
69219
69220
69221
69222
69223
69224
69225
69226
69227
69228
69229
69230
69231
69232
69233
69234
69235
69236
69237
69238
69239
69240
69241
69242
69243
69244
69245
69246
69247
69248
69249
69250
69251
69252
69253
69254
69255
69256
69257
69258
69259
69260
69261
69262
69263
69264
69265
69266
69267
69268
69269
69270
69271
69272
69273
69274
69275
69276
69277
69278
69279
69280
69281
69282
69283
69284
69285
69286
69287
69288
69289
69290
69291
69292
69293
69294
69295
69296
69297
69298
69299
69300
69301
69302
69303
69304
69305
69306
69307
69308
69309
69310
69311
69312
69313
69314
69315
69316
69317
69318
69319
69320
69321
69322
69323
69324
69325
69326
69327
69328
69329
69330
69331
69332
69333
69334
69335
69336
69337
69338
69339
69340
69341
69342
69343
69344
69345
69346
69347
69348
69349
69350
69351
69352
69353
69354
69355
69356
69357
69358
69359
69360
69361
69362
69363
69364
69365
69366
69367
69368
69369
69370
69371
69372
69373
69374 if (this.
ai[0] != -1
f && Main.rand.Next(1000) == 0)
69375 {
69377 }
69378 bool expertMode = Main.expertMode;
69382 if (expertMode)
69383 {
69385 }
69386 if (Main.getGoodWorld)
69387 {
69389 }
69393 if (expertMode)
69394 {
69397 }
69398 if (Main.getGoodWorld)
69399 {
69402 }
69405 if (expertMode)
69406 {
69408 }
69409 if (Main.getGoodWorld)
69410 {
69412 }
69415 if (expertMode)
69416 {
69419 }
69423 bool flag3 =
false;
69424 bool flag4 =
false;
69426 {
69428 }
69430 {
69431 if (this.
ai[3] < 0
f || !Main.npc[(
int)this.
ai[3]].active || Main.npc[(int)this.
ai[3]].
type != 439)
69432 {
69436 return;
69437 }
69438 this.
ai[0] = Main.npc[(int)this.
ai[3]].
ai[0];
69439 this.
ai[1] = Main.npc[(int)this.
ai[3]].
ai[1];
69440 if (this.
ai[0] == 5
f)
69441 {
69443 {
69447 if (Main.netMode != 1)
69448 {
69449 NetMessage.SendData(23, -1, -1,
null,
whoAmI);
69450 }
69451 NPC obj = Main.npc[(int)this.
ai[3]];
69454 obj.netUpdate = true;
69455 }
69456 }
69457 else
69458 {
69461 }
69462 }
69463 else if (this.
ai[0] == 5
f && this.
ai[1] >= 120
f && this.
ai[1] < 420
f &&
justHit)
69464 {
69471 for (int i = 0; i < 200; i++)
69472 {
69473 if (Main.npc[i].active && Main.npc[i].type == 440 && Main.npc[i].ai[3] == (
float)
whoAmI)
69474 {
69475 list.Add(i);
69476 }
69477 }
69479 if (Main.expertMode)
69480 {
69482 }
69483 foreach (int item in list)
69484 {
69485 NPC nPC = Main.npc[item];
69487 {
69489 nPC.life = 0;
69491 nPC.active = false;
69492 if (Main.netMode != 1)
69493 {
69494 NetMessage.SendData(23, -1, -1, null, item);
69495 }
69496 }
69497 else if (
num60 > 0)
69498 {
69500 nPC.life = 0;
69502 nPC.active = false;
69503 }
69504 }
69505 Main.projectile[(int)this.
ai[2]].
ai[1] = -1
f;
69506 Main.projectile[(int)this.
ai[2]].
netUpdate =
true;
69507 }
69510 float num2 = 5600
f;
69511 if (
target < 0 ||
target == 255 || player.dead || !player.active || Vector2.Distance(player.Center,
center) >
num2)
69512 {
69514 player = Main.player[
target];
69516 }
69517 if (player.dead || !player.active || Vector2.Distance(player.Center,
center) >
num2)
69518 {
69522 if (Main.netMode != 1)
69523 {
69524 NetMessage.SendData(28, -1, -1,
null,
whoAmI, -1
f);
69525 }
69527 for (
int j = 0;
j < 200;
j++)
69528 {
69529 if (Main.npc[
j].active && Main.npc[
j].type == 440 && Main.npc[
j].ai[3] == (
float)
whoAmI)
69530 {
69531 Main.npc[
j].life = 0;
69532 Main.npc[
j].HitEffect();
69533 Main.npc[
j].active =
false;
69534 if (Main.netMode != 1)
69535 {
69536 NetMessage.SendData(28, -1, -1,
null,
whoAmI, -1
f);
69537 }
69538 }
69539 }
69540 }
69541 float num3 = this.
ai[3];
69543 {
69548 if (Main.netMode != 1)
69549 {
69552 }
69553 }
69554 if (this.
ai[0] == -1
f)
69555 {
69558 {
69560 }
69562 if (this.
ai[1] >= 420
f)
69563 {
69567 }
69568 else if (this.
ai[1] > 360
f)
69569 {
69572 {
69574 }
69576 }
69577 else if (this.
ai[1] > 300
f)
69578 {
69581 }
69582 else if (this.
ai[1] > 120
f)
69583 {
69585 }
69586 else
69587 {
69589 }
69592 }
69594 if (this.
ai[0] == 0
f)
69595 {
69596 if (this.
ai[1] == 0
f)
69597 {
69599 }
69603 {
69605 }
69608 {
69611 {
69612 switch ((
int)this.
ai[3])
69613 {
69614 case 0:
69615 num5 = 0;
69616 break;
69617 case 1:
69619 break;
69620 case 2:
69622 break;
69623 case 3:
69625 break;
69626 case 4:
69628 break;
69629 case 5:
69631 break;
69632 case 6:
69634 break;
69635 case 7:
69637 break;
69638 case 8:
69640 break;
69641 case 9:
69643 break;
69644 case 10:
69646 break;
69647 case 11:
69649 break;
69650 case 12:
69652 break;
69653 case 13:
69656 break;
69657 default:
69659 break;
69660 }
69661 }
69662 else
69663 {
69664 switch ((
int)this.
ai[3])
69665 {
69666 case 0:
69667 num5 = 0;
69668 break;
69669 case 1:
69671 break;
69672 case 2:
69674 break;
69675 case 3:
69677 break;
69678 case 4:
69680 break;
69681 case 5:
69683 break;
69684 case 6:
69686 break;
69687 case 7:
69689 break;
69690 case 8:
69692 break;
69693 case 9:
69695 break;
69696 case 10:
69698 break;
69699 case 11:
69702 break;
69703 default:
69705 break;
69706 }
69707 }
69710 {
69712 }
69714 {
69716 }
69718 {
69720 }
69722 {
69726 {
69728 }
69732 for (
int k = 0;
k < 200;
k++)
69733 {
69734 if (Main.npc[
k].active && Main.npc[
k].type == 440 && Main.npc[
k].ai[3] == (
float)
whoAmI)
69735 {
69737 }
69738 }
69739 bool flag5 = list2.Count % 2 == 0;
69741 {
69744 float num8 = (float)((
num7 +
flag5.ToInt() + 1) / 2) * ((
float)Math.PI * 2
f) * 0.4
f / (
float)
list2.Count;
69746 {
69748 }
69749 if (
list2.Count == 1)
69750 {
69752 }
69762 {
69763 nPC2.position -=
nPC2.velocity;
69764 }
69765 nPC2.netUpdate = true;
69767 }
69768 }
69770 {
69771 case 1:
69774 break;
69775 case 2:
69778 break;
69779 case 3:
69782 break;
69783 case 4:
69786 break;
69787 }
69789 {
69792 }
69794 {
69797 }
69799 }
69800 }
69801 else if (this.
ai[0] == 1
f)
69802 {
69805 if ((
float)(
int)this.
ai[1] % 2
f != 0
f && this.
ai[1] != 1
f)
69806 {
69808 }
69810 if (this.
ai[1] <= 0
f)
69811 {
69817 }
69818 }
69819 else if (this.
ai[0] == 2
f)
69820 {
69822 Vector2
vec = Vector2.Normalize(player.Center -
center);
69824 {
69826 }
69827 if (this.
ai[1] >= 4
f &&
flag2 && (
int)(this.
ai[1] - 4
f) %
num == 0)
69828 {
69829 if (Main.netMode != 1)
69830 {
69832 for (
int l = 0;
l < 200;
l++)
69833 {
69834 if (Main.npc[
l].active && Main.npc[
l].type == 440 && Main.npc[
l].ai[3] == (
float)
whoAmI)
69835 {
69837 }
69838 }
69840 {
69845 {
69846 nPC3.direction = (nPC3.spriteDirection =
num9);
69847 }
69848 if (Main.netMode != 1)
69849 {
69850 vec = Vector2.Normalize(player.Center -
center3 + player.velocity * 20
f);
69852 {
69854 }
69856 for (
int m = 0;
m < 1;
m++)
69857 {
69861 }
69862 }
69863 }
69864 }
69865 if (Main.netMode != 1)
69866 {
69867 vec = Vector2.Normalize(player.Center -
center + player.velocity * 20
f);
69869 {
69871 }
69873 for (
int n = 0;
n < 1;
n++)
69874 {
69876 Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
vector11.X,
vector11.Y,
vector12.X,
vector12.Y, 464,
attackDamage_ForProjectiles, 0
f, Main.myPlayer, 0
f, 1
f);
69877 }
69878 }
69879 }
69881 if (this.
ai[1] >= (
float)(4 + num))
69882 {
69888 }
69889 }
69890 else if (this.
ai[0] == 3
f)
69891 {
69893 Vector2
vec2 = Vector2.Normalize(player.Center -
center);
69894 if (
vec2.HasNaNs())
69895 {
69897 }
69899 {
69900 if ((
int)(this.
ai[1] - 4
f) /
num12 == 2)
69901 {
69904 {
69905 if (Main.npc[
num10].active && Main.npc[
num10].type == 440 && Main.npc[
num10].ai[3] == (
float)
whoAmI)
69906 {
69908 }
69909 }
69910 if (Main.netMode != 1)
69911 {
69913 {
69918 {
69919 nPC4.direction = (nPC4.spriteDirection =
num11);
69920 }
69921 if (Main.netMode != 1)
69922 {
69923 vec2 = Vector2.Normalize(player.Center -
center4 + player.velocity * 20
f);
69924 if (
vec2.HasNaNs())
69925 {
69927 }
69930 {
69934 }
69935 }
69936 }
69937 }
69938 }
69941 {
69943 }
69944 if (Main.netMode != 1)
69945 {
69946 vec2 = Vector2.Normalize(player.Center -
center + player.velocity * 20
f);
69947 if (
vec2.HasNaNs())
69948 {
69950 }
69953 {
69957 }
69958 }
69959 }
69961 if (this.
ai[1] >= (
float)(4 + num12 *
num23))
69962 {
69968 }
69969 }
69970 else if (this.
ai[0] == 4
f)
69971 {
69973 {
69975 }
69976 else
69977 {
69979 }
69980 if (this.
ai[1] == 20
f &&
flag2 && Main.netMode != 1)
69981 {
69984 {
69985 if (Main.npc[
num16].active && Main.npc[
num16].type == 440 && Main.npc[
num16].ai[3] == (
float)
whoAmI)
69986 {
69988 }
69989 }
69991 {
69996 {
69997 nPC5.direction = (nPC5.spriteDirection =
num17);
69998 }
69999 if (Main.netMode != 1)
70000 {
70001 Vector2
vector15 = Vector2.Normalize(player.Center -
center5 + player.velocity * 20
f);
70003 {
70005 }
70008 {
70012 }
70013 }
70014 }
70015 if ((
int)(this.
ai[1] - 20
f) %
num34 == 0)
70016 {
70018 }
70019 }
70021 if (this.
ai[1] >= (
float)(20 + num34))
70022 {
70028 }
70029 }
70030 else if (this.
ai[0] == 5
f)
70031 {
70033 if (Vector2.Normalize(player.Center -
center).HasNaNs())
70034 {
70036 }
70037 if (this.
ai[1] >= 0
f && this.
ai[1] < 30
f)
70038 {
70043 }
70044 else if (this.
ai[1] >= 30
f && this.
ai[1] < 90
f)
70045 {
70046 if (this.
ai[1] == 30
f && Main.netMode != 1 &&
flag2)
70047 {
70053 {
70054 if (Main.npc[
num20].active && Main.npc[
num20].type == 440 && Main.npc[
num20].ai[3] == (
float)
whoAmI)
70055 {
70057 }
70058 }
70061 {
70063 }
70065 float[] array =
new float[
num22];
70067 {
70074 }
70077 {
70079 {
70081 }
70082 }
70086 {
70088 {
70095 {
70098 Main.npc[
num29].netUpdate =
true;
70100 }
70101 else
70102 {
70105 NetMessage.SendData(23, -1, -1,
null,
num30);
70106 }
70107 }
70108 }
70109 this.
ai[2] = Projectile.NewProjectile(
GetSpawnSource_ForProjectile(),
base.Center.X,
base.Center.Y, 0
f, 0
f, 490, 0, 0
f, Main.myPlayer, 0
f,
whoAmI);
70117 }
70122 {
70124 vector2 -=
base.Center;
70126 {
70128 }
70131 {
70133 }
70135 {
70137 }
70138 else
70139 {
70141 }
70144 {
70146 }
70147 }
70148 else
70149 {
70150 Vector2
vector3 = Main.projectile[(int)Main.npc[(
int)this.
ai[3]].ai[2]].Center;
70151 vector3 -=
base.Center;
70153 {
70155 }
70158 {
70160 }
70162 {
70164 }
70165 else
70166 {
70168 }
70171 {
70173 }
70174 }
70175 }
70176 else if (this.
ai[1] >= 90
f && this.
ai[1] < 120
f)
70177 {
70180 float num33 = (this.
ai[1] - 90
f) / 30
f;
70182 }
70183 else if (this.
ai[1] >= 120
f && this.
ai[1] < 420
f)
70184 {
70188 {
70190 vector4 -=
base.Center;
70192 {
70194 }
70197 {
70199 }
70201 {
70203 }
70204 else
70205 {
70207 }
70210 {
70212 }
70213 }
70214 else
70215 {
70216 Vector2
vector5 = Main.projectile[(int)Main.npc[(
int)this.
ai[3]].ai[2]].Center;
70217 vector5 -=
base.Center;
70219 {
70221 }
70224 {
70226 }
70228 {
70230 }
70231 else
70232 {
70234 }
70237 {
70239 }
70240 }
70241 }
70243 if (this.
ai[1] >= 420
f)
70244 {
70251 }
70252 }
70253 else if (this.
ai[0] == 6
f)
70254 {
70257 if (this.
ai[1] >= 120
f)
70258 {
70264 }
70265 }
70266 else if (this.
ai[0] == 7
f)
70267 {
70269 Vector2
vec3 = Vector2.Normalize(player.Center -
center);
70270 if (
vec3.HasNaNs())
70271 {
70273 }
70275 {
70276 if ((
int)(this.
ai[1] - 4
f) /
num45 == 2)
70277 {
70280 {
70281 if (Main.npc[
num37].active && Main.npc[
num37].type == 440 && Main.npc[
num37].ai[3] == (
float)
whoAmI)
70282 {
70284 }
70285 }
70287 {
70292 {
70293 nPC6.direction = (nPC6.spriteDirection =
num38);
70294 }
70295 if (Main.netMode != 1)
70296 {
70297 vec3 = Vector2.Normalize(player.Center -
center7 + player.velocity * 20
f);
70298 if (
vec3.HasNaNs())
70299 {
70301 }
70304 {
70308 }
70309 }
70310 }
70311 }
70314 {
70316 }
70317 if (Main.netMode != 1)
70318 {
70319 vec3 = Vector2.Normalize(player.Center -
center + player.velocity * 20
f);
70320 if (
vec3.HasNaNs())
70321 {
70323 }
70328 {
70334 float ai = (Main.rand.NextFloat() - 0.5f) * 0.3
f * ((
float)Math.PI * 2
f) / 60
f;
70337 Main.npc[
num44].netUpdate =
true;
70338 }
70339 }
70340 }
70342 if (this.ai[1] >= (
float)(4 +
num45 *
num56))
70343 {
70349 }
70350 }
70351 else if (this.ai[0] == 8
f)
70352 {
70354 if (this.ai[1] >= 4
f &&
flag2 && (
int)(this.ai[1] - 4
f) %
num58 == 0)
70355 {
70358 {
70359 if (Main.npc[
num46].active && Main.npc[
num46].type == 440 && Main.npc[
num46].ai[3] == (
float)
whoAmI)
70360 {
70362 }
70363 }
70364 int num47 = list8.Count + 1;
70366 {
70368 }
70371 {
70373 }
70374 if (Main.netMode != 1)
70375 {
70377 {
70378 Point point =
base.Center.ToTileCoordinates();
70379 Point
point2 = Main.player[
target].Center.ToTileCoordinates();
70386 bool flag6 =
false;
70388 {
70390 }
70392 {
70397 {
70400 {
70402 }
70404 {
70407 break;
70408 }
70409 }
70410 }
70411 }
70412 }
70413 }
70415 if (this.ai[1] >= (
float)(4 +
num58 *
num59))
70416 {
70422 }
70423 }
70425 {
70427 }
70430 }
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 ...
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.
Vector2 position
The position of this Entity in world coordinates.
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.
int defense
How resistant to damage this NPC is. The List of NPCs wiki pagecan be useful for finding appropriat...
static int CountNPCS(int Type)
Returns the number of active NPC in the world of the given NPC type (F:Terraria.NPC....
float[] localAI
Acts like F:Terraria.NPC.ai, but does not sync to the server. Many vanilla T:Terraria....
int lifeMax
The maximum life of this NPC.
void TargetClosest(bool faceTarget=true)
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...
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
int alpha
0 is opaque, and 255 is transparent. Note that this is the opposite of how alpha is typically express...
IEntitySource GetSpawnSourceForNPCFromNPCAI()
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
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()
void HitEffect(int hitDirection=0, double dmg=10.0, bool? instantKill=null)