public static void NPCAiStyles(NPC npc, int aiStyle) { if (npc.aiStyle == 102) { npc.ai[11]++; if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(false); //Change Target in Multiplayer if current Target is dead } if (!Main.player[npc.target].dead && Main.player[npc.target].active) //If the target is alive then: { float distance = Vector2.Distance(npc.Center, Main.player[npc.target].Center); //Distance from player float num248 = 0.5f; if (Main.expertMode) { num248 = 0.60f; } if ((float)npc.life < (float)npc.lifeMax * num248) { npc.ai[0] = 1f; npc.ai[1] = 0f; npc.ai[2] = 0f; npc.ai[3] = 0f; npc.ai[9] = 0f; if (npc.ai[4] == 0f) { for (int k = 0; k < 20; k++) { int dust = Dust.NewDust(new Vector2(npc.position.X + Main.rand.Next(-2, 2), npc.position.Y + Main.rand.Next(-2, 2)), npc.width, npc.height, 270, (float)Main.rand.Next(-3, 3), (float)Main.rand.Next(-3, 3), 0, default(Color), 1.3f); Main.dust[dust].velocity *= npc.velocity; } npc.ai[4]++; } npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; return; } } if (distance > 750f && npc.ai[11] > 180 && npc.ai[9] < 600f && npc.ai[8] < 600f) { float sp = 30f; Vector2 pos = new Vector2(Main.player[npc.target].Center.X, Main.player[npc.target].Center.Y - 200f) - npc.Center; float mag = (float)Math.Sqrt(Math.Pow(pos.X, 2) + Math.Pow(pos.Y, 2)); if (mag > sp) { pos *= sp / mag; } npc.velocity = pos; } else if (npc.ai[0] == 0f) { npc.ai[9]++; if (npc.ai[9] < 600f) { if (npc.ai[1] == 0f) { float num243 = 10f; if (Main.expertMode) { num243 = 11f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; npc.ai[1] = 1f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } } else if (npc.ai[1] == 1f) { npc.ai[2] += 1f; if (npc.ai[2] >= 20f) { npc.velocity *= 0.97f; if (Main.expertMode) { npc.velocity *= 0.98f; } if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) { npc.velocity.X = 0f; } if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) { npc.velocity.Y = 0f; } } int num247 = 30; if (Main.expertMode) { num247 = 45; } if (npc.ai[2] >= (float)num247) { npc.ai[3] += 1f; npc.ai[2] = 0f; npc.target = 255; if (npc.ai[3] >= 3f) { npc.ai[1] = 0f; npc.ai[3] = 0f; } else { npc.ai[1] = 1f; } } } } else if (npc.ai[9] < 1200f) { float num243 = 1.5f; if (Main.expertMode) { num243 = 2.6f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; npc.ai[1] = 1f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } float velocityCooldown = Main.expertMode ? 0.95f : 0.98f; npc.velocity *= velocityCooldown; int timing = Main.expertMode ? 15 : 30; int damage1 = Main.expertMode ? 5 : 0; if (distance > 750f) { npc.velocity *= 3f; } if (npc.ai[9] % timing == 0) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, -Main.rand.Next(-7, 7), Main.rand.Next(-7, 2), 654, damage1, 4, Main.myPlayer, 0f, 0f); } if (npc.ai[9] % 60 == 0 && Main.expertMode) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, -Main.rand.Next(-7, 7), Main.rand.Next(-7, 2), 656, 23, 4, Main.myPlayer, 0f, 0f); } } else { npc.ai[9] = 0f; } } else { npc.ai[8]++; if (npc.ai[8] < 600f) { if (npc.ai[5] == 0f) { float num243 = 12f; if (Main.expertMode) { num243 = 14f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; npc.ai[5] = 1f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } } else if (npc.ai[5] == 1f) { npc.ai[6] += 1f; if (npc.ai[6] >= 20f) { npc.velocity *= 0.96f; if (Main.expertMode) { npc.velocity *= 0.98f; } if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) { npc.velocity.X = 0f; } if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) { npc.velocity.Y = 0f; } } int num247 = 30; if (Main.expertMode) { num247 = 45; } if (npc.ai[6] >= (float)num247) { npc.ai[7] += 1f; npc.ai[6] = 0f; npc.target = 255; if (npc.ai[7] >= 3f) { npc.ai[5] = 0f; npc.ai[7] = 0f; } else { npc.ai[5] = 1f; } } } } else if (npc.ai[8] <= 900f) { float num243 = 2.3f; if (Main.expertMode) { num243 = 4.3f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y - 200f + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; npc.ai[1] = 1f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } int timing = Main.expertMode ? 60 : 90; int damage1 = Main.expertMode ? 20 : 5; int damage2 = Main.expertMode ? 20 : 5; if (npc.ai[8] % timing == 0) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, 0, 8, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, 4, 4, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, 8, 0, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, 4, -4, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, 0, -8, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, -4, -4, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, -8, 0, 654, damage1, 4, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, -4, 4, 654, damage1, 4, Main.myPlayer, 0f, 0f); } if (npc.ai[9] % 60 == 0 && Main.expertMode) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y + 3f, -Main.rand.Next(-7, 7), Main.rand.Next(-7, 2), 656, damage2, 4, Main.myPlayer, 0f, 0f); } } else { npc.ai[8] = 0f; } } } else { npc.timeLeft = 10; if (npc.velocity.Y > 0) npc.velocity.Y -= 0.17f; else npc.velocity.Y -= 0.11f; npc.velocity.X *= 0.91f; } } else if (npc.aiStyle == 103) { /* Ai 0 - Move counter 1 - Used in Life checking 2 - Which of the two halves is which 3 - Which of the two halves is which 4, 5, 6 - Checking for charging 9 - Should rotate 10 - Spritesheet frame 11 - Drawing the old positions */ if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(false); } if (npc.ai[1] == 1f) { npc.scale = 0.5f; } if (npc.ai[9] == 0f) { Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); float rotation = (float)Math.Atan2((double)direction.Y, (double)direction.X) + MathHelper.PiOver2; float rotation2 = MathHelper.ToDegrees(rotation); if (rotation2 < 0 || rotation2 > 180) { npc.ai[10] = 1f; } else { npc.ai[10] = 0f; } npc.rotation = MathHelper.ToRadians(rotation2); } if (!Main.player[npc.target].dead && Main.player[npc.target].active) { if (npc.ai[2] == 0f && npc.ai[3] == 0f) { //Check Life if ((float)npc.life < (float)npc.lifeMax / 2) { if (npc.ai[1] == 0f) { npc.ai[0] = 1f; npc.ai[9] = 0f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; return; } npc.ai[1]++; npc.active = false; NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 542, 0, 0f, 0f, 1f, 0f); NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 542, 0, 0f, 0f, 0f, 1f); } } // npc.ai[0]++; if (npc.ai[0] < 600) //Slow movement. Occasional laser shot. Slow rotation. { npc.ai[9] = 0f; float num243 = 1.1f; if (Main.expertMode) { num243 = 1.8f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } float projVelVar = 1f; if (Main.expertMode) { projVelVar = 1.4f; } Vector2 vel1 = npc.Center - Main.player[npc.target].Center; float velFloat = (float)Math.Sqrt((double)(vel1.X * vel1.X + vel1.Y * vel1.Y)); velFloat = projVelVar / velFloat; Vector2 newVelocity = new Vector2(vel1.X * velFloat, vel1.Y * velFloat); newVelocity *= 20f; int timing = 45; if (Main.expertMode) { timing = 30; } if (npc.ai[0] % timing == 0) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, -newVelocity.X, -newVelocity.Y, 100, 1, 2f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[0] < 1500) { if (npc.ai[4] == 0f) { float num243 = 34f; if (Main.expertMode) { num243 = 45f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); int randomizeX = Main.rand.Next(2) == 0 ? Main.rand.Next(200, 301) : Main.rand.Next(-300, -199); int randomizeY = Main.rand.Next(2) == 0 ? Main.rand.Next(200, 301) : Main.rand.Next(-300, -199); float num244 = Main.player[npc.target].position.X + randomizeX + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + randomizeY + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); ///////////////////////////////////////////////////////////////////////////////////////////////// Vector2 direction = new Vector2(Main.player[npc.target].Center.X + randomizeX, Main.player[npc.target].Center.Y + randomizeY) - npc.Center; direction.Normalize(); float rotation = (float)Math.Atan2((double)direction.Y, (double)direction.X) + MathHelper.PiOver2; float rotation2 = MathHelper.ToDegrees(rotation); if (rotation2 < 0 || rotation2 > 180) { npc.ai[10] = 1f; } else { npc.ai[10] = 0f; } npc.rotation = MathHelper.ToRadians(rotation2); ////////////////////////////////////////////////////////////////////////////////////////////////// num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; npc.ai[4] = 1f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } } else if (npc.ai[4] == 1f) { npc.ai[5] += 1f; if (npc.ai[5] >= 10f) { npc.velocity *= 0.96f; if (Main.expertMode) { npc.velocity *= 0.95f; } if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) { npc.velocity.X = 0f; } if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) { npc.velocity.Y = 0f; } } int num247 = 30; if (Main.expertMode) { num247 = 35; } if (npc.ai[5] >= (float)num247) { npc.ai[6] += 1f; npc.ai[5] = 0f; npc.target = 255; if (npc.ai[6] >= 3f) { npc.ai[4] = 0f; npc.ai[6] = 0f; } else { npc.ai[4] = 1f; } } } } } else if (npc.ai[2] == 1f && npc.ai[3] == 0f) { } else if (npc.ai[2] == 0f && npc.ai[3] == 1f) { } } else { npc.ai[9] = 0f; npc.velocity.Y -= 0.05f; } } else if (npc.aiStyle == 104) { npc.ai[19] = 0f; if (npc.ai[11] == 1f) { #region jump code, pls leave float num644 = 1f; bool flag65 = false; bool flag66 = false; npc.aiAction = 0; if (npc.ai[3] == 0f && npc.life > 0) { npc.ai[3] = (float)npc.lifeMax; } if (npc.localAI[3] == 0f && Main.netMode != 1) { npc.ai[0] = -100f; npc.localAI[3] = 1f; npc.TargetClosest(true); npc.netUpdate = true; } if (Main.player[npc.target].dead) { npc.TargetClosest(true); if (Main.player[npc.target].dead) { npc.timeLeft = 0; if (Main.player[npc.target].Center.X < npc.Center.X) { npc.direction = 1; } else { npc.direction = -1; } npc.ai[19] = 50f; } } if (!Main.player[npc.target].dead && npc.ai[2] >= 300f && npc.ai[1] < 5f && npc.velocity.Y == 0f) { npc.ai[2] = 0f; npc.ai[0] = 0f; npc.ai[1] = 5f; if (Main.netMode != 1) { npc.TargetClosest(false); Point point5 = npc.Center.ToTileCoordinates(); Point point6 = Main.player[npc.target].Center.ToTileCoordinates(); Vector2 vector65 = Main.player[npc.target].Center - npc.Center; int num645 = 10; int num646 = 0; int num647 = 7; int num648 = 0; bool flag67 = false; if (vector65.Length() > 2000f) { flag67 = true; num648 = 100; } // while (!flag67 && num648 < 100) { num648++; int num649 = Main.rand.Next(point6.X - num645, point6.X + num645 + 1); int num650 = Main.rand.Next(point6.Y - num645, point6.Y + 1); if ((num650 < point6.Y - num647 || num650 > point6.Y + num647 || num649 < point6.X - num647 || num649 > point6.X + num647) && (num650 < point5.Y - num646 || num650 > point5.Y + num646 || num649 < point5.X - num646 || num649 > point5.X + num646) && !Main.tile[num649, num650].nactive()) { int num651 = num650; int num652 = 0; bool flag68 = Main.tile[num649, num651].nactive() && Main.tileSolid[(int)Main.tile[num649, num651].type] && !Main.tileSolidTop[(int)Main.tile[num649, num651].type]; if (flag68) { num652 = 1; } else { while (num652 < 150 && num651 + num652 < Main.maxTilesY) { int num653 = num651 + num652; bool flag69 = Main.tile[num649, num653].nactive() && Main.tileSolid[(int)Main.tile[num649, num653].type] && !Main.tileSolidTop[(int)Main.tile[num649, num653].type]; if (flag69) { num652--; break; } num652++; } } num650 += num652; bool flag70 = true; if (flag70 && Main.tile[num649, num650].lava()) { flag70 = false; } if (flag70 && !Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) { flag70 = false; } if (flag70) { npc.localAI[1] = (float)(num649 * 16 + 8); npc.localAI[2] = (float)(num650 * 16 + 16); break; } } } if (num648 >= 100) { Vector2 bottom = Main.player[(int)Player.FindClosest(npc.position, npc.width, npc.height)].Bottom; npc.localAI[1] = bottom.X; npc.localAI[2] = bottom.Y; } } } if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0)) { npc.ai[2] += 1f; } if (Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 320f) { npc.ai[2] += 1f; } if (npc.ai[1] == 5f) { flag65 = true; npc.aiAction = 1; npc.ai[0] += 1f; num644 = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f); num644 = 0.5f + num644 * 0.5f; if (npc.ai[0] >= 60f) { flag66 = true; } if (npc.ai[0] >= 60f && Main.netMode != 1) { npc.Bottom = new Vector2(npc.localAI[1], npc.localAI[2]); npc.ai[1] = 6f; npc.ai[0] = 0f; npc.netUpdate = true; } if (Main.netMode == 1 && npc.ai[0] >= 120f) { npc.ai[1] = 6f; npc.ai[0] = 0f; } if (!flag66) { for (int num654 = 0; num654 < 10; num654++) { int num655 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); Main.dust[num655].noGravity = true; Main.dust[num655].velocity *= 0.5f; } } } else if (npc.ai[1] == 6f) { flag65 = true; npc.aiAction = 0; npc.ai[0] += 1f; num644 = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); num644 = 0.5f + num644 * 0.5f; if (npc.ai[0] >= 30f && Main.netMode != 1) { npc.ai[1] = 0f; npc.ai[0] = 0f; npc.netUpdate = true; npc.TargetClosest(true); } if (Main.netMode == 1 && npc.ai[0] >= 60f) { npc.ai[1] = 0f; npc.ai[0] = 0f; npc.TargetClosest(true); } for (int num656 = 0; num656 < 10; num656++) { int num657 = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, 4, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); Main.dust[num657].noGravity = true; Main.dust[num657].velocity *= 2f; } } npc.dontTakeDamage = (npc.hide = flag66); if (npc.velocity.Y == 0f) { npc.velocity.X = npc.velocity.X * 0.8f; if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) { npc.velocity.X = 0f; } if (!flag65) { npc.ai[0] += 2f; if ((double)npc.life < (double)npc.lifeMax * 0.8) { npc.ai[0] += 1f; } if ((double)npc.life < (double)npc.lifeMax * 0.6) { npc.ai[0] += 1f; } if ((double)npc.life < (double)npc.lifeMax * 0.4) { npc.ai[0] += 2f; } if ((double)npc.life < (double)npc.lifeMax * 0.2) { npc.ai[0] += 3f; } if ((double)npc.life < (double)npc.lifeMax * 0.1) { npc.ai[0] += 4f; } if (npc.ai[0] >= 0f) { npc.netUpdate = true; npc.TargetClosest(true); if (npc.ai[1] == 3f) { npc.velocity.Y = -12f - npc.ai[19]; npc.velocity.X = npc.velocity.X + 6f * (float)npc.direction; npc.ai[0] = -200f; npc.ai[1] = 0f; } else if (npc.ai[1] == 2f) { npc.velocity.Y = -6f - npc.ai[19]; npc.velocity.X = npc.velocity.X + 12f * (float)npc.direction; npc.ai[0] = -120f; npc.ai[1] += 1f; } else { npc.velocity.Y = -8f - npc.ai[19]; npc.velocity.X = npc.velocity.X + 5f * (float)npc.direction; npc.ai[0] = -120f; npc.ai[1] += 1f; } } else if (npc.ai[0] >= -30f) { npc.aiAction = 1; } } } else if (npc.target < 255 && ((npc.direction == 1 && npc.velocity.X < 3f) || (npc.direction == -1 && npc.velocity.X > -3f))) { if ((npc.direction == -1 && (double)npc.velocity.X < 0.1) || (npc.direction == 1 && (double)npc.velocity.X > -0.1)) { npc.velocity.X = npc.velocity.X + 0.2f * (float)npc.direction; } else { npc.velocity.X = npc.velocity.X * 0.93f; } } int num658 = Dust.NewDust(npc.position, npc.width, npc.height, 4, npc.velocity.X, npc.velocity.Y, 255, new Color(0, 80, 255, 80), npc.scale * 1.2f); Main.dust[num658].noGravity = true; Main.dust[num658].velocity *= 0.5f; #endregion } npc.ai[10]++; if (npc.ai[10] < 600) { npc.ai[11] = 1f; } else if (npc.ai[10] < 700) { npc.velocity.X /= 1.1f; npc.ai[11] = 0f; if (npc.ai[10] % 4 == 0) { float var1 = 0f; float var2 = 0f; int r = Main.rand.Next(0, 24); switch (r) { case 0: var1 = 80f; var2 = 0f; break; case 1: var1 = 74f; var2 = 6f; break; case 2: var1 = 60f; var2 = 20f; break; case 3: var1 = 40f; var2 = 40f; break; case 4: var1 = 20f; var2 = 60f; break; case 5: var1 = 4f; var2 = 74f; break; case 6: var1 = 0f; var2 = 80f; break; case 7: var1 = -6f; var2 = 74f; break; case 8: var1 = -20f; var2 = 60f; break; case 9: var1 = -40f; var2 = 40f; break; case 10: var1 = -60f; var2 = 20f; break; case 11: var1 = -74f; var2 = 6f; break; case 12: var1 = -80f; var2 = 0f; break; case 13: var1 = -74f; var2 = -6f; break; case 14: var1 = -60f; var2 = -20f; break; case 15: var1 = -40f; var2 = -40f; break; case 16: var1 = -20f; var2 = -60f; break; case 17: var1 = -6f; var2 = -74f; break; case 18: var1 = 0f; var2 = -80f; break; case 19: var1 = 6f; var2 = -74f; break; case 20: var1 = 20f; var2 = -60f; break; case 21: var1 = 40f; var2 = -40f; break; case 22: var1 = 60f; var2 = -20f; break; case 23: var1 = 74f; var2 = -6f; break; } float posX = npc.Center.X + var1; float posY = npc.Center.Y + var2; Projectile.NewProjectile(posX, posY, -var1 / 40, -var2 / 40, 659, 50, 5f, Main.myPlayer, 0f, 0f); Projectile.NewProjectile(-posX, -posY, var1 / 40, var2 / 40, 659, 50, 5f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[10] < 880) { if (npc.ai[10] % 15 == 0) { Vector2 Positions = new Vector2(0, 0); Vector2 P = npc.Center; if (npc.ai[10] == 705) { Positions = new Vector2(P.X + -100, P.Y + 0); } if (npc.ai[10] == 720) { Positions = new Vector2(P.X + -67, P.Y + -33); } if (npc.ai[10] == 735) { Positions = new Vector2(P.X + -33, P.Y + -67); } if (npc.ai[10] == 750) { Positions = new Vector2(P.X + 0, P.Y + -100); } if (npc.ai[10] == 765) { Positions = new Vector2(P.X + 33, P.Y + -67); } if (npc.ai[10] == 780) { Positions = new Vector2(P.X + 67, P.Y + -33); } if (npc.ai[10] == 795) { Positions = new Vector2(P.X + 100, P.Y + 0); } if (npc.ai[10] == 810) { Positions = new Vector2(P.X + 67, P.Y + 33); } if (npc.ai[10] == 825) { Positions = new Vector2(P.X + 33, P.Y + 67); } if (npc.ai[10] == 840) { Positions = new Vector2(P.X + 0, P.Y + 100); } if (npc.ai[10] == 855) { Positions = new Vector2(P.X + -33, P.Y + 67); } if (npc.ai[10] == 870) { Positions = new Vector2(P.X + -67, P.Y + 33); } float projVelVar = 1f; if (Main.expertMode) { projVelVar = 1.4f; } Vector2 vel1 = npc.Center - Positions; float velFloat = (float)Math.Sqrt((double)(vel1.X * vel1.X + vel1.Y * vel1.Y)); velFloat = projVelVar / velFloat; Vector2 newVelocity = new Vector2(vel1.X * velFloat, vel1.Y * velFloat); newVelocity *= 20f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, -newVelocity.X, -newVelocity.Y, 660, 45, 2f, Main.myPlayer, 0f, 0f); } } else if (npc.ai[10] < 1200f) { npc.ai[11] = 1f; npc.ai[18] = 0f; } else if (npc.ai[10] == 1201) { npc.ai[20] = npc.Center.Y - Main.rand.Next(21, 45); npc.ai[21] = npc.ai[20] - Main.rand.Next(100, 300); npc.ai[22] = npc.ai[21] - Main.rand.Next(100, 200); } else if (npc.ai[10] < 1500f) { npc.defense = 600; npc.reflectingProjectiles = true; npc.velocity.X /= 1.1f; npc.ai[11] = 0f; npc.ai[15] = 1f; npc.ai[16] = 1f; int timing = 8; if (Main.expertMode) { timing = 6; } if (npc.ai[10] % timing == 0) { Projectile.NewProjectile(Main.player[npc.target].Center.X + 1000, npc.ai[20], -25f, 0, 435, 30, 2f, Main.myPlayer); Projectile.NewProjectile(Main.player[npc.target].Center.X - 1000, npc.ai[21], 25f, 0, 435, 30, 2f, Main.myPlayer); Projectile.NewProjectile(Main.player[npc.target].Center.X + 1000, npc.ai[22], -25f, 0, 435, 30, 2f, Main.myPlayer); } } else { Ulterraria.UlterrariaMain.SetTitle(); npc.defense = 28; npc.reflectingProjectiles = false; npc.ai[15] = 0f; npc.ai[10] = 1f; } } else if (npc.aiStyle == 105) { if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(false); } if (npc.ai[9] == 0f) { Vector2 direction = Main.player[npc.target].Center - npc.Center; direction.Normalize(); float rotation = (float)Math.Atan2((double)direction.Y, (double)direction.X) + MathHelper.PiOver2; float rotation2 = MathHelper.ToDegrees(rotation); if (rotation2 < 0 || rotation2 > 180) { npc.ai[11] = 1f; } else { npc.ai[11] = 0f; } npc.rotation = MathHelper.ToRadians(rotation2); } if (!Main.player[npc.target].dead && Main.player[npc.target].active) { npc.ai[10]++; if (npc.ai[10] < 600) { if (npc.ai[1] == 0f) { NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 600, 23); npc.ai[9] = 0f; float num243 = 10f; if (Main.expertMode) { num243 = 11f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, npc.velocity.X * 2, npc.velocity.Y * 2, 258, 36, 1); npc.ai[1] = 1f; npc.netUpdate = true; if (npc.netSpam > 10) { npc.netSpam = 10; } } else if (npc.ai[1] == 1f) { npc.ai[9] = 1f; npc.ai[2] += 1f; if (npc.ai[2] >= 20f) { npc.velocity *= 0.97f; if (Main.expertMode) { npc.velocity *= 0.98f; } if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) { npc.velocity.X = 0f; } if ((double)npc.velocity.Y > -0.1 && (double)npc.velocity.Y < 0.1) { npc.velocity.Y = 0f; } } int num247 = 30; if (Main.expertMode) { num247 = 45; } if (npc.ai[2] >= (float)num247) { npc.ai[3] += 1f; npc.ai[2] = 0f; npc.target = 255; if (npc.ai[3] >= 3f) { npc.ai[1] = 0f; npc.ai[3] = 0f; } else { npc.ai[1] = 1f; } } } } else if (npc.ai[10] < 1200f) { npc.ai[9] = 0f; float num243 = 1f; if (Main.expertMode) { num243 = 2f; } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = num243 / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; if (npc.ai[10] % 5 == 0) { int p = Projectile.NewProjectile(npc.Center.X, npc.Center.Y * 7, npc.velocity.X * 7, npc.velocity.Y, 85, 40, 0f); Main.projectile[p].hostile = true; } } else { npc.ai[10] = 0f; } } } else if (npc.aiStyle == 106) { if (npc.type == 545) { npc.TargetClosest(false); if (npc.position.X < Main.player[npc.target].position.X) { npc.direction = 1; } if (npc.position.X > Main.player[npc.target].position.X) { npc.direction = -1; } npc.ai[0]++; if (npc.ai[0] < 240f) { if (npc.velocity.X == 0f) { npc.velocity.Y = -4f; } npc.rotation += MathHelper.ToRadians(npc.velocity.X * 2f); if (npc.velocity.X < 4f && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; 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.1f; if (npc.velocity.X < -4f) { npc.velocity.X = -4f; } } } else if (npc.ai[0] < 480f) { npc.velocity.X *= 0.95f; if (npc.ai[0] < 270f) { npc.velocity.Y = -10f; } else if (npc.ai[0] == 290f) { float dist = Vector2.Distance(npc.Center, new Vector2(Main.player[npc.target].Center.X, npc.Center.Y)); float vel = dist * 0.08f; if (vel > 40f) { vel = 40f; } if (vel < -40f) { vel = -40f; } npc.velocity.X = npc.direction * vel; } else if (npc.ai[0] > 290f && npc.ai[0] < 479f) { if (npc.velocity.Y == 0f) { npc.ai[0] = 0f; } npc.rotation += MathHelper.ToRadians(12f); } } else { npc.ai[0] = 0f; } } else if (npc.type == 546) { npc.TargetClosest(false); if (npc.position.X < Main.player[npc.target].position.X) { npc.direction = 1; } if (npc.position.X > Main.player[npc.target].position.X) { npc.direction = -1; } npc.spriteDirection = npc.direction; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { npc.velocity.Y = -6f; npc.velocity.X = 1.6f * npc.direction; } if (npc.velocity.X < 1.6f && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; if (npc.velocity.X > 1.6f) { npc.velocity.X = 1.6f; } } else if (npc.velocity.X > -1.6f && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; if (npc.velocity.X < -1.6f) { npc.velocity.X = -1.6f; } } } else if (npc.type == 547) { if (npc.life < npc.lifeMax / 2 && npc.ai[12] == 0f) { npc.ai[12] = 1f; npc.damage += 10; npc.defense += 10; npc.defDamage += 10; npc.defDefense += 10; } npc.TargetClosest(false); if (npc.position.X < Main.player[npc.target].position.X) { npc.direction = 1; } if (npc.position.X > Main.player[npc.target].position.X) { npc.direction = -1; } npc.spriteDirection = npc.direction; if ((npc.Center.X > Main.player[npc.target].Center.X + 50 || npc.Center.X < Main.player[npc.target].Center.X - 50 || npc.Center.Y > Main.player[npc.target].Center.Y - 20) && npc.ai[14] == 0) { npc.ai[4] = 0f; if (npc.ai[6] < 4) { npc.ai[6] += 0.1f; } if (npc.ai[0] == 180) { npc.ai[10] = 0; npc.ai[11] = 330; } else if (npc.ai[0] % 15 == 0) { npc.ai[10] = Main.rand.Next(-60, 61); npc.ai[11] = Main.rand.Next(270, 390); } Vector2 vector28 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num244 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - npc.ai[10] - vector28.X; float num245 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - npc.ai[11] - vector28.Y; float num246 = (float)Math.Sqrt((double)(num244 * num244 + num245 * num245)); num246 = npc.ai[6] / num246; npc.velocity.X = num244 * num246; npc.velocity.Y = num245 * num246; } else { npc.ai[14] = 1f; npc.ai[0]++; if (npc.ai[0] < 120f) { npc.ai[6] = 0; npc.velocity.X *= 0.96f; npc.ai[4] = 1f; if (npc.velocity.Y < 16) { npc.velocity.Y += 0.6f; } if (npc.velocity.Y >= 16) { npc.velocity.Y = 16f; } } else if (npc.ai[0] < 240f) { npc.velocity.X = 0; npc.ai[4] = 0f; if (npc.velocity.Y > -3) { npc.velocity.Y -= 0.4f; } else { npc.velocity.Y = -3f; } } else { npc.ai[14] = 0f; npc.ai[0] = 0f; } } } else if (npc.type == 548) { npc.TargetClosest(false); if (npc.position.X < Main.player[npc.target].position.X) { npc.direction = 1; } if (npc.position.X > Main.player[npc.target].position.X) { npc.direction = -1; } npc.spriteDirection = npc.direction; npc.ai[0]++; if (npc.ai[0] < 240f) { npc.ai[1] = 0f; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { npc.velocity.Y = -6f; npc.velocity.X = 1.6f * npc.direction; } if (npc.velocity.X < 1.6f && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; if (npc.velocity.X > 1.6f) { npc.velocity.X = 1.6f; } } else if (npc.velocity.X > -1.6f && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; if (npc.velocity.X < -1.6f) { npc.velocity.X = -1.6f; } } } else if (npc.ai[0] < 600) { npc.velocity.X *= 0.93f; npc.ai[1] = 1f; int timing = 120; if (Main.expertMode) { timing = 80; } if (npc.ai[0] % timing == 0) { Vector2 vel1 = npc.Center - Main.player[npc.target].Center; float velFloat = (float)Math.Sqrt((double)(vel1.X * vel1.X + vel1.Y * vel1.Y)); velFloat = 1 / velFloat; Vector2 newVelocity = new Vector2(vel1.X * velFloat, vel1.Y * velFloat); newVelocity *= 4f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, -newVelocity.X, -newVelocity.Y, 680, 20, 3f); } } else { npc.ai[0] = 0f; } } else if (npc.type == 549 || npc.type == 550) { npc.TargetClosest(false); if (npc.position.X < Main.player[npc.target].position.X) { npc.direction = 1; } if (npc.position.X > Main.player[npc.target].position.X) { npc.direction = -1; } npc.spriteDirection = npc.direction; npc.ai[0]++; if (npc.ai[0] < 480) { npc.ai[1] = 0f; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { npc.velocity.Y = -6f; npc.velocity.X = 1.6f * npc.direction; } if (npc.velocity.X < 1.6f && npc.direction == 1) { npc.velocity.X = npc.velocity.X + 0.1f; if (npc.velocity.X > 1.6f) { npc.velocity.X = 1.6f; } } else if (npc.velocity.X > -1.6f && npc.direction == -1) { npc.velocity.X = npc.velocity.X - 0.1f; if (npc.velocity.X < -1.6f) { npc.velocity.X = -1.6f; } } } else if (npc.ai[0] < 800) { if (npc.type == 549) { npc.defense = 35; if (npc.velocity.X > 0f || npc.velocity.X < 0f) { npc.velocity.X *= 0.96f; } if (npc.ai[0] % 10 == 0 && npc.ai[0] < 541) { npc.ai[1] = 1f; Projectile.NewProjectile(npc.position.X, npc.position.Y, 0f, 0f, 681, 35, 5f, Main.myPlayer, 0f, npc.whoAmI); } if (npc.ai[0] > 580) { npc.ai[1] = 2f; if (npc.velocity.X == 0f && npc.velocity.Y == 0f) { npc.velocity.Y = -12f; npc.velocity.X = 1.6f * npc.direction; } if (npc.velocity.X < 8f && npc.direction == 1) { npc.velocity.X += 0.5f; } else if (npc.velocity.X > -8f && npc.direction == -1) { npc.velocity.X -= 0.5f; } } } else { npc.ai[1] = 3f; if (npc.ai[0] % 40 == 0) { int proj = Utils.SelectRandom<int>(Main.rand, new int[] { 682, 683, 684 }); Vector2 vel1 = npc.Center - Main.player[npc.target].Center; float velFloat = (float)Math.Sqrt((double)(vel1.X * vel1.X + vel1.Y * vel1.Y)); velFloat = 1 / velFloat; Vector2 newVelocity = new Vector2(vel1.X * velFloat, vel1.Y * velFloat); newVelocity *= 8f; Projectile.NewProjectile(npc.position.X, npc.position.Y, -newVelocity.X, -newVelocity.Y, proj, 25, 2f, Main.myPlayer); } } } else { npc.ai[0] = 0f; } } else if (npc.type == 551) { if (npc.ai[0] == 0) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, 0, 685, 0, 0, Main.myPlayer, 0f, npc.whoAmI); npc.ai[0] = 69; } npc.ai[12]++; if (npc.ai[12] < 900) { for (int i = 0; i < Main.npc.Length; i++) { if (Main.npc[i].type == 551 && Main.npc[i] != npc) { Main.npc[i].active = false; } } npc.TargetClosest(false); Player p = Main.player[npc.target]; if (npc.position.X < p.position.X - 20) { npc.direction = 1; } else if (npc.position.X > p.position.X + 20) { npc.direction = -1; } else { npc.direction = 0; } if (npc.direction == -1) { npc.rotation -= MathHelper.ToRadians(0.3f); if (npc.rotation < MathHelper.ToRadians(-15f) && npc.rotation > MathHelper.ToRadians(-345f)) { npc.rotation = MathHelper.ToRadians(-15f); } } else if (npc.direction == 1) { npc.rotation += MathHelper.ToRadians(0.3f); if (npc.rotation > MathHelper.ToRadians(15f) && npc.rotation < MathHelper.ToRadians(345f)) { npc.rotation = MathHelper.ToRadians(15f); } } else if (npc.direction == 0) { if (npc.rotation > 0) { npc.rotation -= MathHelper.ToRadians(0.3f); } if (npc.rotation < 0) { npc.rotation += MathHelper.ToRadians(0.3f); } if (npc.rotation > MathHelper.ToRadians(-1f) && npc.rotation < MathHelper.ToRadians(1f)) { npc.rotation = 0f; } } float num229 = 6f; float num230 = 0.06f; Vector2 vector26 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num231 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector26.X; float num232 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector26.Y; float num233 = (float)Math.Sqrt((double)(num231 * num231 + num232 * num232)); float num234 = num233; num233 = num229 / num233; num231 *= num233; num232 *= num233; if (npc.velocity.X < num231) { npc.velocity.X += num230; if (npc.velocity.X < 0f && num231 > 0f) { npc.velocity.X += num230; } } else if (npc.velocity.X > num231) { npc.velocity.X -= num230; if (npc.velocity.X > 0f && num231 < 0f) { npc.velocity.X -= num230; } } if (npc.velocity.Y < num232) { npc.velocity.Y += num230; if (npc.velocity.Y < 0f && num232 > 0f) { npc.velocity.Y += num230; } } else if (npc.velocity.Y > num232) { npc.velocity.Y -= num230; if (npc.velocity.Y > 0f && num232 < 0f) { npc.velocity.Y -= num230; } } } else { npc.velocity.Y -= 0.05f; } } else if (npc.type == 552) { npc.TargetClosest(false); Player player = Main.player[npc.target]; if (npc.position.X < player.position.X) { npc.direction = 1; } if (npc.position.X > player.position.X) { npc.direction = -1; } npc.spriteDirection = npc.direction; if (npc.Center.X > player.Center.X - 5 && npc.Center.X < player.Center.X + 5) { npc.ai[0] = 1; } if (npc.ai[0] == 0) { npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X); float num229 = 6f; float num230 = 0.09f; Vector2 vector26 = npc.Center; float num231 = player.Center.X - vector26.X; float num232 = player.Center.Y + 200f - vector26.Y; float num233 = (float)Math.Sqrt((double)(num231 * num231 + num232 * num232)); float num234 = num233; num233 = num229 / num233; num231 *= num233; num232 *= num233; if (npc.velocity.X < num231) { npc.velocity.X += num230; if (npc.velocity.X < 0f && num231 > 0f) { npc.velocity.X += num230; } } else if (npc.velocity.X > num231) { npc.velocity.X -= num230; if (npc.velocity.X > 0f && num231 < 0f) { npc.velocity.X -= num230; } } if (npc.velocity.Y < num232) { npc.velocity.Y += num230; if (npc.velocity.Y < 0f && num232 > 0f) { npc.velocity.Y += num230; } } else if (npc.velocity.Y > num232) { npc.velocity.Y -= num230; if (npc.velocity.Y > 0f && num232 < 0f) { npc.velocity.Y -= num230; } } } else if (npc.ai[0] == 1) { npc.ai[1]++; if (npc.ai[1] < 180) { npc.velocity.X *= 0.95f; npc.velocity.Y -= 0.05f; } else if (npc.ai[1] < 360) { if (npc.velocity.Y > 0) { npc.velocity.Y += 0.2f; } else { npc.velocity.Y += 0.05f; } } else { npc.ai[0] = 0; npc.ai[1] = 0; } } } } else if (npc.aiStyle == 107) { npc.ai[0] += (float)Math.PI/120; if (npc.ai[0] > Math.PI) { npc.ai[0] = (float)-Math.PI; } npc.ai[1] = (float)Math.Cos(npc.ai[0]) * 20; npc.ai[2] += MathHelper.ToRadians(0.05f); if (MathHelper.ToDegrees(npc.ai[2]) > 360f) { npc.ai[2] = 0; } } else if (npc.aiStyle == 108) { if (Main.npc[(int)npc.ai[0]].ai[1] == 0 || Main.npc[(int)npc.ai[0]].ai[1] == 2 || Main.npc[(int)npc.ai[0]].ai[1] == 3) { npc.position = Main.npc[(int)npc.ai[0]].position + new Vector2(Main.npc[(int)npc.ai[0]].width / 2 - npc.width / 2, 80); } else { if (Main.npc[(int)npc.ai[0]].ai[1] == 2 || Main.npc[(int)npc.ai[0]].ai[1] == 3) { npc.velocity.Y -= 0.1f; npc.velocity.X *= 0.97f; } float maximumVel = 4f; float acceleration = 0.05f; if (Main.expertMode) { maximumVel = 5f; acceleration = 0.08f; } if (npc.ai[2] >= 300 && npc.ai[2] < 780) { maximumVel /= 2; acceleration /= 2; } #region Velocity if (npc.position.Y > Main.player[npc.target].position.Y - 250f) { npc.velocity.Y -= acceleration; if (npc.velocity.Y < -maximumVel) { npc.velocity.Y = -maximumVel; } } if (npc.position.Y < Main.player[npc.target].position.Y - 250f) { npc.velocity.Y += acceleration; if (npc.velocity.Y > maximumVel) { npc.velocity.Y = maximumVel; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.velocity.X -= acceleration; if (npc.velocity.X > maximumVel) { npc.velocity.X = maximumVel; } } if (npc.Center.X < Main.player[npc.target].Center.X) { npc.velocity.X += acceleration; if (npc.velocity.X < -maximumVel) { npc.velocity.X = -maximumVel; } } #endregion } if (!Main.npc[(int)npc.ai[0]].active) { npc.life = -1; npc.HitEffect(0, 10.0); npc.active = false; } if (Main.npc[(int)npc.ai[0]].ai[1] == 1) { npc.ai[1] = 1f; } npc.ai[2]++; if (npc.ai[2] < 180 && npc.ai[2] >= 0) { if (npc.ai[3] == 0) { if (Main.rand.Next(2)==0) { Projectile.NewProjectile(npc.position.X, npc.position.Y + 32, -5, 0, 797, 59, 1f, npc.target); } else { Projectile.NewProjectile(npc.position.X + npc.width, npc.position.Y + 32, 5, 0, 797, 59, 1f, npc.target); } npc.ai[3] = 1; } if (npc.ai[2] == 90) { npc.ai[3] = 0; } if (Main.expertMode) { if (npc.ai[2] == 45) { npc.ai[3] = 0; } if (npc.ai[2] == 135) { npc.ai[3] = 0; } } } else if (npc.ai[2] < 240) { if (npc.ai[3] == 1) { if (!NPC.AnyNPCs(556)) { NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 556, 0, 0f, 0f, 0f, 0f, npc.target); } npc.ai[3] = 0; } } else if (npc.ai[2] < 300) { if (npc.ai[3] == 0) { if (Main.rand.Next(2) == 0) { Projectile.NewProjectile(npc.position.X, npc.position.Y + 32, -5, 0, 797, 68, 1f, npc.target); } else { Projectile.NewProjectile(npc.position.X + npc.width, npc.position.Y + 32, 5, 0, 797, 68, 1f, npc.target); } npc.ai[3] = 1; } if (npc.ai[2] == 270) { npc.ai[3] = 0; } if (Main.expertMode) { if (npc.ai[2] == 255) { npc.ai[3] = 0; } if (npc.ai[2] == 285) { npc.ai[3] = 0; } } } else if (npc.ai[2] < 780) { npc.ai[3] = 0; if (Main.npc[(int)npc.ai[0]].ai[1] == 0) { Main.npc[(int)npc.ai[0]].ai[5] = 1f; } if (npc.ai[2] % 120 == 0) { float originalRot = Main.rand.Next(0, 314) / 100; int amount = Main.expertMode ? 16 : 8; for (int i = 0; i < amount; i++) { originalRot += (float)(Math.PI / (amount / 2)); Vector2 velocity = originalRot.ToRotationVector2(); float velocityMult = Main.expertMode ? 8f : 5f; velocity *= velocityMult; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, 800, 63, 1f, npc.target); } } } else if (npc.ai[2] < 1020) { Main.npc[(int)npc.ai[0]].ai[5] = 0f; if (npc.ai[3] == 0) { if (Main.rand.Next(2) == 0) { Projectile.NewProjectile(npc.position.X, npc.position.Y + 32, -5, 0, 799, 100, 1f, npc.target); } else { Projectile.NewProjectile(npc.position.X + npc.width, npc.position.Y + 32, 5, 0, 799, 100, 1f, npc.target); } npc.ai[3] = 1; } if (Main.npc[(int)npc.ai[0]].ai[1] == 1 && npc.ai[2] == 1000) { npc.ai[3] = 0; } } else { npc.ai[3] = 0; npc.ai[2] = 0; } } else if (npc.aiStyle == 109) { if (npc.ai[0] == 0f) { npc.TargetClosest(false); npc.ai[0]++; int num = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y - 100, 554); Main.npc[num].ai[0] = npc.whoAmI; Main.npc[num].ai[2] = -180; Main.npc[num].target = npc.target; Main.npc[num].netUpdate = true; } if (Main.player[npc.target].dead || Vector2.Distance(npc.Center, Main.player[npc.target].Center) > 2000f) { npc.TargetClosest(false); if (Main.player[npc.target].dead || Vector2.Distance(npc.Center, Main.player[npc.target].Center) > 2000f) { npc.ai[1] = 2f; } } if (Main.dayTime) { npc.ai[1] = 2f; } if (npc.ai[1] == 2f) { npc.velocity.Y -= 0.1f; npc.velocity.X *= 0.97f; } else { float maximumVel = 7f; float acceleration = 0.10f; if (Main.expertMode) { maximumVel = 8f; acceleration = 0.16f; } if (npc.ai[5] == 1f) { maximumVel /= 2; acceleration /= 2; } float minusY = npc.ai[1] == 0 ? 350 : 200; if (npc.ai[10] == 1) { minusY = 120; acceleration *= 1.2f; maximumVel *= 0.8f; } #region Velocity if (npc.position.Y > Main.player[npc.target].position.Y - minusY) { npc.velocity.Y -= acceleration; if (npc.velocity.Y < -maximumVel) { npc.velocity.Y = -maximumVel; } } else if (npc.position.Y < Main.player[npc.target].position.Y - minusY) { npc.velocity.Y += acceleration; if (npc.velocity.Y > maximumVel) { npc.velocity.Y = maximumVel; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.velocity.X -= acceleration; if (npc.velocity.X > maximumVel) { npc.velocity.X = maximumVel; } } else if (npc.Center.X < Main.player[npc.target].Center.X) { npc.velocity.X += acceleration; if (npc.velocity.X < -maximumVel) { npc.velocity.X = -maximumVel; } } #endregion if (npc.ai[1] == 1f) { npc.ai[6]++; if (npc.ai[6] < 120) { if (npc.ai[6] % 10 == 0) { Vector2 vel = Main.player[npc.target].Center - npc.Center; float mag = (float)Math.Sqrt((double)(vel.X * vel.X + vel.Y * vel.Y)); vel.X += Main.rand.Next(-40, 41); vel.Y += Main.rand.Next(-80, 21); vel *= 7f / mag; vel *= 1f + (float)Main.rand.Next(-25, 26) * 0.01f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vel.X, vel.Y, Main.rand.Next(326, 329), 60, 0f, Main.myPlayer); } } else if (npc.ai[6] < 280) { int amount = Main.expertMode ? 16 : 8; if (npc.ai[8] < amount) { if (npc.ai[6] % 8 == 0) { npc.ai[8]++; NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 557); } } } else if (npc.ai[6] < 460) { npc.ai[8] = 0; npc.ai[10] = 1; if (npc.ai[6] % 10 == 0) { Vector2 vel = Main.player[npc.target].Center - npc.Center; float mag = (float)Math.Sqrt((double)(vel.X * vel.X + vel.Y * vel.Y)); vel.X += Main.rand.Next(-40, 41); vel.Y += Main.rand.Next(-80, 21); vel *= 5f / mag; vel *= 1f + (float)Main.rand.Next(-25, 26) * 0.01f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vel.X, vel.Y, Main.rand.Next(326, 329), 65, 0f, Main.myPlayer); } } else if (npc.ai[6] > 580) { npc.ai[10] = 0; npc.ai[6] = 0; } } } } else if (npc.aiStyle == 110) { npc.TargetClosest(false); if (Main.player[npc.target].dead) { npc.velocity.Y -= 0.04f; npc.velocity.X *= 0.97f; } else { #region Homing if (npc.Center.X < Main.player[npc.target].Center.X + (Main.player[npc.target].direction * 100)) { npc.velocity.X += 0.07f; if (npc.velocity.X > 4f) { npc.velocity.X = 4f; } } if (npc.Center.X > Main.player[npc.target].Center.X + (Main.player[npc.target].direction * 100)) { npc.velocity.X -= 0.07f; if (npc.velocity.X < -4f) { npc.velocity.X = -4f; } } if (npc.Center.Y < Main.player[npc.target].Center.Y + 80) { npc.velocity.Y += 0.07f; if (npc.velocity.Y > 4f) { npc.velocity.Y = 4f; } } if (npc.Center.Y > Main.player[npc.target].Center.Y + 80) { npc.velocity.Y -= 0.07f; if (npc.velocity.Y < -4f) { npc.velocity.Y = -4f; } } #endregion npc.ai[5]++; if (npc.ai[5] > 180) { npc.ai[6] = 1; } if (npc.ai[6] == 1) { if (npc.ai[5] > 240) { npc.ai[5] = 0; npc.ai[6] = 0; } if (npc.ai[5] % 12 == 0) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Main.rand.Next(-2, 3), -2f, Main.rand.Next(326, 329), 45, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, Main.rand.Next(-2, 3), 2f, Main.rand.Next(326, 329), 45, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 2f, Main.rand.Next(-2, 3), Main.rand.Next(326, 329), 45, 0f); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, -2f, Main.rand.Next(-2, 3), Main.rand.Next(326, 329), 45, 0f); } } } } else if (npc.aiStyle == 111) { npc.TargetClosest(true); #region Homing if (npc.Center.X < Main.player[npc.target].Center.X) { npc.direction = -1; npc.velocity.X += 0.11f; if (npc.velocity.X > 5f) { npc.velocity.X = 5f; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.direction = 1; npc.velocity.X -= 0.11f; if (npc.velocity.X < -5f) { npc.velocity.X = -5f; } } if (npc.Center.Y < Main.player[npc.target].Center.Y) { npc.velocity.Y += 0.11f; if (npc.velocity.Y > 5f) { npc.velocity.Y = 5f; } } if (npc.Center.Y > Main.player[npc.target].Center.Y) { npc.velocity.Y -= 0.11f; if (npc.velocity.Y < -5f) { npc.velocity.Y = -5f; } } #endregion npc.spriteDirection = npc.direction; } else if (npc.aiStyle == 112) { npc.TargetClosest(true); float num679 = 10f; Vector2 vector67 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num680 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector67.X; float num681 = Main.player[npc.target].position.Y - vector67.Y; float num682 = (float)Math.Sqrt((double)(num680 * num680 + num681 * num681)); num682 = num679 / num682; num680 *= num682; num681 *= num682; Vector2 vel = new Vector2(num680, num681); vel *= 0.5f; if (vel.Y > 0) { vel.Y *= -2f; } else { vel.Y *= 2f; } if (npc.ai[0] > 0f) { npc.ai[0] -= 1f; } if (Main.netMode != 1 && npc.ai[0] == 0f && Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { Main.PlaySound(2, (int)npc.position.X, (int)npc.position.Y, 5); npc.ai[0] = Main.rand.Next(90, 181); int num683 = 55; int num684 = 801; int num685 = Projectile.NewProjectile(vector67.X, vector67.Y, vel.X, vel.Y, num684, num683, 0f, Main.myPlayer, 0f, 0f); Main.projectile[num685].ai[1] = Main.rand.Next(5); Main.projectile[num685].friendly = false; NetMessage.SendData(27, -1, -1, "", num685, 0f, 0f, 0f, 0, 0, 0); npc.netUpdate = true; } try { int num686 = (int)npc.position.X / 16; int num687 = (int)(npc.position.X + (float)(npc.width / 2)) / 16; int num688 = (int)(npc.position.X + (float)npc.width) / 16; int num689 = (int)(npc.position.Y + (float)npc.height) / 16; bool flag75 = false; if (Main.tile[num686, num689] == null) { Main.tile[num686, num689] = new Tile(); } if (Main.tile[num687, num689] == null) { Main.tile[num686, num689] = new Tile(); } if (Main.tile[num688, num689] == null) { Main.tile[num686, num689] = new Tile(); } if ((Main.tile[num686, num689].nactive() && Main.tileSolid[(int)Main.tile[num686, num689].type]) || (Main.tile[num687, num689].nactive() && Main.tileSolid[(int)Main.tile[num687, num689].type]) || (Main.tile[num688, num689].nactive() && Main.tileSolid[(int)Main.tile[num688, num689].type])) { flag75 = true; } if (flag75) { npc.noGravity = true; npc.noTileCollide = true; npc.velocity.Y = -0.2f; } else { npc.noGravity = false; npc.noTileCollide = false; if (Main.rand.Next(2) == 0) { int num690 = Dust.NewDust(new Vector2(npc.position.X - 4f, npc.position.Y + (float)npc.height - 8f), npc.width + 8, 24, 22, 0f, npc.velocity.Y / 2f, 0, default(Color), 1f); Dust expr_289FD_cp_0 = Main.dust[num690]; expr_289FD_cp_0.velocity.X = expr_289FD_cp_0.velocity.X * 0.4f; Dust expr_28A1D_cp_0 = Main.dust[num690]; expr_28A1D_cp_0.velocity.Y = expr_28A1D_cp_0.velocity.Y * -1f; if (Main.rand.Next(2) == 0) { Main.dust[num690].noGravity = true; Main.dust[num690].scale += 0.2f; } } } return; } catch { return; } } else if (npc.aiStyle == 113) { npc.TargetClosest(true); npc.ai[2]++; npc.ai[3] = 0; if (npc.ai[4] == 0) { for (int i = 0; i < 1000; i++) { if (Main.projectile[i].active && Main.projectile[i].type == 801 && Main.projectile[i].ai[2] == npc.whoAmI && Vector2.Distance(Main.projectile[i].Center, npc.Center) < 126f) { npc.ai[3]++; } } } if (npc.ai[3] == 0) { npc.ai[4] = 1; } if (npc.ai[2] > 60f) { npc.ai[2] = 0; if (npc.ai[4] == 1) { int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, 801, 60, 1f); Main.projectile[proj].ai[0] = 1f; Main.projectile[proj].ai[1] = Main.rand.Next(0, 5); Main.projectile[proj].ai[2] = npc.whoAmI; Main.projectile[proj].ai[4] = npc.target; Main.projectile[proj].tileCollide = false; npc.ai[5]++; if (npc.ai[5] == 5) { npc.ai[5] = 0f; npc.ai[4] = 0f; } } } if (npc.ai[14] == 1f) { npc.ai[16]--; if (npc.ai[16] < 0) { npc.ai[14] = 0; } } if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { int distanceFromGround = -1; int current = (int)(npc.position.Y / 16); for (int y = current; y < current + 5; y++) { if (Main.tile[(int)(npc.position.X / 16), y] == null) { Main.tile[(int)(npc.position.X / 16), y] = new Tile(); } if (Main.tile[(int)(npc.position.X / 16), y].active()) { distanceFromGround = y - current; break; } } bool flag2 = false; if (distanceFromGround > 5 || distanceFromGround == -1) { npc.velocity.Y += 0.06f; flag2 = true; } if (npc.ai[2] == 59) { if (npc.ai[4] == 0) { npc.ai[15]++; if (npc.ai[15] > 1f) { npc.ai[14] = 1f; npc.ai[16] = 5f; npc.ai[15] = 0f; } } } float accel = 0.05f; float maxVel = 5f; if (npc.ai[4] == 0) { if (Main.player[npc.target].inventory[Main.player[npc.target].selectedItem].damage < (int)(npc.life / 2.5f)) { if (npc.Center.X < Main.player[npc.target].Center.X) { npc.velocity.X += accel; if (npc.velocity.X > maxVel) { npc.velocity.X = maxVel; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.velocity.X -= accel; if (npc.velocity.X < -maxVel) { npc.velocity.X = -maxVel; } } if (!flag2) { if (npc.Center.Y < Main.player[npc.target].Center.Y) { npc.velocity.Y += accel; if (npc.velocity.Y > maxVel) { npc.velocity.Y = maxVel; } } if (npc.Center.Y > Main.player[npc.target].Center.Y) { npc.velocity.Y -= accel; if (npc.velocity.Y < -maxVel) { npc.velocity.Y = -maxVel; } } } } } else if (npc.ai[4] == 1) { accel = 0.03f; maxVel = 4f; if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 600f) { if (Main.player[npc.target].inventory[Main.player[npc.target].selectedItem].damage > (int)(npc.life / 3.5f)) { if (npc.Center.X < Main.player[npc.target].Center.X) { npc.velocity.X -= accel; if (npc.velocity.X < -maxVel) { npc.velocity.X = -maxVel; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.velocity.X += accel; if (npc.velocity.X > maxVel) { npc.velocity.X = maxVel; } } if (!flag2) { if (npc.Center.Y < Main.player[npc.target].Center.Y) { npc.velocity.Y -= accel; if (npc.velocity.Y < -maxVel) { npc.velocity.Y = -maxVel; } } if (npc.Center.Y > Main.player[npc.target].Center.Y) { npc.velocity.Y += accel; if (npc.velocity.Y > maxVel) { npc.velocity.Y = maxVel; } } } } } bool flag = true; for (int i = 0; i < 1000; i++) { if (Main.projectile[i].friendly && !Main.projectile[i].hostile && Main.projectile[i].active) { if (Vector2.Distance(Main.projectile[i].Center, npc.Center) < 250) { accel = 0.15f; maxVel = 4f; if (npc.Center.X < Main.projectile[i].Center.X) { npc.velocity.X -= accel; if (npc.velocity.X < -maxVel) { npc.velocity.X = -maxVel; } } if (npc.Center.X > Main.projectile[i].Center.X) { npc.velocity.X += accel; if (npc.velocity.X > maxVel) { npc.velocity.X = maxVel; } } if (!flag2) { if (npc.Center.Y < Main.projectile[i].Center.Y) { npc.velocity.Y -= accel; if (npc.velocity.Y < -maxVel) { npc.velocity.Y = -maxVel; } } if (npc.Center.Y > Main.projectile[i].Center.Y) { npc.velocity.Y += accel; if (npc.velocity.Y > maxVel) { npc.velocity.Y = maxVel; } } } flag = false; break; } } } if (flag) { npc.velocity *= 0.96f; } } } else { npc.ai[6]++; if (npc.ai[6] > 120f) { npc.ai[6] = 0; npc.ai[7]++; if (npc.ai[7] == 2) { npc.ai[7] = 0; } } if (npc.ai[7] == 0) { npc.velocity.Y -= 0.005f; if (npc.velocity.Y < -3f) { npc.velocity.Y = -3f; } npc.velocity.Y -= 0.02f; if (npc.velocity.Y < -5f) { npc.velocity.Y = -5f; } } else if (npc.ai[7] == 1) { npc.velocity.Y += 0.005f; if (npc.velocity.Y > 3f) { npc.velocity.Y = 3f; } npc.velocity.X += 0.02f; if (npc.velocity.X > 5f) { npc.velocity.X = 5f; } } } } else if (npc.aiStyle == 114) { if (npc.ai[0] == 0f) { try { npc.ai[0]++; int xPos = (int)(npc.position.X / 16); int yPos = (int)(npc.position.Y / 16); int size = 18; for (int x = xPos - size; x < xPos + size + 1; x++) { for (int y = yPos - size; y < yPos + size + 1; y++) { if (WorldGen.InWorld(x, y - 1) && WorldGen.InWorld(x, y + 1)) { if (Main.tile[x, y] == null) { Main.tile[x, y] = new Tile(); } if (Main.tile[x, y + 1] == null) { Main.tile[x, y + 1] = new Tile(); } if (Main.tile[x, y - 1] == null) { Main.tile[x, y - 1] = new Tile(); } if (Main.tile[x, y].type == 5 && Main.tile[x, y - 1].type == 5 && Main.tile[x, y + 1].type == 5) { npc.ai[1] = x; npc.ai[2] = y; goto FoundTree; } } } } npc.active = false; return; FoundTree: npc.position.X = npc.ai[1] * 16f; npc.position.Y = npc.ai[2] * 16f; } catch { npc.active = false; } } if (Main.tile[(int)npc.ai[1], (int)npc.ai[2]] == null) { Main.tile[(int)npc.ai[1], (int)npc.ai[2]] = new Tile(); } if (Main.tile[(int)npc.ai[1], (int)npc.ai[2] + 1] == null) { Main.tile[(int)npc.ai[1], (int)npc.ai[2] + 1] = new Tile(); } if (Main.tile[(int)npc.ai[1], (int)npc.ai[2] - 1] == null) { Main.tile[(int)npc.ai[1], (int)npc.ai[2] - 1] = new Tile(); } if (Main.tile[(int)npc.ai[1], (int)npc.ai[2]].type != 5) { npc.ai[3] = 10f; } if (npc.ai[3] == 10f) { npc.Transform(568); npc.lifeMax = npc.life = 9999; npc.velocity.Y = 0.06f; } else { npc.TargetClosest(false); if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { if (Main.player[npc.target].Center.X <= (npc.ai[1] * 16f) + 8f) { npc.direction = -1; } else { npc.direction = 1; } } else { if (Main.rand.Next(740) == 0) { npc.direction = -npc.direction; } } if (npc.direction == -1) { npc.position.X = (npc.ai[1] * 16f) - 32; } else { npc.position.X = npc.ai[1] * 16f; } npc.spriteDirection = -npc.direction; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { npc.ai[4]++; if (npc.ai[4] < 180) { npc.ai[10] = 0; } if (npc.ai[4] == 180f) { Vector2 velocity = Main.player[npc.target].Center - npc.Center; float magnitude = (float)Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y); float speed = 5f; velocity.Y -= 2f; if (magnitude > speed) { magnitude = speed / magnitude; } velocity *= magnitude; int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, 752, 65, 1f); Main.projectile[proj].ai[8] = 1f; Main.projectile[proj].friendly = false; Main.projectile[proj].hostile = true; Main.projectile[proj].timeLeft = 120; npc.ai[10] = 2; } if (npc.ai[4] == 185f) { npc.ai[10] = 3; } if (npc.ai[4] == 190f) { npc.ai[10] = 4; } if (npc.ai[4] == 195f) { npc.ai[10] = 0f; npc.ai[4] = 0f; } } else { ///blinking if (npc.ai[11] > 0f) { npc.ai[11] -= 0.3333334f; if (npc.ai[11] < 0) { npc.ai[10] = 0f; } } if (Main.rand.Next(120) == 0) { npc.ai[10] = 1f; npc.ai[11] = 1f; } } } } else if (npc.aiStyle == 115) { npc.TargetClosest(false); if (Main.player[npc.target].Center.X <= npc.Center.X) { npc.direction = -1; npc.velocity.X -= 0.01f; if (npc.velocity.X < -2f) { npc.velocity.X = -2f; } } else { npc.direction = 1; npc.velocity.X += 0.01f; if (npc.velocity.X > 2f) { npc.velocity.X = 2f; } } npc.spriteDirection = npc.direction; for (int y = (int)(npc.position.Y / 16f); y < (int)(npc.position.Y / 16f) + 5; y++) { if (Main.tile[(int)(npc.position.X / 16f), y] == null) { Main.tile[(int)(npc.position.X / 16f), y] = new Tile(); } if (Main.tile[(int)(npc.position.X / 16f) + 1, y] == null) { Main.tile[(int)(npc.position.X / 16f), y] = new Tile(); } if (Main.tile[(int)(npc.position.X / 16f) - 1, y] == null) { Main.tile[(int)(npc.position.X / 16f), y] = new Tile(); } if (Main.tile[(int)(npc.position.X / 16f), y].active() || Main.tile[(int)(npc.position.X / 16f) + 1, y].active() || Main.tile[(int)(npc.position.X / 16f) - 1, y].active()) { npc.ai[26] = 1f; } } if (npc.ai[26] == 1) { npc.HitEffect(0, 10.0); npc.ai[27]++; } } else if (npc.aiStyle == 116) { npc.TargetClosest(false); if (Main.player[npc.target].Center.X < npc.Center.X) { npc.direction = npc.spriteDirection = -1; } else { npc.direction = npc.spriteDirection = 1; } npc.frameCounter++; if (npc.frameCounter <= 7) { npc.AnimationFrame = 0; } else if (npc.frameCounter <= 14) { npc.AnimationFrame = 1; } else if (npc.frameCounter <= 21) { npc.AnimationFrame = 2; } else if (npc.frameCounter <= 28) { npc.AnimationFrame = 3; } else { npc.frameCounter = 0; npc.AnimationFrame = 0; } if (npc.type == 571) { if (npc.ai[0] == 0) { npc.ai[0]++; npc.ai[1] = (int)NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, 572); npc.Partner.ai[1] = npc.whoAmI; } if (npc.Partner.life <= 0 || !npc.Partner.active || npc.Partner.type != 572) { npc.Transform(573); } int distanceFromGround = -1; int current = (int)(npc.position.Y / 16); for (int y = current; y < current + 8; y++) { if (Main.tile[(int)(npc.position.X / 16), y] == null) { Main.tile[(int)(npc.position.X / 16), y] = new Tile(); } if (Main.tile[(int)(npc.position.X / 16), y].active()) { distanceFromGround = y - current; break; } } bool flag = false; if (distanceFromGround > 8 || distanceFromGround == -1) { flag = true; } float acceleration = 0.04f; float maximumVelocity = 5f; npc.ai[15] = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) ? 1f : 0f; if (npc.Center.X < Main.player[npc.target].Center.X) { npc.velocity.X += acceleration; if (npc.velocity.X > maximumVelocity) { npc.velocity.X = maximumVelocity; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.velocity.X -= acceleration; if (npc.velocity.X < -maximumVelocity) { npc.velocity.X = -maximumVelocity; } } if (!flag) { npc.velocity.Y -= acceleration; } else { npc.velocity.Y += acceleration; } } else if (npc.type == 573) { npc.noTileCollide = true; float acceleration = 0.17f; float maximumVelocity = 9f; if (npc.Center.X < Main.player[npc.target].Center.X) { npc.velocity.X += acceleration; if (npc.velocity.X > maximumVelocity) { npc.velocity.X = maximumVelocity; } } if (npc.Center.X > Main.player[npc.target].Center.X) { npc.velocity.X -= acceleration; if (npc.velocity.X < -maximumVelocity) { npc.velocity.X = -maximumVelocity; } } if (npc.Center.Y < Main.player[npc.target].Center.Y) { npc.velocity.X += acceleration; if (npc.velocity.X > maximumVelocity) { npc.velocity.X = maximumVelocity; } } if (npc.Center.Y > Main.player[npc.target].Center.Y) { npc.velocity.Y -= acceleration; if (npc.velocity.Y < -maximumVelocity) { npc.velocity.Y = -maximumVelocity; } } } } else if (npc.aiStyle == 117) { npc.TargetClosest(false); if (!npc.Partner.active || npc.Partner.life <= 0 || npc.Partner.type != 571) { npc.life = -1; npc.HitEffect(0, 10); npc.active = false; return; } int yOff = npc.Partner.AnimationFrame > 1 ? 2 : 0; if (npc.Partner.direction == -1) { npc.direction = -1; npc.position = npc.Partner.position + new Vector2(14, -20 - yOff); } else if (npc.Partner.direction == 1) { npc.direction = 1; npc.position = npc.Partner.position - new Vector2(-6, 20 + yOff); } npc.spriteDirection = npc.Partner.direction; if (npc.Partner.ai[15] == 1) { npc.ai[2]++; if (npc.ai[2] == 135) { npc.AnimationFrame = 1; } if (npc.ai[2] == 140) { npc.AnimationFrame = 2; } if (npc.ai[2] == 145) { npc.AnimationFrame = 3; } if (npc.ai[2] == 150) { npc.ai[2] = 0; npc.AnimationFrame = 0; Vector2 velocity = Main.player[npc.target].Center - npc.Center; float magnitude = (float)Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y); float speed = 8f; if (magnitude > speed) { magnitude = speed / magnitude; } velocity *= magnitude; velocity *= 1.4f; int amount = Main.expertMode ? 10 : 5; for (int t = 0; t < amount; t++) { velocity *= 0.93f; Vector2 vel = velocity; vel.X += Main.rand.Next(-40, 41) * 0.04f; vel.Y += Main.rand.Next(-40, 41) * 0.04f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vel.X, vel.Y, 803, 45, 1f); } } } } else if (npc.aiStyle == 118) { npc.frameCounter++; if (npc.frameCounter < 5) { npc.AnimationFrame = 0; } else if (npc.frameCounter < 10) { npc.AnimationFrame = 1; } else if (npc.frameCounter < 15) { npc.AnimationFrame = 2; } else { npc.frameCounter = 0; npc.AnimationFrame = 0; } npc.TargetClosest(false); Vector2 vel = Main.player[npc.target].Center - npc.Center; float mag = (float)Math.Sqrt(vel.X * vel.X + vel.Y * vel.Y); float speed = 2f; if (mag > speed) { mag = speed / mag; } vel *= mag; npc.velocity = vel; npc.ai[6]++; npc.rotation = npc.velocity.X * 0.1f; if (npc.ai[6] < 600) { npc.ai[8]++; if (npc.justHit) { npc.ai[8] = 0; } if (npc.ai[8] > 60 + Main.rand.Next(60) && !npc.confused) { if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].head)) { npc.ai[8] = 0; float num714 = 10f; Vector2 vector70 = new Vector2(npc.position.X + (float)npc.width * 0.5f - 4f, npc.position.Y + (float)npc.height * 0.7f); float num715 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector70.X; float num716 = Math.Abs(num715) * 0.1f; float num717 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector70.Y - num716; num715 += (float)Main.rand.Next(-10, 11); num717 += (float)Main.rand.Next(-30, 21); float num718 = (float)Math.Sqrt((double)(num715 * num715 + num717 * num717)); num718 = num714 / num718; num715 *= num718; num717 *= num718; int num719 = 45; int num720 = 804; Projectile.NewProjectile(vector70.X, vector70.Y, num715, num717, num720, num719, 0f, Main.myPlayer, 0f, 0f); } } } else if (npc.ai[6] < 1200) { npc.ai[8] = 0; if (npc.Hitbox.Intersects(Main.player[npc.target].Hitbox)) { Main.player[npc.target].AddBuff(205, 8); } } else { npc.ai[6] = 0; } } else if (npc.aiStyle == 119) { npc.TargetClosest(false); npc.frameCounter++; if (npc.frameCounter < 5) { npc.AnimationFrame = 0; } else if (npc.frameCounter < 10) { npc.AnimationFrame = 1; } else if (npc.frameCounter < 15) { npc.AnimationFrame = 2; } else if (npc.frameCounter < 20) { npc.AnimationFrame = 3; } else { npc.frameCounter = 0; npc.AnimationFrame = 0; } if (npc.ai[0] == 0f) { npc.ai[0] = 1; for (int i = 6; i < 9; i++) { npc.ai[i] = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, 805, 50, 0f, Main.myPlayer, npc.whoAmI, (float)((8-i) * (((Math.PI * 2) / 360) * 120))); Main.projectile[(int)npc.ai[i]].ai[2] = 1; } } npc.ai[5]++; if (npc.ai[5] == 90) { //shoot banana Vector2 velocity = Main.player[npc.target].Center - npc.Center; float mag = (float)Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y); float speed = 3.5f; if (mag > speed) { mag = speed / mag; } velocity *= mag; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, velocity.X, velocity.Y, 805, 50, 0f); } if (npc.ai[5] < 120) { npc.alpha -= 18; if (npc.alpha < 0) { npc.alpha = 0; } for (int k = 6; k < 9; k++) { Main.projectile[(int)npc.ai[k]].alpha -= 18; if (Main.projectile[(int)npc.ai[k]].alpha < 0) { Main.projectile[(int)npc.ai[k]].alpha = 0; } } } if (npc.ai[5] > 120) { npc.alpha += 5; for (int k = 6; k < 9; k++) { Main.projectile[(int)npc.ai[k]].alpha += 5; if (Main.projectile[(int)npc.ai[k]].alpha > 255) { Main.projectile[(int)npc.ai[k]].alpha = 255; } } if (npc.alpha >= 255) { npc.ai[5] = 0; for (int j = 6; j < 9; j++) { Main.projectile[(int)npc.ai[j]].alpha = 0; } int num214 = (int)Main.player[npc.target].position.X / 16; int num215 = (int)Main.player[npc.target].position.Y / 16; int num216 = (int)npc.position.X / 16; int num217 = (int)npc.position.Y / 16; int num218 = 20; int num219 = 0; bool flag28 = 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) { num219 = 100; flag28 = true; } while (!flag28) { if (num219 >= 100) { return; } num219++; int num220 = Main.rand.Next(num214 - num218, num214 + num218); int num221 = Main.rand.Next(num215 - num218, num215 + num218); for (int num222 = num221; num222 < num215 + num218; num222++) { if ((num222 < num215 - 4 || num222 > num215 + 4 || num220 < num214 - 4 || num220 > num214 + 4) && (num222 < num217 - 1 || num222 > num217 + 1 || num220 < num216 - 1 || num220 > num216 + 1) && Main.tile[num220, num222].nactive()) { bool flag29 = true; if (Main.tile[num220, num222 - 1].lava()) { flag29 = false; } if (flag29 && Main.tileSolid[(int)Main.tile[num220, num222].type] && !Collision.SolidTiles(num220 - 1, num220 + 1, num222 - 4, num222 - 1)) { npc.position.X = (float)(num220 * 16 - npc.width / 2); npc.position.Y = (float)(num222 * 16 - npc.height); npc.netUpdate = true; } } } } } } } else if (npc.aiStyle == 120) { npc.TargetClosest(false); npc.frameCounter++; if (npc.frameCounter < 5) { npc.AnimationFrame = 0; } else if (npc.frameCounter < 10) { npc.AnimationFrame = 1; } else if (npc.frameCounter < 15) { npc.AnimationFrame = 2; } else if (npc.frameCounter < 20) { npc.AnimationFrame = 3; } else { npc.frameCounter = 0; npc.AnimationFrame = 0; } if (Main.player[npc.target].Center.X < npc.Center.X) { npc.direction = npc.spriteDirection = 1; } else { npc.direction = npc.spriteDirection = -1; } if (npc.ai[16] <= 0) { npc.ai[15]++; } bool canSee = false; int timeBetween = 120; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { canSee = true; } if (npc.life < npc.lifeMax / 2) { timeBetween = 60; } if (npc.ai[15] < timeBetween) { if (Vector2.Distance(npc.Center, Main.player[npc.target].Center) < 300) { MoveAway(ref npc, 0.01f, 2f); } else { MoveTowards(ref npc, 0.02f, 2.4f); } } else { npc.ai[16] = Main.rand.Next(1, 5); npc.ai[15] = 0f; } if (npc.ai[16] > 0) { switch((int)npc.ai[16]) { case 1: npc.ai[17]++; if (npc.ai[17] == 30) { int amount = Main.rand.Next(6, 10); float velocity = 8f; if (Main.expertMode) { velocity = 14f; } for (int i = 0; i < amount; i++) { float angle = Main.rand.Next(0, 361); Vector2 vel = new Vector2((float)Math.Cos(angle) * velocity, (float)Math.Sin(angle) * velocity); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vel.X, vel.Y, 31, 16, 0f); } } if (npc.ai[17] > 45) { npc.ai[17] = 0; npc.ai[16] = 0; } break; case 2: if (npc.ai[18] == 0) { npc.ai[17]++; float iteration = Main.rand.Next(250, 501) / 100; iteration -= npc.ai[17] / 30; for (float x = npc.position.X; x < npc.position.X + npc.width; x += iteration) { for (float y = npc.position.Y; y < npc.position.Y + npc.height; y += iteration) { if (Main.rand.Next(4) == 0) { int du = Dust.NewDust(new Vector2(x, y), 0, 0, 32, 0f, 0f); Main.dust[du].velocity = Vector2.Zero; Main.dust[du].noGravity = true; } } } if (npc.ai[17] > 25) { npc.alpha += 10; if (npc.alpha >= 255) { float xOffset = Main.rand.Next(2) == 0 ? Main.rand.Next(-500, -399) : Main.rand.Next(400, 501); npc.Center = Main.player[npc.target].Center + new Vector2(xOffset, 0f); npc.alpha = 0; npc.ai[18] = 1; } } } else { if (npc.ai[18] == 1) { if (npc.Center.X < Main.player[npc.target].Center.X) { npc.ai[19] = -1; } } npc.ai[18]++; if (npc.ai[18] < 60) { if (npc.ai[19] == -1) { if (npc.Center.X >= Main.player[npc.target].Center.X) { npc.velocity.X *= 0.97f; } else { npc.velocity.X = 0.16f; } } else { if (npc.Center.X <= Main.player[npc.target].Center.X) { npc.velocity.X *= 0.97f; } else { npc.velocity.X = -0.16f; } } } else { npc.ai[16] = 0; npc.ai[17] = 0; npc.ai[18] = 0; npc.ai[19] = 0; } } break; case 3: npc.ai[17]++; if (npc.ai[17] == 30) { Vector2 vel = Main.player[npc.target].Center - npc.Center; float m = (float)Math.Sqrt(vel.X * vel.X + vel.Y * vel.Y); float sp = 6f; if (m > sp) { m = sp / m; } vel *= m; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, vel.X, vel.Y, 807, 20, 1f); } if (npc.ai[17] > 60) { npc.ai[16] = 0; npc.ai[17] = 0; } break; } } } }