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

◆ AI_003_Fighters()

void Terraria.NPC.AI_003_Fighters ( )
inlineprivate

Definition at line 48965 of file NPC.cs.

48966 {
48967 if (Main.player[target].position.Y + (float)Main.player[target].height == position.Y + (float)height)
48968 {
48969 directionY = -1;
48970 }
48971 bool flag = false;
48972 if (type == 624 && AI_003_Gnomes_ShouldTurnToStone())
48973 {
48974 int num = (int)(base.Center.X / 16f);
48975 int num2 = (int)(base.Bottom.Y / 16f);
48977 int num3 = Dust.NewDust(position, width, height, 43, 0f, 0f, 254, Color.White, 0.5f);
48978 Main.dust[num3].velocity *= 0.2f;
48980 if (WorldGen.SolidTileAllowBottomSlope(num, num2))
48981 {
48982 for (int i = 0; i < 5; i++)
48983 {
48985 int num4 = Dust.NewDust(position, width, height, 43, 0f, 0f, 254, Color.White, 0.5f);
48986 Main.dust[num4].velocity *= 0.2f;
48988 }
48989 if (Main.netMode != 1 && TileObject.CanPlace(num, num2 - 1, 567, 0, direction, out var _, onlyCheck: true) && WorldGen.PlaceTile(num, num2 - 1, 567, mute: false, forced: false, -1, Main.rand.Next(5)))
48990 {
48991 if (Main.netMode == 2)
48992 {
48993 NetMessage.SendTileSquare(-1, num, num2 - 2, 1, 2);
48994 }
48995 if (Main.netMode != 1)
48996 {
48998 {
48999 Main.BestiaryTracker.Kills.RegisterKill(this);
49000 }
49002 }
49003 life = 0;
49004 active = false;
49006 return;
49007 }
49008 }
49009 }
49010 if (type == 466)
49011 {
49012 int num5 = 200;
49013 if (ai[2] == 0f)
49014 {
49015 alpha = num5;
49016 TargetClosest();
49017 if (!Main.player[target].dead && (Main.player[target].Center - base.Center).Length() < 170f)
49018 {
49019 ai[2] = -16f;
49020 }
49021 if (velocity.X != 0f || velocity.Y < 0f || velocity.Y > 2f || justHit)
49022 {
49023 ai[2] = -16f;
49024 }
49025 return;
49026 }
49027 if (ai[2] < 0f)
49028 {
49029 if (alpha > 0)
49030 {
49031 alpha -= num5 / 16;
49032 if (alpha < 0)
49033 {
49034 alpha = 0;
49035 }
49036 }
49037 ai[2] += 1f;
49038 if (ai[2] == 0f)
49039 {
49040 ai[2] = 1f;
49041 velocity.X = direction * 2;
49042 }
49043 return;
49044 }
49045 alpha = 0;
49046 }
49047 if (type == 166)
49048 {
49049 if (Main.netMode != 1 && Main.rand.Next(240) == 0)
49050 {
49051 ai[2] = Main.rand.Next(-480, -60);
49052 netUpdate = true;
49053 }
49054 if (ai[2] < 0f)
49055 {
49056 TargetClosest();
49057 if (justHit)
49058 {
49059 ai[2] = 0f;
49060 }
49061 if (Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
49062 {
49063 ai[2] = 0f;
49064 }
49065 }
49066 if (ai[2] < 0f)
49067 {
49068 velocity.X *= 0.9f;
49069 if ((double)velocity.X > -0.1 && (double)velocity.X < 0.1)
49070 {
49071 velocity.X = 0f;
49072 }
49073 ai[2] += 1f;
49074 if (ai[2] == 0f)
49075 {
49076 velocity.X = (float)direction * 0.1f;
49077 }
49078 return;
49079 }
49080 }
49081 if (type == 461)
49082 {
49083 if (wet)
49084 {
49085 knockBackResist = 0f;
49086 ai[3] = -0.10101f;
49087 noGravity = true;
49088 Vector2 center = base.Center;
49089 width = 34;
49090 height = 24;
49091 position.X = center.X - (float)(width / 2);
49092 position.Y = center.Y - (float)(height / 2);
49093 TargetClosest();
49094 if (collideX)
49095 {
49096 velocity.X = 0f - oldVelocity.X;
49097 }
49098 if (velocity.X < 0f)
49099 {
49100 direction = -1;
49101 }
49102 if (velocity.X > 0f)
49103 {
49104 direction = 1;
49105 }
49106 if (Collision.CanHit(position, width, height, Main.player[target].Center, 1, 1))
49107 {
49108 Vector2 vector = Main.player[target].Center - base.Center;
49109 vector.Normalize();
49110 vector *= 5f;
49111 velocity = (velocity * 19f + vector) / 20f;
49112 return;
49113 }
49114 float num6 = 5f;
49115 if (velocity.Y > 0f)
49116 {
49117 num6 = 3f;
49118 }
49119 if (velocity.Y < 0f)
49120 {
49121 num6 = 8f;
49122 }
49123 Vector2 vector2 = new Vector2(direction, -1f);
49124 vector2.Normalize();
49125 vector2 *= num6;
49126 if (num6 < 5f)
49127 {
49128 velocity = (velocity * 24f + vector2) / 25f;
49129 }
49130 else
49131 {
49132 velocity = (velocity * 9f + vector2) / 10f;
49133 }
49134 return;
49135 }
49136 knockBackResist = 0.4f * Main.GameModeInfo.KnockbackToEnemiesMultiplier;
49137 noGravity = false;
49138 Vector2 center2 = base.Center;
49139 width = 18;
49140 height = 40;
49141 position.X = center2.X - (float)(width / 2);
49142 position.Y = center2.Y - (float)(height / 2);
49143 if (ai[3] == -0.10101f)
49144 {
49145 ai[3] = 0f;
49146 float num7 = velocity.Length();
49147 num7 *= 2f;
49148 if (num7 > 10f)
49149 {
49150 num7 = 10f;
49151 }
49153 velocity *= num7;
49154 if (velocity.X < 0f)
49155 {
49156 direction = -1;
49157 }
49158 if (velocity.X > 0f)
49159 {
49160 direction = 1;
49161 }
49163 }
49164 }
49165 if (type == 586)
49166 {
49167 if (alpha == 255)
49168 {
49169 TargetClosest();
49171 velocity.Y = -6f;
49172 netUpdate = true;
49173 for (int j = 0; j < 35; j++)
49174 {
49175 Dust dust = Dust.NewDustDirect(position, width, height, 5);
49176 dust.velocity *= 1f;
49177 dust.scale = 1f + Main.rand.NextFloat() * 0.5f;
49178 dust.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f;
49179 dust.velocity += velocity * 0.5f;
49180 }
49181 }
49182 alpha -= 15;
49183 if (alpha < 0)
49184 {
49185 alpha = 0;
49186 }
49188 if (alpha != 0)
49189 {
49190 for (int k = 0; k < 2; k++)
49191 {
49192 Dust dust2 = Dust.NewDustDirect(position, width, height, 5);
49193 dust2.velocity *= 1f;
49194 dust2.scale = 1f + Main.rand.NextFloat() * 0.5f;
49195 dust2.fadeIn = 1.5f + Main.rand.NextFloat() * 0.5f;
49196 dust2.velocity += velocity * 0.3f;
49197 }
49198 }
49199 if (Main.rand.Next(3) == 0)
49200 {
49201 Dust dust3 = Dust.NewDustDirect(position, width, height, 5);
49202 dust3.velocity *= 0f;
49203 dust3.alpha = 120;
49204 dust3.scale = 0.7f + Main.rand.NextFloat() * 0.5f;
49205 dust3.velocity += velocity * 0.3f;
49206 }
49208 if (wet)
49209 {
49210 knockBackResist = 0f;
49211 ai[3] = -0.10101f;
49212 noGravity = true;
49213 Vector2 center3 = base.Center;
49214 position.X = center3.X - (float)(width / 2);
49215 position.Y = center3.Y - (float)(height / 2);
49216 TargetClosest();
49217 if (collideX)
49218 {
49219 velocity.X = 0f - oldVelocity.X;
49220 }
49221 if (velocity.X < 0f)
49222 {
49223 direction = -1;
49224 }
49225 if (velocity.X > 0f)
49226 {
49227 direction = 1;
49228 }
49229 if (Collision.CanHit(position, width, height, Main.player[target].Center, 1, 1))
49230 {
49231 Vector2 vector3 = Main.player[target].Center - base.Center;
49232 vector3.Normalize();
49233 float num8 = 1f;
49234 num8 += Math.Abs(base.Center.Y - Main.player[target].Center.Y) / 40f;
49235 num8 = MathHelper.Clamp(num8, 5f, 20f);
49236 vector3 *= num8;
49237 if (velocity.Y > 0f)
49238 {
49239 velocity = (velocity * 29f + vector3) / 30f;
49240 }
49241 else
49242 {
49243 velocity = (velocity * 4f + vector3) / 5f;
49244 }
49245 return;
49246 }
49247 float num9 = 5f;
49248 if (velocity.Y > 0f)
49249 {
49250 num9 = 3f;
49251 }
49252 if (velocity.Y < 0f)
49253 {
49254 num9 = 8f;
49255 }
49256 Vector2 vector4 = new Vector2(direction, -1f);
49257 vector4.Normalize();
49258 vector4 *= num9;
49259 if (num9 < 5f)
49260 {
49261 velocity = (velocity * 24f + vector4) / 25f;
49262 }
49263 else
49264 {
49265 velocity = (velocity * 9f + vector4) / 10f;
49266 }
49267 return;
49268 }
49269 noGravity = false;
49270 Vector2 center4 = base.Center;
49271 position.X = center4.X - (float)(width / 2);
49272 position.Y = center4.Y - (float)(height / 2);
49273 if (ai[3] == -0.10101f)
49274 {
49275 ai[3] = 0f;
49276 float num10 = velocity.Length();
49277 num10 *= 2f;
49278 if (num10 > 15f)
49279 {
49280 num10 = 15f;
49281 }
49283 velocity *= num10;
49284 if (velocity.X < 0f)
49285 {
49286 direction = -1;
49287 }
49288 if (velocity.X > 0f)
49289 {
49290 direction = 1;
49291 }
49293 }
49294 }
49295 if (type == 379 || type == 380)
49296 {
49297 if (ai[3] < 0f)
49298 {
49299 directionY = -1;
49300 flag = false;
49301 damage = 0;
49302 velocity.X *= 0.93f;
49303 if ((double)velocity.X > -0.1 && (double)velocity.X < 0.1)
49304 {
49305 velocity.X = 0f;
49306 }
49307 int num11 = (int)(0f - ai[3] - 1f);
49308 int num12 = Math.Sign(Main.npc[num11].Center.X - base.Center.X);
49309 if (num12 != direction)
49310 {
49311 velocity.X = 0f;
49312 direction = num12;
49313 netUpdate = true;
49314 }
49315 if (justHit && Main.netMode != 1 && Main.npc[num11].localAI[0] == 0f)
49316 {
49317 Main.npc[num11].localAI[0] = 1f;
49318 }
49319 if (ai[0] < 1000f)
49320 {
49321 ai[0] = 1000f;
49322 }
49323 if ((ai[0] += 1f) >= 1300f)
49324 {
49325 ai[0] = 1000f;
49326 netUpdate = true;
49327 }
49328 return;
49329 }
49330 if (ai[0] >= 1000f)
49331 {
49332 ai[0] = 0f;
49333 }
49334 damage = defDamage;
49335 }
49336 if (type == 383 && ai[2] == 0f && localAI[0] == 0f && Main.netMode != 1)
49337 {
49338 int num13 = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)base.Center.X, (int)base.Center.Y, 384, whoAmI);
49339 ai[2] = num13 + 1;
49340 localAI[0] = -1f;
49341 netUpdate = true;
49342 Main.npc[num13].ai[0] = whoAmI;
49343 Main.npc[num13].netUpdate = true;
49344 }
49345 if (type == 383)
49346 {
49347 int num14 = (int)ai[2] - 1;
49348 if (num14 != -1 && Main.npc[num14].active && Main.npc[num14].type == 384)
49349 {
49350 dontTakeDamage = true;
49351 }
49352 else
49353 {
49354 dontTakeDamage = false;
49355 ai[2] = 0f;
49356 if (localAI[0] == -1f)
49357 {
49358 localAI[0] = 180f;
49359 }
49360 if (localAI[0] > 0f)
49361 {
49362 localAI[0] -= 1f;
49363 }
49364 }
49365 }
49366 if (type == 482)
49367 {
49368 int num15 = 300;
49369 int num16 = 120;
49370 dontTakeDamage = false;
49371 if (ai[2] < 0f)
49372 {
49373 dontTakeDamage = true;
49374 ai[2] += 1f;
49375 velocity.X *= 0.9f;
49376 if ((double)Math.Abs(velocity.X) < 0.001)
49377 {
49378 velocity.X = 0.001f * (float)direction;
49379 }
49380 if (Math.Abs(velocity.Y) > 1f)
49381 {
49382 ai[2] += 10f;
49383 }
49384 if (ai[2] >= 0f)
49385 {
49386 netUpdate = true;
49387 velocity.X += (float)direction * 0.3f;
49388 }
49389 return;
49390 }
49391 if (ai[2] < (float)num15)
49392 {
49393 if (justHit)
49394 {
49395 ai[2] += 15f;
49396 }
49397 ai[2] += 1f;
49398 }
49399 else if (velocity.Y == 0f)
49400 {
49401 ai[2] = -num16;
49402 netUpdate = true;
49403 }
49404 }
49405 if (type == 631)
49406 {
49407 if (target < 0 || target == 255 || Main.player[target].dead || !Main.player[target].active)
49408 {
49409 TargetClosest(ai[2] > 0f);
49410 }
49411 Player player = Main.player[target];
49412 bool flag2 = !player.dead && player.active && base.Center.Distance(player.Center) < 320f;
49413 int num17 = 100;
49414 int num18 = 32;
49415 if (ai[2] == 0f)
49416 {
49417 ai[3] = 65f;
49418 if (flag2 && Collision.CanHit(player, this))
49419 {
49420 ai[2] = num17;
49421 ai[3] = 0f;
49422 velocity.X = (float)direction * 0.01f;
49423 netUpdate = true;
49424 }
49425 }
49426 else
49427 {
49428 if (ai[2] < (float)num17)
49429 {
49430 ai[2] += 1f;
49431 velocity.X *= 0.9f;
49432 if ((double)Math.Abs(velocity.X) < 0.001)
49433 {
49434 velocity.X = 0f;
49435 }
49436 if (Math.Abs(velocity.Y) > 1f)
49437 {
49438 ai[2] = 0f;
49439 }
49440 if (ai[2] == (float)(num17 - num18 / 2) && Main.netMode != 1 && !player.Hitbox.Intersects(base.Hitbox) && Collision.CanHit(player, this))
49441 {
49442 float num19 = 8f;
49443 Vector2 center5 = base.Center;
49444 Vector2 vector5 = DirectionTo(Main.player[target].Center) * num19;
49445 if (vector5.HasNaNs())
49446 {
49447 vector5 = new Vector2((float)direction * num19, 0f);
49448 }
49449 int num20 = 20;
49450 Vector2 v = vector5 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f);
49451 v = v.SafeNormalize(Vector2.Zero);
49452 v *= num19;
49453 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), center5.X, center5.Y, v.X, v.Y, 909, num20, 1f, Main.myPlayer);
49454 }
49455 if (ai[2] >= (float)num17)
49456 {
49457 ai[2] = num17;
49458 ai[3] = 0f;
49459 velocity.X = (float)direction * 0.01f;
49460 netUpdate = true;
49461 }
49462 return;
49463 }
49464 if (velocity.Y == 0f && flag2 && (player.Hitbox.Intersects(base.Hitbox) || Collision.CanHit(player, this)))
49465 {
49466 ai[2] = num17 - num18;
49467 netUpdate = true;
49468 }
49469 }
49470 }
49471 if (type == 480)
49472 {
49473 int num21 = 180;
49474 int num22 = 300;
49475 int num23 = 180;
49476 int num24 = 60;
49477 int num25 = 20;
49478 if (life < lifeMax / 3)
49479 {
49480 num21 = 120;
49481 num22 = 240;
49482 num23 = 240;
49483 num24 = 90;
49484 }
49485 if (ai[2] > 0f)
49486 {
49487 ai[2] -= 1f;
49488 }
49489 else if (ai[2] == 0f)
49490 {
49491 if (((Main.player[target].Center.X < base.Center.X && direction < 0) || (Main.player[target].Center.X > base.Center.X && direction > 0)) && velocity.Y == 0f && Distance(Main.player[target].Center) < 900f && Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
49492 {
49493 ai[2] = -num23 - num25;
49494 netUpdate = true;
49495 }
49496 }
49497 else
49498 {
49499 if (ai[2] < 0f && ai[2] < (float)(-num23))
49500 {
49502 velocity.X *= 0.9f;
49503 if (velocity.Y < -2f || velocity.Y > 4f || justHit)
49504 {
49505 ai[2] = num21;
49506 }
49507 else
49508 {
49509 ai[2] += 1f;
49510 if (ai[2] == 0f)
49511 {
49512 ai[2] = num22;
49513 }
49514 }
49515 float num26 = ai[2] + (float)num23 + (float)num25;
49516 if (num26 == 1f)
49517 {
49518 SoundEngine.PlaySound(4, (int)position.X, (int)position.Y, 17);
49519 }
49520 if (num26 < (float)num25)
49521 {
49522 Vector2 vector6 = base.Top + new Vector2(spriteDirection * 6, 6f);
49523 float num27 = MathHelper.Lerp(20f, 30f, (num26 * 3f + 50f) / 182f);
49524 Main.rand.NextFloat();
49525 for (float num28 = 0f; num28 < 2f; num28 += 1f)
49526 {
49527 Vector2 vector7 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f);
49528 Dust obj = Main.dust[Dust.NewDust(vector6, 0, 0, 228)];
49529 obj.position = vector6 + vector7 * num27;
49530 obj.noGravity = true;
49531 obj.velocity = vector7 * 2f;
49532 obj.scale = 0.5f + Main.rand.NextFloat() * 0.5f;
49533 }
49534 }
49535 Lighting.AddLight(base.Center, 0.9f, 0.75f, 0.1f);
49537 return;
49538 }
49539 if (ai[2] < 0f && ai[2] >= (float)(-num23))
49540 {
49542 Lighting.AddLight(base.Center, 0.9f, 0.75f, 0.1f);
49543 velocity.X *= 0.9f;
49544 if (velocity.Y < -2f || velocity.Y > 4f || justHit)
49545 {
49546 ai[2] = num21;
49547 }
49548 else
49549 {
49550 ai[2] += 1f;
49551 if (ai[2] == 0f)
49552 {
49553 ai[2] = num22;
49554 }
49555 }
49556 float num29 = ai[2] + (float)num23;
49557 if (num29 < 180f && (Main.rand.Next(3) == 0 || ai[2] % 3f == 0f))
49558 {
49559 Vector2 vector8 = base.Top + new Vector2(spriteDirection * 10, 10f);
49560 float num30 = MathHelper.Lerp(20f, 30f, (num29 * 3f + 50f) / 182f);
49561 Main.rand.NextFloat();
49562 for (float num31 = 0f; num31 < 1f; num31 += 1f)
49563 {
49564 Vector2 vector9 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f);
49565 Dust obj2 = Main.dust[Dust.NewDust(vector8, 0, 0, 228)];
49566 obj2.position = vector8 + vector9 * num30;
49567 obj2.noGravity = true;
49568 obj2.velocity = vector9 * 4f;
49569 obj2.scale = 0.5f + Main.rand.NextFloat();
49570 }
49571 }
49573 if (Main.netMode == 2)
49574 {
49575 return;
49576 }
49577 Player player2 = Main.player[Main.myPlayer];
49578 _ = Main.myPlayer;
49579 if (player2.dead || !player2.active || player2.FindBuffIndex(156) != -1)
49580 {
49581 return;
49582 }
49583 Vector2 vector10 = player2.Center - base.Center;
49584 if (!(vector10.Length() < 700f))
49585 {
49586 return;
49587 }
49588 bool flag3 = vector10.Length() < 30f;
49589 if (!flag3)
49590 {
49591 float x = ((float)Math.PI / 4f).ToRotationVector2().X;
49593 if (vector11.X > x || vector11.X < 0f - x)
49594 {
49595 flag3 = true;
49596 }
49597 }
49598 if (((player2.Center.X < base.Center.X && direction < 0 && player2.direction > 0) || (player2.Center.X > base.Center.X && direction > 0 && player2.direction < 0)) && flag3 && (Collision.CanHitLine(base.Center, 1, 1, player2.Center, 1, 1) || Collision.CanHitLine(base.Center - Vector2.UnitY * 16f, 1, 1, player2.Center, 1, 1) || Collision.CanHitLine(base.Center + Vector2.UnitY * 8f, 1, 1, player2.Center, 1, 1)) && !player2.creativeGodMode)
49599 {
49600 player2.AddBuff(156, num24 + (int)ai[2] * -1);
49601 }
49602 return;
49603 }
49604 }
49605 }
49606 if (type == 471)
49607 {
49608 if (ai[3] < 0f)
49609 {
49610 knockBackResist = 0f;
49611 defense = (int)((double)defDefense * 1.1);
49612 noGravity = true;
49613 noTileCollide = true;
49614 if (velocity.X < 0f)
49615 {
49616 direction = -1;
49617 }
49618 else if (velocity.X > 0f)
49619 {
49620 direction = 1;
49621 }
49622 rotation = velocity.X * 0.1f;
49623 if (Main.netMode != 1)
49624 {
49625 localAI[3] += 1f;
49626 if (localAI[3] > (float)Main.rand.Next(20, 180))
49627 {
49628 localAI[3] = 0f;
49629 Vector2 center6 = base.Center;
49630 center6 += velocity;
49631 NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)center6.X, (int)center6.Y, 30);
49632 }
49633 }
49634 }
49635 else
49636 {
49637 localAI[3] = 0f;
49638 knockBackResist = 0.35f * Main.GameModeInfo.KnockbackToEnemiesMultiplier;
49639 rotation *= 0.9f;
49641 noGravity = false;
49642 noTileCollide = false;
49643 }
49644 if (ai[3] == 1f)
49645 {
49646 knockBackResist = 0f;
49647 defense += 10;
49648 }
49649 if (ai[3] == -1f)
49650 {
49651 TargetClosest();
49652 float num32 = 8f;
49653 float num33 = 40f;
49654 Vector2 vector12 = Main.player[target].Center - base.Center;
49655 float num34 = vector12.Length();
49656 num32 += num34 / 200f;
49657 vector12.Normalize();
49658 vector12 *= num32;
49659 velocity = (velocity * (num33 - 1f) + vector12) / num33;
49660 if (num34 < 500f && !Collision.SolidCollision(position, width, height))
49661 {
49662 ai[3] = 0f;
49663 ai[2] = 0f;
49664 }
49665 return;
49666 }
49667 if (ai[3] == -2f)
49668 {
49669 velocity.Y -= 0.2f;
49670 if (velocity.Y < -10f)
49671 {
49672 velocity.Y = -10f;
49673 }
49674 if (Main.player[target].Center.Y - base.Center.Y > 200f)
49675 {
49676 TargetClosest();
49677 ai[3] = -3f;
49678 if (Main.player[target].Center.X > base.Center.X)
49679 {
49680 ai[2] = 1f;
49681 }
49682 else
49683 {
49684 ai[2] = -1f;
49685 }
49686 }
49687 velocity.X *= 0.99f;
49688 return;
49689 }
49690 if (ai[3] == -3f)
49691 {
49692 if (direction == 0)
49693 {
49694 TargetClosest();
49695 }
49696 if (ai[2] == 0f)
49697 {
49698 ai[2] = direction;
49699 }
49700 velocity.Y *= 0.9f;
49701 velocity.X += ai[2] * 0.3f;
49702 if (velocity.X > 10f)
49703 {
49704 velocity.X = 10f;
49705 }
49706 if (velocity.X < -10f)
49707 {
49708 velocity.X = -10f;
49709 }
49710 float num35 = Main.player[target].Center.X - base.Center.X;
49711 if ((ai[2] < 0f && num35 > 300f) || (ai[2] > 0f && num35 < -300f))
49712 {
49713 ai[3] = -4f;
49714 ai[2] = 0f;
49715 }
49716 else if (Math.Abs(num35) > 800f)
49717 {
49718 ai[3] = -1f;
49719 ai[2] = 0f;
49720 }
49721 return;
49722 }
49723 if (ai[3] == -4f)
49724 {
49725 ai[2] += 1f;
49726 velocity.Y += 0.1f;
49727 if (velocity.Length() > 4f)
49728 {
49729 velocity *= 0.9f;
49730 }
49731 int num36 = (int)base.Center.X / 16;
49732 int num37 = (int)(position.Y + (float)height + 12f) / 16;
49733 bool flag4 = false;
49734 for (int l = num36 - 1; l <= num36 + 1; l++)
49735 {
49736 if (Main.tile[l, num37] == null)
49737 {
49738 Main.tile[num36, num37] = new Tile();
49739 }
49740 if (Main.tile[l, num37].active() && Main.tileSolid[Main.tile[l, num37].type])
49741 {
49742 flag4 = true;
49743 }
49744 }
49745 if (flag4 && !Collision.SolidCollision(position, width, height))
49746 {
49747 ai[3] = 0f;
49748 ai[2] = 0f;
49749 }
49750 else if (ai[2] > 300f || base.Center.Y > Main.player[target].Center.Y + 200f)
49751 {
49752 ai[3] = -1f;
49753 ai[2] = 0f;
49754 }
49755 }
49756 else
49757 {
49758 if (ai[3] == 1f)
49759 {
49760 Vector2 center7 = base.Center;
49761 center7.Y -= 70f;
49762 velocity.X *= 0.8f;
49763 ai[2] += 1f;
49764 if (ai[2] == 60f)
49765 {
49766 if (Main.netMode != 1)
49767 {
49768 NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)center7.X, (int)center7.Y + 18, 472);
49769 }
49770 }
49771 else if (ai[2] >= 90f)
49772 {
49773 ai[3] = -2f;
49774 ai[2] = 0f;
49775 }
49776 for (int m = 0; m < 2; m++)
49777 {
49779 Vector2 vector14 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
49780 vector14.Normalize();
49781 vector14 *= (float)Main.rand.Next(0, 100) * 0.1f;
49783 vector14.Normalize();
49784 vector14 *= (float)Main.rand.Next(50, 90) * 0.1f;
49785 int num38 = Dust.NewDust(vector15, 1, 1, 27);
49786 Main.dust[num38].velocity = -vector14 * 0.3f;
49787 Main.dust[num38].alpha = 100;
49788 if (Main.rand.Next(2) == 0)
49789 {
49790 Main.dust[num38].noGravity = true;
49791 Main.dust[num38].scale += 0.3f;
49792 }
49793 }
49794 return;
49795 }
49796 ai[2] += 1f;
49797 int num39 = 10;
49798 if (velocity.Y == 0f && CountNPCS(472) < num39)
49799 {
49800 if (ai[2] >= 180f)
49801 {
49802 ai[2] = 0f;
49803 ai[3] = 1f;
49804 }
49805 }
49806 else
49807 {
49808 if (CountNPCS(472) >= num39)
49809 {
49810 ai[2] += 1f;
49811 }
49812 if (ai[2] >= 360f)
49813 {
49814 ai[2] = 0f;
49815 ai[3] = -2f;
49816 velocity.Y -= 3f;
49817 }
49818 }
49819 if (target >= 0 && !Main.player[target].dead && (Main.player[target].Center - base.Center).Length() > 800f)
49820 {
49821 ai[3] = -1f;
49822 ai[2] = 0f;
49823 }
49824 }
49825 if (Main.player[target].dead)
49826 {
49827 TargetClosest();
49828 if (Main.player[target].dead)
49829 {
49831 }
49832 }
49833 }
49834 if (type == 419)
49835 {
49836 reflectsProjectiles = false;
49838 int num40 = 6;
49839 int num41 = 10;
49840 float num42 = 16f;
49841 if (ai[2] > 0f)
49842 {
49843 ai[2] -= 1f;
49844 }
49845 if (ai[2] == 0f)
49846 {
49847 if (((Main.player[target].Center.X < base.Center.X && direction < 0) || (Main.player[target].Center.X > base.Center.X && direction > 0)) && Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
49848 {
49849 ai[2] = -1f;
49850 netUpdate = true;
49851 TargetClosest();
49852 }
49853 }
49854 else
49855 {
49856 if (ai[2] < 0f && ai[2] > (float)(-num40))
49857 {
49858 ai[2] -= 1f;
49859 velocity.X *= 0.9f;
49860 return;
49861 }
49862 if (ai[2] == (float)(-num40))
49863 {
49864 ai[2] -= 1f;
49865 TargetClosest();
49866 Vector2 vector16 = DirectionTo(Main.player[target].Top + new Vector2(0f, -30f));
49867 if (vector16.HasNaNs())
49868 {
49870 }
49872 netUpdate = true;
49873 return;
49874 }
49875 if (ai[2] < (float)(-num40))
49876 {
49877 ai[2] -= 1f;
49878 if (velocity.Y == 0f)
49879 {
49880 ai[2] = 60f;
49881 }
49882 else if (ai[2] < (float)(-num40 - num41))
49883 {
49884 velocity.Y += 0.15f;
49885 if (velocity.Y > 24f)
49886 {
49887 velocity.Y = 24f;
49888 }
49889 }
49890 reflectsProjectiles = true;
49892 if (justHit)
49893 {
49894 ai[2] = 60f;
49895 netUpdate = true;
49896 }
49897 return;
49898 }
49899 }
49900 }
49901 if (type == 415)
49902 {
49903 int num43 = 42;
49904 int num44 = 18;
49905 if (justHit)
49906 {
49907 ai[2] = 120f;
49908 netUpdate = true;
49909 }
49910 if (ai[2] > 0f)
49911 {
49912 ai[2] -= 1f;
49913 }
49914 if (ai[2] == 0f)
49915 {
49916 int num45 = 0;
49917 for (int n = 0; n < 200; n++)
49918 {
49919 if (Main.npc[n].active && Main.npc[n].type == 516)
49920 {
49921 num45++;
49922 }
49923 }
49924 if (num45 > 6)
49925 {
49926 ai[2] = 90f;
49927 }
49928 else if (((Main.player[target].Center.X < base.Center.X && direction < 0) || (Main.player[target].Center.X > base.Center.X && direction > 0)) && Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
49929 {
49930 ai[2] = -1f;
49931 netUpdate = true;
49932 TargetClosest();
49933 }
49934 }
49935 else if (ai[2] < 0f && ai[2] > (float)(-num43))
49936 {
49937 ai[2] -= 1f;
49938 if (ai[2] == (float)(-num43))
49939 {
49940 ai[2] = 180 + 30 * Main.rand.Next(10);
49941 }
49942 velocity.X *= 0.8f;
49943 if (ai[2] == (float)(-num44) || ai[2] == (float)(-num44 - 8) || ai[2] == (float)(-num44 - 16))
49944 {
49946 for (int num46 = 0; num46 < 20; num46++)
49947 {
49948 Vector2 vector17 = base.Center + Vector2.UnitX * spriteDirection * 40f;
49949 Dust obj3 = Main.dust[Dust.NewDust(vector17, 0, 0, 259)];
49950 Vector2 vector18 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
49951 obj3.position = vector17 + vector18 * 4f;
49952 obj3.velocity = vector18 * 2f + Vector2.UnitX * Main.rand.NextFloat() * spriteDirection * 3f;
49953 obj3.scale = 0.3f + vector18.X * (float)(-spriteDirection);
49954 obj3.fadeIn = 0.7f;
49955 obj3.noGravity = true;
49956 }
49958 if (velocity.X > -0.5f && velocity.X < 0.5f)
49959 {
49960 velocity.X = 0f;
49961 }
49962 if (Main.netMode != 1)
49963 {
49964 NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)base.Center.X + spriteDirection * 45, (int)base.Center.Y + 8, 516, 0, 0f, 0f, 0f, 0f, target);
49965 }
49966 }
49967 return;
49968 }
49969 }
49970 if (type == 428)
49971 {
49972 localAI[0] += 1f;
49973 if (localAI[0] >= 300f)
49974 {
49975 int num47 = (int)base.Center.X / 16 - 1;
49976 int num48 = (int)base.Center.Y / 16 - 1;
49977 if (!Collision.SolidTiles(num47, num47 + 2, num48, num48 + 1) && Main.netMode != 1)
49978 {
49979 Transform(427);
49980 life = lifeMax;
49981 localAI[0] = 0f;
49982 return;
49983 }
49984 }
49985 int num49 = 0;
49986 num49 = ((localAI[0] < 60f) ? 16 : ((localAI[0] < 120f) ? 8 : ((localAI[0] < 180f) ? 4 : ((localAI[0] < 240f) ? 2 : ((!(localAI[0] < 300f)) ? 1 : 1)))));
49987 if (Main.rand.Next(num49) == 0)
49988 {
49990 Dust dust4 = Main.dust[Dust.NewDust(position, width, height, 229)];
49991 dust4.noGravity = true;
49992 dust4.scale = 1f;
49993 dust4.noLight = true;
49994 dust4.velocity = DirectionFrom(dust4.position) * dust4.velocity.Length();
49995 dust4.position -= dust4.velocity * 5f;
49996 dust4.position.X += direction * 6;
49997 dust4.position.Y += 4f;
49999 }
50000 }
50001 if (type == 427)
50002 {
50003 localAI[0] += 1f;
50004 localAI[0] += Math.Abs(velocity.X) / 2f;
50005 if (localAI[0] >= 1200f && Main.netMode != 1)
50006 {
50007 int num50 = (int)base.Center.X / 16 - 2;
50008 int num51 = (int)base.Center.Y / 16 - 3;
50009 if (!Collision.SolidTiles(num50, num50 + 4, num51, num51 + 4))
50010 {
50011 Transform(426);
50012 life = lifeMax;
50013 localAI[0] = 0f;
50014 return;
50015 }
50016 }
50017 int num52 = 0;
50018 num52 = ((localAI[0] < 360f) ? 32 : ((localAI[0] < 720f) ? 16 : ((localAI[0] < 1080f) ? 6 : ((localAI[0] < 1440f) ? 2 : ((!(localAI[0] < 1800f)) ? 1 : 1)))));
50019 if (Main.rand.Next(num52) == 0)
50020 {
50022 Dust obj4 = Main.dust[Dust.NewDust(position, width, height, 229)];
50023 obj4.noGravity = true;
50024 obj4.scale = 1f;
50025 obj4.noLight = true;
50027 }
50028 }
50029 if (type == 590)
50030 {
50032 int num53 = (int)(position.Y + 6f) / 16;
50033 if (spriteDirection < 0)
50034 {
50035 int num54 = (int)(base.Center.X - 22f) / 16;
50036 Tile tileSafely = Framing.GetTileSafely(num54, num53);
50037 Tile tileSafely2 = Framing.GetTileSafely(num54 + 1, num53);
50038 if (WorldGen.InWorld(num54, num53) && tileSafely2.liquid == 0 && tileSafely.liquid == 0)
50039 {
50040 Lighting.AddLight(num54, num53, 1f, 0.95f, 0.8f);
50041 if (Main.rand.Next(30) == 0)
50042 {
50043 Dust.NewDust(new Vector2(base.Center.X - 22f, position.Y + 6f), 1, 1, 6);
50044 }
50045 }
50046 }
50047 else
50048 {
50049 int num55 = (int)(base.Center.X + 14f) / 16;
50050 Tile tileSafely3 = Framing.GetTileSafely(num55, num53);
50051 Tile tileSafely4 = Framing.GetTileSafely(num55 - 1, num53);
50052 if (WorldGen.InWorld(num55, num53) && tileSafely4.liquid == 0 && tileSafely3.liquid == 0)
50053 {
50054 Lighting.AddLight(num55, num53, 1f, 0.95f, 0.8f);
50055 if (Main.rand.Next(30) == 0)
50056 {
50057 Dust.NewDust(new Vector2(base.Center.X + 14f, position.Y + 6f), 1, 1, 6);
50058 }
50059 }
50060 }
50062 }
50063 else if (type == 591)
50064 {
50066 if (!wet)
50067 {
50068 if (spriteDirection < 0)
50069 {
50070 Lighting.AddLight(new Vector2(base.Center.X - 36f, position.Y + 24f), 1f, 0.95f, 0.8f);
50071 if (ai[2] == 0f && Main.rand.Next(30) == 0)
50072 {
50073 Dust.NewDust(new Vector2(base.Center.X - 36f, position.Y + 24f), 1, 1, 6);
50074 }
50075 }
50076 else
50077 {
50078 Lighting.AddLight(new Vector2(base.Center.X + 28f, position.Y + 24f), 1f, 0.95f, 0.8f);
50079 if (ai[2] == 0f && Main.rand.Next(30) == 0)
50080 {
50081 Dust.NewDust(new Vector2(base.Center.X + 28f, position.Y + 24f), 1, 1, 6);
50082 }
50083 }
50084 }
50086 }
50087 bool flag5 = false;
50088 bool flag6 = false;
50089 if (velocity.X == 0f)
50090 {
50091 flag6 = true;
50092 }
50093 if (justHit)
50094 {
50095 flag6 = false;
50096 }
50097 if (Main.netMode != 1 && type == 198 && (double)life <= (double)lifeMax * 0.55)
50098 {
50099 Transform(199);
50100 }
50101 if (Main.netMode != 1 && type == 348 && (double)life <= (double)lifeMax * 0.55)
50102 {
50103 Transform(349);
50104 }
50105 int num56 = 60;
50106 if (type == 120)
50107 {
50108 num56 = 180;
50109 if (ai[3] == -120f)
50110 {
50111 velocity *= 0f;
50112 ai[3] = 0f;
50115 Vector2 vector19 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
50116 float num57 = oldPos[2].X + (float)width * 0.5f - vector19.X;
50117 float num58 = oldPos[2].Y + (float)height * 0.5f - vector19.Y;
50118 float num59 = (float)Math.Sqrt(num57 * num57 + num58 * num58);
50119 num59 = 2f / num59;
50120 num57 *= num59;
50121 num58 *= num59;
50122 for (int num60 = 0; num60 < 20; num60++)
50123 {
50124 int num61 = Dust.NewDust(position, width, height, 71, num57, num58, 200, default(Color), 2f);
50125 Main.dust[num61].noGravity = true;
50126 Main.dust[num61].velocity.X *= 2f;
50127 }
50128 for (int num62 = 0; num62 < 20; num62++)
50129 {
50130 int num63 = Dust.NewDust(oldPos[2], width, height, 71, 0f - num57, 0f - num58, 200, default(Color), 2f);
50131 Main.dust[num63].noGravity = true;
50132 Main.dust[num63].velocity.X *= 2f;
50133 }
50135 }
50136 }
50137 bool flag7 = false;
50138 bool flag8 = true;
50139 if (type == 343 || type == 47 || type == 67 || type == 109 || type == 110 || type == 111 || type == 120 || type == 163 || type == 164 || type == 239 || type == 168 || type == 199 || type == 206 || type == 214 || type == 215 || type == 216 || type == 217 || type == 218 || type == 219 || type == 220 || type == 226 || type == 243 || type == 251 || type == 257 || type == 258 || type == 290 || type == 291 || type == 292 || type == 293 || type == 305 || type == 306 || type == 307 || type == 308 || type == 309 || type == 348 || type == 349 || type == 350 || type == 351 || type == 379 || (type >= 430 && type <= 436) || type == 591 || type == 380 || type == 381 || type == 382 || type == 383 || type == 386 || type == 391 || (type >= 449 && type <= 452) || type == 466 || type == 464 || type == 166 || type == 469 || type == 468 || type == 471 || type == 470 || type == 480 || type == 481 || type == 482 || type == 411 || type == 424 || type == 409 || (type >= 494 && type <= 506) || type == 425 || type == 427 || type == 426 || type == 428 || type == 580 || type == 508 || type == 415 || type == 419 || type == 520 || (type >= 524 && type <= 527) || type == 528 || type == 529 || type == 530 || type == 532 || type == 582 || type == 624 || type == 631)
50140 {
50141 flag8 = false;
50142 }
50143 bool flag9 = false;
50144 int num64 = type;
50145 if (num64 == 425 || num64 == 471)
50146 {
50147 flag9 = true;
50148 }
50149 bool flag10 = true;
50150 switch (type)
50151 {
50152 case 110:
50153 case 111:
50154 case 206:
50155 case 214:
50156 case 215:
50157 case 216:
50158 case 291:
50159 case 292:
50160 case 293:
50161 case 350:
50162 case 379:
50163 case 380:
50164 case 381:
50165 case 382:
50166 case 409:
50167 case 411:
50168 case 424:
50169 case 426:
50170 case 466:
50171 case 498:
50172 case 499:
50173 case 500:
50174 case 501:
50175 case 502:
50176 case 503:
50177 case 504:
50178 case 505:
50179 case 506:
50180 case 520:
50181 if (ai[2] > 0f)
50182 {
50183 flag10 = false;
50184 }
50185 break;
50186 }
50187 if (!flag9 && flag10)
50188 {
50189 if (velocity.Y == 0f && ((velocity.X > 0f && direction < 0) || (velocity.X < 0f && direction > 0)))
50190 {
50191 flag7 = true;
50192 }
50193 if (position.X == oldPosition.X || ai[3] >= (float)num56 || flag7)
50194 {
50195 ai[3] += 1f;
50196 }
50197 else if ((double)Math.Abs(velocity.X) > 0.9 && ai[3] > 0f)
50198 {
50199 ai[3] -= 1f;
50200 }
50201 if (ai[3] > (float)(num56 * 10))
50202 {
50203 ai[3] = 0f;
50204 }
50205 if (justHit)
50206 {
50207 ai[3] = 0f;
50208 }
50209 if (ai[3] == (float)num56)
50210 {
50211 netUpdate = true;
50212 }
50213 if (Main.player[target].Hitbox.Intersects(base.Hitbox))
50214 {
50215 ai[3] = 0f;
50216 }
50217 }
50218 if (type == 463 && Main.netMode != 1)
50219 {
50220 if (localAI[3] > 0f)
50221 {
50222 localAI[3] -= 1f;
50223 }
50224 if (justHit && localAI[3] <= 0f && Main.rand.Next(3) == 0)
50225 {
50226 localAI[3] = 30f;
50227 int num65 = Main.rand.Next(3, 6);
50228 int[] array = new int[num65];
50229 int num66 = 0;
50230 for (int num67 = 0; num67 < 255; num67++)
50231 {
50232 if (Main.player[num67].active && !Main.player[num67].dead && Collision.CanHitLine(position, width, height, Main.player[num67].position, Main.player[num67].width, Main.player[num67].height))
50233 {
50234 array[num66] = num67;
50235 num66++;
50236 if (num66 == num65)
50237 {
50238 break;
50239 }
50240 }
50241 }
50242 if (num66 > 1)
50243 {
50244 for (int num68 = 0; num68 < 100; num68++)
50245 {
50246 int num69 = Main.rand.Next(num66);
50247 int num70;
50248 for (num70 = num69; num70 == num69; num70 = Main.rand.Next(num66))
50249 {
50250 }
50251 int num71 = array[num69];
50252 array[num69] = array[num70];
50253 array[num70] = num71;
50254 }
50255 }
50256 Vector2 vector20 = new Vector2(-1f, -1f);
50257 for (int num72 = 0; num72 < num66; num72++)
50258 {
50259 Vector2 vector21 = Main.npc[array[num72]].Center - base.Center;
50260 vector21.Normalize();
50261 vector20 += vector21;
50262 }
50263 vector20.Normalize();
50264 for (int num73 = 0; num73 < num65; num73++)
50265 {
50266 float num74 = Main.rand.Next(8, 13);
50267 Vector2 vector22 = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
50268 vector22.Normalize();
50269 if (num66 > 0)
50270 {
50271 vector22 += vector20;
50272 vector22.Normalize();
50273 }
50274 vector22 *= num74;
50275 if (num66 > 0)
50276 {
50277 num66--;
50278 vector22 = Main.player[array[num66]].Center - base.Center;
50279 vector22.Normalize();
50280 vector22 *= num74;
50281 }
50282 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X, position.Y + (float)(width / 4), vector22.X, vector22.Y, 498, (int)((double)damage * 0.15), 1f, Main.myPlayer);
50283 }
50284 }
50285 }
50286 if (type == 460)
50287 {
50288 if (velocity.Y < 0f - gravity || velocity.Y > gravity)
50289 {
50290 knockBackResist = 0f;
50291 }
50292 else
50293 {
50294 knockBackResist = 0.25f * Main.GameModeInfo.KnockbackToEnemiesMultiplier;
50295 }
50296 }
50297 if (type == 469)
50298 {
50299 knockBackResist = 0.45f * Main.GameModeInfo.KnockbackToEnemiesMultiplier;
50300 if (ai[2] == 1f)
50301 {
50302 knockBackResist = 0f;
50303 }
50304 bool flag11 = false;
50305 int num75 = (int)base.Center.X / 16;
50306 int num76 = (int)base.Center.Y / 16;
50307 for (int num77 = num75 - 1; num77 <= num75 + 1; num77++)
50308 {
50309 for (int num78 = num76 - 1; num78 <= num76 + 1; num78++)
50310 {
50311 if (Main.tile[num77, num78] != null && Main.tile[num77, num78].wall > 0)
50312 {
50313 flag11 = true;
50314 break;
50315 }
50316 }
50317 if (flag11)
50318 {
50319 break;
50320 }
50321 }
50322 if (ai[2] == 0f && flag11)
50323 {
50324 if (velocity.Y == 0f)
50325 {
50326 flag = true;
50327 velocity.Y = -4.6f;
50328 velocity.X *= 1.3f;
50329 }
50330 else if (velocity.Y > 0f && !Main.player[target].dead)
50331 {
50332 ai[2] = 1f;
50333 }
50334 }
50335 if (flag11 && ai[2] == 1f && !Main.player[target].dead && Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
50336 {
50337 Vector2 vector23 = Main.player[target].Center - base.Center;
50338 float num79 = vector23.Length();
50339 vector23.Normalize();
50340 vector23 *= 4.5f + num79 / 300f;
50341 velocity = (velocity * 29f + vector23) / 30f;
50342 noGravity = true;
50343 ai[2] = 1f;
50344 return;
50345 }
50346 noGravity = false;
50347 ai[2] = 0f;
50348 }
50349 if (type == 462 && velocity.Y == 0f && (Main.player[target].Center - base.Center).Length() < 150f && Math.Abs(velocity.X) > 3f && ((velocity.X < 0f && base.Center.X > Main.player[target].Center.X) || (velocity.X > 0f && base.Center.X < Main.player[target].Center.X)))
50350 {
50351 flag = true;
50352 velocity.X *= 1.75f;
50353 velocity.Y -= 4.5f;
50354 if (base.Center.Y - Main.player[target].Center.Y > 20f)
50355 {
50356 velocity.Y -= 0.5f;
50357 }
50358 if (base.Center.Y - Main.player[target].Center.Y > 40f)
50359 {
50360 velocity.Y -= 1f;
50361 }
50362 if (base.Center.Y - Main.player[target].Center.Y > 80f)
50363 {
50364 velocity.Y -= 1.5f;
50365 }
50366 if (base.Center.Y - Main.player[target].Center.Y > 100f)
50367 {
50368 velocity.Y -= 1.5f;
50369 }
50370 if (Math.Abs(velocity.X) > 7f)
50371 {
50372 if (velocity.X < 0f)
50373 {
50374 velocity.X = -7f;
50375 }
50376 else
50377 {
50378 velocity.X = 7f;
50379 }
50380 }
50381 }
50382 if (type == 624 && target < 255)
50383 {
50384 if (!Main.remixWorld && !Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
50385 {
50386 ai[3] = num56;
50387 directionY = -1;
50388 if (type == 624 && !AI_003_Gnomes_ShouldTurnToStone() && (base.Center - Main.player[target].Center).Length() > 500f)
50389 {
50390 velocity.X *= 0.95f;
50391 if ((double)velocity.X > -0.1 && (double)velocity.X < 0.1)
50392 {
50393 velocity.X = 0f;
50394 }
50395 return;
50396 }
50397 }
50398 else if (Main.player[target].Center.Y > base.Center.Y - 128f)
50399 {
50400 ai[3] = 0f;
50401 }
50402 }
50404 {
50405 if (shimmerTransparency < 1f)
50406 {
50407 if ((type == 3 || type == 591 || type == 590 || type == 331 || type == 332 || type == 21 || (type >= 449 && type <= 452) || type == 31 || type == 294 || type == 295 || type == 296 || type == 77 || type == 110 || type == 132 || type == 167 || type == 161 || type == 162 || type == 186 || type == 187 || type == 188 || type == 189 || type == 197 || type == 200 || type == 201 || type == 202 || type == 203 || type == 223 || type == 291 || type == 292 || type == 293 || type == 320 || type == 321 || type == 319 || type == 481 || type == 632 || type == 635) && Main.rand.Next(1000) == 0)
50408 {
50409 SoundEngine.PlaySound(14, (int)position.X, (int)position.Y);
50410 }
50411 if ((type == 489 || type == 586) && Main.rand.Next(800) == 0)
50412 {
50413 SoundEngine.PlaySound(14, (int)position.X, (int)position.Y, type);
50414 }
50415 if ((type == 78 || type == 79 || type == 80 || type == 630) && Main.rand.Next(500) == 0)
50416 {
50417 SoundEngine.PlaySound(26, (int)position.X, (int)position.Y);
50418 }
50419 if (type == 159 && Main.rand.Next(500) == 0)
50420 {
50421 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, 7);
50422 }
50423 if (type == 162 && Main.rand.Next(500) == 0)
50424 {
50425 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, 6);
50426 }
50427 if (type == 181 && Main.rand.Next(500) == 0)
50428 {
50429 SoundEngine.PlaySound(29, (int)position.X, (int)position.Y, 8);
50430 }
50431 if (type >= 269 && type <= 280 && Main.rand.Next(1000) == 0)
50432 {
50433 SoundEngine.PlaySound(14, (int)position.X, (int)position.Y);
50434 }
50435 }
50436 TargetClosest();
50437 if (directionY > 0 && Main.player[target].Center.Y <= base.Bottom.Y)
50438 {
50439 directionY = -1;
50440 }
50441 }
50443 {
50444 if (Main.IsItDay() && (double)(position.Y / 16f) < Main.worldSurface && type != 624 && type != 631)
50445 {
50446 EncourageDespawn(10);
50447 }
50448 if (velocity.X == 0f)
50449 {
50450 if (velocity.Y == 0f)
50451 {
50452 ai[0] += 1f;
50453 if (ai[0] >= 2f)
50454 {
50455 direction *= -1;
50457 ai[0] = 0f;
50458 }
50459 }
50460 }
50461 else
50462 {
50463 ai[0] = 0f;
50464 }
50465 if (direction == 0)
50466 {
50467 direction = 1;
50468 }
50469 }
50470 if (type == 159 || type == 349)
50471 {
50472 if (type == 159 && ((velocity.X > 0f && direction < 0) || (velocity.X < 0f && direction > 0)))
50473 {
50474 velocity.X *= 0.95f;
50475 }
50476 if (velocity.X < -6f || velocity.X > 6f)
50477 {
50478 if (velocity.Y == 0f)
50479 {
50480 velocity *= 0.8f;
50481 }
50482 }
50483 else if (velocity.X < 6f && direction == 1)
50484 {
50485 if (velocity.Y == 0f && velocity.X < 0f)
50486 {
50487 velocity.X *= 0.99f;
50488 }
50489 velocity.X += 0.07f;
50490 if (velocity.X > 6f)
50491 {
50492 velocity.X = 6f;
50493 }
50494 }
50495 else if (velocity.X > -6f && direction == -1)
50496 {
50497 if (velocity.Y == 0f && velocity.X > 0f)
50498 {
50499 velocity.X *= 0.99f;
50500 }
50501 velocity.X -= 0.07f;
50502 if (velocity.X < -6f)
50503 {
50504 velocity.X = -6f;
50505 }
50506 }
50507 }
50508 else if (type == 199)
50509 {
50510 if (velocity.X < -4f || velocity.X > 4f)
50511 {
50512 if (velocity.Y == 0f)
50513 {
50514 velocity *= 0.8f;
50515 }
50516 }
50517 else if (velocity.X < 4f && direction == 1)
50518 {
50519 if (velocity.Y == 0f && velocity.X < 0f)
50520 {
50521 velocity.X *= 0.8f;
50522 }
50523 velocity.X += 0.1f;
50524 if (velocity.X > 4f)
50525 {
50526 velocity.X = 4f;
50527 }
50528 }
50529 else if (velocity.X > -4f && direction == -1)
50530 {
50531 if (velocity.Y == 0f && velocity.X > 0f)
50532 {
50533 velocity.X *= 0.8f;
50534 }
50535 velocity.X -= 0.1f;
50536 if (velocity.X < -4f)
50537 {
50538 velocity.X = -4f;
50539 }
50540 }
50541 }
50542 else if (type == 120 || type == 166 || type == 213 || type == 258 || type == 528 || type == 529)
50543 {
50544 if (velocity.X < -3f || velocity.X > 3f)
50545 {
50546 if (velocity.Y == 0f)
50547 {
50548 velocity *= 0.8f;
50549 }
50550 }
50551 else if (velocity.X < 3f && direction == 1)
50552 {
50553 if (velocity.Y == 0f && velocity.X < 0f)
50554 {
50555 velocity.X *= 0.99f;
50556 }
50557 velocity.X += 0.07f;
50558 if (velocity.X > 3f)
50559 {
50560 velocity.X = 3f;
50561 }
50562 }
50563 else if (velocity.X > -3f && direction == -1)
50564 {
50565 if (velocity.Y == 0f && velocity.X > 0f)
50566 {
50567 velocity.X *= 0.99f;
50568 }
50569 velocity.X -= 0.07f;
50570 if (velocity.X < -3f)
50571 {
50572 velocity.X = -3f;
50573 }
50574 }
50575 }
50576 else if (type == 461 || type == 27 || type == 77 || type == 104 || type == 163 || type == 162 || type == 196 || type == 197 || type == 212 || type == 257 || type == 326 || type == 343 || type == 348 || type == 351 || (type >= 524 && type <= 527) || type == 530 || type == 236)
50577 {
50578 if (velocity.X < -2f || velocity.X > 2f)
50579 {
50580 if (velocity.Y == 0f)
50581 {
50582 velocity *= 0.8f;
50583 }
50584 }
50585 else if (velocity.X < 2f && direction == 1)
50586 {
50587 velocity.X += 0.07f;
50588 if (velocity.X > 2f)
50589 {
50590 velocity.X = 2f;
50591 }
50592 }
50593 else if (velocity.X > -2f && direction == -1)
50594 {
50595 velocity.X -= 0.07f;
50596 if (velocity.X < -2f)
50597 {
50598 velocity.X = -2f;
50599 }
50600 }
50601 }
50602 else if (type == 109)
50603 {
50604 if (velocity.X < -2f || velocity.X > 2f)
50605 {
50606 if (velocity.Y == 0f)
50607 {
50608 velocity *= 0.8f;
50609 }
50610 }
50611 else if (velocity.X < 2f && direction == 1)
50612 {
50613 velocity.X += 0.04f;
50614 if (velocity.X > 2f)
50615 {
50616 velocity.X = 2f;
50617 }
50618 }
50619 else if (velocity.X > -2f && direction == -1)
50620 {
50621 velocity.X -= 0.04f;
50622 if (velocity.X < -2f)
50623 {
50624 velocity.X = -2f;
50625 }
50626 }
50627 }
50628 else if (type == 21 || type == 26 || type == 31 || type == 294 || type == 295 || type == 296 || type == 47 || type == 73 || type == 140 || type == 164 || type == 239 || type == 167 || type == 168 || type == 185 || type == 198 || type == 201 || type == 202 || type == 203 || type == 217 || type == 218 || type == 219 || type == 226 || type == 181 || type == 254 || type == 338 || type == 339 || type == 340 || type == 342 || type == 385 || type == 389 || type == 462 || type == 463 || type == 466 || type == 464 || type == 469 || type == 470 || type == 480 || type == 482 || type == 425 || type == 429 || type == 586 || type == 631 || type == 635)
50629 {
50630 float num80 = 1.5f;
50631 if (type == 181 && Main.remixWorld)
50632 {
50633 num80 = 3.75f;
50634 }
50635 else if (type == 294)
50636 {
50637 num80 = 2f;
50638 }
50639 else if (type == 295)
50640 {
50641 num80 = 1.75f;
50642 }
50643 else if (type == 296)
50644 {
50645 num80 = 1.25f;
50646 }
50647 else if (type == 201)
50648 {
50649 num80 = 1.1f;
50650 }
50651 else if (type == 202)
50652 {
50653 num80 = 0.9f;
50654 }
50655 else if (type == 203)
50656 {
50657 num80 = 1.2f;
50658 }
50659 else if (type == 338)
50660 {
50661 num80 = 1.75f;
50662 }
50663 else if (type == 339)
50664 {
50665 num80 = 1.25f;
50666 }
50667 else if (type == 340)
50668 {
50669 num80 = 2f;
50670 }
50671 else if (type == 385)
50672 {
50673 num80 = 1.8f;
50674 }
50675 else if (type == 389)
50676 {
50677 num80 = 2.25f;
50678 }
50679 else if (type == 462)
50680 {
50681 num80 = 4f;
50682 }
50683 else if (type == 463)
50684 {
50685 num80 = 0.75f;
50686 }
50687 else if (type == 466)
50688 {
50689 num80 = 3.75f;
50690 }
50691 else if (type == 469)
50692 {
50693 num80 = 3.25f;
50694 }
50695 else if (type == 480)
50696 {
50697 num80 = 1.5f + (1f - (float)life / (float)lifeMax) * 2f;
50698 }
50699 else if (type == 425)
50700 {
50701 num80 = 6f;
50702 }
50703 else if (type == 429)
50704 {
50705 num80 = 4f;
50706 }
50707 else if (type == 631)
50708 {
50709 num80 = 0.9f;
50710 }
50711 else if (type == 586)
50712 {
50713 num80 = 1.5f + (1f - (float)life / (float)lifeMax) * 3.5f;
50714 }
50715 if (type == 21 || type == 201 || type == 202 || type == 203 || type == 342 || type == 635)
50716 {
50717 num80 *= 1f + (1f - scale);
50718 }
50719 if (velocity.X < 0f - num80 || velocity.X > num80)
50720 {
50721 if (velocity.Y == 0f)
50722 {
50723 velocity *= 0.8f;
50724 }
50725 }
50726 else if (velocity.X < num80 && direction == 1)
50727 {
50728 if (type == 466 && velocity.X < -2f)
50729 {
50730 velocity.X *= 0.9f;
50731 }
50732 if (type == 586 && velocity.Y == 0f && velocity.X < -1f)
50733 {
50734 velocity.X *= 0.9f;
50735 }
50736 velocity.X += 0.07f;
50737 if (velocity.X > num80)
50738 {
50739 velocity.X = num80;
50740 }
50741 }
50742 else if (velocity.X > 0f - num80 && direction == -1)
50743 {
50744 if (type == 466 && velocity.X > 2f)
50745 {
50746 velocity.X *= 0.9f;
50747 }
50748 if (type == 586 && velocity.Y == 0f && velocity.X > 1f)
50749 {
50750 velocity.X *= 0.9f;
50751 }
50752 velocity.X -= 0.07f;
50753 if (velocity.X < 0f - num80)
50754 {
50755 velocity.X = 0f - num80;
50756 }
50757 }
50758 if (velocity.Y == 0f && type == 462 && ((direction > 0 && velocity.X < 0f) || (direction < 0 && velocity.X > 0f)))
50759 {
50760 velocity.X *= 0.9f;
50761 }
50762 }
50763 else if (type >= 269 && type <= 280)
50764 {
50765 float num81 = 1.5f;
50766 if (type == 269)
50767 {
50768 num81 = 2f;
50769 }
50770 if (type == 270)
50771 {
50772 num81 = 1f;
50773 }
50774 if (type == 271)
50775 {
50776 num81 = 1.5f;
50777 }
50778 if (type == 272)
50779 {
50780 num81 = 3f;
50781 }
50782 if (type == 273)
50783 {
50784 num81 = 1.25f;
50785 }
50786 if (type == 274)
50787 {
50788 num81 = 3f;
50789 }
50790 if (type == 275)
50791 {
50792 num81 = 3.25f;
50793 }
50794 if (type == 276)
50795 {
50796 num81 = 2f;
50797 }
50798 if (type == 277)
50799 {
50800 num81 = 2.75f;
50801 }
50802 if (type == 278)
50803 {
50804 num81 = 1.8f;
50805 }
50806 if (type == 279)
50807 {
50808 num81 = 1.3f;
50809 }
50810 if (type == 280)
50811 {
50812 num81 = 2.5f;
50813 }
50814 num81 *= 1f + (1f - scale);
50815 if (velocity.X < 0f - num81 || velocity.X > num81)
50816 {
50817 if (velocity.Y == 0f)
50818 {
50819 velocity *= 0.8f;
50820 }
50821 }
50822 else if (velocity.X < num81 && direction == 1)
50823 {
50824 velocity.X += 0.07f;
50825 if (velocity.X > num81)
50826 {
50827 velocity.X = num81;
50828 }
50829 }
50830 else if (velocity.X > 0f - num81 && direction == -1)
50831 {
50832 velocity.X -= 0.07f;
50833 if (velocity.X < 0f - num81)
50834 {
50835 velocity.X = 0f - num81;
50836 }
50837 }
50838 }
50839 else if (type >= 305 && type <= 314)
50840 {
50841 float num82 = 1.5f;
50842 if (type == 305 || type == 310)
50843 {
50844 num82 = 2f;
50845 }
50846 if (type == 306 || type == 311)
50847 {
50848 num82 = 1.25f;
50849 }
50850 if (type == 307 || type == 312)
50851 {
50852 num82 = 2.25f;
50853 }
50854 if (type == 308 || type == 313)
50855 {
50856 num82 = 1.5f;
50857 }
50858 if (type == 309 || type == 314)
50859 {
50860 num82 = 1f;
50861 }
50862 if (type < 310)
50863 {
50864 if (velocity.Y == 0f)
50865 {
50866 velocity.X *= 0.85f;
50867 if ((double)velocity.X > -0.3 && (double)velocity.X < 0.3)
50868 {
50869 flag = true;
50870 velocity.Y = -7f;
50871 velocity.X = num82 * (float)direction;
50872 }
50873 }
50874 else if (spriteDirection == direction)
50875 {
50876 velocity.X = (velocity.X * 10f + num82 * (float)direction) / 11f;
50877 }
50878 }
50879 else if (velocity.X < 0f - num82 || velocity.X > num82)
50880 {
50881 if (velocity.Y == 0f)
50882 {
50883 velocity *= 0.8f;
50884 }
50885 }
50886 else if (velocity.X < num82 && direction == 1)
50887 {
50888 velocity.X += 0.07f;
50889 if (velocity.X > num82)
50890 {
50891 velocity.X = num82;
50892 }
50893 }
50894 else if (velocity.X > 0f - num82 && direction == -1)
50895 {
50896 velocity.X -= 0.07f;
50897 if (velocity.X < 0f - num82)
50898 {
50899 velocity.X = 0f - num82;
50900 }
50901 }
50902 }
50903 else if (type == 67 || type == 220 || type == 428)
50904 {
50905 if (velocity.X < -0.5f || velocity.X > 0.5f)
50906 {
50907 if (velocity.Y == 0f)
50908 {
50909 velocity *= 0.7f;
50910 }
50911 }
50912 else if (velocity.X < 0.5f && direction == 1)
50913 {
50914 velocity.X += 0.03f;
50915 if (velocity.X > 0.5f)
50916 {
50917 velocity.X = 0.5f;
50918 }
50919 }
50920 else if (velocity.X > -0.5f && direction == -1)
50921 {
50922 velocity.X -= 0.03f;
50923 if (velocity.X < -0.5f)
50924 {
50925 velocity.X = -0.5f;
50926 }
50927 }
50928 }
50929 else if (type == 78 || type == 79 || type == 80 || type == 630)
50930 {
50931 float num83 = 1f;
50932 float num84 = 0.05f;
50933 if (life < lifeMax / 2)
50934 {
50935 num83 = 2f;
50936 num84 = 0.1f;
50937 }
50938 if (type == 79 || type == 630)
50939 {
50940 num83 *= 1.5f;
50941 }
50942 if (velocity.X < 0f - num83 || velocity.X > num83)
50943 {
50944 if (velocity.Y == 0f)
50945 {
50946 velocity *= 0.7f;
50947 }
50948 }
50949 else if (velocity.X < num83 && direction == 1)
50950 {
50951 velocity.X += num84;
50952 if (velocity.X > num83)
50953 {
50954 velocity.X = num83;
50955 }
50956 }
50957 else if (velocity.X > 0f - num83 && direction == -1)
50958 {
50959 velocity.X -= num84;
50960 if (velocity.X < 0f - num83)
50961 {
50962 velocity.X = 0f - num83;
50963 }
50964 }
50965 }
50966 else if (type == 287)
50967 {
50968 float num85 = 5f;
50969 float num86 = 0.2f;
50970 if (velocity.X < 0f - num85 || velocity.X > num85)
50971 {
50972 if (velocity.Y == 0f)
50973 {
50974 velocity *= 0.7f;
50975 }
50976 }
50977 else if (velocity.X < num85 && direction == 1)
50978 {
50979 velocity.X += num86;
50980 if (velocity.X > num85)
50981 {
50982 velocity.X = num85;
50983 }
50984 }
50985 else if (velocity.X > 0f - num85 && direction == -1)
50986 {
50987 velocity.X -= num86;
50988 if (velocity.X < 0f - num85)
50989 {
50990 velocity.X = 0f - num85;
50991 }
50992 }
50993 }
50994 else if (type == 243)
50995 {
50996 float num87 = 1f;
50997 float num88 = 0.07f;
50998 num87 += (1f - (float)life / (float)lifeMax) * 1.5f;
50999 num88 += (1f - (float)life / (float)lifeMax) * 0.15f;
51000 if (velocity.X < 0f - num87 || velocity.X > num87)
51001 {
51002 if (velocity.Y == 0f)
51003 {
51004 velocity *= 0.7f;
51005 }
51006 }
51007 else if (velocity.X < num87 && direction == 1)
51008 {
51009 velocity.X += num88;
51010 if (velocity.X > num87)
51011 {
51012 velocity.X = num87;
51013 }
51014 }
51015 else if (velocity.X > 0f - num87 && direction == -1)
51016 {
51017 velocity.X -= num88;
51018 if (velocity.X < 0f - num87)
51019 {
51020 velocity.X = 0f - num87;
51021 }
51022 }
51023 }
51024 else if (type == 251)
51025 {
51026 float num89 = 1f;
51027 float num90 = 0.08f;
51028 num89 += (1f - (float)life / (float)lifeMax) * 2f;
51029 num90 += (1f - (float)life / (float)lifeMax) * 0.2f;
51030 if (velocity.X < 0f - num89 || velocity.X > num89)
51031 {
51032 if (velocity.Y == 0f)
51033 {
51034 velocity *= 0.7f;
51035 }
51036 }
51037 else if (velocity.X < num89 && direction == 1)
51038 {
51039 velocity.X += num90;
51040 if (velocity.X > num89)
51041 {
51042 velocity.X = num89;
51043 }
51044 }
51045 else if (velocity.X > 0f - num89 && direction == -1)
51046 {
51047 velocity.X -= num90;
51048 if (velocity.X < 0f - num89)
51049 {
51050 velocity.X = 0f - num89;
51051 }
51052 }
51053 }
51054 else if (type == 386)
51055 {
51056 if (ai[2] > 0f)
51057 {
51058 if (velocity.Y == 0f)
51059 {
51060 velocity.X *= 0.8f;
51061 }
51062 }
51063 else
51064 {
51065 float num91 = 0.15f;
51066 float num92 = 1.5f;
51067 if (velocity.X < 0f - num92 || velocity.X > num92)
51068 {
51069 if (velocity.Y == 0f)
51070 {
51071 velocity *= 0.7f;
51072 }
51073 }
51074 else if (velocity.X < num92 && direction == 1)
51075 {
51076 velocity.X += num91;
51077 if (velocity.X > num92)
51078 {
51079 velocity.X = num92;
51080 }
51081 }
51082 else if (velocity.X > 0f - num92 && direction == -1)
51083 {
51084 velocity.X -= num91;
51085 if (velocity.X < 0f - num92)
51086 {
51087 velocity.X = 0f - num92;
51088 }
51089 }
51090 }
51091 }
51092 else if (type == 460)
51093 {
51094 float num93 = 3f;
51095 float num94 = 0.1f;
51096 if (Math.Abs(velocity.X) > 2f)
51097 {
51098 num94 *= 0.8f;
51099 }
51100 if ((double)Math.Abs(velocity.X) > 2.5)
51101 {
51102 num94 *= 0.8f;
51103 }
51104 if (Math.Abs(velocity.X) > 3f)
51105 {
51106 num94 *= 0.8f;
51107 }
51108 if ((double)Math.Abs(velocity.X) > 3.5)
51109 {
51110 num94 *= 0.8f;
51111 }
51112 if (Math.Abs(velocity.X) > 4f)
51113 {
51114 num94 *= 0.8f;
51115 }
51116 if ((double)Math.Abs(velocity.X) > 4.5)
51117 {
51118 num94 *= 0.8f;
51119 }
51120 if (Math.Abs(velocity.X) > 5f)
51121 {
51122 num94 *= 0.8f;
51123 }
51124 if ((double)Math.Abs(velocity.X) > 5.5)
51125 {
51126 num94 *= 0.8f;
51127 }
51128 num93 += (1f - (float)life / (float)lifeMax) * 3f;
51129 if (velocity.X < 0f - num93 || velocity.X > num93)
51130 {
51131 if (velocity.Y == 0f)
51132 {
51133 velocity *= 0.7f;
51134 }
51135 }
51136 else if (velocity.X < num93 && direction == 1)
51137 {
51138 if (velocity.X < 0f)
51139 {
51140 velocity.X *= 0.93f;
51141 }
51142 velocity.X += num94;
51143 if (velocity.X > num93)
51144 {
51145 velocity.X = num93;
51146 }
51147 }
51148 else if (velocity.X > 0f - num93 && direction == -1)
51149 {
51150 if (velocity.X > 0f)
51151 {
51152 velocity.X *= 0.93f;
51153 }
51154 velocity.X -= num94;
51155 if (velocity.X < 0f - num93)
51156 {
51157 velocity.X = 0f - num93;
51158 }
51159 }
51160 }
51161 else if (type == 508 || type == 580 || type == 582)
51162 {
51163 float num95 = 2.5f;
51164 float num96 = 10f;
51165 float num97 = Math.Abs(velocity.X);
51166 if (type == 582)
51167 {
51168 num95 = 2.25f;
51169 num96 = 7f;
51170 if (num97 > 2.5f)
51171 {
51172 num95 = 3f;
51173 num96 += 75f;
51174 }
51175 else if (num97 > 2f)
51176 {
51177 num95 = 2.75f;
51178 num96 += 55f;
51179 }
51180 }
51181 else if (num97 > 2.75f)
51182 {
51183 num95 = 3.5f;
51184 num96 += 80f;
51185 }
51186 else if ((double)num97 > 2.25)
51187 {
51188 num95 = 3f;
51189 num96 += 60f;
51190 }
51191 if ((double)Math.Abs(velocity.Y) < 0.5)
51192 {
51193 if (velocity.X > 0f && direction < 0)
51194 {
51195 velocity *= 0.95f;
51196 }
51197 if (velocity.X < 0f && direction > 0)
51198 {
51199 velocity *= 0.95f;
51200 }
51201 }
51202 if (Math.Abs(velocity.Y) > gravity)
51203 {
51204 float num98 = 3f;
51205 if (type == 582)
51206 {
51207 num98 = 2f;
51208 }
51209 num96 *= num98;
51210 }
51211 if (velocity.X <= 0f && direction < 0)
51212 {
51213 velocity.X = (velocity.X * num96 - num95) / (num96 + 1f);
51214 }
51215 else if (velocity.X >= 0f && direction > 0)
51216 {
51217 velocity.X = (velocity.X * num96 + num95) / (num96 + 1f);
51218 }
51219 else if (Math.Abs(base.Center.X - Main.player[target].Center.X) > 20f && Math.Abs(velocity.Y) <= gravity)
51220 {
51221 velocity.X *= 0.99f;
51222 velocity.X += (float)direction * 0.025f;
51223 }
51224 }
51225 else if (type == 391 || type == 427 || type == 415 || type == 419 || type == 518 || type == 532)
51226 {
51227 float num99 = 5f;
51228 float num100 = 0.25f;
51229 float num101 = 0.7f;
51230 if (type == 427)
51231 {
51232 num99 = 6f;
51233 num100 = 0.2f;
51234 num101 = 0.8f;
51235 }
51236 else if (type == 415)
51237 {
51238 num99 = 4f;
51239 num100 = 0.1f;
51240 num101 = 0.95f;
51241 }
51242 else if (type == 419)
51243 {
51244 num99 = 6f;
51245 num100 = 0.15f;
51246 num101 = 0.85f;
51247 }
51248 else if (type == 518)
51249 {
51250 num99 = 5f;
51251 num100 = 0.1f;
51252 num101 = 0.95f;
51253 }
51254 else if (type == 532)
51255 {
51256 num99 = 5f;
51257 num100 = 0.15f;
51258 num101 = 0.98f;
51259 }
51260 if (velocity.X < 0f - num99 || velocity.X > num99)
51261 {
51262 if (velocity.Y == 0f)
51263 {
51264 velocity *= num101;
51265 }
51266 }
51267 else if (velocity.X < num99 && direction == 1)
51268 {
51269 velocity.X += num100;
51270 if (velocity.X > num99)
51271 {
51272 velocity.X = num99;
51273 }
51274 }
51275 else if (velocity.X > 0f - num99 && direction == -1)
51276 {
51277 velocity.X -= num100;
51278 if (velocity.X < 0f - num99)
51279 {
51280 velocity.X = 0f - num99;
51281 }
51282 }
51283 }
51284 else if ((type >= 430 && type <= 436) || type == 494 || type == 495 || type == 591)
51285 {
51286 if (ai[2] == 0f)
51287 {
51288 damage = defDamage;
51289 float num102 = 1f;
51290 num102 *= 1f + (1f - scale);
51291 if (velocity.X < 0f - num102 || velocity.X > num102)
51292 {
51293 if (velocity.Y == 0f)
51294 {
51295 velocity *= 0.8f;
51296 }
51297 }
51298 else if (velocity.X < num102 && direction == 1)
51299 {
51300 velocity.X += 0.07f;
51301 if (velocity.X > num102)
51302 {
51303 velocity.X = num102;
51304 }
51305 }
51306 else if (velocity.X > 0f - num102 && direction == -1)
51307 {
51308 velocity.X -= 0.07f;
51309 if (velocity.X < 0f - num102)
51310 {
51311 velocity.X = 0f - num102;
51312 }
51313 }
51314 if (velocity.Y == 0f && (!Main.IsItDay() || (double)position.Y > Main.worldSurface * 16.0) && !Main.player[target].dead)
51315 {
51316 Vector2 vector24 = base.Center - Main.player[target].Center;
51317 int num103 = 50;
51318 if (type >= 494 && type <= 495)
51319 {
51320 num103 = 42;
51321 }
51322 if (vector24.Length() < (float)num103 && Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
51323 {
51324 velocity.X *= 0.7f;
51325 ai[2] = 1f;
51326 }
51327 }
51328 }
51329 else
51330 {
51331 damage = (int)((double)defDamage * 1.5);
51332 ai[3] = 1f;
51333 velocity.X *= 0.9f;
51334 if ((double)Math.Abs(velocity.X) < 0.1)
51335 {
51336 velocity.X = 0f;
51337 }
51338 ai[2] += 1f;
51339 if (ai[2] >= 20f || velocity.Y != 0f || (Main.IsItDay() && (double)position.Y < Main.worldSurface * 16.0))
51340 {
51341 ai[2] = 0f;
51342 }
51343 }
51344 }
51345 else if (type != 110 && type != 111 && type != 206 && type != 214 && type != 215 && type != 216 && type != 290 && type != 291 && type != 292 && type != 293 && type != 350 && type != 379 && type != 380 && type != 381 && type != 382 && (type < 449 || type > 452) && type != 468 && type != 481 && type != 411 && type != 409 && (type < 498 || type > 506) && type != 424 && type != 426 && type != 520)
51346 {
51347 float num104 = 1f;
51348 if (type == 624)
51349 {
51350 num104 = 2.5f;
51351 }
51352 if (type == 186)
51353 {
51354 num104 = 1.1f;
51355 }
51356 if (type == 187)
51357 {
51358 num104 = 0.9f;
51359 }
51360 if (type == 188)
51361 {
51362 num104 = 1.2f;
51363 }
51364 if (type == 189)
51365 {
51366 num104 = 0.8f;
51367 }
51368 if (type == 132)
51369 {
51370 num104 = 0.95f;
51371 }
51372 if (type == 200)
51373 {
51374 num104 = 0.87f;
51375 }
51376 if (type == 223)
51377 {
51378 num104 = 1.05f;
51379 }
51380 if (type == 632)
51381 {
51382 num104 = 0.8f;
51383 }
51384 if (type == 489)
51385 {
51386 float num105 = (Main.player[target].Center - base.Center).Length();
51387 num105 *= 0.0025f;
51388 if ((double)num105 > 1.5)
51389 {
51390 num105 = 1.5f;
51391 }
51392 num104 = ((!Main.expertMode) ? (2.5f - num105) : (3f - num105));
51393 num104 *= 0.8f;
51394 }
51395 if (type == 489 || type == 3 || type == 132 || type == 186 || type == 187 || type == 188 || type == 189 || type == 200 || type == 223 || type == 331 || type == 332)
51396 {
51397 num104 *= 1f + (1f - scale);
51398 }
51399 if (velocity.X < 0f - num104 || velocity.X > num104)
51400 {
51401 if (velocity.Y == 0f)
51402 {
51403 velocity *= 0.8f;
51404 }
51405 }
51406 else if (velocity.X < num104 && direction == 1)
51407 {
51408 velocity.X += 0.07f;
51409 if (velocity.X > num104)
51410 {
51411 velocity.X = num104;
51412 }
51413 }
51414 else if (velocity.X > 0f - num104 && direction == -1)
51415 {
51416 velocity.X -= 0.07f;
51417 if (velocity.X < 0f - num104)
51418 {
51419 velocity.X = 0f - num104;
51420 }
51421 }
51422 }
51423 if (type >= 277 && type <= 280)
51424 {
51425 Lighting.AddLight((int)base.Center.X / 16, (int)base.Center.Y / 16, 0.2f, 0.1f, 0f);
51426 }
51427 else if (type == 520)
51428 {
51429 Lighting.AddLight(base.Top + new Vector2(0f, 20f), 0.3f, 0.3f, 0.7f);
51430 }
51431 else if (type == 525)
51432 {
51433 Vector3 rgb = new Vector3(0.7f, 1f, 0.2f) * 0.5f;
51434 Lighting.AddLight(base.Top + new Vector2(0f, 15f), rgb);
51435 }
51436 else if (type == 526)
51437 {
51438 Vector3 rgb2 = new Vector3(1f, 1f, 0.5f) * 0.4f;
51439 Lighting.AddLight(base.Top + new Vector2(0f, 15f), rgb2);
51440 }
51441 else if (type == 527)
51442 {
51443 Vector3 rgb3 = new Vector3(0.6f, 0.3f, 1f) * 0.4f;
51444 Lighting.AddLight(base.Top + new Vector2(0f, 15f), rgb3);
51445 }
51446 else if (type == 415)
51447 {
51448 hide = false;
51449 for (int num106 = 0; num106 < 200; num106++)
51450 {
51451 if (Main.npc[num106].active && Main.npc[num106].type == 416 && Main.npc[num106].ai[0] == (float)whoAmI)
51452 {
51453 hide = true;
51454 break;
51455 }
51456 }
51457 }
51458 else if (type == 258)
51459 {
51460 if (velocity.Y != 0f)
51461 {
51462 TargetClosest();
51464 if (Main.player[target].Center.X < position.X && velocity.X > 0f)
51465 {
51466 velocity.X *= 0.95f;
51467 }
51468 else if (Main.player[target].Center.X > position.X + (float)width && velocity.X < 0f)
51469 {
51470 velocity.X *= 0.95f;
51471 }
51472 if (Main.player[target].Center.X < position.X && velocity.X > -5f)
51473 {
51474 velocity.X -= 0.1f;
51475 }
51476 else if (Main.player[target].Center.X > position.X + (float)width && velocity.X < 5f)
51477 {
51478 velocity.X += 0.1f;
51479 }
51480 }
51481 else if (Main.player[target].Center.Y + 50f < position.Y && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
51482 {
51483 flag = true;
51484 velocity.Y = -7f;
51485 }
51486 }
51487 else if (type == 425)
51488 {
51489 if (localAI[3] == 0f)
51490 {
51491 localAI[3] = 1f;
51492 ai[3] = -120f;
51493 }
51494 if (velocity.Y == 0f)
51495 {
51496 ai[2] = 0f;
51497 }
51498 if (velocity.Y != 0f && ai[2] == 1f)
51499 {
51500 TargetClosest();
51502 if (Collision.CanHit(base.Center, 0, 0, Main.player[target].Center, 0, 0))
51503 {
51504 float num107 = 0.3f;
51505 float num108 = 8f;
51506 float num109 = 0.3f;
51507 float num110 = 7f;
51508 float num111 = Main.player[target].Center.X - (float)(direction * 300) - base.Center.X;
51509 float num112 = Main.player[target].Bottom.Y - base.Bottom.Y;
51511 {
51512 velocity.X *= 0.9f;
51513 }
51514 else if (num111 > 0f && velocity.X < 0f)
51515 {
51516 velocity.X *= 0.9f;
51517 }
51519 {
51520 velocity.X -= num109;
51521 }
51522 else if (num111 > 0f && velocity.X < num110)
51523 {
51524 velocity.X += num109;
51525 }
51526 if (velocity.X > num110)
51527 {
51528 velocity.X = num110;
51529 }
51530 if (velocity.X < 0f - num110)
51531 {
51532 velocity.X = 0f - num110;
51533 }
51535 {
51536 velocity.Y *= 0.8f;
51537 }
51538 else if (num112 > 20f && velocity.Y < 0f)
51539 {
51540 velocity.Y *= 0.8f;
51541 }
51543 {
51544 velocity.Y -= num107;
51545 }
51546 else if (num112 > 20f && velocity.Y < num108)
51547 {
51548 velocity.Y += num107;
51549 }
51550 }
51551 if (Main.rand.Next(3) == 0)
51552 {
51554 Vector2 vector25 = base.Center + new Vector2(direction * -14, -8f) - Vector2.One * 4f;
51555 Vector2 vector26 = new Vector2(direction * -6, 12f) * 0.2f + Utils.RandomVector2(Main.rand, -1f, 1f) * 0.1f;
51556 Dust obj5 = Main.dust[Dust.NewDust(vector25, 8, 8, 229, vector26.X, vector26.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 0.5f)];
51557 obj5.noGravity = true;
51558 obj5.velocity = vector26;
51559 obj5.customData = this;
51561 }
51562 for (int num113 = 0; num113 < 200; num113++)
51563 {
51564 if (num113 != whoAmI && Main.npc[num113].active && Main.npc[num113].type == type && Math.Abs(position.X - Main.npc[num113].position.X) + Math.Abs(position.Y - Main.npc[num113].position.Y) < (float)width)
51565 {
51566 if (position.X < Main.npc[num113].position.X)
51567 {
51568 velocity.X -= 0.15f;
51569 }
51570 else
51571 {
51572 velocity.X += 0.15f;
51573 }
51574 if (position.Y < Main.npc[num113].position.Y)
51575 {
51576 velocity.Y -= 0.15f;
51577 }
51578 else
51579 {
51580 velocity.Y += 0.15f;
51581 }
51582 }
51583 }
51584 }
51585 else if (Main.player[target].Center.Y + 100f < position.Y && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
51586 {
51587 flag = true;
51588 velocity.Y = -5f;
51589 ai[2] = 1f;
51590 }
51591 if (ai[3] < 0f)
51592 {
51593 ai[3] += 1f;
51594 }
51595 int num114 = 30;
51596 int num115 = 10;
51597 int num116 = 180;
51598 if (ai[3] >= 0f && ai[3] <= (float)num114)
51599 {
51600 Vector2 vector27 = DirectionTo(Main.player[target].Center);
51601 bool flag12 = Math.Abs(vector27.Y) <= Math.Abs(vector27.X);
51602 bool flag13 = Distance(Main.player[target].Center) < 800f && flag12 && Collision.CanHitLine(base.Center, 0, 0, Main.player[target].Center, 0, 0);
51603 ai[3] = MathHelper.Clamp(ai[3] + (float)flag13.ToDirectionInt(), 0f, num114);
51604 }
51605 if (ai[3] >= (float)(num114 + 1) && (ai[3] += 1f) >= (float)(num114 + num115))
51606 {
51607 ai[3] = num114 - num116;
51608 netUpdate = true;
51609 }
51610 if (Main.netMode != 1 && ai[3] == (float)num114)
51611 {
51612 ai[3] += 1f;
51613 netUpdate = true;
51614 int num117 = 20;
51615 Vector2 chaserPosition = base.Center + new Vector2(direction * 30, 2f);
51616 Vector2 vector28 = DirectionTo(Main.player[target].Center) * num117;
51617 if (vector28.HasNaNs())
51618 {
51619 vector28 = new Vector2(direction * num117, 0f);
51620 }
51621 int num118 = 2;
51622 Utils.ChaseResults chaseResults = Utils.GetChaseResults(chaserPosition, num117, Main.player[target].Center, Main.player[target].velocity * 0.5f / num118);
51623 if (chaseResults.InterceptionHappens)
51624 {
51625 Vector2 vector29 = chaseResults.ChaserVelocity / num118;
51626 vector28.X = vector29.X;
51627 vector28.Y = vector29.Y;
51628 }
51630 for (int num119 = 0; num119 < 4; num119++)
51631 {
51632 Vector2 vector30 = vector28 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f) * ((num119 != 0) ? 1 : 0);
51633 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), chaserPosition.X, chaserPosition.Y, vector30.X, vector30.Y, 577, attackDamage_ForProjectiles, 1f, Main.myPlayer);
51634 }
51635 }
51636 }
51637 else if (type == 427)
51638 {
51639 if (velocity.Y == 0f)
51640 {
51641 ai[2] = 0f;
51642 rotation = 0f;
51643 }
51644 else
51645 {
51646 rotation = velocity.X * 0.1f;
51647 }
51648 if (velocity.Y != 0f && ai[2] == 1f)
51649 {
51650 TargetClosest();
51652 if (Collision.CanHit(base.Center, 0, 0, Main.player[target].Center, 0, 0))
51653 {
51654 float num120 = Main.player[target].Center.X - base.Center.X;
51655 float num121 = Main.player[target].Center.Y - base.Center.Y;
51657 {
51658 velocity.X *= 0.98f;
51659 }
51660 else if (num120 > 0f && velocity.X < 0f)
51661 {
51662 velocity.X *= 0.98f;
51663 }
51665 {
51666 velocity.X -= 0.015f;
51667 }
51668 else if (num120 > 20f && velocity.X < 6f)
51669 {
51670 velocity.X += 0.015f;
51671 }
51672 if (velocity.X > 6f)
51673 {
51674 velocity.X = 6f;
51675 }
51676 if (velocity.X < -6f)
51677 {
51678 velocity.X = -6f;
51679 }
51681 {
51682 velocity.Y *= 0.98f;
51683 }
51684 else if (num121 > 20f && velocity.Y < 0f)
51685 {
51686 velocity.Y *= 0.98f;
51687 }
51689 {
51690 velocity.Y -= 0.15f;
51691 }
51692 else if (num121 > 20f && velocity.Y < 6f)
51693 {
51694 velocity.Y += 0.15f;
51695 }
51696 }
51697 for (int num122 = 0; num122 < 200; num122++)
51698 {
51699 if (num122 != whoAmI && Main.npc[num122].active && Main.npc[num122].type == type && Math.Abs(position.X - Main.npc[num122].position.X) + Math.Abs(position.Y - Main.npc[num122].position.Y) < (float)width)
51700 {
51701 if (position.X < Main.npc[num122].position.X)
51702 {
51703 velocity.X -= 0.05f;
51704 }
51705 else
51706 {
51707 velocity.X += 0.05f;
51708 }
51709 if (position.Y < Main.npc[num122].position.Y)
51710 {
51711 velocity.Y -= 0.05f;
51712 }
51713 else
51714 {
51715 velocity.Y += 0.05f;
51716 }
51717 }
51718 }
51719 }
51720 else if (Main.player[target].Center.Y + 100f < position.Y && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
51721 {
51722 flag = true;
51723 velocity.Y = -5f;
51724 ai[2] = 1f;
51725 }
51726 }
51727 else if (type == 426)
51728 {
51729 float num123 = 6f;
51730 float num124 = 0.2f;
51731 float num125 = 6f;
51732 if (ai[1] > 0f && velocity.Y > 0f)
51733 {
51734 velocity.Y *= 0.85f;
51735 if (velocity.Y == 0f)
51736 {
51737 velocity.Y = -0.4f;
51738 }
51739 }
51740 if (velocity.Y != 0f)
51741 {
51742 TargetClosest();
51744 if (Collision.CanHit(base.Center, 0, 0, Main.player[target].Center, 0, 0))
51745 {
51746 float num126 = Main.player[target].Center.X - (float)(direction * 300) - base.Center.X;
51748 {
51749 velocity.X *= 0.98f;
51750 }
51751 else if (num126 > 40f && velocity.X < 0f)
51752 {
51753 velocity.X *= 0.98f;
51754 }
51756 {
51757 velocity.X -= num124;
51758 }
51759 else if (num126 > 40f && velocity.X < num123)
51760 {
51761 velocity.X += num124;
51762 }
51763 if (velocity.X > num123)
51764 {
51765 velocity.X = num123;
51766 }
51767 if (velocity.X < 0f - num123)
51768 {
51769 velocity.X = 0f - num123;
51770 }
51771 }
51772 }
51773 else if (Main.player[target].Center.Y + 100f < position.Y && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
51774 {
51775 flag = true;
51776 velocity.Y = 0f - num125;
51777 }
51778 for (int num127 = 0; num127 < 200; num127++)
51779 {
51780 if (num127 != whoAmI && Main.npc[num127].active && Main.npc[num127].type == type && Math.Abs(position.X - Main.npc[num127].position.X) + Math.Abs(position.Y - Main.npc[num127].position.Y) < (float)width)
51781 {
51782 if (position.X < Main.npc[num127].position.X)
51783 {
51784 velocity.X -= 0.1f;
51785 }
51786 else
51787 {
51788 velocity.X += 0.1f;
51789 }
51790 if (position.Y < Main.npc[num127].position.Y)
51791 {
51792 velocity.Y -= 0.1f;
51793 }
51794 else
51795 {
51796 velocity.Y += 0.1f;
51797 }
51798 }
51799 }
51800 if (Main.rand.Next(6) == 0 && ai[1] <= 20f)
51801 {
51803 Dust obj6 = Main.dust[Dust.NewDust(base.Center + new Vector2((spriteDirection == 1) ? 8 : (-20), -20f), 8, 8, 229, velocity.X, velocity.Y, 100)];
51804 obj6.velocity = obj6.velocity / 4f + velocity / 2f;
51805 obj6.scale = 0.6f;
51806 obj6.noLight = true;
51808 }
51809 if (ai[1] >= 57f)
51810 {
51812 int num128 = Utils.SelectRandom<int>(Main.rand, 161, 229);
51813 Dust obj7 = Main.dust[Dust.NewDust(base.Center + new Vector2((spriteDirection == 1) ? 8 : (-20), -20f), 8, 8, num128, velocity.X, velocity.Y, 100)];
51814 obj7.velocity = obj7.velocity / 4f + DirectionTo(Main.player[target].Top);
51815 obj7.scale = 1.2f;
51816 obj7.noLight = true;
51818 }
51819 if (Main.rand.Next(6) == 0)
51820 {
51822 Dust dust5 = Main.dust[Dust.NewDust(base.Center, 2, 2, 229)];
51823 dust5.position = base.Center + new Vector2((spriteDirection == 1) ? 26 : (-26), 24f);
51824 dust5.velocity.X = 0f;
51825 if (dust5.velocity.Y < 0f)
51826 {
51827 dust5.velocity.Y = 0f;
51828 }
51829 dust5.noGravity = true;
51830 dust5.scale = 1f;
51831 dust5.noLight = true;
51833 }
51834 }
51835 else if (type == 185)
51836 {
51837 if (velocity.Y == 0f)
51838 {
51839 rotation = 0f;
51840 localAI[0] = 0f;
51841 }
51842 else if (localAI[0] == 1f)
51843 {
51844 rotation += velocity.X * 0.05f;
51845 }
51846 }
51847 else if (type == 428)
51848 {
51849 if (velocity.Y == 0f)
51850 {
51851 rotation = 0f;
51852 }
51853 else
51854 {
51855 rotation += velocity.X * 0.08f;
51856 }
51857 }
51858 if (type == 159 && Main.netMode != 1)
51859 {
51860 Vector2 vector31 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
51861 float num129 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector31.X;
51862 float num130 = Main.player[target].position.Y + (float)Main.player[target].height * 0.5f - vector31.Y;
51863 if ((float)Math.Sqrt(num129 * num129 + num130 * num130) > 300f)
51864 {
51865 Transform(158);
51866 }
51867 }
51868 if (Main.netMode != 1)
51869 {
51870 if (Main.expertMode && target >= 0 && (type == 163 || type == 238 || type == 236 || type == 237) && Collision.CanHit(base.Center, 1, 1, Main.player[target].Center, 1, 1))
51871 {
51872 localAI[0] += 1f;
51873 if (justHit)
51874 {
51875 localAI[0] -= Main.rand.Next(20, 60);
51876 if (localAI[0] < 0f)
51877 {
51878 localAI[0] = 0f;
51879 }
51880 }
51881 if (localAI[0] > (float)Main.rand.Next(180, 900))
51882 {
51883 localAI[0] = 0f;
51884 Vector2 vector32 = Main.player[target].Center - base.Center;
51885 vector32.Normalize();
51886 vector32 *= 8f;
51888 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X, base.Center.Y, vector32.X, vector32.Y, 472, attackDamage_ForProjectiles2, 0f, Main.myPlayer);
51889 }
51890 }
51891 if (velocity.Y == 0f)
51892 {
51893 int num131 = -1;
51894 switch (type)
51895 {
51896 case 164:
51897 num131 = 165;
51898 break;
51899 case 236:
51900 num131 = 237;
51901 break;
51902 case 163:
51903 num131 = 238;
51904 break;
51905 case 239:
51906 num131 = 240;
51907 break;
51908 case 530:
51909 num131 = 531;
51910 break;
51911 }
51912 if (num131 != -1 && NPCCanStickToWalls())
51913 {
51915 }
51916 }
51917 }
51918 if (type == 243)
51919 {
51920 if (justHit && Main.rand.Next(3) == 0)
51921 {
51922 ai[2] -= Main.rand.Next(30);
51923 }
51924 if (ai[2] < 0f)
51925 {
51926 ai[2] = 0f;
51927 }
51928 if (confused)
51929 {
51930 ai[2] = 0f;
51931 }
51932 ai[2] += 1f;
51933 float num132 = Main.rand.Next(30, 900);
51934 num132 *= (float)life / (float)lifeMax;
51935 num132 += 30f;
51936 if (Main.netMode != 1 && ai[2] >= num132 && velocity.Y == 0f && !Main.player[target].dead && !Main.player[target].frozen && ((direction > 0 && base.Center.X < Main.player[target].Center.X) || (direction < 0 && base.Center.X > Main.player[target].Center.X)) && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
51937 {
51938 Vector2 vector33 = new Vector2(position.X + (float)width * 0.5f, position.Y + 20f);
51939 vector33.X += 10 * direction;
51940 float num133 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector33.X;
51941 float num134 = Main.player[target].position.Y + (float)Main.player[target].height * 0.5f - vector33.Y;
51942 num133 += (float)Main.rand.Next(-40, 41);
51943 num134 += (float)Main.rand.Next(-40, 41);
51944 float num135 = (float)Math.Sqrt(num133 * num133 + num134 * num134);
51945 netUpdate = true;
51946 num135 = 15f / num135;
51947 num133 *= num135;
51948 num134 *= num135;
51949 int num136 = 32;
51950 int num137 = 257;
51951 vector33.X += num133 * 3f;
51952 vector33.Y += num134 * 3f;
51953 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector33.X, vector33.Y, num133, num134, num137, num136, 0f, Main.myPlayer);
51954 ai[2] = 0f;
51955 }
51956 }
51957 if (type == 251)
51958 {
51959 if (justHit)
51960 {
51961 ai[2] -= Main.rand.Next(30);
51962 }
51963 if (ai[2] < 0f)
51964 {
51965 ai[2] = 0f;
51966 }
51967 if (confused)
51968 {
51969 ai[2] = 0f;
51970 }
51971 ai[2] += 1f;
51972 float num138 = Main.rand.Next(60, 1800);
51973 num138 *= (float)life / (float)lifeMax;
51974 num138 += 15f;
51975 if (Main.netMode != 1 && ai[2] >= num138 && velocity.Y == 0f && !Main.player[target].dead && !Main.player[target].frozen && ((direction > 0 && base.Center.X < Main.player[target].Center.X) || (direction < 0 && base.Center.X > Main.player[target].Center.X)) && Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height))
51976 {
51977 Vector2 vector34 = new Vector2(position.X + (float)width * 0.5f, position.Y + 12f);
51978 vector34.X += 6 * direction;
51979 float num139 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector34.X;
51980 float num140 = Main.player[target].position.Y + (float)Main.player[target].height * 0.5f - vector34.Y;
51981 num139 += (float)Main.rand.Next(-40, 41);
51982 num140 += (float)Main.rand.Next(-30, 0);
51983 float num141 = (float)Math.Sqrt(num139 * num139 + num140 * num140);
51984 netUpdate = true;
51985 num141 = 15f / num141;
51986 num139 *= num141;
51987 num140 *= num141;
51988 int num142 = 30;
51989 int num143 = 83;
51990 vector34.X += num139 * 3f;
51991 vector34.Y += num140 * 3f;
51992 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector34.X, vector34.Y, num139, num140, num143, num142, 0f, Main.myPlayer);
51993 ai[2] = 0f;
51994 }
51995 }
51996 if (type == 386)
51997 {
51998 if (confused)
51999 {
52000 ai[2] = -60f;
52001 }
52002 else
52003 {
52004 if (ai[2] < 60f)
52005 {
52006 ai[2] += 1f;
52007 }
52008 if (ai[2] > 0f && CountNPCS(387) >= 4 * CountNPCS(386))
52009 {
52010 ai[2] = 0f;
52011 }
52012 if (justHit)
52013 {
52014 ai[2] = -30f;
52015 }
52016 if (ai[2] == 30f)
52017 {
52018 int num144 = (int)position.X / 16;
52019 int num145 = (int)position.Y / 16;
52020 int num146 = (int)position.X / 16;
52021 int num147 = (int)position.Y / 16;
52022 int num148 = 5;
52023 int num149 = 0;
52024 bool flag14 = false;
52025 int num150 = 2;
52026 int num151 = 0;
52027 while (!flag14 && num149 < 100)
52028 {
52029 num149++;
52030 int num152 = Main.rand.Next(num144 - num148, num144 + num148);
52031 for (int num153 = Main.rand.Next(num145 - num148, num145 + num148); num153 < num145 + num148; num153++)
52032 {
52034 {
52035 bool flag15 = true;
52036 if (Main.tile[num152, num153 - 1].lava())
52037 {
52038 flag15 = false;
52039 }
52040 if (flag15 && Main.tileSolid[Main.tile[num152, num153].type] && !Collision.SolidTiles(num152 - 1, num152 + 1, num153 - 4, num153 - 1))
52041 {
52042 int num154 = NewNPC(GetSpawnSourceForNPCFromNPCAI(), num152 * 16 - width / 2, num153 * 16, 387);
52043 Main.npc[num154].position.Y = num153 * 16 - Main.npc[num154].height;
52044 flag14 = true;
52045 netUpdate = true;
52046 break;
52047 }
52048 }
52049 }
52050 }
52051 }
52052 if (ai[2] == 60f)
52053 {
52054 ai[2] = -120f;
52055 }
52056 }
52057 }
52058 if (type == 389)
52059 {
52060 if (confused)
52061 {
52062 ai[2] = -60f;
52063 }
52064 else
52065 {
52066 if (ai[2] < 20f)
52067 {
52068 ai[2] += 1f;
52069 }
52070 if (justHit)
52071 {
52072 ai[2] = -30f;
52073 }
52074 if (ai[2] == 20f && Main.netMode != 1)
52075 {
52076 ai[2] = -10 + Main.rand.Next(3) * -10;
52077 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X, base.Center.Y + 8f, direction * 6, 0f, 437, 25, 1f, Main.myPlayer);
52078 }
52079 }
52080 }
52081 if (type == 110 || type == 111 || type == 206 || type == 214 || type == 215 || type == 216 || type == 290 || type == 291 || type == 292 || type == 293 || type == 350 || type == 379 || type == 380 || type == 381 || type == 382 || (type >= 449 && type <= 452) || type == 468 || type == 481 || type == 411 || type == 409 || (type >= 498 && type <= 506) || type == 424 || type == 426 || type == 520)
52082 {
52083 bool flag16 = type == 381 || type == 382 || type == 520;
52084 bool flag17 = type == 426;
52085 bool flag18 = true;
52086 int num155 = -1;
52087 int num156 = -1;
52088 if (type == 411)
52089 {
52090 flag16 = true;
52091 num155 = 120;
52092 num156 = 120;
52093 if (ai[1] <= 220f)
52094 {
52095 flag18 = false;
52096 }
52097 }
52098 if (ai[1] > 0f)
52099 {
52100 ai[1] -= 1f;
52101 }
52102 if (justHit)
52103 {
52104 ai[1] = 30f;
52105 ai[2] = 0f;
52106 }
52107 int num157 = 70;
52108 if (type == 379 || type == 380)
52109 {
52110 num157 = 80;
52111 }
52112 if (type == 381 || type == 382)
52113 {
52114 num157 = 80;
52115 }
52116 if (type == 520)
52117 {
52118 num157 = 15;
52119 }
52120 if (type == 350)
52121 {
52122 num157 = 110;
52123 }
52124 if (type == 291)
52125 {
52126 num157 = 200;
52127 }
52128 if (type == 292)
52129 {
52130 num157 = 120;
52131 }
52132 if (type == 293)
52133 {
52134 num157 = 90;
52135 }
52136 if (type == 111)
52137 {
52138 num157 = 180;
52139 }
52140 if (type == 206)
52141 {
52142 num157 = 50;
52143 }
52144 if (type == 481)
52145 {
52146 num157 = 100;
52147 }
52148 if (type == 214)
52149 {
52150 num157 = 40;
52151 }
52152 if (type == 215)
52153 {
52154 num157 = 80;
52155 }
52156 if (type == 290)
52157 {
52158 num157 = 30;
52159 }
52160 if (type == 411)
52161 {
52162 num157 = 330;
52163 }
52164 if (type == 409)
52165 {
52166 num157 = 60;
52167 }
52168 if (type == 424)
52169 {
52170 num157 = 180;
52171 }
52172 if (type == 426)
52173 {
52174 num157 = 60;
52175 }
52176 bool flag19 = false;
52177 if (type == 216)
52178 {
52179 if (localAI[2] >= 20f)
52180 {
52181 flag19 = true;
52182 }
52183 num157 = ((!flag19) ? 8 : 60);
52184 }
52185 int num158 = num157 / 2;
52186 if (type == 424)
52187 {
52188 num158 = num157 - 1;
52189 }
52190 if (type == 426)
52191 {
52192 num158 = num157 - 1;
52193 }
52194 if (type == 411)
52195 {
52196 num158 = 220;
52197 }
52198 if (confused)
52199 {
52200 ai[2] = 0f;
52201 }
52202 if (ai[2] > 0f)
52203 {
52204 if (flag18)
52205 {
52206 TargetClosest();
52207 }
52208 if (ai[1] == (float)num158)
52209 {
52210 if (type == 216)
52211 {
52212 localAI[2] += 1f;
52213 }
52214 float num159 = 11f;
52215 if (type == 111)
52216 {
52217 num159 = 9f;
52218 }
52219 if (type == 206)
52220 {
52221 num159 = 7f;
52222 }
52223 if (type == 290)
52224 {
52225 num159 = 9f;
52226 }
52227 if (type == 293)
52228 {
52229 num159 = 4f;
52230 }
52231 if (type == 214)
52232 {
52233 num159 = 14f;
52234 }
52235 if (type == 215)
52236 {
52237 num159 = 16f;
52238 }
52239 if (type == 382)
52240 {
52241 num159 = 7f;
52242 }
52243 if (type == 520)
52244 {
52245 num159 = 8f;
52246 }
52247 if (type == 409)
52248 {
52249 num159 = 4f;
52250 }
52251 if (type >= 449 && type <= 452)
52252 {
52253 num159 = 7f;
52254 }
52255 if (type == 481)
52256 {
52257 num159 = 8f;
52258 }
52259 if (type == 468)
52260 {
52261 num159 = 7.5f;
52262 }
52263 if (type == 411)
52264 {
52265 num159 = 1f;
52266 }
52267 if (type >= 498 && type <= 506)
52268 {
52269 num159 = 7f;
52270 }
52271 Vector2 chaserPosition2 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
52272 if (type == 481)
52273 {
52274 chaserPosition2.Y -= 14f;
52275 }
52276 if (type == 206)
52277 {
52278 chaserPosition2.Y -= 10f;
52279 }
52280 if (type == 290)
52281 {
52282 chaserPosition2.Y -= 10f;
52283 }
52284 if (type == 381 || type == 382)
52285 {
52286 chaserPosition2.Y += 6f;
52287 }
52288 if (type == 520)
52289 {
52290 chaserPosition2.Y = position.Y + 20f;
52291 }
52292 if (type >= 498 && type <= 506)
52293 {
52294 chaserPosition2.Y -= 8f;
52295 }
52296 if (type == 426)
52297 {
52298 chaserPosition2 += new Vector2(spriteDirection * 2, -12f);
52299 num159 = 7f;
52300 }
52301 float num160 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - chaserPosition2.X;
52302 float num161 = Math.Abs(num160) * 0.1f;
52303 if (type == 291 || type == 292)
52304 {
52305 num161 = 0f;
52306 }
52307 if (type == 215)
52308 {
52309 num161 = Math.Abs(num160) * 0.08f;
52310 }
52311 if (type == 214 || (type == 216 && !flag19))
52312 {
52313 num161 = 0f;
52314 }
52315 if (type == 381 || type == 382 || type == 520)
52316 {
52317 num161 = 0f;
52318 }
52319 if (type >= 449 && type <= 452)
52320 {
52321 num161 = Math.Abs(num160) * (float)Main.rand.Next(10, 50) * 0.01f;
52322 }
52323 if (type == 468)
52324 {
52325 num161 = Math.Abs(num160) * (float)Main.rand.Next(10, 50) * 0.01f;
52326 }
52327 if (type == 481)
52328 {
52329 num161 = Math.Abs(num160) * (float)Main.rand.Next(-10, 11) * 0.0035f;
52330 }
52331 if (type >= 498 && type <= 506)
52332 {
52333 num161 = Math.Abs(num160) * (float)Main.rand.Next(1, 11) * 0.0025f;
52334 }
52335 float num162 = Main.player[target].position.Y + (float)Main.player[target].height * 0.5f - chaserPosition2.Y - num161;
52336 if (type == 291)
52337 {
52338 num160 += (float)Main.rand.Next(-40, 41) * 0.2f;
52339 num162 += (float)Main.rand.Next(-40, 41) * 0.2f;
52340 }
52341 else if (type == 381 || type == 382 || type == 520)
52342 {
52343 num160 += (float)Main.rand.Next(-100, 101) * 0.4f;
52344 num162 += (float)Main.rand.Next(-100, 101) * 0.4f;
52345 num160 *= (float)Main.rand.Next(85, 116) * 0.01f;
52346 num162 *= (float)Main.rand.Next(85, 116) * 0.01f;
52347 if (type == 520)
52348 {
52349 num160 += (float)Main.rand.Next(-100, 101) * 0.6f;
52350 num162 += (float)Main.rand.Next(-100, 101) * 0.6f;
52351 num160 *= (float)Main.rand.Next(85, 116) * 0.015f;
52352 num162 *= (float)Main.rand.Next(85, 116) * 0.015f;
52353 }
52354 }
52355 else if (type == 481)
52356 {
52357 num160 += (float)Main.rand.Next(-40, 41) * 0.4f;
52358 num162 += (float)Main.rand.Next(-40, 41) * 0.4f;
52359 }
52360 else if (type >= 498 && type <= 506)
52361 {
52362 num160 += (float)Main.rand.Next(-40, 41) * 0.3f;
52363 num162 += (float)Main.rand.Next(-40, 41) * 0.3f;
52364 }
52365 else if (type == 426)
52366 {
52367 num160 += (float)Main.rand.Next(-30, 31) * 0.3f;
52368 num162 += (float)Main.rand.Next(-30, 31) * 0.3f;
52369 }
52370 else if (type != 292)
52371 {
52372 num160 += (float)Main.rand.Next(-40, 41);
52373 num162 += (float)Main.rand.Next(-40, 41);
52374 }
52375 float num163 = (float)Math.Sqrt(num160 * num160 + num162 * num162);
52376 netUpdate = true;
52377 num163 = num159 / num163;
52378 num160 *= num163;
52379 num162 *= num163;
52380 int num164 = 35;
52381 int num165 = 82;
52382 if (type == 111)
52383 {
52384 num164 = 11;
52385 }
52386 if (type == 206)
52387 {
52388 num164 = 37;
52389 }
52390 if (type == 379 || type == 380)
52391 {
52392 num164 = 40;
52393 }
52394 if (type == 350)
52395 {
52396 num164 = 45;
52397 }
52398 if (type == 468)
52399 {
52400 num164 = 50;
52401 }
52402 if (type == 111)
52403 {
52404 num165 = 81;
52405 }
52406 if (type == 379 || type == 380)
52407 {
52408 num165 = 81;
52409 }
52410 if (type == 381)
52411 {
52412 num165 = 436;
52413 num164 = 24;
52414 }
52415 if (type == 382)
52416 {
52417 num165 = 438;
52418 num164 = 30;
52419 }
52420 if (type == 520)
52421 {
52422 num165 = 592;
52423 num164 = 35;
52424 }
52425 if (type >= 449 && type <= 452)
52426 {
52427 num165 = 471;
52428 num164 = 15;
52429 }
52430 if (type >= 498 && type <= 506)
52431 {
52432 num165 = 572;
52433 num164 = 14;
52434 }
52435 if (type == 481)
52436 {
52437 num165 = 508;
52438 num164 = 18;
52439 }
52440 if (type == 206)
52441 {
52442 num165 = 177;
52443 }
52444 if (type == 468)
52445 {
52446 num165 = 501;
52447 }
52448 if (type == 411)
52449 {
52450 num165 = 537;
52452 }
52453 if (type == 424)
52454 {
52455 num165 = 573;
52457 }
52458 if (type == 426)
52459 {
52460 num165 = 581;
52462 }
52463 if (type == 291)
52464 {
52465 num165 = 302;
52466 num164 = 100;
52467 }
52468 if (type == 290)
52469 {
52470 num165 = 300;
52471 num164 = 60;
52472 }
52473 if (type == 293)
52474 {
52475 num165 = 303;
52476 num164 = 60;
52477 }
52478 if (type == 214)
52479 {
52480 num165 = 180;
52481 num164 = 25;
52482 }
52483 if (type == 215)
52484 {
52485 num165 = 82;
52486 num164 = 40;
52487 }
52488 if (type == 292)
52489 {
52490 num164 = 50;
52491 num165 = 180;
52492 }
52493 if (type == 216)
52494 {
52495 num165 = 180;
52496 num164 = 30;
52497 if (flag19)
52498 {
52499 num164 = 100;
52500 num165 = 240;
52501 localAI[2] = 0f;
52502 }
52503 }
52504 Player player3 = Main.player[target];
52505 Vector2? vector35 = null;
52506 if (type == 426)
52507 {
52508 vector35 = Main.rand.NextVector2FromRectangle(player3.Hitbox);
52509 }
52510 if (vector35.HasValue)
52511 {
52512 Utils.ChaseResults chaseResults2 = Utils.GetChaseResults(chaserPosition2, num159, vector35.Value, player3.velocity);
52513 if (chaseResults2.InterceptionHappens)
52514 {
52515 Vector2 vector36 = Utils.FactorAcceleration(chaseResults2.ChaserVelocity, chaseResults2.InterceptionTime, new Vector2(0f, 0.1f), 15);
52516 num160 = vector36.X;
52517 num162 = vector36.Y;
52518 }
52519 }
52520 chaserPosition2.X += num160;
52521 chaserPosition2.Y += num162;
52522 if (type == 290)
52523 {
52525 }
52526 if (type >= 381 && type <= 392)
52527 {
52529 }
52530 if (Main.netMode != 1)
52531 {
52532 if (type == 292)
52533 {
52534 for (int num166 = 0; num166 < 4; num166++)
52535 {
52536 num160 = player3.position.X + (float)player3.width * 0.5f - chaserPosition2.X;
52537 num162 = player3.position.Y + (float)player3.height * 0.5f - chaserPosition2.Y;
52538 num163 = (float)Math.Sqrt(num160 * num160 + num162 * num162);
52539 num163 = 12f / num163;
52540 num160 = (num160 += (float)Main.rand.Next(-40, 41));
52541 num162 = (num162 += (float)Main.rand.Next(-40, 41));
52542 num160 *= num163;
52543 num162 *= num163;
52544 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), chaserPosition2.X, chaserPosition2.Y, num160, num162, num165, num164, 0f, Main.myPlayer);
52545 }
52546 }
52547 else if (type == 411)
52548 {
52549 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), chaserPosition2.X, chaserPosition2.Y, num160, num162, num165, num164, 0f, Main.myPlayer, 0f, whoAmI);
52550 }
52551 else if (type == 424)
52552 {
52553 for (int num167 = 0; num167 < 4; num167++)
52554 {
52555 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), base.Center.X - (float)(spriteDirection * 4), base.Center.Y + 6f, (float)(-3 + 2 * num167) * 0.15f, (float)(-Main.rand.Next(0, 3)) * 0.2f - 0.1f, num165, num164, 0f, Main.myPlayer, 0f, whoAmI);
52556 }
52557 }
52558 else if (type == 409)
52559 {
52560 int num168 = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)base.Center.X, (int)base.Center.Y, 410, whoAmI);
52561 Main.npc[num168].velocity = new Vector2(num160, -6f + num162);
52562 }
52563 else
52564 {
52565 Projectile.NewProjectile(GetSpawnSource_ForProjectile(), chaserPosition2.X, chaserPosition2.Y, num160, num162, num165, num164, 0f, Main.myPlayer);
52566 }
52567 }
52568 if (Math.Abs(num162) > Math.Abs(num160) * 2f)
52569 {
52570 if (num162 > 0f)
52571 {
52572 ai[2] = 1f;
52573 }
52574 else
52575 {
52576 ai[2] = 5f;
52577 }
52578 }
52579 else if (Math.Abs(num160) > Math.Abs(num162) * 2f)
52580 {
52581 ai[2] = 3f;
52582 }
52583 else if (num162 > 0f)
52584 {
52585 ai[2] = 2f;
52586 }
52587 else
52588 {
52589 ai[2] = 4f;
52590 }
52591 }
52592 if ((velocity.Y != 0f && !flag17) || ai[1] <= 0f)
52593 {
52594 ai[2] = 0f;
52595 ai[1] = 0f;
52596 }
52597 else if (!flag16 || (num155 != -1 && ai[1] >= (float)num155 && ai[1] < (float)(num155 + num156) && (!flag17 || velocity.Y == 0f)))
52598 {
52599 velocity.X *= 0.9f;
52601 }
52602 }
52603 if (type == 468 && !Main.eclipse)
52604 {
52605 flag16 = true;
52606 }
52607 else if ((ai[2] <= 0f || flag16) && (velocity.Y == 0f || flag17) && ai[1] <= 0f && !Main.player[target].dead)
52608 {
52609 bool flag20 = Collision.CanHit(position, width, height, Main.player[target].position, Main.player[target].width, Main.player[target].height);
52610 if (type == 520)
52611 {
52612 flag20 = Collision.CanHitLine(base.Top + new Vector2(0f, 20f), 0, 0, Main.player[target].position, Main.player[target].width, Main.player[target].height);
52613 }
52614 if (Main.player[target].stealth == 0f && Main.player[target].itemAnimation == 0)
52615 {
52616 flag20 = false;
52617 }
52618 if (flag20)
52619 {
52620 float num169 = 10f;
52621 Vector2 vector37 = new Vector2(position.X + (float)width * 0.5f, position.Y + (float)height * 0.5f);
52622 float num170 = Main.player[target].position.X + (float)Main.player[target].width * 0.5f - vector37.X;
52623 float num171 = Math.Abs(num170) * 0.1f;
52624 float num172 = Main.player[target].position.Y + (float)Main.player[target].height * 0.5f - vector37.Y - num171;
52625 num170 += (float)Main.rand.Next(-40, 41);
52626 num172 += (float)Main.rand.Next(-40, 41);
52627 float num173 = (float)Math.Sqrt(num170 * num170 + num172 * num172);
52628 float num174 = 700f;
52629 if (type == 214)
52630 {
52631 num174 = 550f;
52632 }
52633 if (type == 215)
52634 {
52635 num174 = 800f;
52636 }
52637 if (type >= 498 && type <= 506)
52638 {
52639 num174 = 190f;
52640 }
52641 if (type >= 449 && type <= 452)
52642 {
52643 num174 = 200f;
52644 }
52645 if (type == 481)
52646 {
52647 num174 = 400f;
52648 }
52649 if (type == 468)
52650 {
52651 num174 = 400f;
52652 }
52653 if (num173 < num174)
52654 {
52655 netUpdate = true;
52656 velocity.X *= 0.5f;
52657 num173 = num169 / num173;
52658 num170 *= num173;
52659 num172 *= num173;
52660 ai[2] = 3f;
52661 ai[1] = num157;
52662 if (Math.Abs(num172) > Math.Abs(num170) * 2f)
52663 {
52664 if (num172 > 0f)
52665 {
52666 ai[2] = 1f;
52667 }
52668 else
52669 {
52670 ai[2] = 5f;
52671 }
52672 }
52673 else if (Math.Abs(num170) > Math.Abs(num172) * 2f)
52674 {
52675 ai[2] = 3f;
52676 }
52677 else if (num172 > 0f)
52678 {
52679 ai[2] = 2f;
52680 }
52681 else
52682 {
52683 ai[2] = 4f;
52684 }
52685 }
52686 }
52687 }
52688 if (ai[2] <= 0f || (flag16 && (num155 == -1 || !(ai[1] >= (float)num155) || !(ai[1] < (float)(num155 + num156)))))
52689 {
52690 float num175 = 1f;
52691 float num176 = 0.07f;
52692 float num177 = 0.8f;
52693 if (type == 214)
52694 {
52695 num175 = 2f;
52696 num176 = 0.09f;
52697 }
52698 else if (type == 215)
52699 {
52700 num175 = 1.5f;
52701 num176 = 0.08f;
52702 }
52703 else if (type == 381 || type == 382)
52704 {
52705 num175 = 2f;
52706 num176 = 0.5f;
52707 }
52708 else if (type == 520)
52709 {
52710 num175 = 4f;
52711 num176 = 1f;
52712 num177 = 0.7f;
52713 }
52714 else if (type == 411)
52715 {
52716 num175 = 2f;
52717 num176 = 0.5f;
52718 }
52719 else if (type == 409)
52720 {
52721 num175 = 2f;
52722 num176 = 0.5f;
52723 }
52724 else if (type == 426)
52725 {
52726 num175 = 4f;
52727 num176 = 0.6f;
52728 num177 = 0.95f;
52729 }
52730 bool flag21 = false;
52731 if ((type == 381 || type == 382) && Vector2.Distance(base.Center, Main.player[target].Center) < 300f && Collision.CanHitLine(base.Center, 0, 0, Main.player[target].Center, 0, 0))
52732 {
52733 flag21 = true;
52734 ai[3] = 0f;
52735 }
52736 if (type == 520 && Vector2.Distance(base.Center, Main.player[target].Center) < 400f && Collision.CanHitLine(base.Center, 0, 0, Main.player[target].Center, 0, 0))
52737 {
52738 flag21 = true;
52739 ai[3] = 0f;
52740 }
52741 if (velocity.X < 0f - num175 || velocity.X > num175 || flag21)
52742 {
52743 if (velocity.Y == 0f)
52744 {
52745 velocity *= num177;
52746 }
52747 }
52748 else if (velocity.X < num175 && direction == 1)
52749 {
52750 velocity.X += num176;
52751 if (velocity.X > num175)
52752 {
52753 velocity.X = num175;
52754 }
52755 }
52756 else if (velocity.X > 0f - num175 && direction == -1)
52757 {
52758 velocity.X -= num176;
52759 if (velocity.X < 0f - num175)
52760 {
52761 velocity.X = 0f - num175;
52762 }
52763 }
52764 }
52765 if (type == 520)
52766 {
52767 localAI[2] += 1f;
52768 if (localAI[2] >= 6f)
52769 {
52770 localAI[2] = 0f;
52771 localAI[3] = Main.player[target].DirectionFrom(base.Top + new Vector2(0f, 20f)).ToRotation();
52772 }
52773 }
52774 }
52775 if (type == 109 && Main.netMode != 1 && !Main.player[target].dead)
52776 {
52777 if (justHit)
52778 {
52779 ai[2] = 0f;
52780 }
52781 ai[2] += 1f;
52782 if (ai[2] > 60f)
52783 {
52784 Vector2 vector38 = new Vector2(position.X + (float)width * 0.5f - (float)(direction * 24), position.Y + 4f);
52785 if (Main.rand.Next(5) != 0 || AnyNPCs(378))
52786 {
52787 int num178 = Main.rand.Next(3, 8) * direction;
52788 int num179 = Main.rand.Next(-8, -5);
52789 int num180 = Projectile.NewProjectile(GetSpawnSource_ForProjectile(), vector38.X, vector38.Y, num178, num179, 75, 80, 0f, Main.myPlayer);
52790 Main.projectile[num180].timeLeft = 300;
52791 ai[2] = 0f;
52792 }
52793 else
52794 {
52795 ai[2] = -120f;
52796 int number = NewNPC(GetSpawnSourceForNPCFromNPCAI(), (int)vector38.X, (int)vector38.Y, 378);
52797 NetMessage.SendData(23, -1, -1, null, number);
52798 }
52799 }
52800 }
52801 if (velocity.Y == 0f || flag)
52802 {
52803 int num181 = (int)(position.Y + (float)height + 7f) / 16;
52804 int num182 = (int)(position.Y - 9f) / 16;
52805 int num183 = (int)position.X / 16;
52806 int num184 = (int)(position.X + (float)width) / 16;
52807 int num185 = (int)(position.X + 8f) / 16;
52808 int num186 = (int)(position.X + (float)width - 8f) / 16;
52809 bool flag22 = false;
52810 for (int num187 = num185; num187 <= num186; num187++)
52811 {
52812 if (num187 >= num183 && num187 <= num184 && Main.tile[num187, num181] == null)
52813 {
52814 flag22 = true;
52815 continue;
52816 }
52817 if (Main.tile[num187, num182] != null && Main.tile[num187, num182].nactive() && Main.tileSolid[Main.tile[num187, num182].type])
52818 {
52819 flag5 = false;
52820 break;
52821 }
52822 if (!flag22 && num187 >= num183 && num187 <= num184 && Main.tile[num187, num181].nactive() && Main.tileSolid[Main.tile[num187, num181].type])
52823 {
52824 flag5 = true;
52825 }
52826 }
52827 if (!flag5 && velocity.Y < 0f)
52828 {
52829 velocity.Y = 0f;
52830 }
52831 if (flag22)
52832 {
52833 return;
52834 }
52835 }
52836 if (type == 428)
52837 {
52838 flag5 = false;
52839 }
52840 if (velocity.Y >= 0f && (type != 580 || directionY != 1))
52841 {
52842 int num188 = 0;
52843 if (velocity.X < 0f)
52844 {
52845 num188 = -1;
52846 }
52847 if (velocity.X > 0f)
52848 {
52849 num188 = 1;
52850 }
52852 vector39.X += velocity.X;
52853 int num189 = (int)((vector39.X + (float)(width / 2) + (float)((width / 2 + 1) * num188)) / 16f);
52854 int num190 = (int)((vector39.Y + (float)height - 1f) / 16f);
52855 if (WorldGen.InWorld(num189, num190, 4))
52856 {
52857 if (Main.tile[num189, num190] == null)
52858 {
52859 Main.tile[num189, num190] = new Tile();
52860 }
52861 if (Main.tile[num189, num190 - 1] == null)
52862 {
52863 Main.tile[num189, num190 - 1] = new Tile();
52864 }
52865 if (Main.tile[num189, num190 - 2] == null)
52866 {
52867 Main.tile[num189, num190 - 2] = new Tile();
52868 }
52869 if (Main.tile[num189, num190 - 3] == null)
52870 {
52871 Main.tile[num189, num190 - 3] = new Tile();
52872 }
52873 if (Main.tile[num189, num190 + 1] == null)
52874 {
52875 Main.tile[num189, num190 + 1] = new Tile();
52876 }
52877 if (Main.tile[num189 - num188, num190 - 3] == null)
52878 {
52879 Main.tile[num189 - num188, num190 - 3] = new Tile();
52880 }
52881 if ((float)(num189 * 16) < vector39.X + (float)width && (float)(num189 * 16 + 16) > vector39.X && ((Main.tile[num189, num190].nactive() && !Main.tile[num189, num190].topSlope() && !Main.tile[num189, num190 - 1].topSlope() && Main.tileSolid[Main.tile[num189, num190].type] && !Main.tileSolidTop[Main.tile[num189, num190].type]) || (Main.tile[num189, num190 - 1].halfBrick() && Main.tile[num189, num190 - 1].nactive())) && (!Main.tile[num189, num190 - 1].nactive() || !Main.tileSolid[Main.tile[num189, num190 - 1].type] || Main.tileSolidTop[Main.tile[num189, num190 - 1].type] || (Main.tile[num189, num190 - 1].halfBrick() && (!Main.tile[num189, num190 - 4].nactive() || !Main.tileSolid[Main.tile[num189, num190 - 4].type] || Main.tileSolidTop[Main.tile[num189, num190 - 4].type]))) && (!Main.tile[num189, num190 - 2].nactive() || !Main.tileSolid[Main.tile[num189, num190 - 2].type] || Main.tileSolidTop[Main.tile[num189, num190 - 2].type]) && (!Main.tile[num189, num190 - 3].nactive() || !Main.tileSolid[Main.tile[num189, num190 - 3].type] || Main.tileSolidTop[Main.tile[num189, num190 - 3].type]) && (!Main.tile[num189 - num188, num190 - 3].nactive() || !Main.tileSolid[Main.tile[num189 - num188, num190 - 3].type]))
52882 {
52883 float num191 = num190 * 16;
52884 if (Main.tile[num189, num190].halfBrick())
52885 {
52886 num191 += 8f;
52887 }
52888 if (Main.tile[num189, num190 - 1].halfBrick())
52889 {
52890 num191 -= 8f;
52891 }
52892 if (num191 < vector39.Y + (float)height)
52893 {
52894 float num192 = vector39.Y + (float)height - num191;
52895 float num193 = 16.1f;
52896 if (type == 163 || type == 164 || type == 236 || type == 239 || type == 530)
52897 {
52898 num193 += 8f;
52899 }
52900 if (num192 <= num193)
52901 {
52902 gfxOffY += position.Y + (float)height - num191;
52903 position.Y = num191 - (float)height;
52904 if (num192 < 9f)
52905 {
52906 stepSpeed = 1f;
52907 }
52908 else
52909 {
52910 stepSpeed = 2f;
52911 }
52912 }
52913 }
52914 }
52915 }
52916 }
52917 if (flag5)
52918 {
52919 int num194 = (int)((position.X + (float)(width / 2) + (float)(15 * direction)) / 16f);
52920 int num195 = (int)((position.Y + (float)height - 15f) / 16f);
52921 if (type == 109 || type == 163 || type == 164 || type == 199 || type == 236 || type == 239 || type == 257 || type == 258 || type == 290 || type == 391 || type == 425 || type == 427 || type == 426 || type == 580 || type == 508 || type == 415 || type == 530 || type == 532 || type == 582)
52922 {
52923 num194 = (int)((position.X + (float)(width / 2) + (float)((width / 2 + 16) * direction)) / 16f);
52924 }
52925 if (Main.tile[num194, num195] == null)
52926 {
52927 Main.tile[num194, num195] = new Tile();
52928 }
52929 if (Main.tile[num194, num195 - 1] == null)
52930 {
52931 Main.tile[num194, num195 - 1] = new Tile();
52932 }
52933 if (Main.tile[num194, num195 - 2] == null)
52934 {
52935 Main.tile[num194, num195 - 2] = new Tile();
52936 }
52937 if (Main.tile[num194, num195 - 3] == null)
52938 {
52939 Main.tile[num194, num195 - 3] = new Tile();
52940 }
52941 if (Main.tile[num194, num195 + 1] == null)
52942 {
52943 Main.tile[num194, num195 + 1] = new Tile();
52944 }
52945 if (Main.tile[num194 + direction, num195 - 1] == null)
52946 {
52947 Main.tile[num194 + direction, num195 - 1] = new Tile();
52948 }
52949 if (Main.tile[num194 + direction, num195 + 1] == null)
52950 {
52951 Main.tile[num194 + direction, num195 + 1] = new Tile();
52952 }
52953 if (Main.tile[num194 - direction, num195 + 1] == null)
52954 {
52955 Main.tile[num194 - direction, num195 + 1] = new Tile();
52956 }
52957 Main.tile[num194, num195 + 1].halfBrick();
52958 if (Main.tile[num194, num195 - 1].nactive() && (Main.tile[num194, num195 - 1].type == 10 || Main.tile[num194, num195 - 1].type == 388) && flag8)
52959 {
52960 ai[2] += 1f;
52961 ai[3] = 0f;
52962 if (ai[2] >= 60f)
52963 {
52964 bool flag23 = type == 3 || type == 430 || type == 590 || type == 331 || type == 332 || type == 132 || type == 161 || type == 186 || type == 187 || type == 188 || type == 189 || type == 200 || type == 223 || type == 320 || type == 321 || type == 319 || type == 21 || type == 324 || type == 323 || type == 322 || type == 44 || type == 196 || type == 167 || type == 77 || type == 197 || type == 202 || type == 203 || type == 449 || type == 450 || type == 451 || type == 452 || type == 481 || type == 201 || type == 635;
52965 bool flag24 = Main.player[target].ZoneGraveyard && Main.rand.Next(60) == 0;
52966 if ((!Main.bloodMoon || Main.getGoodWorld) && !flag24 && flag23)
52967 {
52968 ai[1] = 0f;
52969 }
52970 velocity.X = 0.5f * (float)(-direction);
52971 int num196 = 5;
52972 if (Main.tile[num194, num195 - 1].type == 388)
52973 {
52974 num196 = 2;
52975 }
52976 ai[1] += num196;
52977 if (type == 27)
52978 {
52979 ai[1] += 1f;
52980 }
52981 if (type == 31 || type == 294 || type == 295 || type == 296)
52982 {
52983 ai[1] += 6f;
52984 }
52985 ai[2] = 0f;
52986 bool flag25 = false;
52987 if (ai[1] >= 10f)
52988 {
52989 flag25 = true;
52990 ai[1] = 10f;
52991 }
52992 if (type == 460)
52993 {
52994 flag25 = true;
52995 }
52996 WorldGen.KillTile(num194, num195 - 1, fail: true);
52997 if ((Main.netMode != 1 || !flag25) && flag25 && Main.netMode != 1)
52998 {
52999 if (type == 26)
53000 {
53001 WorldGen.KillTile(num194, num195 - 1);
53002 if (Main.netMode == 2)
53003 {
53004 NetMessage.SendData(17, -1, -1, null, 0, num194, num195 - 1);
53005 }
53006 }
53007 else
53008 {
53009 if (Main.tile[num194, num195 - 1].type == 10)
53010 {
53011 bool flag26 = WorldGen.OpenDoor(num194, num195 - 1, direction);
53012 if (!flag26)
53013 {
53014 ai[3] = num56;
53015 netUpdate = true;
53016 }
53017 if (Main.netMode == 2 && flag26)
53018 {
53019 NetMessage.SendData(19, -1, -1, null, 0, num194, num195 - 1, direction);
53020 }
53021 }
53022 if (Main.tile[num194, num195 - 1].type == 388)
53023 {
53024 bool flag27 = WorldGen.ShiftTallGate(num194, num195 - 1, closing: false);
53025 if (!flag27)
53026 {
53027 ai[3] = num56;
53028 netUpdate = true;
53029 }
53030 if (Main.netMode == 2 && flag27)
53031 {
53032 NetMessage.SendData(19, -1, -1, null, 4, num194, num195 - 1);
53033 }
53034 }
53035 }
53036 }
53037 }
53038 }
53039 else
53040 {
53041 int num197 = spriteDirection;
53042 if (type == 425)
53043 {
53044 num197 *= -1;
53045 }
53046 if ((velocity.X < 0f && num197 == -1) || (velocity.X > 0f && num197 == 1))
53047 {
53048 if (height >= 32 && Main.tile[num194, num195 - 2].nactive() && Main.tileSolid[Main.tile[num194, num195 - 2].type])
53049 {
53050 if (Main.tile[num194, num195 - 3].nactive() && Main.tileSolid[Main.tile[num194, num195 - 3].type])
53051 {
53052 velocity.Y = -8f;
53053 netUpdate = true;
53054 }
53055 else
53056 {
53057 velocity.Y = -7f;
53058 netUpdate = true;
53059 }
53060 }
53061 else if (Main.tile[num194, num195 - 1].nactive() && Main.tileSolid[Main.tile[num194, num195 - 1].type])
53062 {
53063 if (type == 624)
53064 {
53065 velocity.Y = -8f;
53066 int num198 = (int)(position.Y + (float)height) / 16;
53067 if (WorldGen.SolidTile((int)base.Center.X / 16, num198 - 8))
53068 {
53069 direction *= -1;
53071 velocity.X = 3 * direction;
53072 }
53073 }
53074 else
53075 {
53076 velocity.Y = -6f;
53077 }
53078 netUpdate = true;
53079 }
53080 else if (position.Y + (float)height - (float)(num195 * 16) > 20f && Main.tile[num194, num195].nactive() && !Main.tile[num194, num195].topSlope() && Main.tileSolid[Main.tile[num194, num195].type])
53081 {
53082 velocity.Y = -5f;
53083 netUpdate = true;
53084 }
53085 else if (directionY < 0 && type != 67 && (!Main.tile[num194, num195 + 1].nactive() || !Main.tileSolid[Main.tile[num194, num195 + 1].type]) && (!Main.tile[num194 + direction, num195 + 1].nactive() || !Main.tileSolid[Main.tile[num194 + direction, num195 + 1].type]))
53086 {
53087 velocity.Y = -8f;
53088 velocity.X *= 1.5f;
53089 netUpdate = true;
53090 }
53091 else if (flag8)
53092 {
53093 ai[1] = 0f;
53094 ai[2] = 0f;
53095 }
53096 if (velocity.Y == 0f && flag6 && ai[3] == 1f)
53097 {
53098 velocity.Y = -5f;
53099 }
53100 if (velocity.Y == 0f && (Main.expertMode || type == 586) && Main.player[target].Bottom.Y < base.Top.Y && Math.Abs(base.Center.X - Main.player[target].Center.X) < (float)(Main.player[target].width * 3) && Collision.CanHit(this, Main.player[target]))
53101 {
53102 if (type == 586)
53103 {
53104 int num199 = (int)((base.Bottom.Y - 16f - Main.player[target].Bottom.Y) / 16f);
53105 if (num199 < 14 && Collision.CanHit(this, Main.player[target]))
53106 {
53107 if (num199 < 7)
53108 {
53109 velocity.Y = -8.8f;
53110 }
53111 else if (num199 < 8)
53112 {
53113 velocity.Y = -9.2f;
53114 }
53115 else if (num199 < 9)
53116 {
53117 velocity.Y = -9.7f;
53118 }
53119 else if (num199 < 10)
53120 {
53121 velocity.Y = -10.3f;
53122 }
53123 else if (num199 < 11)
53124 {
53125 velocity.Y = -10.6f;
53126 }
53127 else
53128 {
53129 velocity.Y = -11f;
53130 }
53131 }
53132 }
53133 if (velocity.Y == 0f)
53134 {
53135 int num200 = 6;
53136 if (Main.player[target].Bottom.Y > base.Top.Y - (float)(num200 * 16))
53137 {
53138 velocity.Y = -7.9f;
53139 }
53140 else
53141 {
53142 int num201 = (int)(base.Center.X / 16f);
53143 int num202 = (int)(base.Bottom.Y / 16f) - 1;
53144 for (int num203 = num202; num203 > num202 - num200; num203--)
53145 {
53146 if (Main.tile[num201, num203].nactive() && TileID.Sets.Platforms[Main.tile[num201, num203].type])
53147 {
53148 velocity.Y = -7.9f;
53149 break;
53150 }
53151 }
53152 }
53153 }
53154 }
53155 }
53156 if ((type == 31 || type == 294 || type == 295 || type == 296 || type == 47 || type == 77 || type == 104 || type == 168 || type == 196 || type == 385 || type == 389 || type == 464 || type == 470 || (type >= 524 && type <= 527)) && velocity.Y == 0f)
53157 {
53158 int num204 = 100;
53159 int num205 = 50;
53160 if (type == 586)
53161 {
53162 num204 = 150;
53163 num205 = 150;
53164 }
53165 if (Math.Abs(position.X + (float)(width / 2) - (Main.player[target].position.X + (float)(Main.player[target].width / 2))) < (float)num204 && Math.Abs(position.Y + (float)(height / 2) - (Main.player[target].position.Y + (float)(Main.player[target].height / 2))) < (float)num205 && ((direction > 0 && velocity.X >= 1f) || (direction < 0 && velocity.X <= -1f)))
53166 {
53167 if (type == 586)
53168 {
53169 velocity.X += direction;
53170 velocity.X *= 2f;
53171 if (velocity.X > 8f)
53172 {
53173 velocity.X = 8f;
53174 }
53175 if (velocity.X < -8f)
53176 {
53177 velocity.X = -8f;
53178 }
53179 velocity.Y = -4.5f;
53180 if (position.Y > Main.player[target].position.Y + 40f)
53181 {
53182 velocity.Y -= 2f;
53183 }
53184 if (position.Y > Main.player[target].position.Y + 80f)
53185 {
53186 velocity.Y -= 2f;
53187 }
53188 if (position.Y > Main.player[target].position.Y + 120f)
53189 {
53190 velocity.Y -= 2f;
53191 }
53192 }
53193 else
53194 {
53195 velocity.X *= 2f;
53196 if (velocity.X > 3f)
53197 {
53198 velocity.X = 3f;
53199 }
53200 if (velocity.X < -3f)
53201 {
53202 velocity.X = -3f;
53203 }
53204 velocity.Y = -4f;
53205 }
53206 netUpdate = true;
53207 }
53208 }
53209 if (type == 120 && velocity.Y < 0f)
53210 {
53211 velocity.Y *= 1.1f;
53212 }
53213 if (type == 287 && velocity.Y == 0f && Math.Abs(position.X + (float)(width / 2) - (Main.player[target].position.X + (float)(Main.player[target].width / 2))) < 150f && Math.Abs(position.Y + (float)(height / 2) - (Main.player[target].position.Y + (float)(Main.player[target].height / 2))) < 50f && ((direction > 0 && velocity.X >= 1f) || (direction < 0 && velocity.X <= -1f)))
53214 {
53215 velocity.X = 8 * direction;
53216 velocity.Y = -4f;
53217 netUpdate = true;
53218 }
53219 if (type == 287 && velocity.Y < 0f)
53220 {
53221 velocity.X *= 1.2f;
53222 velocity.Y *= 1.1f;
53223 }
53224 if (type == 460 && velocity.Y < 0f)
53225 {
53226 velocity.X *= 1.3f;
53227 velocity.Y *= 1.1f;
53228 }
53229 }
53230 }
53231 else if (flag8)
53232 {
53233 ai[1] = 0f;
53234 ai[2] = 0f;
53235 }
53236 if (Main.netMode != 1 && type == 120 && ai[3] >= (float)num56)
53237 {
53238 int targetTileX = (int)Main.player[target].Center.X / 16;
53239 int targetTileY = (int)Main.player[target].Center.Y / 16;
53242 {
53243 position.X = chosenTile.X * 16f - (float)(width / 2);
53244 position.Y = chosenTile.Y * 16f - (float)height;
53245 ai[3] = -120f;
53246 netUpdate = true;
53247 }
53248 }
53249 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
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)
Vector2 DirectionFrom(Vector2 Source)
Definition Entity.cs:202
Vector2 oldPosition
Definition Entity.cs:18
Vector2 velocity
Definition Entity.cs:16
float Distance(Vector2 Other)
Definition Entity.cs:187
Vector2 position
Definition Entity.cs:14
Vector2 oldVelocity
Definition Entity.cs:20
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
static readonly LegacySoundStyle Item8
Definition SoundID.cs:430
static bool[] Platforms
Definition TileID.cs:163
Vector2 netOffset
Definition NPC.cs:103
int defense
Definition NPC.cs:463
int damage
Definition NPC.cs:461
static int CountNPCS(int Type)
Definition NPC.cs:86664
float[] localAI
Definition NPC.cs:449
int spriteDirection
Definition NPC.cs:517
bool confused
Definition NPC.cs:253
void EncourageDespawn(int despawnTime)
Definition NPC.cs:1390
bool reflectsProjectiles
Definition NPC.cs:571
int lifeMax
Definition NPC.cs:479
float gfxOffY
Definition NPC.cs:125
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
float takenDamageMultiplier
Definition NPC.cs:117
bool hide
Definition NPC.cs:491
static float gravity
Definition NPC.cs:129
bool AI_003_Gnomes_ShouldTurnToStone()
Definition NPC.cs:48952
bool noGravity
Definition NPC.cs:503
int defDefense
Definition NPC.cs:467
float[] ai
Definition NPC.cs:447
float knockBackResist
Definition NPC.cs:495
bool dontTakeDamage
Definition NPC.cs:527
void CountKillForBannersAndDropThem()
Definition NPC.cs:72016
float stepSpeed
Definition NPC.cs:127
float scale
Definition NPC.cs:493
bool collideX
Definition NPC.cs:511
static bool AnyNPCs(int Type)
Definition NPC.cs:86689
int type
Definition NPC.cs:445
int alpha
Definition NPC.cs:489
float rotation
Definition NPC.cs:501
bool AI_AttemptToFindTeleportSpot(ref Vector2 chosenTile, int targetTileX, int targetTileY, int rangeFromTargetTile=20, int telefragPreventionDistanceInTiles=5, int solidTileCheckFluff=1, bool solidTileCheckCentered=false, bool teleportInAir=false)
Definition NPC.cs:12861
IEntitySource GetSpawnSourceForNPCFromNPCAI()
Definition NPC.cs:87546
float shimmerTransparency
Definition NPC.cs:207
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
bool noTileCollide
Definition NPC.cs:505
int defDamage
Definition NPC.cs:465
int GetAttackDamage_ForProjectiles(float normalDamage, float expertDamage)
Definition NPC.cs:1082
bool justHit
Definition NPC.cs:455
void Transform(int newType)
Definition NPC.cs:77913
int life
Definition NPC.cs:477
IEntitySource GetSpawnSource_ForProjectile()
Definition NPC.cs:87526
bool IsNPCValidForBestiaryKillCredit()
Definition NPC.cs:71156
bool NPCCanStickToWalls()
Definition NPC.cs:48929
static bool DespawnEncouragement_AIStyle3_Fighters_CanBeBusyWithAction(int npcID)
Definition NPC.cs:53283
static bool DespawnEncouragement_AIStyle3_Fighters_NotDiscouraged(int npcID, Vector2 position, NPC npcInstance)
Definition NPC.cs:53251
int directionY
Definition NPC.cs:443
bool netUpdate
Definition NPC.cs:507
Vector2[] oldPos
Definition NPC.cs:155
int target
Definition NPC.cs:459
static Color Transparent
Definition Color.cs:76
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.NPC.AI_003_Gnomes_ShouldTurnToStone(), Terraria.NPC.AI_AttemptToFindTeleportSpot(), Terraria.NPC.alpha, Terraria.NPC.AnyNPCs(), System.array, Terraria.Main.BestiaryTracker, Terraria.Main.bloodMoon, Terraria.Collision.CanHit(), Terraria.Collision.CanHitLine(), Terraria.TileObject.CanPlace(), Terraria.Entity.Center, Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.NPC.collideX, Terraria.NPC.confused, Terraria.NPC.CountKillForBannersAndDropThem(), Terraria.NPC.CountNPCS(), Terraria.NPC.damage, Terraria.NPC.defDamage, Terraria.NPC.defDefense, Terraria.NPC.defense, Terraria.NPC.DespawnEncouragement_AIStyle3_Fighters_CanBeBusyWithAction(), Terraria.NPC.DespawnEncouragement_AIStyle3_Fighters_NotDiscouraged(), Terraria.Entity.direction, Terraria.Entity.DirectionFrom(), Terraria.Entity.DirectionTo(), Terraria.NPC.directionY, Terraria.Entity.Distance(), Microsoft.Xna.Framework.Vector2.Distance(), Terraria.NPC.dontTakeDamage, Terraria.Main.dust, Terraria.Main.eclipse, Terraria.NPC.EncourageDespawn(), Terraria.Main.expertMode, Terraria.Utils.FactorAcceleration(), Terraria.Main.GameModeInfo, Terraria.NPC.GetAttackDamage_ForProjectiles(), Terraria.Utils.GetChaseResults(), Terraria.Main.getGoodWorld, Terraria.NPC.GetSpawnSource_ForProjectile(), Terraria.NPC.GetSpawnSourceForNPCFromNPCAI(), Terraria.Framing.GetTileSafely(), Terraria.NPC.gfxOffY, Terraria.NPC.gravity, Terraria.Entity.height, Terraria.NPC.hide, Terraria.Entity.Hitbox, Microsoft.Xna.Framework.Rectangle.Intersects(), Terraria.WorldGen.InWorld(), Terraria.Main.IsItDay(), Terraria.NPC.IsNPCValidForBestiaryKillCredit(), Terraria.ID.SoundID.Item8, Terraria.NPC.justHit, Terraria.WorldGen.KillTile(), Terraria.NPC.knockBackResist, 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.netOffset, Terraria.NPC.netUpdate, Terraria.Dust.NewDust(), Terraria.Dust.NewDustDirect(), Terraria.NPC.NewNPC(), Terraria.Projectile.NewProjectile(), Terraria.NPC.noGravity, Microsoft.Xna.Framework.Vector2.Normalize(), Terraria.GameContent.Achievements.AchievementsHelper.NotifyProgressionEvent(), Terraria.NPC.noTileCollide, Terraria.Main.npc, Terraria.NPC.NPCCanStickToWalls(), System.obj, Terraria.NPC.oldPos, Terraria.Entity.oldPosition, Terraria.Entity.oldVelocity, Terraria.WorldGen.OpenDoor(), System.Math.PI, Terraria.WorldGen.PlaceTile(), Terraria.ID.TileID.Sets.Platforms, Terraria.Main.player, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Entity.position, Terraria.Main.projectile, Terraria.Main.rand, Terraria.Utils.RandomVector2(), Terraria.NPC.reflectsProjectiles, Terraria.Main.remixWorld, Terraria.NPC.rotation, Terraria.NPC.scale, Terraria.NetMessage.SendData(), Terraria.NetMessage.SendTileSquare(), Terraria.WorldGen.ShiftTallGate(), Terraria.NPC.shimmerTransparency, System.Math.Sign(), Terraria.Collision.SolidCollision(), Terraria.WorldGen.SolidTile(), Terraria.WorldGen.SolidTileAllowBottomSlope(), Terraria.Collision.SolidTiles(), Terraria.NPC.spriteDirection, System.Math.Sqrt(), Terraria.NPC.stepSpeed, Terraria.NPC.takenDamageMultiplier, Terraria.NPC.target, Terraria.NPC.TargetClosest(), Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileSolid, Terraria.Main.tileSolidTop, Terraria.NPC.Transform(), Microsoft.Xna.Framework.Color.Transparent, Terraria.NPC.type, Microsoft.Xna.Framework.Vector2.UnitY, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Graphics.Vector3, Terraria.Entity.velocity, Terraria.Entity.wet, Microsoft.Xna.Framework.Color.White, Terraria.Entity.whoAmI, 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().