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

◆ AI_069_DukeFishron()

void Terraria.NPC.AI_069_DukeFishron ( )
inlineprivate

Definition at line 41994 of file NPC.cs.

41995 {
41996 bool expertMode = Main.expertMode;
41997 float num = (expertMode ? 1.2f : 1f);
41998 bool flag = (double)life <= (double)lifeMax * 0.5;
41999 bool flag2 = expertMode && (double)life <= (double)lifeMax * 0.15;
42000 bool flag3 = ai[0] > 4f;
42001 bool flag4 = ai[0] > 9f;
42002 bool flag5 = ai[3] < 10f;
42003 if (flag4)
42004 {
42005 damage = (int)((float)defDamage * 1.1f * num);
42006 defense = 0;
42007 }
42008 else if (flag3)
42009 {
42010 damage = (int)((float)defDamage * 1.2f * num);
42011 defense = (int)((float)defDefense * 0.8f);
42012 }
42013 else
42014 {
42015 damage = defDamage;
42017 }
42018 int num2 = (expertMode ? 40 : 60);
42019 float num3 = (expertMode ? 0.55f : 0.45f);
42020 float num4 = (expertMode ? 8.5f : 7.5f);
42021 if (flag4)
42022 {
42023 num3 = 0.7f;
42024 num4 = 12f;
42025 num2 = 30;
42026 }
42027 else if (flag3 && flag5)
42028 {
42029 num3 = (expertMode ? 0.6f : 0.5f);
42030 num4 = (expertMode ? 10f : 8f);
42031 num2 = (expertMode ? 40 : 20);
42032 }
42033 else if (flag5 && !flag3 && !flag4)
42034 {
42035 num2 = 30;
42036 }
42037 int num5 = (expertMode ? 28 : 30);
42038 float num6 = (expertMode ? 17f : 16f);
42039 if (flag4)
42040 {
42041 num5 = 25;
42042 num6 = 27f;
42043 }
42044 else if (flag5 && flag3)
42045 {
42046 num5 = (expertMode ? 27 : 30);
42047 if (expertMode)
42048 {
42049 num6 = 21f;
42050 }
42051 }
42052 int num7 = 80;
42053 int num8 = 4;
42054 float num9 = 0.3f;
42055 float num10 = 5f;
42056 int num11 = 90;
42057 int num12 = 180;
42058 int num13 = 180;
42059 int num14 = 30;
42060 int num15 = 120;
42061 int num16 = 4;
42062 float num17 = 6f;
42063 float num18 = 20f;
42064 float num19 = (float)Math.PI * 2f / (float)(num15 / 2);
42065 int num20 = 75;
42066 Vector2 center = base.Center;
42067 Player player = Main.player[target];
42068 if (target < 0 || target == 255 || player.dead || !player.active || Vector2.Distance(player.Center, center) > 5600f)
42069 {
42070 TargetClosest();
42071 player = Main.player[target];
42072 netUpdate = true;
42073 }
42074 if (player.dead || Vector2.Distance(player.Center, center) > 5600f)
42075 {
42076 velocity.Y -= 0.4f;
42077 EncourageDespawn(10);
42078 if (ai[0] > 4f)
42079 {
42080 ai[0] = 5f;
42081 }
42082 else
42083 {
42084 ai[0] = 0f;
42085 }
42086 ai[2] = 0f;
42087 }
42088 bool flag6 = player.position.Y < 800f || (double)player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (float)(Main.maxTilesX * 16 - 6400));
42089 if (flag6)
42090 {
42091 num2 = 10;
42092 damage = defDamage * 2;
42093 defense = defDefense * 2;
42094 num6 += 6f;
42095 }
42096 bool flag7 = true;
42097 if (localAI[0] == 0f)
42098 {
42099 localAI[0] = 1f;
42100 alpha = 255;
42101 rotation = 0f;
42102 if (Main.netMode != 1)
42103 {
42104 ai[0] = -1f;
42105 netUpdate = true;
42106 }
42107 }
42108 float num21 = (float)Math.Atan2(player.Center.Y - center.Y, player.Center.X - center.X);
42109 if (spriteDirection == 1)
42110 {
42111 num21 += (float)Math.PI;
42112 }
42113 if (num21 < 0f)
42114 {
42115 num21 += (float)Math.PI * 2f;
42116 }
42117 if (num21 > (float)Math.PI * 2f)
42118 {
42119 num21 -= (float)Math.PI * 2f;
42120 }
42121 if (ai[0] == -1f)
42122 {
42123 num21 = 0f;
42124 }
42125 if (ai[0] == 3f)
42126 {
42127 num21 = 0f;
42128 }
42129 if (ai[0] == 4f)
42130 {
42131 num21 = 0f;
42132 }
42133 if (ai[0] == 8f)
42134 {
42135 num21 = 0f;
42136 }
42137 float num22 = 0.04f;
42138 if (ai[0] == 1f || ai[0] == 6f)
42139 {
42140 num22 = 0f;
42141 }
42142 if (ai[0] == 7f)
42143 {
42144 num22 = 0f;
42145 }
42146 if (ai[0] == 3f)
42147 {
42148 num22 = 0.01f;
42149 }
42150 if (ai[0] == 4f)
42151 {
42152 num22 = 0.01f;
42153 }
42154 if (ai[0] == 8f)
42155 {
42156 num22 = 0.01f;
42157 }
42158 if (rotation < num21)
42159 {
42160 if ((double)(num21 - rotation) > Math.PI)
42161 {
42162 rotation -= num22;
42163 }
42164 else
42165 {
42166 rotation += num22;
42167 }
42168 }
42169 if (rotation > num21)
42170 {
42171 if ((double)(rotation - num21) > Math.PI)
42172 {
42173 rotation += num22;
42174 }
42175 else
42176 {
42177 rotation -= num22;
42178 }
42179 }
42180 if (rotation > num21 - num22 && rotation < num21 + num22)
42181 {
42182 rotation = num21;
42183 }
42184 if (rotation < 0f)
42185 {
42186 rotation += (float)Math.PI * 2f;
42187 }
42188 if (rotation > (float)Math.PI * 2f)
42189 {
42190 rotation -= (float)Math.PI * 2f;
42191 }
42192 if (rotation > num21 - num22 && rotation < num21 + num22)
42193 {
42194 rotation = num21;
42195 }
42196 if (ai[0] != -1f && ai[0] < 9f)
42197 {
42198 if (Collision.SolidCollision(position, width, height))
42199 {
42200 alpha += 15;
42201 }
42202 else
42203 {
42204 alpha -= 15;
42205 }
42206 if (alpha < 0)
42207 {
42208 alpha = 0;
42209 }
42210 if (alpha > 150)
42211 {
42212 alpha = 150;
42213 }
42214 }
42215 if (ai[0] == -1f)
42216 {
42217 flag7 = false;
42218 velocity *= 0.98f;
42219 int num23 = Math.Sign(player.Center.X - center.X);
42220 if (num23 != 0)
42221 {
42222 direction = num23;
42224 }
42225 if (ai[2] > 20f)
42226 {
42227 velocity.Y = -2f;
42228 alpha -= 5;
42229 if (Collision.SolidCollision(position, width, height))
42230 {
42231 alpha += 15;
42232 }
42233 if (alpha < 0)
42234 {
42235 alpha = 0;
42236 }
42237 if (alpha > 150)
42238 {
42239 alpha = 150;
42240 }
42241 }
42242 if (ai[2] == (float)(num11 - 30))
42243 {
42244 int num24 = 36;
42245 for (int i = 0; i < num24; i++)
42246 {
42247 Vector2 vector = (Vector2.Normalize(velocity) * new Vector2((float)width / 2f, height) * 0.75f * 0.5f).RotatedBy((float)(i - (num24 / 2 - 1)) * ((float)Math.PI * 2f) / (float)num24) + base.Center;
42248 Vector2 vector2 = vector - base.Center;
42249 int num25 = Dust.NewDust(vector + vector2, 0, 0, 172, vector2.X * 2f, vector2.Y * 2f, 100, default(Color), 1.4f);
42250 Main.dust[num25].noGravity = true;
42251 Main.dust[num25].noLight = true;
42252 Main.dust[num25].velocity = Vector2.Normalize(vector2) * 3f;
42253 }
42254 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42255 }
42256 ai[2] += 1f;
42257 if (ai[2] >= (float)num20)
42258 {
42259 ai[0] = 0f;
42260 ai[1] = 0f;
42261 ai[2] = 0f;
42262 netUpdate = true;
42263 }
42264 }
42265 else if (ai[0] == 0f && !player.dead)
42266 {
42267 if (ai[1] == 0f)
42268 {
42269 ai[1] = 300 * Math.Sign((center - player.Center).X);
42270 }
42271 Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(ai[1], -200f) - center - velocity) * num4;
42272 if (velocity.X < vector3.X)
42273 {
42274 velocity.X += num3;
42275 if (velocity.X < 0f && vector3.X > 0f)
42276 {
42277 velocity.X += num3;
42278 }
42279 }
42280 else if (velocity.X > vector3.X)
42281 {
42282 velocity.X -= num3;
42283 if (velocity.X > 0f && vector3.X < 0f)
42284 {
42285 velocity.X -= num3;
42286 }
42287 }
42288 if (velocity.Y < vector3.Y)
42289 {
42290 velocity.Y += num3;
42291 if (velocity.Y < 0f && vector3.Y > 0f)
42292 {
42293 velocity.Y += num3;
42294 }
42295 }
42296 else if (velocity.Y > vector3.Y)
42297 {
42298 velocity.Y -= num3;
42299 if (velocity.Y > 0f && vector3.Y < 0f)
42300 {
42301 velocity.Y -= num3;
42302 }
42303 }
42304 int num26 = Math.Sign(player.Center.X - center.X);
42305 if (num26 != 0)
42306 {
42307 if (ai[2] == 0f && num26 != direction)
42308 {
42309 rotation += (float)Math.PI;
42310 }
42311 direction = num26;
42312 if (spriteDirection != -direction)
42313 {
42314 rotation += (float)Math.PI;
42315 }
42317 }
42318 ai[2] += 1f;
42319 if (ai[2] >= (float)num2)
42320 {
42321 int num27 = 0;
42322 switch ((int)ai[3])
42323 {
42324 case 0:
42325 case 1:
42326 case 2:
42327 case 3:
42328 case 4:
42329 case 5:
42330 case 6:
42331 case 7:
42332 case 8:
42333 case 9:
42334 num27 = 1;
42335 break;
42336 case 10:
42337 ai[3] = 1f;
42338 num27 = 2;
42339 break;
42340 case 11:
42341 ai[3] = 0f;
42342 num27 = 3;
42343 break;
42344 }
42345 if (flag6 && num27 == 2)
42346 {
42347 num27 = 3;
42348 }
42349 if (flag)
42350 {
42351 num27 = 4;
42352 }
42353 switch (num27)
42354 {
42355 case 1:
42356 ai[0] = 1f;
42357 ai[1] = 0f;
42358 ai[2] = 0f;
42359 velocity = Vector2.Normalize(player.Center - center) * num6;
42360 rotation = (float)Math.Atan2(velocity.Y, velocity.X);
42361 if (num26 != 0)
42362 {
42363 direction = num26;
42364 if (spriteDirection == 1)
42365 {
42366 rotation += (float)Math.PI;
42367 }
42369 }
42370 break;
42371 case 2:
42372 ai[0] = 2f;
42373 ai[1] = 0f;
42374 ai[2] = 0f;
42375 break;
42376 case 3:
42377 ai[0] = 3f;
42378 ai[1] = 0f;
42379 ai[2] = 0f;
42380 if (flag6)
42381 {
42382 ai[2] = num11 - 40;
42383 }
42384 break;
42385 case 4:
42386 ai[0] = 4f;
42387 ai[1] = 0f;
42388 ai[2] = 0f;
42389 break;
42390 }
42391 netUpdate = true;
42392 }
42393 }
42394 else if (ai[0] == 1f)
42395 {
42396 int num28 = 7;
42397 for (int j = 0; j < num28; j++)
42398 {
42399 Vector2 vector4 = (Vector2.Normalize(velocity) * new Vector2((float)(width + 50) / 2f, height) * 0.75f).RotatedBy((double)(j - (num28 / 2 - 1)) * Math.PI / (double)(float)num28) + center;
42400 Vector2 vector5 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - (float)Math.PI / 2f).ToRotationVector2() * Main.rand.Next(3, 8);
42401 int num29 = Dust.NewDust(vector4 + vector5, 0, 0, 172, vector5.X * 2f, vector5.Y * 2f, 100, default(Color), 1.4f);
42402 Main.dust[num29].noGravity = true;
42403 Main.dust[num29].noLight = true;
42404 Main.dust[num29].velocity /= 4f;
42405 Main.dust[num29].velocity -= velocity;
42406 }
42407 ai[2] += 1f;
42408 if (ai[2] >= (float)num5)
42409 {
42410 ai[0] = 0f;
42411 ai[1] = 0f;
42412 ai[2] = 0f;
42413 ai[3] += 2f;
42414 netUpdate = true;
42415 }
42416 }
42417 else if (ai[0] == 2f)
42418 {
42419 if (ai[1] == 0f)
42420 {
42421 ai[1] = 300 * Math.Sign((center - player.Center).X);
42422 }
42423 Vector2 vector6 = Vector2.Normalize(player.Center + new Vector2(ai[1], -200f) - center - velocity) * num10;
42424 if (velocity.X < vector6.X)
42425 {
42426 velocity.X += num9;
42427 if (velocity.X < 0f && vector6.X > 0f)
42428 {
42429 velocity.X += num9;
42430 }
42431 }
42432 else if (velocity.X > vector6.X)
42433 {
42434 velocity.X -= num9;
42435 if (velocity.X > 0f && vector6.X < 0f)
42436 {
42437 velocity.X -= num9;
42438 }
42439 }
42440 if (velocity.Y < vector6.Y)
42441 {
42442 velocity.Y += num9;
42443 if (velocity.Y < 0f && vector6.Y > 0f)
42444 {
42445 velocity.Y += num9;
42446 }
42447 }
42448 else if (velocity.Y > vector6.Y)
42449 {
42450 velocity.Y -= num9;
42451 if (velocity.Y > 0f && vector6.Y < 0f)
42452 {
42453 velocity.Y -= num9;
42454 }
42455 }
42456 if (ai[2] == 0f)
42457 {
42458 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42459 }
42460 if (ai[2] % (float)num8 == 0f)
42461 {
42462 SoundEngine.PlaySound(4, (int)base.Center.X, (int)base.Center.Y, 19);
42463 if (Main.netMode != 1)
42464 {
42465 Vector2 vector7 = Vector2.Normalize(player.Center - center) * (width + 20) / 2f + center;
42466 NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)vector7.X, (int)vector7.Y + 45, 371);
42467 }
42468 }
42469 int num30 = Math.Sign(player.Center.X - center.X);
42470 if (num30 != 0)
42471 {
42472 direction = num30;
42473 if (spriteDirection != -direction)
42474 {
42475 rotation += (float)Math.PI;
42476 }
42478 }
42479 ai[2] += 1f;
42480 if (ai[2] >= (float)num7)
42481 {
42482 ai[0] = 0f;
42483 ai[1] = 0f;
42484 ai[2] = 0f;
42485 netUpdate = true;
42486 }
42487 }
42488 else if (ai[0] == 3f)
42489 {
42490 velocity *= 0.98f;
42491 velocity.Y = MathHelper.Lerp(velocity.Y, 0f, 0.02f);
42492 if (ai[2] == (float)(num11 - 30))
42493 {
42494 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 9);
42495 }
42496 if (Main.netMode != 1 && ai[2] == (float)(num11 - 30))
42497 {
42498 Vector2 vector8 = rotation.ToRotationVector2() * (Vector2.UnitX * direction) * (width + 20) / 2f + center;
42499 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector8.X, vector8.Y, direction * 2, 8f, 385, 0, 0f, Main.myPlayer);
42500 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector8.X, vector8.Y, -direction * 2, 8f, 385, 0, 0f, Main.myPlayer);
42501 }
42502 ai[2] += 1f;
42503 if (ai[2] >= (float)num11)
42504 {
42505 ai[0] = 0f;
42506 ai[1] = 0f;
42507 ai[2] = 0f;
42508 netUpdate = true;
42509 }
42510 }
42511 else if (ai[0] == 4f)
42512 {
42513 flag7 = false;
42514 velocity *= 0.98f;
42515 velocity.Y = MathHelper.Lerp(velocity.Y, 0f, 0.02f);
42516 if (ai[2] == (float)(num12 - 60))
42517 {
42518 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42519 }
42520 ai[2] += 1f;
42521 if (ai[2] >= (float)num12)
42522 {
42523 ai[0] = 5f;
42524 ai[1] = 0f;
42525 ai[2] = 0f;
42526 ai[3] = 0f;
42527 netUpdate = true;
42528 }
42529 }
42530 else if (ai[0] == 5f && !player.dead)
42531 {
42532 if (ai[1] == 0f)
42533 {
42534 ai[1] = 300 * Math.Sign((center - player.Center).X);
42535 }
42536 Vector2 vector9 = Vector2.Normalize(player.Center + new Vector2(ai[1], -200f) - center - velocity) * num4;
42537 if (velocity.X < vector9.X)
42538 {
42539 velocity.X += num3;
42540 if (velocity.X < 0f && vector9.X > 0f)
42541 {
42542 velocity.X += num3;
42543 }
42544 }
42545 else if (velocity.X > vector9.X)
42546 {
42547 velocity.X -= num3;
42548 if (velocity.X > 0f && vector9.X < 0f)
42549 {
42550 velocity.X -= num3;
42551 }
42552 }
42553 if (velocity.Y < vector9.Y)
42554 {
42555 velocity.Y += num3;
42556 if (velocity.Y < 0f && vector9.Y > 0f)
42557 {
42558 velocity.Y += num3;
42559 }
42560 }
42561 else if (velocity.Y > vector9.Y)
42562 {
42563 velocity.Y -= num3;
42564 if (velocity.Y > 0f && vector9.Y < 0f)
42565 {
42566 velocity.Y -= num3;
42567 }
42568 }
42569 int num31 = Math.Sign(player.Center.X - center.X);
42570 if (num31 != 0)
42571 {
42572 if (ai[2] == 0f && num31 != direction)
42573 {
42574 rotation += (float)Math.PI;
42575 }
42576 direction = num31;
42577 if (spriteDirection != -direction)
42578 {
42579 rotation += (float)Math.PI;
42580 }
42582 }
42583 ai[2] += 1f;
42584 if (ai[2] >= (float)num2)
42585 {
42586 int num32 = 0;
42587 switch ((int)ai[3])
42588 {
42589 case 0:
42590 case 1:
42591 case 2:
42592 case 3:
42593 case 4:
42594 case 5:
42595 num32 = 1;
42596 break;
42597 case 6:
42598 ai[3] = 1f;
42599 num32 = 2;
42600 break;
42601 case 7:
42602 ai[3] = 0f;
42603 num32 = 3;
42604 break;
42605 }
42606 if (flag2)
42607 {
42608 num32 = 4;
42609 }
42610 if (flag6 && num32 == 2)
42611 {
42612 num32 = 3;
42613 }
42614 switch (num32)
42615 {
42616 case 1:
42617 ai[0] = 6f;
42618 ai[1] = 0f;
42619 ai[2] = 0f;
42620 velocity = Vector2.Normalize(player.Center - center) * num6;
42621 rotation = (float)Math.Atan2(velocity.Y, velocity.X);
42622 if (num31 != 0)
42623 {
42624 direction = num31;
42625 if (spriteDirection == 1)
42626 {
42627 rotation += (float)Math.PI;
42628 }
42630 }
42631 break;
42632 case 2:
42633 velocity = Vector2.Normalize(player.Center - center) * num18;
42634 rotation = (float)Math.Atan2(velocity.Y, velocity.X);
42635 if (num31 != 0)
42636 {
42637 direction = num31;
42638 if (spriteDirection == 1)
42639 {
42640 rotation += (float)Math.PI;
42641 }
42643 }
42644 ai[0] = 7f;
42645 ai[1] = 0f;
42646 ai[2] = 0f;
42647 break;
42648 case 3:
42649 ai[0] = 8f;
42650 ai[1] = 0f;
42651 ai[2] = 0f;
42652 break;
42653 case 4:
42654 ai[0] = 9f;
42655 ai[1] = 0f;
42656 ai[2] = 0f;
42657 break;
42658 }
42659 netUpdate = true;
42660 }
42661 }
42662 else if (ai[0] == 6f)
42663 {
42664 int num33 = 7;
42665 for (int k = 0; k < num33; k++)
42666 {
42667 Vector2 vector10 = (Vector2.Normalize(velocity) * new Vector2((float)(width + 50) / 2f, height) * 0.75f).RotatedBy((double)(k - (num33 / 2 - 1)) * Math.PI / (double)(float)num33) + center;
42668 Vector2 vector11 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - (float)Math.PI / 2f).ToRotationVector2() * Main.rand.Next(3, 8);
42669 int num34 = Dust.NewDust(vector10 + vector11, 0, 0, 172, vector11.X * 2f, vector11.Y * 2f, 100, default(Color), 1.4f);
42670 Main.dust[num34].noGravity = true;
42671 Main.dust[num34].noLight = true;
42672 Main.dust[num34].velocity /= 4f;
42673 Main.dust[num34].velocity -= velocity;
42674 }
42675 ai[2] += 1f;
42676 if (ai[2] >= (float)num5)
42677 {
42678 ai[0] = 5f;
42679 ai[1] = 0f;
42680 ai[2] = 0f;
42681 ai[3] += 2f;
42682 netUpdate = true;
42683 }
42684 }
42685 else if (ai[0] == 7f)
42686 {
42687 if (ai[2] == 0f)
42688 {
42689 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42690 }
42691 if (ai[2] % (float)num16 == 0f)
42692 {
42693 SoundEngine.PlaySound(4, (int)base.Center.X, (int)base.Center.Y, 19);
42694 if (Main.netMode != 1)
42695 {
42697 int num35 = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)vector12.X, (int)vector12.Y + 45, 371);
42698 Main.npc[num35].target = target;
42699 Main.npc[num35].velocity = Vector2.Normalize(velocity).RotatedBy((float)Math.PI / 2f * (float)direction) * num17;
42700 Main.npc[num35].netUpdate = true;
42701 Main.npc[num35].ai[3] = (float)Main.rand.Next(80, 121) / 100f;
42702 }
42703 }
42704 velocity = velocity.RotatedBy((0f - num19) * (float)direction);
42705 rotation -= num19 * (float)direction;
42706 ai[2] += 1f;
42707 if (ai[2] >= (float)num15)
42708 {
42709 ai[0] = 5f;
42710 ai[1] = 0f;
42711 ai[2] = 0f;
42712 netUpdate = true;
42713 }
42714 }
42715 else if (ai[0] == 8f)
42716 {
42717 velocity *= 0.98f;
42718 velocity.Y = MathHelper.Lerp(velocity.Y, 0f, 0.02f);
42719 if (ai[2] == (float)(num11 - 30))
42720 {
42721 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42722 }
42723 if (Main.netMode != 1 && ai[2] == (float)(num11 - 30))
42724 {
42725 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), center.X, center.Y, 0f, 0f, 385, 0, 0f, Main.myPlayer, 1f, target + 1, flag6 ? 1 : 0);
42726 }
42727 ai[2] += 1f;
42728 if (ai[2] >= (float)num11)
42729 {
42730 ai[0] = 5f;
42731 ai[1] = 0f;
42732 ai[2] = 0f;
42733 netUpdate = true;
42734 }
42735 }
42736 else if (ai[0] == 9f)
42737 {
42738 flag7 = false;
42739 if (ai[2] < (float)(num13 - 90))
42740 {
42741 if (Collision.SolidCollision(position, width, height))
42742 {
42743 alpha += 15;
42744 }
42745 else
42746 {
42747 alpha -= 15;
42748 }
42749 if (alpha < 0)
42750 {
42751 alpha = 0;
42752 }
42753 if (alpha > 150)
42754 {
42755 alpha = 150;
42756 }
42757 }
42758 else if (alpha < 255)
42759 {
42760 alpha += 4;
42761 if (alpha > 255)
42762 {
42763 alpha = 255;
42764 }
42765 }
42766 velocity *= 0.98f;
42767 velocity.Y = MathHelper.Lerp(velocity.Y, 0f, 0.02f);
42768 if (ai[2] == (float)(num13 - 60))
42769 {
42770 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42771 }
42772 ai[2] += 1f;
42773 if (ai[2] >= (float)num13)
42774 {
42775 ai[0] = 10f;
42776 ai[1] = 0f;
42777 ai[2] = 0f;
42778 ai[3] = 0f;
42779 netUpdate = true;
42780 }
42781 }
42782 else if (ai[0] == 10f && !player.dead)
42783 {
42784 chaseable = false;
42785 if (alpha < 255)
42786 {
42787 alpha += 25;
42788 if (alpha > 255)
42789 {
42790 alpha = 255;
42791 }
42792 }
42793 if (ai[1] == 0f)
42794 {
42795 ai[1] = 360 * Math.Sign((center - player.Center).X);
42796 }
42797 Vector2 desiredVelocity = Vector2.Normalize(player.Center + new Vector2(ai[1], -200f) - center - velocity) * num4;
42799 int num36 = Math.Sign(player.Center.X - center.X);
42800 if (num36 != 0)
42801 {
42802 if (ai[2] == 0f && num36 != direction)
42803 {
42804 rotation += (float)Math.PI;
42805 for (int l = 0; l < oldPos.Length; l++)
42806 {
42807 oldPos[l] = Vector2.Zero;
42808 }
42809 }
42810 direction = num36;
42811 if (spriteDirection != -direction)
42812 {
42813 rotation += (float)Math.PI;
42814 }
42816 }
42817 ai[2] += 1f;
42818 if (ai[2] >= (float)num2)
42819 {
42820 int num37 = 0;
42821 switch ((int)ai[3])
42822 {
42823 case 0:
42824 case 2:
42825 case 3:
42826 case 5:
42827 case 6:
42828 case 7:
42829 num37 = 1;
42830 break;
42831 case 1:
42832 case 4:
42833 case 8:
42834 num37 = 2;
42835 break;
42836 }
42837 switch (num37)
42838 {
42839 case 1:
42840 ai[0] = 11f;
42841 ai[1] = 0f;
42842 ai[2] = 0f;
42843 velocity = Vector2.Normalize(player.Center - center) * num6;
42844 rotation = (float)Math.Atan2(velocity.Y, velocity.X);
42845 if (num36 != 0)
42846 {
42847 direction = num36;
42848 if (spriteDirection == 1)
42849 {
42850 rotation += (float)Math.PI;
42851 }
42853 }
42854 break;
42855 case 2:
42856 ai[0] = 12f;
42857 ai[1] = 0f;
42858 ai[2] = 0f;
42859 break;
42860 case 3:
42861 ai[0] = 13f;
42862 ai[1] = 0f;
42863 ai[2] = 0f;
42864 break;
42865 }
42866 netUpdate = true;
42867 }
42868 }
42869 else if (ai[0] == 11f)
42870 {
42871 chaseable = true;
42872 alpha -= 25;
42873 if (alpha < 0)
42874 {
42875 alpha = 0;
42876 }
42877 int num38 = 7;
42878 for (int m = 0; m < num38; m++)
42879 {
42880 Vector2 vector13 = (Vector2.Normalize(velocity) * new Vector2((float)(width + 50) / 2f, height) * 0.75f).RotatedBy((double)(m - (num38 / 2 - 1)) * Math.PI / (double)(float)num38) + center;
42881 Vector2 vector14 = ((float)(Main.rand.NextDouble() * 3.1415927410125732) - (float)Math.PI / 2f).ToRotationVector2() * Main.rand.Next(3, 8);
42882 int num39 = Dust.NewDust(vector13 + vector14, 0, 0, 172, vector14.X * 2f, vector14.Y * 2f, 100, default(Color), 1.4f);
42883 Main.dust[num39].noGravity = true;
42884 Main.dust[num39].noLight = true;
42885 Main.dust[num39].velocity /= 4f;
42886 Main.dust[num39].velocity -= velocity;
42887 }
42888 ai[2] += 1f;
42889 if (ai[2] >= (float)num5)
42890 {
42891 ai[0] = 10f;
42892 ai[1] = 0f;
42893 ai[2] = 0f;
42894 ai[3] += 1f;
42895 netUpdate = true;
42896 }
42897 }
42898 else if (ai[0] == 12f)
42899 {
42900 flag7 = false;
42901 chaseable = false;
42902 if (alpha < 255)
42903 {
42904 alpha += 17;
42905 if (alpha > 255)
42906 {
42907 alpha = 255;
42908 }
42909 }
42910 velocity *= 0.98f;
42911 velocity.Y = MathHelper.Lerp(velocity.Y, 0f, 0.02f);
42912 if (ai[2] == (float)(num14 / 2))
42913 {
42914 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42915 }
42916 if (Main.netMode != 1 && ai[2] == (float)(num14 / 2))
42917 {
42918 if (ai[1] == 0f)
42919 {
42920 ai[1] = 300 * Math.Sign((center - player.Center).X);
42921 }
42922 Vector2 vector15 = player.Center + new Vector2(0f - ai[1], -200f);
42923 Vector2 vector17 = (base.Center = vector15);
42924 center = vector17;
42925 int num40 = Math.Sign(player.Center.X - center.X);
42926 if (num40 != 0)
42927 {
42928 if (ai[2] == 0f && num40 != direction)
42929 {
42930 rotation += (float)Math.PI;
42931 for (int n = 0; n < oldPos.Length; n++)
42932 {
42933 oldPos[n] = Vector2.Zero;
42934 }
42935 }
42936 direction = num40;
42937 if (spriteDirection != -direction)
42938 {
42939 rotation += (float)Math.PI;
42940 }
42942 }
42943 }
42944 ai[2] += 1f;
42945 if (ai[2] >= (float)num14)
42946 {
42947 ai[0] = 10f;
42948 ai[1] = 0f;
42949 ai[2] = 0f;
42950 ai[3] += 1f;
42951 if (ai[3] >= 9f)
42952 {
42953 ai[3] = 0f;
42954 }
42955 netUpdate = true;
42956 }
42957 }
42958 else if (ai[0] == 13f)
42959 {
42960 if (ai[2] == 0f)
42961 {
42962 SoundEngine.PlaySound(29, (int)center.X, (int)center.Y, 20);
42963 }
42964 velocity = velocity.RotatedBy((0f - num19) * (float)direction);
42965 rotation -= num19 * (float)direction;
42966 ai[2] += 1f;
42967 if (ai[2] >= (float)num15)
42968 {
42969 ai[0] = 10f;
42970 ai[1] = 0f;
42971 ai[2] = 0f;
42972 ai[3] += 1f;
42973 netUpdate = true;
42974 }
42975 }
42977 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static double Atan2(double y, double x)
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)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
int defense
Definition NPC.cs:463
int damage
Definition NPC.cs:461
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
bool chaseable
Definition NPC.cs:263
void EncourageDespawn(int despawnTime)
Definition NPC.cs:1390
int lifeMax
Definition NPC.cs:479
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
int defDefense
Definition NPC.cs:467
float[] ai
Definition NPC.cs:447
bool dontTakeDamage
Definition NPC.cs:527
int alpha
Definition NPC.cs:489
float rotation
Definition NPC.cs:501
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:87546
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
int defDamage
Definition NPC.cs:465
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
void SimpleFlyMovement(Vector2 desiredVelocity, float moveSpeed)
Definition NPC.cs:69581
bool netUpdate
Definition NPC.cs:507
Vector2[] oldPos
Definition NPC.cs:155
int target
Definition NPC.cs:459
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91

