public override void AI() { if (runOnce) { actDirection = projectile.velocity.ToRotation(); projectile.velocity /= 5; runOnce = false; } wanderTimer++; if (wanderTimer > 60) { if (Main.netMode == 1 && projectile.owner == Main.myPlayer) { projectile.ai[1] = Main.rand.NextFloat(2 * (float)Math.PI); if (Main.netMode == 1) { QwertysRandomContent.ProjectileAIUpdate(projectile); } projectile.netUpdate = true; } else if (Main.netMode == 0) { projectile.ai[1] = Main.rand.NextFloat(2 * (float)Math.PI); } wanderTimer = 0; } if (projectile.wet) { if (QwertyMethods.ClosestNPC(ref prey, 10000, projectile.Center)) { swimDirection = (projectile.Center - prey.Center).ToRotation() - (float)Math.PI; } else { swimDirection = projectile.ai[1] - (float)Math.PI; } actDirection = QwertyMethods.SlowRotation(actDirection, swimDirection, 4); projectile.velocity.X = (float)Math.Cos(actDirection) * swimSpeed; projectile.velocity.Y = (float)Math.Sin(actDirection) * swimSpeed; projectile.rotation = actDirection + (float)Math.PI / 2; actDirection = projectile.velocity.ToRotation(); } else { actDirection = projectile.velocity.ToRotation(); } }
public override void AI() { Player player = Main.player[projectile.owner]; //Main.NewText(moveTo); QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(mod); if (modPlayer.PlatinumDagger) { projectile.timeLeft = 2; } distanceFromPlayer = (player.Center - projectile.Center).Length(); timer++; switch (AttackMode) { case idle: projectile.tileCollide = true; attackTimer++; if (timer > 60) { if (Main.netMode != 2 && projectile.owner == Main.myPlayer) { projectile.ai[0] = Main.rand.Next(0, 80); projectile.ai[1] = Main.rand.Next(-80, 80); if (Main.netMode == 1) { QwertysRandomContent.ProjectileAIUpdate(projectile); } projectile.netUpdate = true; } timer = 0; } moveTo = new Vector2(player.Center.X + projectile.ai[1], player.Center.Y - projectile.ai[0]); if (attackTimer > attackCooldown) { if (QwertyMethods.ClosestNPC(ref target, targetMaxDistanceFromPlayer, player.Center, false, player.MinionAttackTargetNPC)) { chargeTime = (int)((targetMaxDistanceFromPlayer + 100) / chargeSpeed); for (int k = 0; k < 200; k++) { projectile.localNPCImmunity[k] = 0; } projectile.velocity = (target.Center - projectile.Center).SafeNormalize(-Vector2.UnitY) * chargeSpeed; attackTimer = 0; AttackMode = charging; } } if (distanceFromPlayer > maxDistanceFromPlayer) { AttackMode = returning; } break; case charging: projectile.tileCollide = true; attackTimer++; if (attackTimer > chargeTime) { AttackMode = returning; attackTimer = 0; //projectile.velocity = Vector2.Zero; } break; case returning: projectile.tileCollide = false; moveTo = player.Center; if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size)) { AttackMode = idle; } break; } if (AttackMode == charging) { projectile.friendly = true; projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2; } else { projectile.friendly = false; projectile.velocity += (moveTo - projectile.Center).SafeNormalize(-Vector2.UnitY) * acceleration; if (projectile.velocity.Length() > maxSpeed) { projectile.velocity = (moveTo - projectile.Center).SafeNormalize(-Vector2.UnitY) * maxSpeed; } projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, projectile.velocity.ToRotation() + (float)Math.PI / 2, 3); } //projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2; }
public override void AI() { Player player = Main.player[projectile.owner]; //Main.NewText(moveTo); QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); distanceFromPlayer = (player.Center - projectile.Center).Length(); timer++; switch (AttackMode) { case idle: projectile.timeLeft = 120; attackTimer++; if (timer > 60) { if (Main.netMode != 2 && projectile.owner == Main.myPlayer) { projectile.ai[0] = Main.rand.Next(0, 80); projectile.ai[1] = Main.rand.Next(-80, 80); if (Main.netMode == 1) { QwertysRandomContent.ProjectileAIUpdate(projectile); } projectile.netUpdate = true; } timer = 0; } moveTo = new Vector2(player.Center.X + projectile.ai[1], player.Center.Y - projectile.ai[0]); if (Main.mouseRight && Main.myPlayer == projectile.owner) { projectile.velocity = (Main.MouseWorld - projectile.Center).SafeNormalize(-Vector2.UnitY) * chargeSpeed; attackTimer = 0; AttackMode = charging; } break; case charging: attackTimer++; break; } if (AttackMode == charging) { projectile.friendly = true; projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2; } else { projectile.friendly = false; projectile.velocity += (moveTo - projectile.Center).SafeNormalize(-Vector2.UnitY) * acceleration; if (projectile.velocity.Length() > maxSpeed) { projectile.velocity = (moveTo - projectile.Center).SafeNormalize(-Vector2.UnitY) * maxSpeed; } projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, projectile.velocity.ToRotation() + (float)Math.PI / 2, 3); } targetMaxDistanceFromPlayer = 400; foundTarget = false; //projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2; }
public override void AI() { trigCounter += (float)Math.PI / 60; Player player = Main.player[projectile.owner]; player.UpdateMaxTurrets(); Vector2 DifferenceToGo = Goto - projectile.Center - HeadPos; float speed = DifferenceToGo.Length(); wanderTimer++; if (wanderTimer > 60) { if (Main.netMode == 1 && projectile.owner == Main.myPlayer) { projectile.ai[1] = Main.rand.NextFloat(2 * (float)Math.PI); if (Main.netMode == 1) { QwertysRandomContent.ProjectileAIUpdate(projectile); } projectile.netUpdate = true; } else if (Main.netMode == 0) { projectile.ai[1] = Main.rand.NextFloat(2 * (float)Math.PI); } wanderTimer = 0; } if (QwertyMethods.ClosestNPC(ref target, 700, projectile.Center, true, player.MinionAttackTargetNPC)) { Goto = target.Center; maxSpeed = 6; } else { Goto = projectile.Center + QwertyMethods.PolarVector(100, projectile.ai[1]); } if (speed > maxSpeed) { speed = maxSpeed; } HeadPos += QwertyMethods.PolarVector(speed, DifferenceToGo.ToRotation()); projectile.frameCounter++; if (projectile.frameCounter % 10 == 0) { if (frame == 2 || frame == 0) { animationDir *= -1; } frame += animationDir; } HeadOffPos = HeadPos + QwertyMethods.PolarVector(20 * (float)Math.Sin(trigCounter), HeadPos.ToRotation()); maxSpeed = 3; //were used to check hitbox //Dust.NewDustPerfect((projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(-13, HeadPos.ToRotation()), DustID.Fire); // Dust.NewDustPerfect((projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(28, HeadPos.ToRotation()), DustID.Fire); }