From 43f86f803f29466455d53e41c604bdc331d73dea Mon Sep 17 00:00:00 2001 From: Andrew Marheine Date: Thu, 23 Jan 2020 16:53:40 -0600 Subject: [PATCH] Death Mode fighter AI changes. --- CalPlayer/CalamityPlayerMiscEffects.cs | 2 +- NPCs/CalamityGlobalAI.cs | 3833 +++++++++++++++++++++++- NPCs/CalamityGlobalNPC.cs | 204 +- 3 files changed, 4000 insertions(+), 39 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e8a0b40d18..0e56d27762 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -384,7 +384,7 @@ namespace CalamityMod.CalPlayer } else { - if (player.miscCounter == (int)(240f * frequencyMult)) + if (player.miscCounter == (int)(240f * frequencyMult) && Main.rand.NextBool(3)) { float randomVelocity = Main.rand.NextFloat() - 0.5f; Vector2 fireTo = new Vector2(spawnPoint.X + 100f * randomVelocity, spawnPoint.Y + 900); diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index c8b3003f50..0adac7ef11 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -14061,37 +14061,3810 @@ namespace CalamityMod.NPCs } #endregion - #region Revengeance Basic NPC AI - public static void RevengeanceLihzahrdAI(NPC npc) + #region Death Mode NPC AI + public static bool BuffedFighterAI(NPC npc, Mod mod) { - // Transform into second state sooner - if (Main.netMode != NetmodeID.MultiplayerClient && (double)npc.life <= (double)npc.lifeMax * 0.9) - npc.Transform(NPCID.LihzahrdCrawler); - } - - public static void RevengeanceIceGolemAI(NPC npc) - { - // Increases movement speed - float num63 = 2f; - float num64 = 0.14f; - num63 += (1f - (float)npc.life / (float)npc.lifeMax) * 1.5f; - num64 += (1f - (float)npc.life / (float)npc.lifeMax) * 0.15f; - - if (npc.velocity.X < -num63 || npc.velocity.X > num63) - return; - else if (npc.velocity.X < num63 && npc.direction == 1) - { - npc.velocity.X += num64; - if (npc.velocity.X > num63) - npc.velocity.X = num63; - } - else if (npc.velocity.X > -num63 && npc.direction == -1) - { - npc.velocity.X -= num64; - if (npc.velocity.X < -num63) - npc.velocity.X = -num63; - } - } + if (npc.type == NPCID.Psycho) + { + int num = 200; + if (npc.ai[2] == 0f) + { + npc.alpha = num; + npc.TargetClosest(true); + if (!Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() < 170f) + { + npc.ai[2] = -16f; + } + if (npc.velocity.X != 0f || npc.velocity.Y < 0f || npc.velocity.Y > 2f || npc.justHit) + { + npc.ai[2] = -16f; + } + return false; + } + if (npc.ai[2] < 0f) + { + if (npc.alpha > 0) + { + npc.alpha -= num / 16; + if (npc.alpha < 0) + { + npc.alpha = 0; + } + } + npc.ai[2] += 1f; + if (npc.ai[2] == 0f) + { + npc.ai[2] = 1f; + npc.velocity.X = (float)(npc.direction * 2); + } + return false; + } + npc.alpha = 0; + } + if (npc.type == NPCID.SwampThing) + { + if (Main.netMode != 1 && Main.rand.Next(240) == 0) + { + npc.ai[2] = (float)Main.rand.Next(-480, -60); + npc.netUpdate = true; + } + if (npc.ai[2] < 0f) + { + npc.TargetClosest(true); + if (npc.justHit) + { + npc.ai[2] = 0f; + } + if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.ai[2] = 0f; + } + } + if (npc.ai[2] < 0f) + { + npc.velocity.X = npc.velocity.X * 0.9f; + if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + { + npc.velocity.X = 0f; + } + npc.ai[2] += 1f; + if (npc.ai[2] == 0f) + { + npc.velocity.X = (float)npc.direction * 0.1f; + } + return false; + } + } + if (npc.type == NPCID.CreatureFromTheDeep) + { + if (npc.wet) + { + npc.knockBackResist = 0f; + npc.ai[3] = -0.10101f; + npc.noGravity = true; + Vector2 center = npc.Center; + npc.width = 34; + npc.height = 24; + npc.position.X = center.X - (float)(npc.width / 2); + npc.position.Y = center.Y - (float)(npc.height / 2); + npc.TargetClosest(true); + if (npc.collideX) + { + npc.velocity.X = -npc.oldVelocity.X; + } + if (npc.velocity.X < 0f) + { + npc.direction = -1; + } + if (npc.velocity.X > 0f) + { + npc.direction = 1; + } + if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1)) + { + Vector2 value = Main.player[npc.target].Center - npc.Center; + value.Normalize(); + value *= 10f; + npc.velocity = (npc.velocity * 19f + value) / 20f; + return false; + } + float num2 = 10f; + if (npc.velocity.Y > 0f) + { + num2 = 6f; + } + if (npc.velocity.Y < 0f) + { + num2 = 16f; + } + Vector2 value2 = new Vector2((float)npc.direction, -1f); + value2.Normalize(); + value2 *= num2; + if (num2 < 5f) + { + npc.velocity = (npc.velocity * 24f + value2) / 25f; + return false; + } + npc.velocity = (npc.velocity * 9f + value2) / 10f; + return false; + } + else + { + npc.knockBackResist = 0.2f * Main.knockBackMultiplier; + npc.noGravity = false; + Vector2 center2 = npc.Center; + npc.width = 18; + npc.height = 40; + npc.position.X = center2.X - (float)(npc.width / 2); + npc.position.Y = center2.Y - (float)(npc.height / 2); + if (npc.ai[3] == -0.10101f) + { + npc.ai[3] = 0f; + float num3 = npc.velocity.Length(); + num3 *= 2f; + if (num3 > 12f) + { + num3 = 12f; + } + npc.velocity.Normalize(); + npc.velocity *= num3; + if (npc.velocity.X < 0f) + { + npc.direction = -1; + } + if (npc.velocity.X > 0f) + { + npc.direction = 1; + } + npc.spriteDirection = npc.direction; + } + } + } + if (npc.type == NPCID.CultistArcherBlue || npc.type == NPCID.CultistArcherWhite) + { + if (npc.ai[3] < 0f) + { + npc.damage = 0; + npc.velocity.X = npc.velocity.X * 0.93f; + if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) + { + npc.velocity.X = 0f; + } + int num4 = (int)(-npc.ai[3] - 1f); + int num5 = Math.Sign(Main.npc[num4].Center.X - npc.Center.X); + if (num5 != npc.direction) + { + npc.velocity.X = 0f; + npc.direction = num5; + npc.netUpdate = true; + } + if (npc.justHit && Main.netMode != 1 && Main.npc[num4].localAI[0] == 0f) + { + Main.npc[num4].localAI[0] = 1f; + } + if (npc.ai[0] < 1000f) + { + npc.ai[0] = 1000f; + } + float[] expr_710_cp_0 = npc.ai; + int expr_710_cp_1 = 0; + float num6 = expr_710_cp_0[expr_710_cp_1] + 1f; + expr_710_cp_0[expr_710_cp_1] = num6; + if (num6 >= 1300f) + { + npc.ai[0] = 1000f; + npc.netUpdate = true; + } + return false; + } + if (npc.ai[0] >= 1000f) + { + npc.ai[0] = 0f; + } + npc.damage = npc.defDamage; + } + if (npc.type == NPCID.MartianOfficer && npc.ai[2] == 0f && npc.localAI[0] == 0f && Main.netMode != 1) + { + int num7 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCID.ForceBubble, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + npc.ai[2] = (float)(num7 + 1); + npc.localAI[0] = -1f; + npc.netUpdate = true; + Main.npc[num7].ai[0] = (float)npc.whoAmI; + Main.npc[num7].netUpdate = true; + } + if (npc.type == NPCID.MartianOfficer) + { + int num8 = (int)npc.ai[2] - 1; + if (num8 != -1 && Main.npc[num8].active && Main.npc[num8].type == NPCID.ForceBubble) + { + npc.dontTakeDamage = true; + } + else + { + npc.dontTakeDamage = false; + npc.ai[2] = 0f; + if (npc.localAI[0] == -1f) + { + npc.localAI[0] = 120f; + } + if (npc.localAI[0] > 0f) + { + npc.localAI[0] -= 1f; + } + } + } + if (npc.type == NPCID.GraniteGolem) + { + int num9 = 300; + int num10 = 120; + npc.defense = npc.defDefense; + if (npc.ai[2] < 0f) + { + npc.defense = npc.defDefense + 15; + npc.ai[2] += 1f; + npc.velocity.X = npc.velocity.X * 0.9f; + if ((double)Math.Abs(npc.velocity.X) < 0.001) + { + npc.velocity.X = 0.001f * (float)npc.direction; + } + if (Math.Abs(npc.velocity.Y) > 1f) + { + npc.ai[2] += 10f; + } + if (npc.ai[2] >= 0f) + { + npc.netUpdate = true; + npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.3f; + } + return false; + } + if (npc.ai[2] < (float)num9) + { + if (npc.justHit) + { + npc.ai[2] += 15f; + } + npc.ai[2] += 1f; + } + else if (npc.velocity.Y == 0f) + { + npc.ai[2] = (float)(-(float)num10); + npc.netUpdate = true; + } + } + if (npc.type == NPCID.Medusa) + { + int num11 = 90; + int num12 = 210; + int num13 = 270; + int num14 = 120; + int num15 = 20; + if (npc.ai[2] > 0f) + { + npc.ai[2] -= 1f; + } + else if (npc.ai[2] == 0f) + { + if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && npc.velocity.Y == 0f && npc.Distance(Main.player[npc.target].Center) < 900f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.ai[2] = (float)(-(float)num13 - num15); + npc.netUpdate = true; + } + } + else + { + if (npc.ai[2] < 0f && npc.ai[2] < (float)(-(float)num13)) + { + npc.velocity.X = npc.velocity.X * 0.9f; + if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit) + { + npc.ai[2] = (float)num11; + } + else + { + npc.ai[2] += 1f; + if (npc.ai[2] == 0f) + { + npc.ai[2] = (float)num12; + } + } + float num16 = npc.ai[2] + (float)num13 + (float)num15; + if (num16 == 1f) + { + Main.PlaySound(4, (int)npc.position.X, (int)npc.position.Y, 17, 1f, 0f); + } + if (num16 < (float)num15) + { + Vector2 vector = npc.Top + new Vector2((float)(npc.spriteDirection * 6), 6f); + float scaleFactor = MathHelper.Lerp(20f, 30f, (num16 * 3f + 50f) / 182f); + Main.rand.NextFloat(); + for (float num17 = 0f; num17 < 2f; num17 += 1f) + { + Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f); + Dust expr_D34 = Main.dust[Dust.NewDust(vector, 0, 0, 228, 0f, 0f, 0, default(Color), 1f)]; + expr_D34.position = vector + vector2 * scaleFactor; + expr_D34.noGravity = true; + expr_D34.velocity = vector2 * 2f; + expr_D34.scale = 0.5f + Main.rand.NextFloat() * 0.5f; + } + } + Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f); + return false; + } + if (npc.ai[2] < 0f && npc.ai[2] >= (float)(-(float)num13)) + { + Lighting.AddLight(npc.Center, 0.9f, 0.75f, 0.1f); + npc.velocity.X = npc.velocity.X * 0.9f; + if (npc.velocity.Y < -2f || npc.velocity.Y > 4f || npc.justHit) + { + npc.ai[2] = (float)num11; + } + else + { + npc.ai[2] += 1f; + if (npc.ai[2] == 0f) + { + npc.ai[2] = (float)num12; + } + } + float num18 = npc.ai[2] + (float)num13; + if (num18 < 180f && (Main.rand.Next(3) == 0 || npc.ai[2] % 3f == 0f)) + { + Vector2 vector3 = npc.Top + new Vector2((float)(npc.spriteDirection * 10), 10f); + float scaleFactor2 = MathHelper.Lerp(20f, 30f, (num18 * 3f + 50f) / 182f); + Main.rand.NextFloat(); + for (float num19 = 0f; num19 < 1f; num19 += 1f) + { + Vector2 vector4 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * (Main.rand.NextFloat() * 0.5f + 0.5f); + Dust expr_F62 = Main.dust[Dust.NewDust(vector3, 0, 0, 228, 0f, 0f, 0, default(Color), 1f)]; + expr_F62.position = vector3 + vector4 * scaleFactor2; + expr_F62.noGravity = true; + expr_F62.velocity = vector4 * 4f; + expr_F62.scale = 0.5f + Main.rand.NextFloat(); + } + } + if (Main.netMode != 2) + { + Player player = Main.player[Main.myPlayer]; + int arg_FD9_0 = Main.myPlayer; + if (!player.dead && player.active && player.FindBuffIndex(156) == -1) + { + Vector2 vector5 = player.Center - npc.Center; + if (vector5.Length() < 1000f) + { + bool flag = vector5.Length() < 30f; + if (!flag) + { + float x = 0.7853982f.ToRotationVector2().X; + Vector2 vector6 = Vector2.Normalize(vector5); + if (vector6.X > x || vector6.X < -x) + { + flag = true; + } + } + if (((player.Center.X < npc.Center.X && npc.direction < 0 && player.direction > 0) || (player.Center.X > npc.Center.X && npc.direction > 0 && player.direction < 0)) && flag && (Collision.CanHitLine(npc.Center, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center - Vector2.UnitY * 16f, 1, 1, player.Center, 1, 1) || Collision.CanHitLine(npc.Center + Vector2.UnitY * 8f, 1, 1, player.Center, 1, 1))) + { + player.AddBuff(156, num14 + (int)npc.ai[2] * -1, true); + } + } + } + } + return false; + } + } + } + if (npc.type == NPCID.GoblinSummoner) + { + if (npc.ai[3] < 0f) + { + npc.knockBackResist = 0f; + npc.defense = (int)((double)npc.defDefense * 1.3); + npc.noGravity = true; + npc.noTileCollide = true; + if (npc.velocity.X < 0f) + { + npc.direction = -1; + } + else if (npc.velocity.X > 0f) + { + npc.direction = 1; + } + npc.rotation = npc.velocity.X * 0.1f; + if (Main.netMode != 1) + { + npc.localAI[3] += 1f; + if (npc.localAI[3] > (float)Main.rand.Next(20, 120)) + { + npc.localAI[3] = 0f; + Vector2 vector7 = npc.Center; + vector7 += npc.velocity; + NPC.NewNPC((int)vector7.X, (int)vector7.Y, NPCID.ChaosBall, 0, 0f, 0f, 0f, 0f, 255); + } + } + } + else + { + npc.localAI[3] = 0f; + npc.knockBackResist = 0.2f * Main.knockBackMultiplier; + npc.rotation *= 0.9f; + npc.defense = npc.defDefense; + npc.noGravity = false; + npc.noTileCollide = false; + } + if (npc.ai[3] == 1f) + { + npc.knockBackResist = 0f; + npc.defense += 10; + } + if (npc.ai[3] == -1f) + { + npc.TargetClosest(true); + float num20 = 10f; + float num21 = 40f; + Vector2 value3 = Main.player[npc.target].Center - npc.Center; + float num22 = value3.Length(); + num20 += num22 / 200f; + value3.Normalize(); + value3 *= num20; + npc.velocity = (npc.velocity * (num21 - 1f) + value3) / num21; + if (num22 < 500f && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + npc.ai[3] = 0f; + npc.ai[2] = 0f; + } + return false; + } + if (npc.ai[3] == -2f) + { + npc.velocity.Y = npc.velocity.Y - 0.2f; + if (npc.velocity.Y < -12f) + { + npc.velocity.Y = -12f; + } + if (Main.player[npc.target].Center.Y - npc.Center.Y > 200f) + { + npc.TargetClosest(true); + npc.ai[3] = -3f; + if (Main.player[npc.target].Center.X > npc.Center.X) + { + npc.ai[2] = 1f; + } + else + { + npc.ai[2] = -1f; + } + } + npc.velocity.X = npc.velocity.X * 0.99f; + return false; + } + if (npc.ai[3] == -3f) + { + if (npc.direction == 0) + { + npc.TargetClosest(true); + } + if (npc.ai[2] == 0f) + { + npc.ai[2] = (float)npc.direction; + } + npc.velocity.Y = npc.velocity.Y * 0.9f; + npc.velocity.X = npc.velocity.X + npc.ai[2] * 0.3f; + if (npc.velocity.X > 10f) + { + npc.velocity.X = 10f; + } + if (npc.velocity.X < -10f) + { + npc.velocity.X = -10f; + } + float num23 = Main.player[npc.target].Center.X - npc.Center.X; + if ((npc.ai[2] < 0f && num23 > 300f) || (npc.ai[2] > 0f && num23 < -300f)) + { + npc.ai[3] = -4f; + npc.ai[2] = 0f; + return false; + } + if (Math.Abs(num23) > 800f) + { + npc.ai[3] = -1f; + npc.ai[2] = 0f; + } + return false; + } + else + { + if (npc.ai[3] == -4f) + { + npc.ai[2] += 1f; + npc.velocity.Y = npc.velocity.Y + 0.1f; + if (npc.velocity.Length() > 4f) + { + npc.velocity *= 0.9f; + } + int num24 = (int)npc.Center.X / 16; + int num25 = (int)(npc.position.Y + (float)npc.height + 12f) / 16; + bool flag2 = false; + for (int i = num24 - 1; i <= num24 + 1; i++) + { + if (Main.tile[i, num25] == null) + { + Main.tile[num24, num25] = new Tile(); + } + if (Main.tile[i, num25].active() && Main.tileSolid[(int)Main.tile[i, num25].type]) + { + flag2 = true; + } + } + if (flag2 && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + { + npc.ai[3] = 0f; + npc.ai[2] = 0f; + } + else if (npc.ai[2] > 300f || npc.Center.Y > Main.player[npc.target].Center.Y + 200f) + { + npc.ai[3] = -1f; + npc.ai[2] = 0f; + } + } + else + { + if (npc.ai[3] == 1f) + { + Vector2 center3 = npc.Center; + center3.Y -= 70f; + npc.velocity.X = npc.velocity.X * 0.8f; + npc.ai[2] += 1f; + if (npc.ai[2] == 30f) + { + if (Main.netMode != 1) + { + NPC.NewNPC((int)center3.X, (int)center3.Y + 18, NPCID.ShadowFlameApparition, 0, 0f, 0f, 0f, 0f, 255); + } + } + else if (npc.ai[2] >= 90f) + { + npc.ai[3] = -2f; + npc.ai[2] = 0f; + } + for (int j = 0; j < 2; j++) + { + Vector2 arg_18C0_0 = center3; + Vector2 value4 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + value4.Normalize(); + value4 *= (float)Main.rand.Next(0, 100) * 0.1f; + Vector2 arg_1908_0 = arg_18C0_0 + value4; + value4.Normalize(); + value4 *= (float)Main.rand.Next(50, 90) * 0.1f; + int num26 = Dust.NewDust(arg_1908_0, 1, 1, 27, 0f, 0f, 0, default(Color), 1f); + Main.dust[num26].velocity = -value4 * 0.3f; + Main.dust[num26].alpha = 100; + if (Main.rand.Next(2) == 0) + { + Main.dust[num26].noGravity = true; + Main.dust[num26].scale += 0.3f; + } + } + return false; + } + npc.ai[2] += 1f; + int num27 = 10; + if (npc.velocity.Y == 0f && NPC.CountNPCS(NPCID.ShadowFlameApparition) < num27) + { + if (npc.ai[2] >= 180f) + { + npc.ai[2] = 0f; + npc.ai[3] = 1f; + } + } + else + { + if (NPC.CountNPCS(NPCID.ShadowFlameApparition) >= num27) + { + npc.ai[2] += 1f; + } + if (npc.ai[2] >= 360f) + { + npc.ai[2] = 0f; + npc.ai[3] = -2f; + npc.velocity.Y = npc.velocity.Y - 3f; + } + } + if (npc.target >= 0 && !Main.player[npc.target].dead && (Main.player[npc.target].Center - npc.Center).Length() > 800f) + { + npc.ai[3] = -1f; + npc.ai[2] = 0f; + } + } + if (Main.player[npc.target].dead) + { + npc.TargetClosest(true); + if (Main.player[npc.target].dead && npc.timeLeft > 1) + { + npc.timeLeft = 1; + } + } + } + } + if (npc.type == NPCID.SolarSolenian) + { + npc.reflectingProjectiles = false; + npc.takenDamageMultiplier = 1f; + int num28 = 6; + int num29 = 10; + float scaleFactor3 = 20f; + if (npc.ai[2] > 0f) + { + npc.ai[2] -= 1f; + } + if (npc.ai[2] == 0f) + { + if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.ai[2] = -1f; + npc.netUpdate = true; + npc.TargetClosest(true); + } + } + else + { + if (npc.ai[2] < 0f && npc.ai[2] > (float)(-(float)num28)) + { + npc.ai[2] -= 1f; + npc.velocity.X = npc.velocity.X * 0.9f; + return false; + } + if (npc.ai[2] == (float)(-(float)num28)) + { + npc.ai[2] -= 1f; + npc.TargetClosest(true); + Vector2 vec = npc.DirectionTo(Main.player[npc.target].Top + new Vector2(0f, -30f)); + if (vec.HasNaNs()) + { + vec = Vector2.Normalize(new Vector2((float)npc.spriteDirection, -1f)); + } + npc.velocity = vec * scaleFactor3; + npc.netUpdate = true; + return false; + } + if (npc.ai[2] < (float)(-(float)num28)) + { + npc.ai[2] -= 1f; + if (npc.velocity.Y == 0f) + { + npc.ai[2] = 60f; + } + else if (npc.ai[2] < (float)(-(float)num28 - num29)) + { + npc.velocity.Y = npc.velocity.Y + 0.15f; + if (npc.velocity.Y > 24f) + { + npc.velocity.Y = 24f; + } + } + npc.reflectingProjectiles = true; + npc.takenDamageMultiplier = 3f; + if (npc.justHit) + { + npc.ai[2] = 60f; + npc.netUpdate = true; + } + return false; + } + } + } + if (npc.type == NPCID.SolarDrakomire) + { + int num30 = 42; + int num31 = 18; + if (npc.justHit) + { + npc.ai[2] = 60f; + npc.netUpdate = true; + } + if (npc.ai[2] > 0f) + { + npc.ai[2] -= 1f; + } + if (npc.ai[2] == 0f) + { + int num32 = 0; + for (int k = 0; k < 200; k++) + { + if (Main.npc[k].active && Main.npc[k].type == NPCID.SolarFlare) + { + num32++; + } + } + if (num32 > 6) + { + npc.ai[2] = 60f; + } + else if (((Main.player[npc.target].Center.X < npc.Center.X && npc.direction < 0) || (Main.player[npc.target].Center.X > npc.Center.X && npc.direction > 0)) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.ai[2] = -1f; + npc.netUpdate = true; + npc.TargetClosest(true); + } + } + else if (npc.ai[2] < 0f && npc.ai[2] > (float)(-(float)num30)) + { + npc.ai[2] -= 1f; + if (npc.ai[2] == (float)(-(float)num30)) + { + npc.ai[2] = (float)(180 + 10 * Main.rand.Next(10)); + } + npc.velocity.X = npc.velocity.X * 0.8f; + if (npc.ai[2] == (float)(-(float)num31) || npc.ai[2] == (float)(-(float)num31 - 8) || npc.ai[2] == (float)(-(float)num31 - 16)) + { + for (int l = 0; l < 20; l++) + { + Vector2 vector8 = npc.Center + Vector2.UnitX * (float)npc.spriteDirection * 40f; + Dust arg_2002_0 = Main.dust[Dust.NewDust(vector8, 0, 0, 259, 0f, 0f, 0, default(Color), 1f)]; + Vector2 vector9 = Vector2.UnitY.RotatedByRandom(6.2831854820251465); + arg_2002_0.position = vector8 + vector9 * 4f; + arg_2002_0.velocity = vector9 * 2f + Vector2.UnitX * Main.rand.NextFloat() * (float)npc.spriteDirection * 3f; + arg_2002_0.scale = 0.3f + vector9.X * (float)(-(float)npc.spriteDirection); + arg_2002_0.fadeIn = 0.7f; + arg_2002_0.noGravity = true; + } + if (npc.velocity.X > -0.5f && npc.velocity.X < 0.5f) + { + npc.velocity.X = 0f; + } + if (Main.netMode != 1) + { + NPC.NewNPC((int)npc.Center.X + npc.spriteDirection * 45, (int)npc.Center.Y + 8, NPCID.SolarFlare, 0, 0f, 0f, 0f, 0f, npc.target); + } + } + return false; + } + } + if (npc.type == NPCID.VortexLarva) + { + npc.localAI[0] += 1f; + if (npc.localAI[0] >= 150f) + { + int arg_2177_0 = (int)npc.Center.X / 16 - 1; + int num33 = (int)npc.Center.Y / 16 - 1; + if (!Collision.SolidTiles(arg_2177_0, arg_2177_0 + 2, num33, num33 + 1) && Main.netMode != 1) + { + npc.Transform(NPCID.VortexHornet); + npc.life = npc.lifeMax; + npc.localAI[0] = 0f; + return false; + } + } + int maxValue; + if (npc.localAI[0] < 30f) + { + maxValue = 16; + } + else if (npc.localAI[0] < 60f) + { + maxValue = 8; + } + else if (npc.localAI[0] < 90f) + { + maxValue = 4; + } + else if (npc.localAI[0] < 120f) + { + maxValue = 2; + } + else if (npc.localAI[0] < 150f) + { + maxValue = 1; + } + else + { + maxValue = 1; + } + if (Main.rand.Next(maxValue) == 0) + { + Dust dust = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1f)]; + dust.noGravity = true; + dust.scale = 1f; + dust.noLight = true; + dust.velocity = npc.DirectionFrom(dust.position) * dust.velocity.Length(); + dust.position -= dust.velocity * 5f; + Dust expr_22DE_cp_0_cp_0 = dust; + expr_22DE_cp_0_cp_0.position.X = expr_22DE_cp_0_cp_0.position.X + (float)(npc.direction * 6); + Dust expr_22F7_cp_0_cp_0 = dust; + expr_22F7_cp_0_cp_0.position.Y = expr_22F7_cp_0_cp_0.position.Y + 4f; + } + } + if (npc.type == NPCID.VortexHornet) + { + npc.localAI[0] += 1f; + npc.localAI[0] += Math.Abs(npc.velocity.X) / 2f; + if (npc.localAI[0] >= 600f && Main.netMode != 1) + { + int arg_2386_0 = (int)npc.Center.X / 16 - 2; + int num34 = (int)npc.Center.Y / 16 - 3; + if (!Collision.SolidTiles(arg_2386_0, arg_2386_0 + 4, num34, num34 + 4)) + { + npc.Transform(NPCID.VortexHornetQueen); + npc.life = npc.lifeMax; + npc.localAI[0] = 0f; + return false; + } + } + int maxValue2; + if (npc.localAI[0] < 120f) + { + maxValue2 = 32; + } + else if (npc.localAI[0] < 240f) + { + maxValue2 = 16; + } + else if (npc.localAI[0] < 360f) + { + maxValue2 = 6; + } + else if (npc.localAI[0] < 480f) + { + maxValue2 = 2; + } + else if (npc.localAI[0] < 600f) + { + maxValue2 = 1; + } + else + { + maxValue2 = 1; + } + if (Main.rand.Next(maxValue2) == 0) + { + Dust expr_2471 = Main.dust[Dust.NewDust(npc.position, npc.width, npc.height, 229, 0f, 0f, 0, default(Color), 1f)]; + expr_2471.noGravity = true; + expr_2471.scale = 1f; + expr_2471.noLight = true; + } + } + bool flag3 = false; + if (npc.velocity.X == 0f) + { + flag3 = true; + } + if (npc.justHit) + { + flag3 = false; + } + if (Main.netMode != 1 && npc.type == NPCID.Lihzahrd && (double)npc.life <= (double)npc.lifeMax * 0.9) + { + npc.Transform(NPCID.LihzahrdCrawler); + } + if (Main.netMode != 1 && npc.type == NPCID.Nutcracker && (double)npc.life <= (double)npc.lifeMax * 0.9) + { + npc.Transform(NPCID.NutcrackerSpinning); + } + int num35 = 60; + if (npc.type == NPCID.ChaosElemental) + { + num35 = 180; + if (npc.ai[3] == -30f) + { + npc.velocity *= 0f; + npc.ai[3] = 0f; + Main.PlaySound(SoundID.Item8, npc.position); + Vector2 vector10 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num36 = npc.oldPos[2].X + (float)npc.width * 0.5f - vector10.X; + float num37 = npc.oldPos[2].Y + (float)npc.height * 0.5f - vector10.Y; + float num38 = (float)Math.Sqrt((double)(num36 * num36 + num37 * num37)); + num38 = 2f / num38; + num36 *= num38; + num37 *= num38; + for (int m = 0; m < 20; m++) + { + int num39 = Dust.NewDust(npc.position, npc.width, npc.height, 71, num36, num37, 200, default(Color), 2f); + Main.dust[num39].noGravity = true; + Dust expr_2688_cp_0_cp_0 = Main.dust[num39]; + expr_2688_cp_0_cp_0.velocity.X = expr_2688_cp_0_cp_0.velocity.X * 2f; + } + for (int n = 0; n < 20; n++) + { + int num40 = Dust.NewDust(npc.oldPos[2], npc.width, npc.height, 71, -num36, -num37, 200, default(Color), 2f); + Main.dust[num40].noGravity = true; + Dust expr_26FD_cp_0_cp_0 = Main.dust[num40]; + expr_26FD_cp_0_cp_0.velocity.X = expr_26FD_cp_0_cp_0.velocity.X * 2f; + } + } + } + bool flag4 = false; + bool flag5 = true; + if (npc.type == 343 || npc.type == 47 || npc.type == 67 || npc.type == 109 || npc.type == 110 || npc.type == 111 || npc.type == 120 + || npc.type == 163 || npc.type == 164 || npc.type == 239 || npc.type == 168 || npc.type == 199 || npc.type == 206 || npc.type == 214 + || npc.type == 215 || npc.type == 216 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 220 || npc.type == 226 + || npc.type == 243 || npc.type == 251 || npc.type == 257 || npc.type == 258 || npc.type == 290 || npc.type == 291 || npc.type == 292 + || npc.type == 293 || npc.type == 305 || npc.type == 306 || npc.type == 307 || npc.type == 308 || npc.type == 309 || npc.type == 348 + || npc.type == 349 || npc.type == 350 || npc.type == 351 || npc.type == 379 || (npc.type >= 430 && npc.type <= 436) + || (npc.type == 380 || npc.type == 381 || npc.type == 382 || npc.type == 383 || npc.type == 386 || npc.type == 391 + || (npc.type >= 449 && npc.type <= 452)) || (npc.type == 466 || npc.type == 464 || npc.type == 166 || npc.type == 469 || npc.type == 468 + || npc.type == 471 || npc.type == 470 || npc.type == 480 || npc.type == 481 || npc.type == 482 || npc.type == 411 || npc.type == 424 + || npc.type == 409 || (npc.type >= 494 && npc.type <= 506)) || (npc.type == 425 || npc.type == 427 || npc.type == 426 || npc.type == 428 + || npc.type == 508 || npc.type == 415 || npc.type == 419 || npc.type == 520 || (npc.type >= 524 && npc.type <= 527)) || npc.type == 528 + || npc.type == 529 || npc.type == 530 || npc.type == 532) + { + flag5 = false; + } + bool flag6 = false; + int num41 = npc.type; + if (num41 == 425 || num41 == 471) + { + flag6 = true; + } + bool flag7 = true; + num41 = npc.type; + if (num41 <= 382) + { + if (num41 <= 216) + { + if (num41 - 110 > 1 && num41 != 206 && num41 - 214 > 2) + { + goto IL_2CAD; + } + } + else if (num41 - 291 > 2 && num41 != 350 && num41 - 379 > 3) + { + goto IL_2CAD; + } + } + else if (num41 <= 424) + { + if (num41 != 409 && num41 != 411 && num41 != 424) + { + goto IL_2CAD; + } + } + else if (num41 <= 466) + { + if (num41 != 426 && num41 != 466) + { + goto IL_2CAD; + } + } + else if (num41 - 498 > 8 && num41 != 520) + { + goto IL_2CAD; + } + if (npc.ai[2] > 0f) + { + flag7 = false; + } + IL_2CAD: + if (!flag6 & flag7) + { + if (npc.velocity.Y == 0f && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) + { + flag4 = true; + } + if ((npc.position.X == npc.oldPosition.X || npc.ai[3] >= (float)num35) | flag4) + { + npc.ai[3] += 1f; + } + else if ((double)Math.Abs(npc.velocity.X) > 0.9 && npc.ai[3] > 0f) + { + npc.ai[3] -= 1f; + } + if (npc.ai[3] > (float)(num35 * 10)) + { + npc.ai[3] = 0f; + } + if (npc.justHit) + { + npc.ai[3] = 0f; + } + if (npc.ai[3] == (float)num35) + { + npc.netUpdate = true; + } + } + if (npc.type == NPCID.Nailhead && Main.netMode != 1) + { + if (npc.localAI[3] > 0f) + { + npc.localAI[3] -= 1f; + } + if (npc.justHit && npc.localAI[3] <= 0f && Main.rand.Next(2) == 0) + { + npc.localAI[3] = 30f; + int num42 = Main.rand.Next(3, 6); + int[] array = new int[num42]; + int num43 = 0; + for (int num44 = 0; num44 < 255; num44++) + { + if (Main.player[num44].active && !Main.player[num44].dead && Collision.CanHitLine(npc.position, npc.width, npc.height, Main.player[num44].position, Main.player[num44].width, Main.player[num44].height)) + { + array[num43] = num44; + num43++; + if (num43 == num42) + { + break; + } + } + } + if (num43 > 1) + { + for (int num45 = 0; num45 < 100; num45++) + { + int num46 = Main.rand.Next(num43); + int num47; + for (num47 = num46; num47 == num46; num47 = Main.rand.Next(num43)) + { + } + int num48 = array[num46]; + array[num46] = array[num47]; + array[num47] = num48; + } + } + Vector2 vector11 = new Vector2(-1f, -1f); + for (int num49 = 0; num49 < num43; num49++) + { + Vector2 value5 = Main.npc[array[num49]].Center - npc.Center; + value5.Normalize(); + vector11 += value5; + } + vector11.Normalize(); + for (int num50 = 0; num50 < num42; num50++) + { + float scaleFactor4 = (float)Main.rand.Next(8, 13); + Vector2 vector12 = new Vector2((float)Main.rand.Next(-100, 101), (float)Main.rand.Next(-100, 101)); + vector12.Normalize(); + if (num43 > 0) + { + vector12 += vector11; + vector12.Normalize(); + } + vector12 *= scaleFactor4; + if (num43 > 0) + { + num43--; + vector12 = Main.player[array[num43]].Center - npc.Center; + vector12.Normalize(); + vector12 *= scaleFactor4; + } + Projectile.NewProjectile(npc.Center.X, npc.position.Y + (float)(npc.width / 4), vector12.X, vector12.Y, 498, (int)((double)npc.damage * 0.15), 1f, 255, 0f, 0f); + } + } + } + if (npc.type == NPCID.Butcher) + { + if (npc.velocity.Y < -0.3f || npc.velocity.Y > 0.3f) + { + npc.knockBackResist = 0f; + } + else + { + npc.knockBackResist = 0.1f * Main.knockBackMultiplier; + } + } + if (npc.type == NPCID.ThePossessed) + { + npc.knockBackResist = 0.25f * Main.knockBackMultiplier; + if (npc.ai[2] == 1f) + { + npc.knockBackResist = 0f; + } + bool flag8 = false; + int num51 = (int)npc.Center.X / 16; + int num52 = (int)npc.Center.Y / 16; + for (int num53 = num51 - 1; num53 <= num51 + 1; num53++) + { + for (int num54 = num52 - 1; num54 <= num52 + 1; num54++) + { + if (Main.tile[num53, num54] != null && Main.tile[num53, num54].wall > 0) + { + flag8 = true; + break; + } + } + if (flag8) + { + break; + } + } + if (npc.ai[2] == 0f & flag8) + { + if (npc.velocity.Y == 0f) + { + npc.velocity.Y = -4.6f; + npc.velocity.X = npc.velocity.X * 1.5f; + } + else if (npc.velocity.Y > 0f) + { + npc.ai[2] = 1f; + } + } + if (flag8 && npc.ai[2] == 1f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + Vector2 value6 = Main.player[npc.target].Center - npc.Center; + float num55 = value6.Length(); + value6.Normalize(); + value6 *= 6f + num55 / 300f; + npc.velocity = (npc.velocity * 29f + value6) / 30f; + npc.noGravity = true; + npc.ai[2] = 1f; + return false; + } + npc.noGravity = false; + npc.ai[2] = 0f; + } + if (npc.type == NPCID.Fritz && npc.velocity.Y == 0f && (Main.player[npc.target].Center - npc.Center).Length() < 150f && Math.Abs(npc.velocity.X) > 3f && ((npc.velocity.X < 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X > 0f && npc.Center.X < Main.player[npc.target].Center.X))) + { + npc.velocity.X = npc.velocity.X * 2f; + npc.velocity.Y = npc.velocity.Y - 4.5f; + if (npc.Center.Y - Main.player[npc.target].Center.Y > 20f) + { + npc.velocity.Y = npc.velocity.Y - 0.5f; + } + if (npc.Center.Y - Main.player[npc.target].Center.Y > 40f) + { + npc.velocity.Y = npc.velocity.Y - 1f; + } + if (npc.Center.Y - Main.player[npc.target].Center.Y > 80f) + { + npc.velocity.Y = npc.velocity.Y - 1.5f; + } + if (npc.Center.Y - Main.player[npc.target].Center.Y > 100f) + { + npc.velocity.Y = npc.velocity.Y - 1.5f; + } + if (Math.Abs(npc.velocity.X) > 9f) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = -9f; + } + else + { + npc.velocity.X = 9f; + } + } + } + if (npc.ai[3] < (float)num35 && (Main.eclipse || !Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0 || (Main.invasionType == 1 && (npc.type == 343 || npc.type == 350)) || (Main.invasionType == 1 && (npc.type == 26 || npc.type == 27 || npc.type == 28 || npc.type == 111 || npc.type == 471)) || (npc.type == 73 || (Main.invasionType == 3 && npc.type >= 212 && npc.type <= 216)) || (Main.invasionType == 4 && (npc.type == 381 || npc.type == 382 || npc.type == 383 || npc.type == 385 || npc.type == 386 || npc.type == 389 || npc.type == 391 || npc.type == 520)) || (npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 67 || npc.type == 77 || npc.type == 78 || npc.type == 79 || npc.type == 80 || npc.type == 110 || npc.type == 120 || npc.type == 168 || npc.type == 181 || npc.type == 185 || npc.type == 198 || npc.type == 199 || npc.type == 206 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 220 || npc.type == 239 || npc.type == 243 || npc.type == 254 || npc.type == 255 || npc.type == 257 || npc.type == 258 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 379 || npc.type == 380 || npc.type == 464 || npc.type == 470 || npc.type == 424 || (npc.type == 411 && (npc.ai[1] >= 180f || npc.ai[1] < 90f))) || (npc.type == 409 || npc.type == 425 || npc.type == 429 || npc.type == 427 || npc.type == 428 || npc.type == 508 || npc.type == 415 || npc.type == 419 || (npc.type >= 524 && npc.type <= 527)) || npc.type == 528 || npc.type == 529 || npc.type == 530 || npc.type == 532)) + { + if ((npc.type == 3 || npc.type == 331 || npc.type == 332 || npc.type == 21 || (npc.type >= 449 && npc.type <= 452) || npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 77 || npc.type == 110 || npc.type == 132 || npc.type == 167 || npc.type == 161 || npc.type == 162 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 197 || npc.type == 200 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 223 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 320 || npc.type == 321 || npc.type == 319 || npc.type == 481) && Main.rand.Next(1000) == 0) + { + Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } + if (npc.type == 489 && Main.rand.Next(800) == 0) + { + Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, npc.type, 1f, 0f); + } + if ((npc.type == 78 || npc.type == 79 || npc.type == 80) && Main.rand.Next(500) == 0) + { + Main.PlaySound(26, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } + if (npc.type == 159 && Main.rand.Next(500) == 0) + { + Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 7, 1f, 0f); + } + if (npc.type == 162 && Main.rand.Next(500) == 0) + { + Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 6, 1f, 0f); + } + if (npc.type == 181 && Main.rand.Next(500) == 0) + { + Main.PlaySound(29, (int)npc.position.X, (int)npc.position.Y, 8, 1f, 0f); + } + if (npc.type >= 269 && npc.type <= 280 && Main.rand.Next(1000) == 0) + { + Main.PlaySound(14, (int)npc.position.X, (int)npc.position.Y, 1, 1f, 0f); + } + npc.TargetClosest(true); + } + else if (npc.ai[2] <= 0f || (npc.type != 110 && npc.type != 111 && npc.type != 206 && npc.type != 216 && npc.type != 214 && npc.type != 215 && npc.type != 291 && npc.type != 292 && npc.type != 293 && npc.type != 350 && npc.type != 381 && npc.type != 382 && npc.type != 383 && npc.type != 385 && npc.type != 386 && npc.type != 389 && npc.type != 391 && npc.type != 469 && npc.type != 166 && npc.type != 466 && npc.type != 471 && npc.type != 411 && npc.type != 409 && npc.type != 424 && npc.type != 425 && npc.type != 426 && npc.type != 415 && npc.type != 419 && npc.type != 520)) + { + if (Main.dayTime && (double)(npc.position.Y / 16f) < Main.worldSurface && npc.timeLeft > 10) + { + npc.timeLeft = 10; + } + if (npc.velocity.X == 0f) + { + if (npc.velocity.Y == 0f) + { + npc.ai[0] += 1f; + if (npc.ai[0] >= 2f) + { + npc.direction *= -1; + npc.spriteDirection = npc.direction; + npc.ai[0] = 0f; + } + } + } + else + { + npc.ai[0] = 0f; + } + if (npc.direction == 0) + { + npc.direction = 1; + } + } + if (npc.type == NPCID.Vampire || npc.type == NPCID.NutcrackerSpinning) + { + if (npc.type == NPCID.Vampire && ((npc.velocity.X > 0f && npc.direction < 0) || (npc.velocity.X < 0f && npc.direction > 0))) + { + npc.velocity.X = npc.velocity.X * 0.95f; + } + if (npc.velocity.X < -8f || npc.velocity.X > 8f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < 8f && npc.direction == 1) + { + if (npc.velocity.Y == 0f && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.99f; + } + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > 8f) + { + npc.velocity.X = 8f; + } + } + else if (npc.velocity.X > -8f && npc.direction == -1) + { + if (npc.velocity.Y == 0f && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.99f; + } + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -8f) + { + npc.velocity.X = -8f; + } + } + } + else if (npc.type == NPCID.LihzahrdCrawler) + { + if (npc.velocity.X < -6f || npc.velocity.X > 6f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < 6f && npc.direction == 1) + { + if (npc.velocity.Y == 0f && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.8f; + } + npc.velocity.X = npc.velocity.X + 0.12f; + if (npc.velocity.X > 6f) + { + npc.velocity.X = 6f; + } + } + else if (npc.velocity.X > -6f && npc.direction == -1) + { + if (npc.velocity.Y == 0f && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.8f; + } + npc.velocity.X = npc.velocity.X - 0.12f; + if (npc.velocity.X < -6f) + { + npc.velocity.X = -6f; + } + } + } + else if (npc.type == 120 || npc.type == 166 || npc.type == 213 || npc.type == 258 || npc.type == 528 || npc.type == 529) + { + if (npc.velocity.X < -4f || npc.velocity.X > 4f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < 4f && npc.direction == 1) + { + if (npc.velocity.Y == 0f && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.99f; + } + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > 4f) + { + npc.velocity.X = 4f; + } + } + else if (npc.velocity.X > -4f && npc.direction == -1) + { + if (npc.velocity.Y == 0f && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.99f; + } + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -4f) + { + npc.velocity.X = -4f; + } + } + } + else if (npc.type == 461 || npc.type == 27 || npc.type == 77 || npc.type == 104 || npc.type == 163 || npc.type == 162 || npc.type == 196 || npc.type == 197 || npc.type == 212 || npc.type == 257 || npc.type == 326 || npc.type == 343 || npc.type == 348 || npc.type == 351 || (npc.type >= 524 && npc.type <= 527) || npc.type == 530) + { + if (npc.velocity.X < -3f || npc.velocity.X > 3f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < 3f && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > 3f) + { + npc.velocity.X = 3f; + } + } + else if (npc.velocity.X > -3f && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -3f) + { + npc.velocity.X = -3f; + } + } + } + else if (npc.type == NPCID.Clown) + { + if (npc.velocity.X < -4f || npc.velocity.X > 4f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < 4f && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.06f; + if (npc.velocity.X > 4f) + { + npc.velocity.X = 4f; + } + } + else if (npc.velocity.X > -4f && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.06f; + if (npc.velocity.X < -4f) + { + npc.velocity.X = -4f; + } + } + } + else if (npc.type == 21 || npc.type == 26 || npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 73 || npc.type == 140 || npc.type == 164 || npc.type == 239 || npc.type == 167 || npc.type == 168 || npc.type == 185 || npc.type == 198 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 217 || npc.type == 218 || npc.type == 219 || npc.type == 226 || npc.type == 181 || npc.type == 254 || npc.type == 338 || npc.type == 339 || npc.type == 340 || npc.type == 342 || npc.type == 385 || npc.type == 389 || npc.type == 462 || npc.type == 463 || npc.type == 466 || npc.type == 464 || npc.type == 469 || npc.type == 470 || npc.type == 480 || npc.type == 482 || npc.type == 425 || npc.type == 429) + { + float num56 = 1.5f; + if (npc.type == 294) + { + num56 = 2f; + } + else if (npc.type == 295) + { + num56 = 1.75f; + } + else if (npc.type == 296) + { + num56 = 1.25f; + } + else if (npc.type == 201) + { + num56 = 1.1f; + } + else if (npc.type == 202) + { + num56 = 0.9f; + } + else if (npc.type == 203) + { + num56 = 1.2f; + } + else if (npc.type == 338) + { + num56 = 1.75f; + } + else if (npc.type == 339) + { + num56 = 1.25f; + } + else if (npc.type == 340) + { + num56 = 2f; + } + else if (npc.type == 385) + { + num56 = 1.8f; + } + else if (npc.type == 389) + { + num56 = 2.25f; + } + else if (npc.type == 462) + { + num56 = 4f; + } + else if (npc.type == 463) + { + num56 = 0.75f; + } + else if (npc.type == 466) + { + num56 = 3.75f; + } + else if (npc.type == 469) + { + num56 = 3.25f; + } + else if (npc.type == 480) + { + num56 = 1.5f + (1f - (float)npc.life / (float)npc.lifeMax) * 2f; + } + else if (npc.type == 425) + { + num56 = 6f; + } + else if (npc.type == 429) + { + num56 = 4f; + } + if (npc.type == 21 || npc.type == 201 || npc.type == 202 || npc.type == 203 || npc.type == 342) + { + num56 *= 1f + (1f - npc.scale); + } + num56 *= 1.5f; + if (npc.velocity.X < -num56 || npc.velocity.X > num56) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < num56 && npc.direction == 1) + { + if (npc.type == 466 && npc.velocity.X < -2f) + { + npc.velocity.X = npc.velocity.X * 0.9f; + } + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > num56) + { + npc.velocity.X = num56; + } + } + else if (npc.velocity.X > -num56 && npc.direction == -1) + { + if (npc.type == 466 && npc.velocity.X > 2f) + { + npc.velocity.X = npc.velocity.X * 0.9f; + } + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -num56) + { + npc.velocity.X = -num56; + } + } + if (npc.velocity.Y == 0f && npc.type == 462 && ((npc.direction > 0 && npc.velocity.X < 0f) || (npc.direction < 0 && npc.velocity.X > 0f))) + { + npc.velocity.X = npc.velocity.X * 0.9f; + } + } + else if (npc.type >= 269 && npc.type <= 280) + { + float num57 = 1.5f; + if (npc.type == 269) + { + num57 = 2f; + } + if (npc.type == 270) + { + num57 = 1f; + } + if (npc.type == 271) + { + num57 = 1.5f; + } + if (npc.type == 272) + { + num57 = 3f; + } + if (npc.type == 273) + { + num57 = 1.25f; + } + if (npc.type == 274) + { + num57 = 3f; + } + if (npc.type == 275) + { + num57 = 3.25f; + } + if (npc.type == 276) + { + num57 = 2f; + } + if (npc.type == 277) + { + num57 = 2.75f; + } + if (npc.type == 278) + { + num57 = 1.8f; + } + if (npc.type == 279) + { + num57 = 1.3f; + } + if (npc.type == 280) + { + num57 = 2.5f; + } + num57 *= 1f + (1f - npc.scale); + num57 *= 1.5f; + if (npc.velocity.X < -num57 || npc.velocity.X > num57) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < num57 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > num57) + { + npc.velocity.X = num57; + } + } + else if (npc.velocity.X > -num57 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -num57) + { + npc.velocity.X = -num57; + } + } + } + else if (npc.type >= 305 && npc.type <= 314) + { + float num58 = 1.5f; + if (npc.type == 305 || npc.type == 310) + { + num58 = 2f; + } + if (npc.type == 306 || npc.type == 311) + { + num58 = 1.25f; + } + if (npc.type == 307 || npc.type == 312) + { + num58 = 2.25f; + } + if (npc.type == 308 || npc.type == 313) + { + num58 = 1.5f; + } + if (npc.type == 309 || npc.type == 314) + { + num58 = 1f; + } + num58 *= 1.5f; + if (npc.type < 310) + { + if (npc.velocity.Y == 0f) + { + npc.velocity.X = npc.velocity.X * 0.85f; + if ((double)npc.velocity.X > -0.3 && (double)npc.velocity.X < 0.3) + { + npc.velocity.Y = -9f; + npc.velocity.X = num58 * (float)npc.direction; + } + } + else if (npc.spriteDirection == npc.direction) + { + npc.velocity.X = (npc.velocity.X * 10f + num58 * (float)npc.direction) / 11f; + } + } + else if (npc.velocity.X < -num58 || npc.velocity.X > num58) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < num58 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > num58) + { + npc.velocity.X = num58; + } + } + else if (npc.velocity.X > -num58 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -num58) + { + npc.velocity.X = -num58; + } + } + } + else if (npc.type == 67 || npc.type == 220 || npc.type == 428) + { + if (npc.velocity.X < -1f || npc.velocity.X > 1f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < 1f && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.06f; + if (npc.velocity.X > 1f) + { + npc.velocity.X = 1f; + } + } + else if (npc.velocity.X > -1f && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.06f; + if (npc.velocity.X < -1f) + { + npc.velocity.X = -1f; + } + } + } + else if (npc.type == 78 || npc.type == 79 || npc.type == 80) + { + float num59 = 3f; + float num60 = 0.15f; + if (npc.type == 79) + { + num59 *= 1.5f; + } + if (npc.velocity.X < -num59 || npc.velocity.X > num59) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < num59 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num60; + if (npc.velocity.X > num59) + { + npc.velocity.X = num59; + } + } + else if (npc.velocity.X > -num59 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num60; + if (npc.velocity.X < -num59) + { + npc.velocity.X = -num59; + } + } + } + else if (npc.type == NPCID.BoneLee) + { + float num61 = 7f; + float num62 = 0.3f; + if (npc.velocity.X < -num61 || npc.velocity.X > num61) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < num61 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num62; + if (npc.velocity.X > num61) + { + npc.velocity.X = num61; + } + } + else if (npc.velocity.X > -num61 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num62; + if (npc.velocity.X < -num61) + { + npc.velocity.X = -num61; + } + } + } + else if (npc.type == NPCID.IceGolem) + { + float num63 = 3f; + float num64 = 0.3f; + if (npc.velocity.X < -num63 || npc.velocity.X > num63) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < num63 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num64; + if (npc.velocity.X > num63) + { + npc.velocity.X = num63; + } + } + else if (npc.velocity.X > -num63 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num64; + if (npc.velocity.X < -num63) + { + npc.velocity.X = -num63; + } + } + } + else if (npc.type == NPCID.Eyezor) + { + float num65 = 3.5f; + float num66 = 0.3f; + if (npc.velocity.X < -num65 || npc.velocity.X > num65) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < num65 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num66; + if (npc.velocity.X > num65) + { + npc.velocity.X = num65; + } + } + else if (npc.velocity.X > -num65 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num66; + if (npc.velocity.X < -num65) + { + npc.velocity.X = -num65; + } + } + } + else if (npc.type == NPCID.MartianEngineer) + { + if (npc.ai[2] > 0f) + { + if (npc.velocity.Y == 0f) + { + npc.velocity.X = npc.velocity.X * 0.8f; + } + } + else + { + float num67 = 0.2f; + float num68 = 3f; + if (npc.velocity.X < -num68 || npc.velocity.X > num68) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < num68 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num67; + if (npc.velocity.X > num68) + { + npc.velocity.X = num68; + } + } + else if (npc.velocity.X > -num68 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num67; + if (npc.velocity.X < -num68) + { + npc.velocity.X = -num68; + } + } + } + } + else if (npc.type == NPCID.Butcher) + { + float num69 = 7f; + float num70 = 0.2f; + if (Math.Abs(npc.velocity.X) > 2f) + { + num70 *= 0.8f; + } + if ((double)Math.Abs(npc.velocity.X) > 2.5) + { + num70 *= 0.8f; + } + if (Math.Abs(npc.velocity.X) > 3f) + { + num70 *= 0.8f; + } + if ((double)Math.Abs(npc.velocity.X) > 3.5) + { + num70 *= 0.8f; + } + if (Math.Abs(npc.velocity.X) > 4f) + { + num70 *= 0.8f; + } + if ((double)Math.Abs(npc.velocity.X) > 4.5) + { + num70 *= 0.8f; + } + if (Math.Abs(npc.velocity.X) > 5f) + { + num70 *= 0.8f; + } + if ((double)Math.Abs(npc.velocity.X) > 5.5) + { + num70 *= 0.8f; + } + if (npc.velocity.X < -num69 || npc.velocity.X > num69) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.7f; + } + } + else if (npc.velocity.X < num69 && npc.direction == 1) + { + if (npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.93f; + } + npc.velocity.X = npc.velocity.X + num70; + if (npc.velocity.X > num69) + { + npc.velocity.X = num69; + } + } + else if (npc.velocity.X > -num69 && npc.direction == -1) + { + if (npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.93f; + } + npc.velocity.X = npc.velocity.X - num70; + if (npc.velocity.X < -num69) + { + npc.velocity.X = -num69; + } + } + } + else if (npc.type == NPCID.WalkingAntlion) + { + float num71 = 2.5f; + float num72 = 60f; + float num73 = Math.Abs(npc.velocity.X); + if (num73 > 2.75f) + { + num71 = 7f; + num72 += 100f; + } + else if ((double)num73 > 2.25) + { + num71 = 5f; + num72 += 80f; + } + if ((double)Math.Abs(npc.velocity.Y) < 0.5) + { + if (npc.velocity.X > 0f && npc.direction < 0) + { + npc.velocity *= 0.9f; + } + if (npc.velocity.X < 0f && npc.direction > 0) + { + npc.velocity *= 0.9f; + } + } + if (Math.Abs(npc.velocity.Y) > 0.3f) + { + num72 *= 3f; + } + if (npc.velocity.X <= 0f && npc.direction < 0) + { + npc.velocity.X = (npc.velocity.X * num72 - num71) / (num72 + 1f); + } + else if (npc.velocity.X >= 0f && npc.direction > 0) + { + npc.velocity.X = (npc.velocity.X * num72 + num71) / (num72 + 1f); + } + else if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > 20f && Math.Abs(npc.velocity.Y) <= 0.3f) + { + npc.velocity.X = npc.velocity.X * 0.99f; + npc.velocity.X = npc.velocity.X + (float)npc.direction * 0.025f; + } + } + else if (npc.type == 391 || npc.type == 427 || npc.type == 415 || npc.type == 419 || npc.type == 518 || npc.type == 532) + { + float num74 = 5f; + float num75 = 0.25f; + float scaleFactor5 = 0.7f; + if (npc.type == 427) + { + num74 = 6f; + num75 = 0.2f; + scaleFactor5 = 0.8f; + } + else if (npc.type == 415) + { + num74 = 4f; + num75 = 0.1f; + scaleFactor5 = 0.95f; + } + else if (npc.type == 419) + { + num74 = 6f; + num75 = 0.15f; + scaleFactor5 = 0.85f; + } + else if (npc.type == 518) + { + num74 = 5f; + num75 = 0.1f; + scaleFactor5 = 0.95f; + } + else if (npc.type == 532) + { + num74 = 5f; + num75 = 0.15f; + scaleFactor5 = 0.98f; + } + num74 *= 1.5f; + num75 *= 1.5f; + if (npc.velocity.X < -num74 || npc.velocity.X > num74) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= scaleFactor5; + } + } + else if (npc.velocity.X < num74 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num75; + if (npc.velocity.X > num74) + { + npc.velocity.X = num74; + } + } + else if (npc.velocity.X > -num74 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num75; + if (npc.velocity.X < -num74) + { + npc.velocity.X = -num74; + } + } + } + else if ((npc.type >= 430 && npc.type <= 436) || npc.type == 494 || npc.type == 495) + { + if (npc.ai[2] == 0f) + { + npc.damage = npc.defDamage; + float num76 = 1.5f; + num76 *= 1f + (1f - npc.scale); + if (npc.velocity.X < -num76 || npc.velocity.X > num76) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < num76 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > num76) + { + npc.velocity.X = num76; + } + } + else if (npc.velocity.X > -num76 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -num76) + { + npc.velocity.X = -num76; + } + } + if (npc.velocity.Y == 0f && (!Main.dayTime || (double)npc.position.Y > Main.worldSurface * 16.0) && !Main.player[npc.target].dead) + { + Vector2 vector13 = npc.Center - Main.player[npc.target].Center; + int num77 = 50; + if (npc.type >= 494 && npc.type <= 495) + { + num77 = 42; + } + if (vector13.Length() < (float)num77 && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.velocity.X = npc.velocity.X * 0.7f; + npc.ai[2] = 1f; + } + } + } + else + { + npc.damage = npc.defDamage * 2; + npc.ai[3] = 1f; + npc.velocity.X = npc.velocity.X * 0.9f; + if ((double)Math.Abs(npc.velocity.X) < 0.1) + { + npc.velocity.X = 0f; + } + npc.ai[2] += 1f; + if (npc.ai[2] >= 20f || npc.velocity.Y != 0f || (Main.dayTime && (double)npc.position.Y < Main.worldSurface * 16.0)) + { + npc.ai[2] = 0f; + } + } + } + else if (npc.type != 110 && npc.type != 111 && npc.type != 206 && npc.type != 214 && npc.type != 215 && npc.type != 216 && npc.type != 290 && npc.type != 291 && npc.type != 292 && npc.type != 293 && npc.type != 350 && npc.type != 379 && npc.type != 380 && npc.type != 381 && npc.type != 382 && (npc.type < 449 || npc.type > 452) && npc.type != 468 && npc.type != 481 && npc.type != 411 && npc.type != 409 && (npc.type < 498 || npc.type > 506) && npc.type != 424 && npc.type != 426 && npc.type != 520) + { + float num78 = 1f; + if (npc.type == 186) + { + num78 = 1.1f; + } + if (npc.type == 187) + { + num78 = 0.9f; + } + if (npc.type == 188) + { + num78 = 1.2f; + } + if (npc.type == 189) + { + num78 = 0.8f; + } + if (npc.type == 132) + { + num78 = 0.95f; + } + if (npc.type == 200) + { + num78 = 0.87f; + } + if (npc.type == 223) + { + num78 = 1.05f; + } + if (npc.type == 489) + { + float num79 = (Main.player[npc.target].Center - npc.Center).Length(); + num79 *= 0.0025f; + if ((double)num79 > 1.5) + { + num79 = 1.5f; + } + if (Main.expertMode) + { + num78 = 3f - num79; + } + else + { + num78 = 2.5f - num79; + } + num78 *= 0.8f; + } + if (npc.type == 489 || npc.type == 3 || npc.type == 132 || npc.type == 186 || npc.type == 187 || npc.type == 188 || npc.type == 189 || npc.type == 200 || npc.type == 223 || npc.type == 331 || npc.type == 332) + { + num78 *= 1f + (1f - npc.scale); + } + num78 *= 1.5f; + if (npc.velocity.X < -num78 || npc.velocity.X > num78) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= 0.8f; + } + } + else if (npc.velocity.X < num78 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + 0.09f; + if (npc.velocity.X > num78) + { + npc.velocity.X = num78; + } + } + else if (npc.velocity.X > -num78 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - 0.09f; + if (npc.velocity.X < -num78) + { + npc.velocity.X = -num78; + } + } + } + if (npc.type >= 277 && npc.type <= 280) + { + Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.2f, 0.1f, 0f); + } + else if (npc.type == 520) + { + Lighting.AddLight(npc.Top + new Vector2(0f, 20f), 0.3f, 0.3f, 0.7f); + } + else if (npc.type == 525) + { + Vector3 rgb = new Vector3(0.7f, 1f, 0.2f) * 0.5f; + Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb); + } + else if (npc.type == 526) + { + Vector3 rgb2 = new Vector3(1f, 1f, 0.5f) * 0.4f; + Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb2); + } + else if (npc.type == 527) + { + Vector3 rgb3 = new Vector3(0.6f, 0.3f, 1f) * 0.4f; + Lighting.AddLight(npc.Top + new Vector2(0f, 15f), rgb3); + } + else if (npc.type == 415) + { + npc.hide = false; + for (int num80 = 0; num80 < 200; num80++) + { + if (Main.npc[num80].active && Main.npc[num80].type == 416 && Main.npc[num80].ai[0] == (float)npc.whoAmI) + { + npc.hide = true; + break; + } + } + } + else if (npc.type == NPCID.MushiLadybug) + { + if (npc.velocity.Y != 0f) + { + npc.TargetClosest(true); + npc.spriteDirection = npc.direction; + if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.95f; + } + else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.95f; + } + if (Main.player[npc.target].Center.X < npc.position.X && npc.velocity.X > -5f) + { + npc.velocity.X = npc.velocity.X - 0.1f; + } + else if (Main.player[npc.target].Center.X > npc.position.X + (float)npc.width && npc.velocity.X < 5f) + { + npc.velocity.X = npc.velocity.X + 0.1f; + } + } + else if (Main.player[npc.target].Center.Y + 50f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + npc.velocity.Y = -9f; + } + } + else if (npc.type == NPCID.VortexRifleman) + { + if (npc.velocity.Y == 0f) + { + npc.ai[2] = 0f; + } + if (npc.velocity.Y != 0f && npc.ai[2] == 1f) + { + npc.TargetClosest(true); + npc.spriteDirection = -npc.direction; + if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + { + float num81 = Main.player[npc.target].Center.X - (float)(npc.direction * 600) - npc.Center.X; + float num82 = Main.player[npc.target].Bottom.Y - npc.Bottom.Y; + if (num81 < 0f && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.9f; + } + else if (num81 > 0f && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.9f; + } + if (num81 < 0f && npc.velocity.X > -7f) + { + npc.velocity.X = npc.velocity.X - 0.12f; + } + else if (num81 > 0f && npc.velocity.X < 7f) + { + npc.velocity.X = npc.velocity.X + 0.12f; + } + if (npc.velocity.X > 8f) + { + npc.velocity.X = 8f; + } + if (npc.velocity.X < -8f) + { + npc.velocity.X = -8f; + } + if (num82 < -20f && npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y * 0.8f; + } + else if (num82 > 20f && npc.velocity.Y < 0f) + { + npc.velocity.Y = npc.velocity.Y * 0.8f; + } + if (num82 < -20f && npc.velocity.Y > -7f) + { + npc.velocity.Y = npc.velocity.Y - 0.35f; + } + else if (num82 > 20f && npc.velocity.Y < 7f) + { + npc.velocity.Y = npc.velocity.Y + 0.35f; + } + } + if (Main.rand.Next(3) == 0) + { + Vector2 position = npc.Center + new Vector2((float)(npc.direction * -14), -8f) - Vector2.One * 4f; + Vector2 vector14 = new Vector2((float)(npc.direction * -6), 12f) * 0.2f + Utils.RandomVector2(Main.rand, -1f, 1f) * 0.1f; + Dust expr_70AD = Main.dust[Dust.NewDust(position, 8, 8, 229, vector14.X, vector14.Y, 100, Color.Transparent, 1f + Main.rand.NextFloat() * 0.5f)]; + expr_70AD.noGravity = true; + expr_70AD.velocity = vector14; + expr_70AD.customData = npc; + } + for (int num83 = 0; num83 < 200; num83++) + { + if (num83 != npc.whoAmI && Main.npc[num83].active && Main.npc[num83].type == npc.type && Math.Abs(npc.position.X - Main.npc[num83].position.X) + Math.Abs(npc.position.Y - Main.npc[num83].position.Y) < (float)npc.width) + { + if (npc.position.X < Main.npc[num83].position.X) + { + npc.velocity.X = npc.velocity.X - 0.05f; + } + else + { + npc.velocity.X = npc.velocity.X + 0.05f; + } + if (npc.position.Y < Main.npc[num83].position.Y) + { + npc.velocity.Y = npc.velocity.Y - 0.05f; + } + else + { + npc.velocity.Y = npc.velocity.Y + 0.05f; + } + } + } + } + else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + npc.velocity.Y = -7f; + npc.ai[2] = 1f; + } + if (Main.netMode != 1) + { + npc.localAI[2] += 1f; + if (npc.localAI[2] >= (float)(240 + Main.rand.Next(240)) && npc.Distance(Main.player[npc.target].Center) < 600f && Math.Abs(npc.DirectionTo(Main.player[npc.target].Center).Y) < 0.5f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + { + npc.localAI[2] = 0f; + Vector2 vector15 = npc.Center + new Vector2((float)(npc.direction * 30), 2f); + Vector2 vector16 = npc.DirectionTo(Main.player[npc.target].Center) * 9f; + if (vector16.HasNaNs()) + { + vector16 = new Vector2((float)(npc.direction * 10), 0f); + } + int num84 = Main.expertMode ? 50 : 75; + for (int num85 = 0; num85 < 4; num85++) + { + Vector2 vector17 = vector16 + Utils.RandomVector2(Main.rand, -0.8f, 0.8f); + Projectile.NewProjectile(vector15.X, vector15.Y, vector17.X, vector17.Y, 577, num84, 1f, Main.myPlayer, 0f, 0f); + } + } + } + } + else if (npc.type == NPCID.VortexHornet) + { + if (npc.velocity.Y == 0f) + { + npc.ai[2] = 0f; + npc.rotation = 0f; + } + else + { + npc.rotation = npc.velocity.X * 0.1f; + } + if (npc.velocity.Y != 0f && npc.ai[2] == 1f) + { + npc.TargetClosest(true); + npc.spriteDirection = -npc.direction; + if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + { + float num86 = Main.player[npc.target].Center.X - npc.Center.X; + float num87 = Main.player[npc.target].Center.Y - npc.Center.Y; + if (num86 < 0f && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.98f; + } + else if (num86 > 0f && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.98f; + } + if (num86 < -20f && npc.velocity.X > -8f) + { + npc.velocity.X = npc.velocity.X - 0.025f; + } + else if (num86 > 20f && npc.velocity.X < 8f) + { + npc.velocity.X = npc.velocity.X + 0.025f; + } + if (npc.velocity.X > 8f) + { + npc.velocity.X = 8f; + } + if (npc.velocity.X < -8f) + { + npc.velocity.X = -8f; + } + if (num87 < -20f && npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y * 0.98f; + } + else if (num87 > 20f && npc.velocity.Y < 0f) + { + npc.velocity.Y = npc.velocity.Y * 0.98f; + } + if (num87 < -20f && npc.velocity.Y > -8f) + { + npc.velocity.Y = npc.velocity.Y - 0.25f; + } + else if (num87 > 20f && npc.velocity.Y < 8f) + { + npc.velocity.Y = npc.velocity.Y + 0.25f; + } + } + for (int num88 = 0; num88 < 200; num88++) + { + if (num88 != npc.whoAmI && Main.npc[num88].active && Main.npc[num88].type == npc.type && Math.Abs(npc.position.X - Main.npc[num88].position.X) + Math.Abs(npc.position.Y - Main.npc[num88].position.Y) < (float)npc.width) + { + if (npc.position.X < Main.npc[num88].position.X) + { + npc.velocity.X = npc.velocity.X - 0.05f; + } + else + { + npc.velocity.X = npc.velocity.X + 0.05f; + } + if (npc.position.Y < Main.npc[num88].position.Y) + { + npc.velocity.Y = npc.velocity.Y - 0.05f; + } + else + { + npc.velocity.Y = npc.velocity.Y + 0.05f; + } + } + } + } + else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + npc.velocity.Y = -7f; + npc.ai[2] = 1f; + } + } + else if (npc.type == NPCID.VortexHornetQueen) + { + if (npc.ai[1] > 0f && npc.velocity.Y > 0f) + { + npc.velocity.Y = npc.velocity.Y * 0.85f; + if (npc.velocity.Y == 0f) + { + npc.velocity.Y = -0.4f; + } + } + if (npc.velocity.Y != 0f) + { + npc.TargetClosest(true); + npc.spriteDirection = npc.direction; + if (Collision.CanHit(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + { + float num89 = Main.player[npc.target].Center.X - (float)(npc.direction * 450) - npc.Center.X; + if (num89 < 40f && npc.velocity.X > 0f) + { + npc.velocity.X = npc.velocity.X * 0.98f; + } + else if (num89 > 40f && npc.velocity.X < 0f) + { + npc.velocity.X = npc.velocity.X * 0.98f; + } + if (num89 < 40f && npc.velocity.X > -7f) + { + npc.velocity.X = npc.velocity.X - 0.25f; + } + else if (num89 > 40f && npc.velocity.X < 7f) + { + npc.velocity.X = npc.velocity.X + 0.25f; + } + if (npc.velocity.X > 8f) + { + npc.velocity.X = 8f; + } + if (npc.velocity.X < -8f) + { + npc.velocity.X = -8f; + } + } + } + else if (Main.player[npc.target].Center.Y + 100f < npc.position.Y && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + npc.velocity.Y = -8f; + } + for (int num90 = 0; num90 < 200; num90++) + { + if (num90 != npc.whoAmI && Main.npc[num90].active && Main.npc[num90].type == npc.type && Math.Abs(npc.position.X - Main.npc[num90].position.X) + Math.Abs(npc.position.Y - Main.npc[num90].position.Y) < (float)npc.width) + { + if (npc.position.X < Main.npc[num90].position.X) + { + npc.velocity.X = npc.velocity.X - 0.1f; + } + else + { + npc.velocity.X = npc.velocity.X + 0.1f; + } + if (npc.position.Y < Main.npc[num90].position.Y) + { + npc.velocity.Y = npc.velocity.Y - 0.1f; + } + else + { + npc.velocity.Y = npc.velocity.Y + 0.1f; + } + } + } + if (Main.rand.Next(6) == 0 && npc.ai[1] <= 20f) + { + Dust expr_7CF3 = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, 229, npc.velocity.X, npc.velocity.Y, 100, default(Color), 1f)]; + expr_7CF3.velocity = expr_7CF3.velocity / 4f + npc.velocity / 2f; + expr_7CF3.scale = 0.6f; + expr_7CF3.noLight = true; + } + if (npc.ai[1] >= 57f) + { + int num91 = Utils.SelectRandom(Main.rand, new int[] + { + 161, + 229 + }); + Dust expr_7DBD = Main.dust[Dust.NewDust(npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 8 : -20), -20f), 8, 8, num91, npc.velocity.X, npc.velocity.Y, 100, default(Color), 1f)]; + expr_7DBD.velocity = expr_7DBD.velocity / 4f + npc.DirectionTo(Main.player[npc.target].Top); + expr_7DBD.scale = 1.2f; + expr_7DBD.noLight = true; + } + if (Main.rand.Next(6) == 0) + { + Dust dust2 = Main.dust[Dust.NewDust(npc.Center, 2, 2, 229, 0f, 0f, 0, default(Color), 1f)]; + dust2.position = npc.Center + new Vector2((float)((npc.spriteDirection == 1) ? 26 : -26), 24f); + dust2.velocity.X = 0f; + if (dust2.velocity.Y < 0f) + { + dust2.velocity.Y = 0f; + } + dust2.noGravity = true; + dust2.scale = 1f; + dust2.noLight = true; + } + } + else if (npc.type == NPCID.SnowFlinx) + { + if (npc.velocity.Y == 0f) + { + npc.rotation = 0f; + npc.localAI[0] = 0f; + } + else if (npc.localAI[0] == 1f) + { + npc.rotation += npc.velocity.X * 0.05f; + } + } + else if (npc.type == NPCID.VortexLarva) + { + if (npc.velocity.Y == 0f) + { + npc.rotation = 0f; + } + else + { + npc.rotation += npc.velocity.X * 0.08f; + } + } + if (npc.type == NPCID.Vampire && Main.netMode != 1) + { + Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float arg_803C_0 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector18.X; + float num92 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector18.Y; + if ((float)Math.Sqrt((double)(arg_803C_0 * arg_803C_0 + num92 * num92)) > 300f) + { + npc.Transform(NPCID.VampireBat); + } + } + if (npc.type == NPCID.WallCreeper && Main.netMode != 1 && npc.velocity.Y == 0f) + { + int num93 = (int)npc.Center.X / 16; + int num94 = (int)npc.Center.Y / 16; + bool flag9 = false; + for (int num95 = num93 - 1; num95 <= num93 + 1; num95++) + { + for (int num96 = num94 - 1; num96 <= num94 + 1; num96++) + { + if (Main.tile[num95, num96].wall > 0) + { + flag9 = true; + } + } + } + if (flag9) + { + npc.Transform(NPCID.WallCreeperWall); + } + } + if (npc.type == NPCID.BloodCrawler && Main.netMode != 1 && npc.velocity.Y == 0f) + { + int num97 = (int)npc.Center.X / 16; + int num98 = (int)npc.Center.Y / 16; + bool flag10 = false; + for (int num99 = num97 - 1; num99 <= num97 + 1; num99++) + { + for (int num100 = num98 - 1; num100 <= num98 + 1; num100++) + { + if (Main.tile[num99, num100].wall > 0) + { + flag10 = true; + } + } + } + if (flag10) + { + npc.Transform(NPCID.BloodCrawlerWall); + } + } + if (npc.type == NPCID.DesertScorpionWalk && Main.netMode != 1 && npc.velocity.Y == 0f) + { + int num101 = (int)npc.Center.X / 16; + int num102 = (int)npc.Center.Y / 16; + bool flag11 = false; + for (int num103 = num101 - 1; num103 <= num101 + 1; num103++) + { + for (int num104 = num102 - 1; num104 <= num102 + 1; num104++) + { + if (Main.tile[num103, num104].wall > 0) + { + flag11 = true; + } + } + } + if (flag11) + { + npc.Transform(NPCID.DesertScorpionWall); + } + } + if (Main.netMode != 1 && Main.expertMode && npc.target >= 0 && (npc.type == 163 || npc.type == 238) && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) + { + npc.localAI[0] += 1f; + if (npc.justHit) + { + npc.localAI[0] -= (float)Main.rand.Next(5, 20); + if (npc.localAI[0] < 0f) + { + npc.localAI[0] = 0f; + } + } + if (npc.localAI[0] > (float)Main.rand.Next(120, 240)) + { + npc.localAI[0] = 0f; + Vector2 vector19 = Main.player[npc.target].Center - npc.Center; + vector19.Normalize(); + vector19 *= 10f; + Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vector19.X, vector19.Y, 472, 18, 0f, Main.myPlayer, 0f, 0f); + } + } + if (npc.type == NPCID.BlackRecluse && Main.netMode != 1 && npc.velocity.Y == 0f) + { + int num105 = (int)npc.Center.X / 16; + int num106 = (int)npc.Center.Y / 16; + bool flag12 = false; + for (int num107 = num105 - 1; num107 <= num105 + 1; num107++) + { + for (int num108 = num106 - 1; num108 <= num106 + 1; num108++) + { + if (Main.tile[num107, num108].wall > 0) + { + flag12 = true; + } + } + } + if (flag12) + { + npc.Transform(NPCID.BlackRecluseWall); + } + } + if (npc.type == NPCID.JungleCreeper && Main.netMode != 1 && npc.velocity.Y == 0f) + { + int num109 = (int)npc.Center.X / 16; + int num110 = (int)npc.Center.Y / 16; + bool flag13 = false; + for (int num111 = num109 - 1; num111 <= num109 + 1; num111++) + { + for (int num112 = num110 - 1; num112 <= num110 + 1; num112++) + { + if (Main.tile[num111, num112].wall > 0) + { + flag13 = true; + } + } + } + if (flag13) + { + npc.Transform(NPCID.JungleCreeperWall); + } + } + if (npc.type == NPCID.IceGolem) + { + if (npc.justHit && Main.rand.Next(3) == 0) + { + npc.ai[2] -= (float)Main.rand.Next(20); + } + if (npc.ai[2] < 0f) + { + npc.ai[2] = 0f; + } + if (npc.confused) + { + npc.ai[2] = 0f; + } + npc.ai[2] += 1f; + if (Main.netMode != 1 && npc.ai[2] >= 90f && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float arg_87C1_0 = 15f; + Vector2 vector20 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + 20f); + vector20.X += (float)(10 * npc.direction); + float num114 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector20.X; + float num115 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector20.Y; + float num116 = (float)Math.Sqrt((double)(num114 * num114 + num115 * num115)); + npc.netUpdate = true; + num116 = arg_87C1_0 / num116; + num114 *= num116; + num115 *= num116; + int num117 = 32; + int num118 = 257; + vector20.X += num114 * 3f; + vector20.Y += num115 * 3f; + Projectile.NewProjectile(vector20.X, vector20.Y, num114, num115, num118, num117, 0f, Main.myPlayer, 0f, 0f); + npc.ai[2] = 0f; + } + } + if (npc.type == NPCID.Eyezor) + { + if (npc.justHit) + { + npc.ai[2] -= (float)Main.rand.Next(20); + } + if (npc.ai[2] < 0f) + { + npc.ai[2] = 0f; + } + if (npc.confused) + { + npc.ai[2] = 0f; + } + npc.ai[2] += 1f; + if (Main.netMode != 1 && npc.ai[2] >= 60f && npc.velocity.Y == 0f && !Main.player[npc.target].dead && !Main.player[npc.target].frozen && ((npc.direction > 0 && npc.Center.X < Main.player[npc.target].Center.X) || (npc.direction < 0 && npc.Center.X > Main.player[npc.target].Center.X)) && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float arg_8AF5_0 = 15f; + Vector2 vector21 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + 12f); + vector21.X += (float)(6 * npc.direction); + float num120 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector21.X; + float num121 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector21.Y; + float num122 = (float)Math.Sqrt((double)(num120 * num120 + num121 * num121)); + npc.netUpdate = true; + num122 = arg_8AF5_0 / num122; + num120 *= num122; + num121 *= num122; + int num123 = 30; + int num124 = 83; + vector21.X += num120 * 3f; + vector21.Y += num121 * 3f; + Projectile.NewProjectile(vector21.X, vector21.Y, num120, num121, num124, num123, 0f, Main.myPlayer, 0f, 0f); + npc.ai[2] = 0f; + } + } + if (npc.type == NPCID.MartianEngineer) + { + if (npc.confused) + { + npc.ai[2] = -40f; + } + else + { + if (npc.ai[2] < 40f) + { + npc.ai[2] += 1f; + } + if (npc.ai[2] > 0f && NPC.CountNPCS(NPCID.MartianTurret) >= 4 * NPC.CountNPCS(NPCID.MartianEngineer)) + { + npc.ai[2] = 0f; + } + if (npc.justHit) + { + npc.ai[2] = -20f; + } + if (npc.ai[2] == 20f) + { + int num125 = (int)npc.position.X / 16; + int num126 = (int)npc.position.Y / 16; + int num127 = (int)npc.position.X / 16; + int num128 = (int)npc.position.Y / 16; + int num129 = 5; + int num130 = 0; + bool flag14 = false; + int num131 = 2; + int num132 = 0; + while (!flag14 && num130 < 100) + { + num130++; + int num133 = Main.rand.Next(num125 - num129, num125 + num129); + for (int num134 = Main.rand.Next(num126 - num129, num126 + num129); num134 < num126 + num129; num134++) + { + if ((num134 < num126 - num131 || num134 > num126 + num131 || num133 < num125 - num131 || num133 > num125 + num131) && (num134 < num128 - num132 || num134 > num128 + num132 || num133 < num127 - num132 || num133 > num127 + num132) && Main.tile[num133, num134].nactive()) + { + bool flag15 = true; + if (Main.tile[num133, num134 - 1].lava()) + { + flag15 = false; + } + if (flag15 && Main.tileSolid[(int)Main.tile[num133, num134].type] && !Collision.SolidTiles(num133 - 1, num133 + 1, num134 - 4, num134 - 1)) + { + int num135 = NPC.NewNPC(num133 * 16 - npc.width / 2, num134 * 16, NPCID.MartianTurret, 0, 0f, 0f, 0f, 0f, 255); + Main.npc[num135].position.Y = (float)(num134 * 16 - Main.npc[num135].height); + flag14 = true; + npc.netUpdate = true; + break; + } + } + } + } + } + if (npc.ai[2] == 40f) + { + npc.ai[2] = -90f; + } + } + } + if (npc.type == NPCID.GigaZapper) + { + if (npc.confused) + { + npc.ai[2] = -40f; + } + else + { + if (npc.ai[2] < 20f) + { + npc.ai[2] += 1f; + } + if (npc.justHit) + { + npc.ai[2] = -20f; + } + if (npc.ai[2] == 20f && Main.netMode != 1) + { + npc.ai[2] = (float)(-10 + Main.rand.Next(3) * -10); + Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 8f, (float)(npc.direction * 8), 0f, 437, 25, 1f, Main.myPlayer, 0f, 0f); + } + } + } + if (npc.type == 110 || npc.type == 111 || npc.type == 206 || npc.type == 214 || npc.type == 215 || npc.type == 216 || npc.type == 290 || npc.type == 291 || npc.type == 292 || npc.type == 293 || npc.type == 350 || npc.type == 379 || npc.type == 380 || npc.type == 381 || npc.type == 382 || (npc.type >= 449 && npc.type <= 452) || (npc.type == 468 || npc.type == 481 || npc.type == 411 || npc.type == 409 || (npc.type >= 498 && npc.type <= 506)) || npc.type == 424 || npc.type == 426 || npc.type == 520) + { + bool flag16 = npc.type == 381 || npc.type == 382 || npc.type == 520; + bool flag17 = npc.type == 426; + bool flag18 = true; + int num136 = -1; + int num137 = -1; + if (npc.type == 411) + { + flag16 = true; + num136 = 90; + num137 = 90; + if (npc.ai[1] <= 150f) + { + flag18 = false; + } + } + if (npc.confused) + { + npc.ai[2] = 0f; + } + else + { + if (npc.ai[1] > 0f) + { + npc.ai[1] -= 1f; + } + if (npc.justHit) + { + npc.ai[1] = 30f; + npc.ai[2] = 0f; + } + int num138 = 70; + if (npc.type == 379 || npc.type == 380) + { + num138 = 80; + } + if (npc.type == 381 || npc.type == 382) + { + num138 = 80; + } + if (npc.type == 520) + { + num138 = 15; + } + if (npc.type == 350) + { + num138 = 110; + } + if (npc.type == 291) + { + num138 = 200; + } + if (npc.type == 292) + { + num138 = 120; + } + if (npc.type == 293) + { + num138 = 90; + } + if (npc.type == 111) + { + num138 = 180; + } + if (npc.type == 206) + { + num138 = 50; + } + if (npc.type == 481) + { + num138 = 100; + } + if (npc.type == 214) + { + num138 = 40; + } + if (npc.type == 215) + { + num138 = 80; + } + if (npc.type == 290) + { + num138 = 30; + } + if (npc.type == 411) + { + num138 = 300; + } + if (npc.type == 409) + { + num138 = 60; + } + if (npc.type == 424) + { + num138 = 180; + } + if (npc.type == 426) + { + num138 = 60; + } + bool flag19 = false; + if (npc.type == 216) + { + if (npc.localAI[2] >= 20f) + { + flag19 = true; + } + if (flag19) + { + num138 = 60; + } + else + { + num138 = 8; + } + } + num138 = (int)(num138 * 0.75); + int num139 = num138 / 2; + if (npc.type == 424) + { + num139 = num138 - 1; + } + if (npc.type == 426) + { + num139 = num138 - 1; + } + if (npc.ai[2] > 0f) + { + if (flag18) + { + npc.TargetClosest(true); + } + if (npc.ai[1] == (float)num139) + { + if (npc.type == 216) + { + npc.localAI[2] += 1f; + } + float num140 = 11f; + if (npc.type == 111) + { + num140 = 9f; + } + if (npc.type == 206) + { + num140 = 7f; + } + if (npc.type == 290) + { + num140 = 9f; + } + if (npc.type == 293) + { + num140 = 4f; + } + if (npc.type == 214) + { + num140 = 14f; + } + if (npc.type == 215) + { + num140 = 16f; + } + if (npc.type == 382) + { + num140 = 7f; + } + if (npc.type == 520) + { + num140 = 8f; + } + if (npc.type == 409) + { + num140 = 4f; + } + if (npc.type >= 449 && npc.type <= 452) + { + num140 = 7f; + } + if (npc.type == 481) + { + num140 = 8f; + } + if (npc.type == 468) + { + num140 = 7.5f; + } + if (npc.type == 411) + { + num140 = 1f; + } + if (npc.type >= 498 && npc.type <= 506) + { + num140 = 7f; + } + num140 *= 1.25f; + Vector2 vector22 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + if (npc.type == 481) + { + vector22.Y -= 14f; + } + if (npc.type == 206) + { + vector22.Y -= 10f; + } + if (npc.type == 290) + { + vector22.Y -= 10f; + } + if (npc.type == 381 || npc.type == 382) + { + vector22.Y += 6f; + } + if (npc.type == 520) + { + vector22.Y = npc.position.Y + 20f; + } + if (npc.type >= 498 && npc.type <= 506) + { + vector22.Y -= 8f; + } + if (npc.type == 426) + { + vector22 += new Vector2((float)(npc.spriteDirection * 2), -12f); + } + float num141 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector22.X; + float num142 = Math.Abs(num141) * 0.1f; + if (npc.type == 291 || npc.type == 292) + { + num142 = 0f; + } + if (npc.type == 215) + { + num142 = Math.Abs(num141) * 0.08f; + } + if (npc.type == 214 || (npc.type == 216 && !flag19)) + { + num142 = 0f; + } + if (npc.type == 381 || npc.type == 382 || npc.type == 520) + { + num142 = 0f; + } + if (npc.type >= 449 && npc.type <= 452) + { + num142 = Math.Abs(num141) * (float)Main.rand.Next(10, 50) * 0.01f; + } + if (npc.type == 468) + { + num142 = Math.Abs(num141) * (float)Main.rand.Next(10, 50) * 0.01f; + } + if (npc.type == 481) + { + num142 = Math.Abs(num141) * (float)Main.rand.Next(-10, 11) * 0.0035f; + } + if (npc.type >= 498 && npc.type <= 506) + { + num142 = Math.Abs(num141) * (float)Main.rand.Next(1, 11) * 0.0025f; + } + float num143 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector22.Y - num142; + float num144 = (float)Math.Sqrt((double)(num141 * num141 + num143 * num143)); + npc.netUpdate = true; + num144 = num140 / num144; + num141 *= num144; + num143 *= num144; + int num145 = 35; + int num146 = 82; + if (npc.type == 111) + { + num145 = 11; + } + if (npc.type == 206) + { + num145 = 37; + } + if (npc.type == 379 || npc.type == 380) + { + num145 = 40; + } + if (npc.type == 350) + { + num145 = 45; + } + if (npc.type == 468) + { + num145 = 50; + } + if (npc.type == 111) + { + num146 = 81; + } + if (npc.type == 379 || npc.type == 380) + { + num146 = 81; + } + if (npc.type == 381) + { + num146 = 436; + num145 = 24; + } + if (npc.type == 382) + { + num146 = 438; + num145 = 30; + } + if (npc.type == 520) + { + num146 = 592; + num145 = 35; + } + if (npc.type >= 449 && npc.type <= 452) + { + num146 = 471; + num145 = 20; + } + if (npc.type >= 498 && npc.type <= 506) + { + num146 = 572; + num145 = 14; + } + if (npc.type == 481) + { + num146 = 508; + num145 = 18; + } + if (npc.type == 206) + { + num146 = 177; + } + if (npc.type == 468) + { + num146 = 501; + } + if (npc.type == 411) + { + num146 = 537; + num145 = (Main.expertMode ? 45 : 60); + } + if (npc.type == 424) + { + num146 = 573; + num145 = (Main.expertMode ? 45 : 60); + } + if (npc.type == 426) + { + num146 = 581; + num145 = (Main.expertMode ? 45 : 60); + } + if (npc.type == 291) + { + num146 = 302; + num145 = 100; + } + if (npc.type == 290) + { + num146 = 300; + num145 = 60; + } + if (npc.type == 293) + { + num146 = 303; + num145 = 60; + } + if (npc.type == 214) + { + num146 = 180; + num145 = 25; + } + if (npc.type == 215) + { + num146 = 82; + num145 = 40; + } + if (npc.type == 292) + { + num145 = 50; + num146 = 180; + } + if (npc.type == 216) + { + num146 = 180; + num145 = 30; + if (flag19) + { + num145 = 100; + num146 = 240; + npc.localAI[2] = 0f; + } + } + vector22.X += num141; + vector22.Y += num143; + if (Main.expertMode && npc.type == 290) + { + num145 = (int)((double)num145 * 0.75); + } + if (Main.expertMode && npc.type >= 381 && npc.type <= 392) + { + num145 = (int)((double)num145 * 0.8); + } + if (Main.netMode != 1) + { + if (npc.type == 292) + { + for (int num147 = 0; num147 < 4; num147++) + { + num141 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector22.X; + num143 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector22.Y; + num144 = (float)Math.Sqrt((double)(num141 * num141 + num143 * num143)); + num144 = 12f / num144; + num141 += (float)Main.rand.Next(-40, 41); + num143 += (float)Main.rand.Next(-40, 41); + num141 *= num144; + num143 *= num144; + Projectile.NewProjectile(vector22.X, vector22.Y, num141, num143, num146, num145, 0f, Main.myPlayer, 0f, 0f); + } + } + else if (npc.type == 411) + { + Projectile.NewProjectile(vector22.X, vector22.Y, num141, num143, num146, num145, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); + } + else if (npc.type == 424) + { + for (int num148 = 0; num148 < 4; num148++) + { + Projectile.NewProjectile(npc.Center.X - (float)(npc.spriteDirection * 4), npc.Center.Y + 6f, (float)(-3 + 2 * num148) * 0.15f, (float)(-(float)Main.rand.Next(0, 3)) * 0.2f - 0.1f, num146, num145, 0f, Main.myPlayer, 0f, (float)npc.whoAmI); + } + } + else if (npc.type == 409) + { + int num149 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 410, npc.whoAmI, 0f, 0f, 0f, 0f, 255); + Main.npc[num149].velocity = new Vector2(num141, -6f + num143); + } + else + { + Projectile.NewProjectile(vector22.X, vector22.Y, num141, num143, num146, num145, 0f, Main.myPlayer, 0f, 0f); + } + } + if (Math.Abs(num143) > Math.Abs(num141) * 2f) + { + if (num143 > 0f) + { + npc.ai[2] = 1f; + } + else + { + npc.ai[2] = 5f; + } + } + else if (Math.Abs(num141) > Math.Abs(num143) * 2f) + { + npc.ai[2] = 3f; + } + else if (num143 > 0f) + { + npc.ai[2] = 2f; + } + else + { + npc.ai[2] = 4f; + } + } + if ((npc.velocity.Y != 0f && !flag17) || npc.ai[1] <= 0f) + { + npc.ai[2] = 0f; + npc.ai[1] = 0f; + } + else if (!flag16 || (num136 != -1 && npc.ai[1] >= (float)num136 && npc.ai[1] < (float)(num136 + num137) && (!flag17 || npc.velocity.Y == 0f))) + { + npc.velocity.X = npc.velocity.X * 0.9f; + npc.spriteDirection = npc.direction; + } + } + if (npc.type == 468 && !Main.eclipse) + { + flag16 = true; + } + else if ((npc.ai[2] <= 0f | flag16) && (npc.velocity.Y == 0f | flag17) && npc.ai[1] <= 0f && !Main.player[npc.target].dead) + { + bool flag20 = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + if (npc.type == 520) + { + flag20 = Collision.CanHitLine(npc.Top + new Vector2(0f, 20f), 0, 0, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + } + if (Main.player[npc.target].stealth == 0f && Main.player[npc.target].itemAnimation == 0) + { + flag20 = false; + } + if (flag20) + { + float num150 = 10f; + Vector2 vector23 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num151 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector23.X; + float num152 = Math.Abs(num151) * 0.1f; + float num153 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector23.Y - num152; + num151 += (float)Main.rand.Next(-40, 41); + num153 += (float)Main.rand.Next(-40, 41); + float num154 = (float)Math.Sqrt((double)(num151 * num151 + num153 * num153)); + float num155 = 700f; + if (npc.type == 214) + { + num155 = 550f; + } + if (npc.type == 215) + { + num155 = 800f; + } + if (npc.type >= 498 && npc.type <= 506) + { + num155 = 190f; + } + if (npc.type >= 449 && npc.type <= 452) + { + num155 = 200f; + } + if (npc.type == 481) + { + num155 = 400f; + } + if (npc.type == 468) + { + num155 = 400f; + } + if (num154 < num155) + { + npc.netUpdate = true; + npc.velocity.X = npc.velocity.X * 0.5f; + num154 = num150 / num154; + num151 *= num154; + num153 *= num154; + npc.ai[2] = 3f; + npc.ai[1] = (float)num138; + if (Math.Abs(num153) > Math.Abs(num151) * 2f) + { + if (num153 > 0f) + { + npc.ai[2] = 1f; + } + else + { + npc.ai[2] = 5f; + } + } + else if (Math.Abs(num151) > Math.Abs(num153) * 2f) + { + npc.ai[2] = 3f; + } + else if (num153 > 0f) + { + npc.ai[2] = 2f; + } + else + { + npc.ai[2] = 4f; + } + } + } + } + if (npc.ai[2] <= 0f || (flag16 && (num136 == -1 || npc.ai[1] < (float)num136 || npc.ai[1] >= (float)(num136 + num137)))) + { + float num156 = 1f; + float num157 = 0.07f; + float scaleFactor6 = 0.8f; + if (npc.type == 214) + { + num156 = 2f; + num157 = 0.09f; + } + else if (npc.type == 215) + { + num156 = 1.5f; + num157 = 0.08f; + } + else if (npc.type == 381 || npc.type == 382) + { + num156 = 2f; + num157 = 0.5f; + } + else if (npc.type == 520) + { + num156 = 4f; + num157 = 1f; + scaleFactor6 = 0.7f; + } + else if (npc.type == 411) + { + num156 = 2f; + num157 = 0.5f; + } + else if (npc.type == 409) + { + num156 = 2f; + num157 = 0.5f; + } + num156 *= 1.5f; + num157 *= 1.5f; + bool flag21 = false; + if ((npc.type == 381 || npc.type == 382) && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 300f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + { + flag21 = true; + npc.ai[3] = 0f; + } + if (npc.type == 520 && Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 400f && Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) + { + flag21 = true; + npc.ai[3] = 0f; + } + if ((npc.velocity.X < -num156 || npc.velocity.X > num156) | flag21) + { + if (npc.velocity.Y == 0f) + { + npc.velocity *= scaleFactor6; + } + } + else if (npc.velocity.X < num156 && npc.direction == 1) + { + npc.velocity.X = npc.velocity.X + num157; + if (npc.velocity.X > num156) + { + npc.velocity.X = num156; + } + } + else if (npc.velocity.X > -num156 && npc.direction == -1) + { + npc.velocity.X = npc.velocity.X - num157; + if (npc.velocity.X < -num156) + { + npc.velocity.X = -num156; + } + } + } + if (npc.type == 520) + { + npc.localAI[2] += 1f; + if (npc.localAI[2] >= 6f) + { + npc.localAI[2] = 0f; + npc.localAI[3] = Main.player[npc.target].DirectionFrom(npc.Top + new Vector2(0f, 20f)).ToRotation(); + } + } + } + } + if (npc.type == 109 && Main.netMode != 1 && !Main.player[npc.target].dead) + { + npc.ai[2] += 1f; + if (npc.ai[2] > 180f) + { + Vector2 vector24 = new Vector2(npc.position.X + (float)npc.width * 0.5f - (float)(npc.direction * 24), npc.position.Y + 4f); + int num158 = 3 * npc.direction; + int num159 = -5; + int num160 = Projectile.NewProjectile(vector24.X, vector24.Y, (float)num158, (float)num159, 75, 0, 0f, Main.myPlayer, 0f, 0f); + Main.projectile[num160].timeLeft = 300; + npc.ai[2] = 0f; + } + } + bool flag22 = false; + if (npc.velocity.Y == 0f) + { + int num161 = (int)(npc.position.Y + (float)npc.height + 7f) / 16; + int arg_A8FB_0 = (int)npc.position.X / 16; + int num162 = (int)(npc.position.X + (float)npc.width) / 16; + for (int num163 = arg_A8FB_0; num163 <= num162; num163++) + { + if (Main.tile[num163, num161] == null) + { + return false; + } + if (Main.tile[num163, num161].nactive() && Main.tileSolid[(int)Main.tile[num163, num161].type]) + { + flag22 = true; + break; + } + } + } + if (npc.type == 428) + { + flag22 = false; + } + if (npc.velocity.Y >= 0f) + { + int num164 = 0; + if (npc.velocity.X < 0f) + { + num164 = -1; + } + if (npc.velocity.X > 0f) + { + num164 = 1; + } + Vector2 position2 = npc.position; + position2.X += npc.velocity.X; + int num165 = (int)((position2.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 1) * num164)) / 16f); + int num166 = (int)((position2.Y + (float)npc.height - 1f) / 16f); + if (Main.tile[num165, num166] == null) + { + Main.tile[num165, num166] = new Tile(); + } + if (Main.tile[num165, num166 - 1] == null) + { + Main.tile[num165, num166 - 1] = new Tile(); + } + if (Main.tile[num165, num166 - 2] == null) + { + Main.tile[num165, num166 - 2] = new Tile(); + } + if (Main.tile[num165, num166 - 3] == null) + { + Main.tile[num165, num166 - 3] = new Tile(); + } + if (Main.tile[num165, num166 + 1] == null) + { + Main.tile[num165, num166 + 1] = new Tile(); + } + if (Main.tile[num165 - num164, num166 - 3] == null) + { + Main.tile[num165 - num164, num166 - 3] = new Tile(); + } + if ((float)(num165 * 16) < position2.X + (float)npc.width && (float)(num165 * 16 + 16) > position2.X && ((Main.tile[num165, num166].nactive() && !Main.tile[num165, num166].topSlope() && !Main.tile[num165, num166 - 1].topSlope() && Main.tileSolid[(int)Main.tile[num165, num166].type] && !Main.tileSolidTop[(int)Main.tile[num165, num166].type]) || (Main.tile[num165, num166 - 1].halfBrick() && Main.tile[num165, num166 - 1].nactive())) && (!Main.tile[num165, num166 - 1].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 1].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 1].type] || (Main.tile[num165, num166 - 1].halfBrick() && (!Main.tile[num165, num166 - 4].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 4].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 4].type]))) && (!Main.tile[num165, num166 - 2].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 2].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 2].type]) && (!Main.tile[num165, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165, num166 - 3].type] || Main.tileSolidTop[(int)Main.tile[num165, num166 - 3].type]) && (!Main.tile[num165 - num164, num166 - 3].nactive() || !Main.tileSolid[(int)Main.tile[num165 - num164, num166 - 3].type])) + { + float num167 = (float)(num166 * 16); + if (Main.tile[num165, num166].halfBrick()) + { + num167 += 8f; + } + if (Main.tile[num165, num166 - 1].halfBrick()) + { + num167 -= 8f; + } + if (num167 < position2.Y + (float)npc.height) + { + float num168 = position2.Y + (float)npc.height - num167; + float num169 = 16.1f; + if (npc.type == 163 || npc.type == 164 || npc.type == 236 || npc.type == 239 || npc.type == 530) + { + num169 += 8f; + } + if (num168 <= num169) + { + npc.gfxOffY += npc.position.Y + (float)npc.height - num167; + npc.position.Y = num167 - (float)npc.height; + if (num168 < 9f) + { + npc.stepSpeed = 1f; + } + else + { + npc.stepSpeed = 2f; + } + } + } + } + } + if (flag22) + { + int num170 = (int)((npc.position.X + (float)(npc.width / 2) + (float)(15 * npc.direction)) / 16f); + int num171 = (int)((npc.position.Y + (float)npc.height - 15f) / 16f); + if (npc.type == 109 || npc.type == 163 || npc.type == 164 || npc.type == 199 || npc.type == 236 || npc.type == 239 || npc.type == 257 || npc.type == 258 || npc.type == 290 || npc.type == 391 || npc.type == 425 || npc.type == 427 || npc.type == 426 || npc.type == 508 || npc.type == 415 || npc.type == 530 || npc.type == 532) + { + num170 = (int)((npc.position.X + (float)(npc.width / 2) + (float)((npc.width / 2 + 16) * npc.direction)) / 16f); + } + if (Main.tile[num170, num171] == null) + { + Main.tile[num170, num171] = new Tile(); + } + if (Main.tile[num170, num171 - 1] == null) + { + Main.tile[num170, num171 - 1] = new Tile(); + } + if (Main.tile[num170, num171 - 2] == null) + { + Main.tile[num170, num171 - 2] = new Tile(); + } + if (Main.tile[num170, num171 - 3] == null) + { + Main.tile[num170, num171 - 3] = new Tile(); + } + if (Main.tile[num170, num171 + 1] == null) + { + Main.tile[num170, num171 + 1] = new Tile(); + } + if (Main.tile[num170 + npc.direction, num171 - 1] == null) + { + Main.tile[num170 + npc.direction, num171 - 1] = new Tile(); + } + if (Main.tile[num170 + npc.direction, num171 + 1] == null) + { + Main.tile[num170 + npc.direction, num171 + 1] = new Tile(); + } + if (Main.tile[num170 - npc.direction, num171 + 1] == null) + { + Main.tile[num170 - npc.direction, num171 + 1] = new Tile(); + } + Main.tile[num170, num171 + 1].halfBrick(); + if ((Main.tile[num170, num171 - 1].nactive() && (Main.tile[num170, num171 - 1].type == 10 || Main.tile[num170, num171 - 1].type == 388)) & flag5) + { + npc.ai[2] += 1f; + npc.ai[3] = 0f; + if (npc.ai[2] >= 60f) + { + npc.velocity.X = 0.5f * (float)(-(float)npc.direction); + int num172 = 5; + if (Main.tile[num170, num171 - 1].type == 388) + { + num172 = 2; + } + npc.ai[1] += (float)num172; + if (npc.type == 27) + { + npc.ai[1] += 1f; + } + if (npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296) + { + npc.ai[1] += 6f; + } + npc.ai[2] = 0f; + bool flag23 = false; + if (npc.ai[1] >= 10f) + { + flag23 = true; + npc.ai[1] = 10f; + } + if (npc.type == 460) + { + flag23 = true; + } + WorldGen.KillTile(num170, num171 - 1, true, false, false); + if ((Main.netMode != 1 || !flag23) && flag23 && Main.netMode != 1) + { + if (npc.type == 26) + { + WorldGen.KillTile(num170, num171 - 1, false, false, false); + if (Main.netMode == 2) + { + NetMessage.SendData(17, -1, -1, null, 0, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + } + } + else + { + if (Main.tile[num170, num171 - 1].type == 10) + { + bool flag24 = WorldGen.OpenDoor(num170, num171 - 1, npc.direction); + if (!flag24) + { + npc.ai[3] = (float)num35; + npc.netUpdate = true; + } + if (Main.netMode == 2 & flag24) + { + NetMessage.SendData(19, -1, -1, null, 0, (float)num170, (float)(num171 - 1), (float)npc.direction, 0, 0, 0); + } + } + if (Main.tile[num170, num171 - 1].type == 388) + { + bool flag25 = WorldGen.ShiftTallGate(num170, num171 - 1, false); + if (!flag25) + { + npc.ai[3] = (float)num35; + npc.netUpdate = true; + } + if (Main.netMode == 2 & flag25) + { + NetMessage.SendData(19, -1, -1, null, 4, (float)num170, (float)(num171 - 1), 0f, 0, 0, 0); + } + } + } + } + } + } + else + { + int num173 = npc.spriteDirection; + if (npc.type == 425) + { + num173 *= -1; + } + if ((npc.velocity.X < 0f && num173 == -1) || (npc.velocity.X > 0f && num173 == 1)) + { + if (npc.height >= 32 && Main.tile[num170, num171 - 2].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 2].type]) + { + if (Main.tile[num170, num171 - 3].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 3].type]) + { + npc.velocity.Y = -9f; + npc.netUpdate = true; + } + else + { + npc.velocity.Y = -8f; + npc.netUpdate = true; + } + } + else if (Main.tile[num170, num171 - 1].nactive() && Main.tileSolid[(int)Main.tile[num170, num171 - 1].type]) + { + npc.velocity.Y = -7f; + npc.netUpdate = true; + } + else if (npc.position.Y + (float)npc.height - (float)(num171 * 16) > 20f && Main.tile[num170, num171].nactive() && !Main.tile[num170, num171].topSlope() && Main.tileSolid[(int)Main.tile[num170, num171].type]) + { + npc.velocity.Y = -6f; + npc.netUpdate = true; + } + else if (npc.directionY < 0 && npc.type != 67 && (!Main.tile[num170, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170, num171 + 1].type]) && (!Main.tile[num170 + npc.direction, num171 + 1].nactive() || !Main.tileSolid[(int)Main.tile[num170 + npc.direction, num171 + 1].type])) + { + npc.velocity.Y = -9f; + npc.velocity.X = npc.velocity.X * 2f; + npc.netUpdate = true; + } + else if (flag5) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + if ((npc.velocity.Y == 0f & flag3) && npc.ai[3] == 1f) + { + npc.velocity.Y = -6f; + } + } + if ((npc.type == 31 || npc.type == 294 || npc.type == 295 || npc.type == 296 || npc.type == 47 || npc.type == 77 || npc.type == 104 || npc.type == 168 || npc.type == 196 || npc.type == 385 || npc.type == 389 || npc.type == 464 || npc.type == 470 || (npc.type >= 524 && npc.type <= 527)) && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 100f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f))) + { + npc.velocity.X = npc.velocity.X * 3f; + if (npc.velocity.X > 4f) + { + npc.velocity.X = 4f; + } + if (npc.velocity.X < -4f) + { + npc.velocity.X = -4f; + } + npc.velocity.Y = -5f; + npc.netUpdate = true; + } + if (npc.type == 120 && npc.velocity.Y < 0f) + { + npc.velocity.Y = npc.velocity.Y * 1.1f; + } + if (npc.type == 287 && npc.velocity.Y == 0f && Math.Abs(npc.position.X + (float)(npc.width / 2) - (Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2))) < 150f && Math.Abs(npc.position.Y + (float)(npc.height / 2) - (Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2))) < 50f && ((npc.direction > 0 && npc.velocity.X >= 1f) || (npc.direction < 0 && npc.velocity.X <= -1f))) + { + npc.velocity.X = (float)(9 * npc.direction); + npc.velocity.Y = -5f; + npc.netUpdate = true; + } + if (npc.type == 287 && npc.velocity.Y < 0f) + { + npc.velocity.X = npc.velocity.X * 1.25f; + npc.velocity.Y = npc.velocity.Y * 1.15f; + } + if (npc.type == 460 && npc.velocity.Y < 0f) + { + npc.velocity.X = npc.velocity.X * 1.35f; + npc.velocity.Y = npc.velocity.Y * 1.15f; + } + } + } + else if (flag5) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + } + if (Main.netMode != 1 && npc.type == NPCID.ChaosElemental && npc.ai[3] >= (float)num35) + { + int num174 = (int)Main.player[npc.target].position.X / 16; + int num175 = (int)Main.player[npc.target].position.Y / 16; + int num176 = (int)npc.position.X / 16; + int num177 = (int)npc.position.Y / 16; + int num178 = 20; + int num179 = 0; + bool flag26 = false; + if (Math.Abs(npc.position.X - Main.player[npc.target].position.X) + Math.Abs(npc.position.Y - Main.player[npc.target].position.Y) > 2000f) + { + num179 = 100; + flag26 = true; + } + while (!flag26 && num179 < 100) + { + num179++; + int num180 = Main.rand.Next(num174 - num178, num174 + num178); + for (int num181 = Main.rand.Next(num175 - num178, num175 + num178); num181 < num175 + num178; num181++) + { + if ((num181 < num175 - 4 || num181 > num175 + 4 || num180 < num174 - 4 || num180 > num174 + 4) && (num181 < num177 - 1 || num181 > num177 + 1 || num180 < num176 - 1 || num180 > num176 + 1) && Main.tile[num180, num181].nactive()) + { + bool flag27 = true; + if (npc.type == 32 && Main.tile[num180, num181 - 1].wall == 0) + { + flag27 = false; + } + else if (Main.tile[num180, num181 - 1].lava()) + { + flag27 = false; + } + if (flag27 && Main.tileSolid[(int)Main.tile[num180, num181].type] && !Collision.SolidTiles(num180 - 1, num180 + 1, num181 - 4, num181 - 1)) + { + npc.position.X = (float)(num180 * 16 - npc.width / 2); + npc.position.Y = (float)(num181 * 16 - npc.height); + npc.netUpdate = true; + npc.ai[3] = -30f; + } + } + } + } + } + return false; + } #endregion } } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index ade603f0d8..91a21da51b 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1550,6 +1550,202 @@ namespace CalamityMod.NPCs } } + if (CalamityWorld.death) + { + switch (npc.aiStyle) + { + case 3: + switch (npc.type) + { + case NPCID.Zombie: + case NPCID.ArmedZombie: + case NPCID.ArmedZombieEskimo: + case NPCID.ArmedZombiePincussion: + case NPCID.ArmedZombieSlimed: + case NPCID.ArmedZombieSwamp: + case NPCID.ArmedZombieTwiggy: + case NPCID.ArmedZombieCenx: + case NPCID.Skeleton: + case NPCID.AngryBones: + case NPCID.UndeadMiner: + case NPCID.CorruptBunny: + case NPCID.DoctorBones: + case NPCID.TheGroom: + case NPCID.Crab: + case NPCID.GoblinScout: + case NPCID.ArmoredSkeleton: + case NPCID.Mummy: + case NPCID.DarkMummy: + case NPCID.LightMummy: + case NPCID.Werewolf: + case NPCID.Clown: + case NPCID.SkeletonArcher: + case NPCID.ChaosElemental: + case NPCID.BaldZombie: + case NPCID.PossessedArmor: + case NPCID.ZombieEskimo: + case NPCID.BlackRecluse: + case NPCID.WallCreeper: + case NPCID.UndeadViking: + case NPCID.CorruptPenguin: + case NPCID.FaceMonster: + case NPCID.SnowFlinx: + case NPCID.PincushionZombie: + case NPCID.SlimedZombie: + case NPCID.SwampZombie: + case NPCID.TwiggyZombie: + case NPCID.Nymph: + case NPCID.ArmoredViking: + case NPCID.Lihzahrd: + case NPCID.LihzahrdCrawler: + case NPCID.FemaleZombie: + case NPCID.HeadacheSkeleton: + case NPCID.MisassembledSkeleton: + case NPCID.PantlessSkeleton: + case NPCID.IcyMerman: + case NPCID.PirateDeckhand: + case NPCID.PirateCorsair: + case NPCID.PirateDeadeye: + case NPCID.PirateCrossbower: + case NPCID.PirateCaptain: + case NPCID.CochinealBeetle: + case NPCID.CyanBeetle: + case NPCID.LacBeetle: + case NPCID.SeaSnail: + case NPCID.ZombieRaincoat: + case NPCID.JungleCreeper: + case NPCID.BloodCrawler: + case NPCID.IceGolem: + case NPCID.Eyezor: + case NPCID.ZombieMushroom: + case NPCID.ZombieMushroomHat: + case NPCID.AnomuraFungus: + case NPCID.MushiLadybug: + case NPCID.RustyArmoredBonesAxe: + case NPCID.RustyArmoredBonesFlail: + case NPCID.RustyArmoredBonesSword: + case NPCID.RustyArmoredBonesSwordNoArmor: + case NPCID.BlueArmoredBones: + case NPCID.BlueArmoredBonesMace: + case NPCID.BlueArmoredBonesNoPants: + case NPCID.BlueArmoredBonesSword: + case NPCID.HellArmoredBones: + case NPCID.HellArmoredBonesSpikeShield: + case NPCID.HellArmoredBonesMace: + case NPCID.HellArmoredBonesSword: + case NPCID.BoneLee: + case NPCID.Paladin: + case NPCID.SkeletonSniper: + case NPCID.TacticalSkeleton: + case NPCID.SkeletonCommando: + case NPCID.AngryBonesBig: + case NPCID.AngryBonesBigMuscle: + case NPCID.AngryBonesBigHelmet: + case NPCID.Scarecrow1: + case NPCID.Scarecrow2: + case NPCID.Scarecrow3: + case NPCID.Scarecrow4: + case NPCID.Scarecrow5: + case NPCID.Scarecrow6: + case NPCID.Scarecrow7: + case NPCID.Scarecrow8: + case NPCID.Scarecrow9: + case NPCID.Scarecrow10: + case NPCID.ZombieDoctor: + case NPCID.ZombieSuperman: + case NPCID.ZombiePixie: + case NPCID.SkeletonTopHat: + case NPCID.SkeletonAstonaut: + case NPCID.SkeletonAlien: + case NPCID.Splinterling: + case NPCID.ZombieXmas: + case NPCID.ZombieSweater: + case NPCID.ZombieElf: + case NPCID.ZombieElfBeard: + case NPCID.ZombieElfGirl: + case NPCID.GingerbreadMan: + case NPCID.Yeti: + case NPCID.Nutcracker: + case NPCID.NutcrackerSpinning: + case NPCID.ElfArcher: + case NPCID.Krampus: + case NPCID.CultistArcherBlue: + case NPCID.CultistArcherWhite: + case NPCID.BrainScrambler: + case NPCID.RayGunner: + case NPCID.MartianOfficer: + case NPCID.GrayGrunt: + case NPCID.MartianEngineer: + case NPCID.GigaZapper: + case NPCID.Scutlix: + case NPCID.BoneThrowingSkeleton: + case NPCID.BoneThrowingSkeleton2: + case NPCID.BoneThrowingSkeleton3: + case NPCID.BoneThrowingSkeleton4: + case NPCID.CrimsonBunny: + case NPCID.CrimsonPenguin: + case NPCID.Medusa: + case NPCID.GreekSkeleton: + case NPCID.GraniteGolem: + case NPCID.BloodZombie: + case NPCID.Crawdad: + case NPCID.Crawdad2: + case NPCID.Salamander: + case NPCID.Salamander2: + case NPCID.Salamander3: + case NPCID.Salamander4: + case NPCID.Salamander5: + case NPCID.Salamander6: + case NPCID.Salamander7: + case NPCID.Salamander8: + case NPCID.Salamander9: + case NPCID.WalkingAntlion: + case NPCID.DesertGhoul: + case NPCID.DesertGhoulCorruption: + case NPCID.DesertGhoulCrimson: + case NPCID.DesertGhoulHallow: + case NPCID.DesertLamiaLight: + case NPCID.DesertLamiaDark: + case NPCID.DesertScorpionWalk: + case NPCID.DesertBeast: + case NPCID.StardustSoldier: + case NPCID.StardustSpiderBig: + case NPCID.NebulaSoldier: + case NPCID.VortexRifleman: + case NPCID.VortexSoldier: + case NPCID.VortexLarva: + case NPCID.VortexHornet: + case NPCID.VortexHornetQueen: + case NPCID.SolarDrakomire: + case NPCID.SolarSpearman: + case NPCID.SolarSolenian: + case NPCID.Frankenstein: + case NPCID.SwampThing: + case NPCID.Vampire: + case NPCID.Butcher: + case NPCID.CreatureFromTheDeep: + case NPCID.Fritz: + case NPCID.Nailhead: + case NPCID.Psycho: + case NPCID.ThePossessed: + case NPCID.DrManFly: + case NPCID.GoblinPeon: + case NPCID.GoblinThief: + case NPCID.GoblinWarrior: + case NPCID.GoblinArcher: + case NPCID.GoblinSummoner: + case NPCID.MartianWalker: + case NPCID.DemonTaxCollector: + case NPCID.TheBride: + return CalamityGlobalAI.BuffedFighterAI(npc, mod); + } + break; + + default: + break; + } + } + return true; } #endregion @@ -2094,14 +2290,6 @@ namespace CalamityMod.NPCs CalamityGlobalAI.RevengeanceDungeonGuardianAI(npc, configBossRushBoost, enraged > 0); break; - case NPCID.Lihzahrd: - CalamityGlobalAI.RevengeanceLihzahrdAI(npc); - break; - - case NPCID.IceGolem: - CalamityGlobalAI.RevengeanceIceGolemAI(npc); - break; - default: break; }