References Terraria.Entity.active, Terraria.NPC.ai, Terraria.NPC.alpha, System.Math.Atan2(), Terraria.Entity.Center, Terraria.NPC.chaseable, Terraria.NPC.damage, Terraria.Player.dead, Terraria.NPC.defDamage, Terraria.NPC.defDefense, Terraria.NPC.defense, Terraria.Entity.direction, Microsoft.Xna.Framework.Vector2.Distance(), Terraria.NPC.dontTakeDamage, Terraria.Main.dust, Terraria.NPC.EncourageDespawn(), Terraria.Main.expertMode, Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.Entity.height, Microsoft.Xna.Framework.Vector2.Length(), Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.NPC.life, Terraria.NPC.lifeMax, Terraria.NPC.localAI, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.NPC.NewNPC(), Terraria.Projectile.NewProjectile(), Microsoft.Xna.Framework.Vector2.Normalize(), Terraria.Main.npc, Terraria.NPC.oldPos, System.Math.PI, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.rand, Terraria.NPC.rotation, System.Math.Sign(), Terraria.NPC.SimpleFlyMovement(), Terraria.Collision.SolidCollision(), Terraria.NPC.spriteDirection, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Microsoft.Xna.Framework.Graphics.Vector2, Terraria.Entity.velocity, Terraria.Entity.width, Terraria.Main.worldSurface, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.NPC.AI().