public override void AI() { if (npc.life < npc.lifeMax / 4) { if (!rage) { rage = true; Main.NewText("VOID's form begins to destabilize", Color.LightCyan); } music = mod.GetSoundSlot(SoundType.Music, "Sounds/Music/Pinch"); } Lighting.AddLight(npc.Center, 0, .1f, .3f); isCharging = false; Player player = Main.player[npc.target]; Vector2 targetPos; npc.TargetClosest(); SuckPlayer(); switch ((int)npc.ai[0]) { case 0: //fly to corner for dash if (!AliveCheck(player)) { break; } targetPos = player.Center; targetPos.X += 430 * (npc.Center.X < targetPos.X ? -1 : 1); targetPos.Y -= 430; Movement(targetPos, .7f); if (++npc.ai[1] > 180 || Math.Abs(npc.Center.Y - targetPos.Y) < 100) //initiate dash { npc.ai[0]++; npc.ai[1] = 0; npc.netUpdate = true; npc.velocity = npc.DirectionTo(player.Center) * 45; } break; case 1: //dashing isCharging = true; if (npc.Center.Y > player.Center.Y + 500 || Math.Abs(npc.Center.X - player.Center.X) > 1000) { npc.velocity.Y *= 0.5f; npc.ai[1] = 0; if (++npc.ai[2] >= Repeats() - 1) //repeat three times { npc.ai[0]++; npc.ai[2] = 0; } else { npc.ai[0]--; } npc.netUpdate = true; } break; case 2: npc.velocity *= 0; if (npc.ai[1] < 90) { if (npc.ai[3] < Repeats() - 1) { if (Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[2]++; } int teleportRate = npc.life < npc.lifeMax / 4 ? 15 : 30; if (npc.ai[2] >= teleportRate) // + lasers { Teleport(); Starblast(); npc.ai[3] += 1; npc.ai[2] = 0; npc.netUpdate = true; } break; } else { npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = 0; } } break; case 3: //prepare for queen bee dashes if (!AliveCheck(player)) { break; } if (++npc.ai[1] > 60) { targetPos = player.Center; targetPos.X += 400 * (npc.Center.X < targetPos.X ? -1 : 1); Movement(targetPos, 1f); if (npc.ai[1] > 180 || Math.Abs(npc.Center.Y - targetPos.Y) < 40) //initiate dash { npc.ai[0]++; npc.ai[1] = 0; npc.netUpdate = true; npc.velocity.X = -40 * (npc.Center.X < player.Center.X ? -1 : 1); npc.velocity.Y *= 0.1f; } } else { npc.velocity *= 0.9f; //decelerate briefly } break; case 4: isCharging = true; if (++npc.ai[1] > 240 || (Math.Sign(npc.velocity.X) > 0 ? npc.Center.X > player.Center.X + 900 : npc.Center.X < player.Center.X - 900)) { npc.ai[1] = 0; npc.ai[2] = 0; if (++npc.ai[3] >= 3) //repeat dash three times { Teleport(); npc.ai[0]++; npc.ai[3] = 0; } else { npc.ai[0]--; } npc.netUpdate = true; } if (npc.ai[1] % 20 == 0) { int a = Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <VoidVortex>(), npc.damage / 2, 3); Main.projectile[a].Center = npc.Center; } if (npc.ai[1] % 30 == 0) { if (npc.life < npc.lifeMax / 3) { Starblast(); } } break; case 5: //Prep Deathray if (!AliveCheck(Main.player[npc.target])) { break; } npc.velocity *= 0; if (!CUtils.AnyProjectiles(ModContent.ProjectileType <VoidraySmall>())) { float dir = Pi2 / 8; if (Main.rand.NextBool() || npc.life < npc.lifeMax / 2) { dir = 0; } int loops = (npc.life < npc.lifeMax / 2 ? 8 : 4); for (int l = 0; l < loops; l++) { float LaserPos = Pi2 / loops; float laserDir = LaserPos * l + dir; Projectile.NewProjectile(npc.Center, (npc.rotation + laserDir).ToRotationVector2(), ModContent.ProjectileType <VoidraySmall>(), npc.damage / 4, 0f, Main.myPlayer, laserDir, npc.whoAmI); } } if (++npc.ai[2] > 60) { npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; if (Main.netMode != NetmodeID.MultiplayerClient) { npc.TargetClosest(false); } if (npc.life < npc.lifeMax / 2 && Main.netMode != NetmodeID.MultiplayerClient) { int choice = Main.rand.Next(2); if (choice == 0) { Main.PlaySound(SoundID.Item73, (int)npc.position.X, (int)npc.position.Y); int a = Projectile.NewProjectile(npc.Center, new Vector2(0f, -12f), mod.ProjectileType("VoidShot"), npc.damage / 2, 3); Main.projectile[a].Center = npc.Center; int b = Projectile.NewProjectile(npc.Center, new Vector2(0f, 12f), mod.ProjectileType("VoidShot"), npc.damage / 2, 3); Main.projectile[b].Center = npc.Center; int c = Projectile.NewProjectile(npc.Center, new Vector2(-12f, 0f), mod.ProjectileType("VoidShot"), npc.damage / 2, 3); Main.projectile[c].Center = npc.Center; int d = Projectile.NewProjectile(npc.Center, new Vector2(12f, 0f), mod.ProjectileType("VoidShot"), npc.damage / 2, 3); Main.projectile[d].Center = npc.Center; } else { int a = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <Enemies.AbyssGazer>()); Main.npc[a].Center = npc.Center + new Vector2(0, 60); int b = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <Enemies.AbyssGazer>()); Main.npc[b].Center = npc.Center + new Vector2(0, -60); int c = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <Enemies.AbyssGazer>()); Main.npc[c].Center = npc.Center + new Vector2(-60, 0); int d = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType <Enemies.AbyssGazer>()); Main.npc[d].Center = npc.Center + new Vector2(-60, 0); } npc.netUpdate = true; } } break; case 6: //firing mega ray npc.velocity *= 0; if (++npc.ai[1] > 180) { npc.velocity *= .98f; npc.ai[0]++; npc.ai[1] = 0; npc.ai[3] = 0; npc.netUpdate = true; } break; case 7: //prepare for fishron dash if (!AliveCheck(player)) { break; } targetPos = player.Center + player.DirectionTo(npc.Center) * 600; Movement(targetPos, 0.6f); if (++npc.ai[1] > 20) { npc.ai[0]++; npc.ai[1] = 0; npc.netUpdate = true; npc.velocity = npc.DirectionTo(player.Center) * 40; } break; case 8: //dashing isCharging = true; if (++npc.ai[1] > 40) { npc.ai[1] = 0; npc.ai[2] = 0; if (++npc.ai[3] >= Repeats()) { npc.ai[0]++; npc.ai[3] = 0; } else { npc.ai[0]--; } npc.netUpdate = true; } break; case 9: //hover nearby, shoot lightning if (!AliveCheck(player)) { break; } npc.velocity *= 0; if (++npc.ai[2] > 60) { Teleport(); npc.ai[2] = 0; if (Main.netMode != NetmodeID.MultiplayerClient) //spawn lightning { if (npc.life < npc.lifeMax / 2) { float dir = Pi2 / 8; if (Main.rand.NextBool()) { dir = 0; } for (int l = 0; l < 4; l++) { float LaserPos = Pi2 / 4; float laserDir = LaserPos * l + dir; Vector2 velocity = (npc.rotation + laserDir).ToRotationVector2(); Projectile.NewProjectile(npc.Center, velocity, ModContent.ProjectileType <VoidShock>(), npc.damage / 4, 0f, Main.myPlayer, velocity.ToRotation(), 0f); } } else { float dir = (float)Math.PI; if (Main.rand.NextBool()) { dir = 0; } for (int l = 0; l < 2; l++) { float LaserPos = Pi2 / 2; float laserDir = LaserPos * l + dir; Vector2 velocity = (npc.rotation + laserDir).ToRotationVector2(); Projectile.NewProjectile(npc.Center, velocity, ModContent.ProjectileType <VoidShock>(), npc.damage / 4, 0f, Main.myPlayer, velocity.ToRotation(), 0f); } } } } if (++npc.ai[1] > 360) { npc.ai[0]++; npc.ai[1] = 0; npc.ai[2] = 0; npc.ai[3] = npc.Distance(player.Center); npc.netUpdate = true; } break; case 30: if (npc.ai[1]++ > 80) { npc.ai[0] = 0; npc.dontTakeDamage = false; npc.ai[1] = 0; } break; default: npc.ai[0] = 0; goto case 0; } for (int m = npc.oldPos.Length - 1; m > 0; m--) { npc.oldPos[m] = npc.oldPos[m - 1]; } npc.oldPos[0] = npc.position; npc.rotation = 0; if (npc.dontTakeDamage) { npc.ai[0] = 30; } }
public override void AI() { if (!title) { CSkies.ShowTitle(npc, 1); title = true; } npc.TargetClosest(); if (!Main.dayTime) { if (npc.alpha <= 0) { npc.alpha = 0; } else { Dust.NewDust(npc.position, npc.width, npc.height, 17, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, DustID.Electric, Color.White, 1f); npc.alpha -= 3; } } else { if (npc.alpha >= 255) { npc.active = false; } else { Dust.NewDust(npc.position, npc.width, npc.height, 17, npc.velocity.X * 0.2f, npc.velocity.Y * 0.2f, DustID.Electric, Color.White, 1f); npc.alpha += 3; } } if (internalAI[3] == 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { for (int m = 0; m < StarCount; m++) { int projectileID = Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Star"), npc.damage, 4, Main.myPlayer); Main.projectile[projectileID].Center = npc.Center; Main.projectile[projectileID].velocity = new Vector2(MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble())); Main.projectile[projectileID].velocity *= 8f; Main.projectile[projectileID].ai[0] = m; } internalAI[3] = 1; npc.netUpdate = true; } } if (internalAI[1] < 120) { internalAI[1] += 2; } else { internalAI[1] = 120; npc.netUpdate = true; } BaseAI.AISpaceOctopus(npc, ref npc.ai, .2f, 6, 270, 70, null); if (Main.netMode != NetmodeID.MultiplayerClient) { if (internalAI[2]++ > 100) { FireLaser(npc); internalAI[2] = 0; npc.netUpdate = true; } if (npc.ai[2]++ == (Main.expertMode ? 501 : 701)) { internalAI[0] += 1; npc.netUpdate = true; } if (!CUtils.AnyProjectiles(ModContent.ProjectileType <Star>())) { npc.ai[2] = 0; internalAI[0] = 0; internalAI[1] = 0; internalAI[2] = 0; internalAI[3] = 0; npc.netUpdate = true; } } npc.rotation = 0; for (int m = npc.oldPos.Length - 1; m > 0; m--) { npc.oldPos[m] = npc.oldPos[m - 1]; } npc.oldPos[0] = npc.position; }
public override void AI() { if (!title) { CSkies.ShowTitle(npc, 3); title = true; } Lighting.AddLight(npc.Center, 0, 0f, .15f); npc.TargetClosest(); if (!Main.dayTime) { if (npc.alpha <= 0) { npc.alpha = 0; } else { npc.alpha -= 5; } } else { if (npc.alpha >= 255) { npc.active = false; } else { npc.alpha += 5; } } if (internalAI[3] == 0 && npc.ai[3] < 1000) { if (Main.netMode != NetmodeID.MultiplayerClient) { for (int m = 0; m < StarCount; m++) { int projectileID = Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("BlackHole"), npc.damage / 4, 4, Main.myPlayer, m); Main.projectile[projectileID].Center = npc.Center; Main.projectile[projectileID].velocity = new Vector2(MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble())); Main.projectile[projectileID].velocity *= 8f; } internalAI[3] = 1; npc.netUpdate = true; } } if (internalAI[1] < 120) { internalAI[1] += 2; } else { internalAI[1] = 120; npc.netUpdate = true; } BaseAI.AISkull(npc, ref npc.ai, true, 11, 350, .05f, .07f); if (Main.netMode != NetmodeID.MultiplayerClient) { if (internalAI[2]++ > 200) { FireLaser(npc); internalAI[2] = 0; npc.netUpdate = true; } if (npc.ai[3] == 1200f) { npc.netUpdate = true; } else if (npc.ai[3] < 1200) { npc.ai[3]++; npc.netUpdate = true; if (npc.ai[2]++ == (Main.expertMode ? 400 : 500)) { internalAI[0] += 1; npc.netUpdate = true; } } if (!CUtils.AnyProjectiles(ModContent.ProjectileType <BlackHole>())) { npc.ai[2] = 0; internalAI[0] = 0; internalAI[1] = 0; internalAI[2] = 0; internalAI[3] = 0; npc.netUpdate = true; } } if (npc.ai[3] >= 1200f) { if (npc.ai[3] > (Main.expertMode ? 1500 : 1400)) { npc.ai[3] = 0; npc.netUpdate = true; } else { npc.ai[3]++; } npc.ai[2] = 0; npc.velocity *= .98f; if (VortexScale < 1f) { VortexScale += .01f; } VortexRotation += .3f; for (int u = 0; u < Main.maxPlayers; u++) { Player target = Main.player[u]; if (target.active && Vector2.Distance(npc.Center, target.Center) < 260 * VortexScale) { float num3 = 6f; Vector2 vector = new Vector2(target.position.X + target.width / 4, target.position.Y + target.height / 4); float num4 = npc.Center.X - vector.X; float num5 = npc.Center.Y - vector.Y; float num6 = (float)Math.Sqrt(num4 * num4 + num5 * num5); num6 = num3 / num6; num4 *= num6; num5 *= num6; int num7 = 4; target.velocity.X = (target.velocity.X * (num7 - 1) + num4) / num7; target.velocity.Y = (target.velocity.Y * (num7 - 1) + num5) / num7; } } } else { if (VortexScale > 0f) { VortexScale -= .05f; } VortexRotation += .05f; } npc.rotation = 0; for (int m = npc.oldPos.Length - 1; m > 0; m--) { npc.oldPos[m] = npc.oldPos[m - 1]; } npc.oldPos[0] = npc.position; }
public override void AI() { Player player = Main.player[npc.target]; Vector2 targetPos; if (!npc.HasPlayerTarget) { npc.TargetClosest(); } int speed = 16; float interval = .025f; if (npc.life < npc.lifeMax / 2) { if (!Phase2) { npc.velocity *= .92f; PhaseTimer++; if (PhaseTimer == 120) { CombatText.NewText(npc.Hitbox, Color.Purple, "Target threat level underestimated. Engaging melee protocols.", true); } if (PhaseTimer >= 180) { Phase2 = true; internalAI[0] = 6; } return; } speed = 18; interval = .03f; music = mod.GetSoundSlot(Terraria.ModLoader.SoundType.Music, "Sounds/Music/Novacore2"); } if (npc.life < npc.lifeMax / 4) { Lighting.AddLight(npc.Center, Warning.R / 150, Warning.G / 150, Warning.B / 150); if (!WarningText) { CombatText.NewText(npc.Hitbox, Color.Red, "ERROR. DRASTIC PHYSICAL DAMAGE TO CHASSIS! ASTRAL ENERGY LEAKS IMMINENT!", true); WarningText = true; } music = mod.GetSoundSlot(Terraria.ModLoader.SoundType.Music, "Sounds/Music/Pinch"); speed = 20; interval = .03f; if (Main.rand.Next(30) == 0) { Lightning(); } } else { Lighting.AddLight(npc.Center, Color.Purple.R / 150, Color.Purple.G / 150, Color.Purple.B / 150); } if (!MeleeMode) { BaseAI.AISkull(npc, ref npc.ai, true, speed, 280, interval, .05f); } OrbitterDist += 2f; if (OrbitterDist > 300) { OrbitterDist = 300; } CWorld.NovacoreCounter = npc.ai[2]; if (MeleeMode) { internalAI[3]++; switch (internalAI[1]) { #region Diagonal Dashes case 0: if (!AliveCheck(player)) { break; } targetPos = player.Center; targetPos.X += 430 * (npc.Center.X < targetPos.X ? -1 : 1); targetPos.Y -= 430; Movement(targetPos, .7f); if (internalAI[3] > 180 || Math.Abs(npc.Center.Y - targetPos.Y) < 100) //initiate dash { internalAI[1]++; internalAI[3] = 0; npc.netUpdate = true; npc.velocity = npc.DirectionTo(player.Center) * 45; } break; case 1: //dashing if (npc.Center.Y > player.Center.Y + 500 || Math.Abs(npc.Center.X - player.Center.X) > 1000) { npc.velocity.Y *= 0.5f; internalAI[3] = 0; if (++internalAI[2] >= Repeats() - 1) //repeat three times { internalAI[1] = 0; internalAI[2] = 0; internalAI[3] = 0; MeleeMode = false; } else { internalAI[1]--; } npc.netUpdate = true; } break; #endregion #region Horizontal Dash case 2: //prepare for queen bee dashes if (!AliveCheck(player)) { break; } if (internalAI[3] > 60) { targetPos = player.Center; targetPos.X += 400 * (npc.Center.X < targetPos.X ? -1 : 1); Movement(targetPos, 1f); if (internalAI[3] > 180 || Math.Abs(npc.Center.Y - targetPos.Y) < 40) //initiate dash { internalAI[1]++; internalAI[3] = 0; npc.netUpdate = true; npc.velocity.X = -40 * (npc.Center.X < player.Center.X ? -1 : 1); npc.velocity.Y *= 0.1f; } } else { npc.velocity *= 0.9f; //decelerate briefly } break; case 3: if (internalAI[3] > 240 || (Math.Sign(npc.velocity.X) > 0 ? npc.Center.X > player.Center.X + 900 : npc.Center.X < player.Center.X - 900)) { internalAI[3] = 0; if (++internalAI[2] >= Repeats()) //repeat dash three times { internalAI[1] = 0; internalAI[2] = 0; internalAI[3] = 0; MeleeMode = false; } else { internalAI[1]--; } npc.netUpdate = true; } break; default: internalAI[1] = 0; goto case 0; #endregion } } else { if (npc.ai[2]++ > AIRate) { if (internalAI[0] != 5) { if (npc.velocity.X >= 0) { npc.rotation += .06f; npc.spriteDirection = 1; } else if (npc.velocity.X < 0) { npc.rotation -= .06f; npc.spriteDirection = -1; } } else { npc.rotation += .03f; } switch (internalAI[0]) { case 0: case 1: case 2: #region Lightning case 3: if (!AliveCheck(Main.player[npc.target])) { break; } if (npc.localAI[0] == 0f) { npc.localAI[0] = 1f; int num833 = Player.FindClosest(npc.Center, 0, 0); Vector2 vector62 = Main.player[num833].Center - npc.Center; if (vector62 == Vector2.Zero) { vector62 = Vector2.UnitY; } closestPlayer = vector62.ToRotation(); npc.netUpdate = true; } if (npc.ai[2] % 45 == 0) { Main.PlaySound(SoundID.Item8, npc.position); Vector2 vector71 = closestPlayer.ToRotationVector2(); Vector2 value56 = vector71.RotatedBy(1.5707963705062866) * (Main.rand.Next(2) == 0).ToDirectionInt() * Main.rand.Next(10, 21); vector71 *= Main.rand.Next(-80, 81); Vector2 velocity3 = (vector71 - value56) / 10f; Dust dust25 = Main.dust[Dust.NewDust(npc.Center, 0, 0, ModContent.DustType <Dusts.CDust>())]; dust25.noGravity = true; dust25.position = npc.Center + value56; dust25.velocity = velocity3; dust25.scale = 0.5f + Main.rand.NextFloat(); dust25.fadeIn = 0.5f; if (Main.netMode != NetmodeID.MultiplayerClient) { for (int a = 0; a < Repeats() + 1; a++) { Vector2 vector72 = closestPlayer.ToRotationVector2() * 8f; float ai2 = Main.rand.Next(80); Projectile.NewProjectile(npc.Center.X - vector72.X, npc.Center.Y - vector72.Y, vector72.X, vector72.Y, ModContent.ProjectileType <Novashock>(), 15, 1f, Main.myPlayer, closestPlayer, ai2); } } npc.localAI[0] = 0; } if (npc.ai[2] > AIRate + 140 && Main.netMode != NetmodeID.MultiplayerClient) { AIChange(); } break; #endregion #region Turrets case 4: if (!AliveCheck(Main.player[npc.target])) { break; } if (!AnyOrbitters) { OrbitterDist = 0; for (int m = 0; m < TurretCount(); m++) { int projectileID = Projectile.NewProjectile(npc.Center, Vector2.Zero, ModContent.ProjectileType <NovaTurretProj>(), npc.damage, 4, Main.myPlayer); Main.projectile[projectileID].Center = npc.Center; Main.projectile[projectileID].velocity = new Vector2(MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble()), MathHelper.Lerp(-1f, 1f, (float)Main.rand.NextDouble())); Main.projectile[projectileID].velocity *= 8f; Main.projectile[projectileID].ai[0] = m; } } AIChange(); break; #endregion #region Lasers case 5: //Nova Beams if (!AliveCheck(Main.player[npc.target])) { break; } npc.velocity *= .94f; LaserAttack(); if (!CUtils.AnyProjectiles(ModContent.ProjectileType <NovaBeam>()) || !CUtils.AnyProjectiles(ModContent.ProjectileType <NovaBeamSmall>()) && !LaserShot) { AIChange(); } break; #endregion } } else { if (npc.velocity.X > 0) { npc.rotation += .03f; } else if (npc.velocity.X < 0) { npc.rotation -= .03f; } if (npc.life < npc.lifeMax / 2) { if (Shoot > 30) { if (Shoot % 10 == 0) { if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 spinningpoint2 = 0 * Vector2.UnitX; spinningpoint2 = spinningpoint2.RotatedBy((Main.rand.NextDouble() - 0.5) * 0.78539818525314331); spinningpoint2 *= 8f; Projectile.NewProjectile(npc.Center.X, npc.Center.Y, spinningpoint2.X, spinningpoint2.Y, ModContent.ProjectileType <NovaRocket>(), npc.damage / 3, 0f, Main.myPlayer, 0f, 20f); if (Shoot > 60) { Shoot = 0; npc.netUpdate = true; } } Main.PlaySound(SoundID.Item39, npc.Center); } } } } } }