public override void AI() { Player player = Main.player[projectile.owner]; player.UpdateMaxTurrets(); if (runOnce) { if (player.direction == -1) { gunRotation = (float)Math.PI; } runOnce = false; } if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC)) { aimRotation = (target.Center - projectile.Center).ToRotation(); shotCooldown++; if (shotCooldown >= 12) { if (QwertyMethods.AngularDifference(aimRotation, gunRotation) < (float)Math.PI / 8) { Shoot(); } } } else { aimRotation = player.direction == 1 ? 0 : (float)Math.PI; } gunRotation = QwertyMethods.SlowRotation(gunRotation, aimRotation, 5); }
public override void AI() { Player player = Main.player[npc.target]; if (npc.wet && (player.Center - npc.Center).Length() < laserDistance && Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { npc.velocity = Vector2.Zero; npc.aiStyle = 0; aiType = 0; npc.rotation = QwertyMethods.SlowRotation(npc.rotation, (player.Center - npc.Center).ToRotation() + (npc.spriteDirection == -1 ? (float)Math.PI : 0), 2); if (QwertyMethods.AngularDifference(npc.rotation, (player.Center - npc.Center).ToRotation() + (npc.spriteDirection == -1 ? (float)Math.PI : 0)) < (float)Math.PI / 20) { laserTimer++; if (laserTimer > 60) { laserTimer = 0; Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(58, npc.rotation + (npc.spriteDirection == -1 ? (float)Math.PI : 0)), QwertyMethods.PolarVector(12f, npc.rotation + (npc.spriteDirection == -1 ? (float)Math.PI : 0)), ProjectileID.PinkLaser, 20, 0f, Main.myPlayer); } } } else { npc.aiStyle = 16; aiType = NPCID.Shark; } }
public override void AI() { //QwertyMethods.ServerClientCheck(timer); Player player = Main.player[npc.target]; npc.chaseable = false; if (npc.ai[3] > 10) { npc.chaseable = true; } else { for (int i = 0; i < Main.player.Length; i++) { if ((Main.player[i].active && (QwertysRandomContent.LocalCursor[i] - npc.Center).Length() < 180) || (Main.player[i].Center - npc.Center).Length() < orbitDistance) { npc.chaseable = true; break; } } } npc.TargetClosest(false); pupilDirection = (player.Center - npc.Center).ToRotation(); pulseCounter += (float)Math.PI / 30; npc.scale = 1f + .05f * (float)Math.Sin(pulseCounter); pupilStareOutAmount = (player.Center - npc.Center).Length() / 300f; if (pupilStareOutAmount > 1f) { pupilStareOutAmount = 1f; } blinkCounter--; if (blinkCounter < 0 && attackType != 1) { if (blinkCounter % 10 == 0) { if (frame == 7) { blinkCounter = Main.rand.Next(180, 240); } else { frame++; } } } else { frame = 0; } if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead) { canDespawn = true; npc.velocity = new Vector2(0f, 10f); if (npc.timeLeft > 10) { npc.timeLeft = 10; } return; } } else { canDespawn = false; if ((cloak == null || cloak.type != mod.ProjectileType("Cloak") || !cloak.active) && Main.netMode != 1) { cloak = Main.projectile[Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Cloak"), 0, 0, Main.myPlayer, npc.whoAmI)]; } if (playerviewRadius > 80) { playerviewRadius -= 10; } if (Main.netMode != 1) { cloak.ai[1] = playerviewRadius; cloak.timeLeft = 2; } if (myWall != null) { myWall.timeLeft = 2; } if (npc.ai[3] > 0) { npc.ai[3]--; } if (attackType != 0) { timer++; if (player.velocity.Length() > 0f) { lastMoved = player.velocity; } } switch (attackType) { case -1: if (timer > 120 * (Main.expertMode ? .2f + .8f * ((float)npc.life / npc.lifeMax) : 1f) && (player.Center - npc.Center).Length() < 1000f) { if (Main.netMode != 1) { attackType = Main.rand.Next(7); switch (attackType) { default: orbitalVelocity = 14f; if (Main.rand.Next(2) == 0) { orbitalVelocity *= -1; } break; case 0: orbitalVelocity = defaultOrbitalSpeed() * 4f; break; case 1: orbitalVelocity = 0; Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Warning"), 0, 0f, Main.myPlayer, 0, 0); if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/Notice").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } npc.velocity = Vector2.Zero; break; } npc.netUpdate = true; } timer = 0; } break; default: if (timer >= 60) { orbitalVelocity = defaultOrbitalSpeed(); timer = 0; attackType = -1; } else if (timer % 15 == 0 && Main.netMode != 1) { Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("EtimsicCannon"), Main.expertMode ? 18 : 24, 0f, Main.myPlayer, (player.Center - npc.Center).ToRotation()); Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Warning"), 0, 0f, Main.myPlayer, 1, (player.Center - npc.Center).ToRotation()); if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/Notice").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } } break; case 0: if (timer == 0 && QwertyMethods.AngularDifference(lastMoved.ToRotation(), (npc.Center - player.Center).ToRotation()) < (float)Math.PI / 30) { if (Main.netMode != 1) { myWall = Main.projectile[Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("EtimsicWall"), Main.expertMode ? 24 : 36, 0f, Main.myPlayer, (player.Center - npc.Center).ToRotation() + (float)Math.PI / 2)]; Projectile.NewProjectile(npc.Center, Vector2.Zero, mod.ProjectileType("Warning"), 0, 0f, Main.myPlayer, 2, (player.Center - npc.Center).ToRotation() + (float)Math.PI / 2); } if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/Notice").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } timer = 1; npc.netUpdate = true; } if (timer > 0) { timer++; } if (timer >= 60) { orbitalVelocity = defaultOrbitalSpeed(); npc.netUpdate = true; timer = 0; attackType = -1; } break; case 1: if (timer > 60) { npc.ai[3] = 80; if (timer < 180 && timer % 15 == 0) { npc.velocity = Vector2.Zero; if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center + new Vector2((float)Math.Cos(pupilDirection) * greaterPupilRadius * pupilStareOutAmount, (float)Math.Sin(pupilDirection) * lesserPupilRadius) * npc.scale, QwertyMethods.PolarVector(10, pupilDirection), mod.ProjectileType("EtimsicRay"), Main.expertMode ? 18 : 24, 0f, Main.myPlayer); } if (!Main.dedServ) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/SoundEffects/PewPew").WithVolume(3f).WithPitchVariance(.5f), npc.Center); } } if (timer == 179 && Main.netMode != 1) { npc.netUpdate = true; } if (timer == 180) { npc.velocity = QwertyMethods.PolarVector(15, (player.Center - npc.Center).ToRotation()); npc.netUpdate = true; } if (timer > 240) { npc.netUpdate = true; orbitalVelocity = defaultOrbitalSpeed(); timer = 0; attackType = -1; } } break; } //movement if (attackType == 1) { } else { npc.velocity = QwertyMethods.PolarVector(orbitalVelocity, (player.Center - npc.Center).ToRotation() + (float)Math.PI / 2); if ((player.Center - npc.Center).Length() < orbitDistance - 50) { npc.velocity += QwertyMethods.PolarVector(-retreatApproachSpeed, (player.Center - npc.Center).ToRotation()); } else if ((player.Center - npc.Center).Length() > orbitDistance + 50) { npc.velocity += QwertyMethods.PolarVector(retreatApproachSpeed, (player.Center - npc.Center).ToRotation()); } } } }