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[projectile.owner]; player.UpdateMaxTurrets(); timer++; if (QwertyMethods.ClosestNPC(ref target, maxDistance, projectile.Center, false, player.MinionAttackTargetNPC)) { projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (timer % 60 == 0 && player.whoAmI == Main.myPlayer) { int numOfProj = 8 + Main.rand.Next(8); for (int p = 0; p < numOfProj; p++) { Projectile s = Main.projectile[Projectile.NewProjectile(projectile.Center, QwertyMethods.PolarVector(Main.rand.NextFloat(4, 16), projectile.rotation - (float)Math.PI / 8 + Main.rand.NextFloat((float)Math.PI / 4)), ProjectileID.SporeCloud, projectile.damage, projectile.knockBack, player.whoAmI)]; s.melee = false; s.minion = true; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(s); } } } } }
public override void AI() { Main.player[projectile.owner].UpdateMaxTurrets(); Player player = Main.player[projectile.owner]; for (int i = 0; i < missileCounters.Length; i++) { if (missileCounters[i] < missileTime) { missileCounters[i]++; break; } } if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC)) { for (int i = 0; i < missileCounters.Length; i++) { projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (missileCounters[i] == missileTime) { //shoot missileCounters[i] = 0; Projectile.NewProjectile(projectile.Center + QwertyMethods.PolarVector(2f, projectile.rotation) + QwertyMethods.PolarVector(missileLoadPosition * (i == 0 ? 1 : -1), projectile.rotation + (float)Math.PI / 2), QwertyMethods.PolarVector(2f, projectile.rotation), mod.ProjectileType("AshMissile"), projectile.damage, projectile.knockBack, projectile.owner); } } } }
public override void AI() { if (runOnce) { direction = projectile.velocity.ToRotation(); runOnce = false; } Player player = Main.player[projectile.owner]; for (int k = 0; k < 200; k++) { possibleTarget = Main.npc[k]; if (!Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, possibleTarget.position, possibleTarget.Size)) { projectile.localNPCImmunity[k] = 0; } } if (QwertyMethods.ClosestNPC(ref target, maxDistance, projectile.Center)) { direction = QwertyMethods.SlowRotation(direction, (target.Center - projectile.Center).ToRotation(), 10f); } projectile.velocity = new Vector2((float)Math.Cos(direction) * speed, (float)Math.Sin(direction) * speed); foundTarget = false; maxDistance = 10000f; Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("CaeliteDust")); projectile.rotation += (float)Math.PI / 7.5f; }
public override void NonStickingBehavior() { if (QwertyMethods.ClosestNPC(ref target, 300, projectile.Center)) { float dir = projectile.velocity.ToRotation(); dir = QwertyMethods.SlowRotation(dir, (target.Center - projectile.Center).ToRotation(), 1); projectile.velocity = QwertyMethods.PolarVector(projectile.velocity.Length(), dir); } }
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { NPC target = new NPC(); if (QwertyMethods.ClosestNPC(ref target, 100, Main.MouseWorld, true)) { target.GetGlobalNPC <GraveMisery>().MiseryIntensity = (int)(item.damage * 2 * player.magicDamage); } return(false); }
public override void AI() { Player player = Main.player[projectile.owner]; player.UpdateMaxTurrets(); if (runOnce) { Fist = Main.projectile[Projectile.NewProjectile(projectile.Center, Vector2.Zero, mod.ProjectileType("PunnishFist"), projectile.damage, 0, player.whoAmI, projectile.whoAmI)]; runOnce = false; } if (projectile.ai[1] == 1) { if (FistExtension <= 17) { FistExtension = 17; projectile.ai[1] = 0; } else { FistExtension -= FistExtensionSpeed; } wait = 0; } else if (QwertyMethods.ClosestNPC(ref target, 800f, projectile.Center, false, player.MinionAttackTargetNPC)) { wait++; projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (wait == 10) { for (int k = 0; k < 200; k++) { Fist.localNPCImmunity[k] = 0; } } if (wait > 10) { FistExtension += FistExtensionSpeed; if (FistExtension > maxFistExtension) { projectile.ai[1] = 1; } } } else { projectile.ai[1] = 1; } Fist.timeLeft = 2; Fist.Center = projectile.Center + QwertyMethods.PolarVector(FistExtension, projectile.rotation); Fist.rotation = projectile.rotation + (float)Math.PI / 2; }
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); sniperCount = player.ownedProjectileCounts[mod.ProjectileType("ChlorophyteSniper")]; if (modPlayer.chlorophyteSniper) { projectile.timeLeft = 2; } for (int p = 0; p < 1000; p++) { if (Main.projectile[p].type == mod.ProjectileType("ChlorophyteSniper")) { if (p == projectile.whoAmI) { break; } else { identity++; } } } timer++; if (sniperCount != 0) { projectile.ai[0] = 40f; flyTo = player.Center + QwertyMethods.PolarVector(projectile.ai[0], -modPlayer.mythrilPrismRotation + (2f * (float)Math.PI * identity) / sniperCount); projectile.velocity = (flyTo - projectile.Center) * .1f; if (QwertyMethods.ClosestNPC(ref target, 100000, projectile.Center, false, player.MinionAttackTargetNPC) && timer > 180) { Projectile.NewProjectile(projectile.Center, QwertyMethods.PolarVector(10, (target.Center - projectile.Center).ToRotation()), mod.ProjectileType("ChlorophyteSnipe"), projectile.damage, projectile.knockBack, player.whoAmI); timer = 0; } //Main.NewText(projectile.Center);/ //projectile.Center = flyTo; } identity = 0; }
public override void PreUpdate() { if (helmEffect) { PrismTrigonometryCounterOfAwsomenessWowThisIsAVeryLongVariableName += (float)MathHelper.Pi / 30; prismDazzleCounter--; NPC target = new NPC(); Vector2 prismCenter = player.Center + new Vector2((float)Math.Sin(PrismTrigonometryCounterOfAwsomenessWowThisIsAVeryLongVariableName) * 40f, 0); if (QwertyMethods.ClosestNPC(ref target, 4000, prismCenter) && prismDazzleCounter <= 0) { Projectile.NewProjectile(prismCenter, QwertyMethods.PolarVector(1, (target.Center - prismCenter).ToRotation()), mod.ProjectileType("PrismDazzle"), (int)(10f * player.magicDamage), 0f, player.whoAmI); prismDazzleCounter = 60; } } }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); varTime++; if (varTime >= 60) { varTime = 0; if (Main.netMode != 2) { Yvar = Main.rand.Next(0, 80); Xvar = Main.rand.Next(-80, 80); } } Vector2 moveTo = new Vector2(player.Center.X + Xvar, player.Center.Y - Yvar) - projectile.Center; projectile.velocity = (moveTo) * .04f; if (modPlayer.LuneArcher) { projectile.timeLeft = 2; } timer++; if (QwertyMethods.ClosestNPC(ref target, 10000, player.Center, false, player.MinionAttackTargetNPC)) { projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (timer > 90) { int weaponDamage = projectile.damage; float weaponKnockback = projectile.knockBack; player.PickAmmo(QwertyMethods.MakeItemFromID(39), ref arrow, ref speedB, ref canShoot, ref weaponDamage, ref weaponKnockback, Main.rand.Next(2) == 0); if (Main.netMode != 1) { Projectile bul = Main.projectile[Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(projectile.rotation) * BulVel, (float)Math.Sin(projectile.rotation) * BulVel, arrow, weaponDamage, weaponKnockback, Main.myPlayer)]; bul.ranged = false; bul.minion = true; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(bul); } } timer = 0; } projectile.rotation += (float)Math.PI / 2; } }
public override void AI() { Main.player[projectile.owner].UpdateMaxTurrets(); Player player = Main.player[projectile.owner]; projectile.rotation += (float)Math.PI / 60; //this make the projctile to rotate if (QwertyMethods.ClosestNPC(ref confirmTarget, 100000, projectile.Center, false, player.MinionAttackTargetNPC)) { drawLine = true; lineLength = (confirmTarget.Center - projectile.Center).Length(); Aim = (confirmTarget.Center - projectile.Center).ToRotation(); timer++; if (timer == 420) { startCountdown = true; } if (timer >= 600) { if (Main.netMode != 1) { Projectile.NewProjectile(projectile.Center, QwertyMethods.PolarVector(shardVelocity, Aim), mod.ProjectileType("RhuthiniumShard"), projectile.damage, projectile.knockBack, Main.myPlayer, 0f, 0f); } timer = 0; } } if (startCountdown) { alternateColor = true; countdownTimer++; if (countdownTimer == 180) { startCountdown = false; } } else { alternateColor = false; countdownTimer = 0; } }
public override void AI() { Player player = Main.player[projectile.owner]; player.UpdateMaxTurrets(); timer++; if (QwertyMethods.ClosestNPC(ref target, maxDistance, projectile.Center, false, player.MinionAttackTargetNPC)) { projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (timer % 10 == 0) { Vector2 offset = QwertyMethods.PolarVector(bladeStartDist, ((float)(timer % 80) / 80f) * (float)Math.PI * 2); if (offset.X > 0) { offset.X += target.width / 2; } else if (offset.X < 0) { offset.X -= target.width / 2; } if (offset.Y > 0) { offset.Y += target.height / 2; } else if (offset.Y < 0) { offset.Y -= target.height / 2; } Projectile.NewProjectile(target.Center + offset, -offset.SafeNormalize(-Vector2.UnitY) * 8, mod.ProjectileType("Excalimini"), projectile.damage, projectile.knockBack, player.whoAmI); if (timer % 20 == 0) { Projectile.NewProjectile(projectile.Center, QwertyMethods.PolarVector(8, projectile.rotation + (float)Math.PI / 2), mod.ProjectileType("ExcaliminiDraw"), projectile.damage, projectile.knockBack, player.whoAmI); } else { Projectile.NewProjectile(projectile.Center, QwertyMethods.PolarVector(8, projectile.rotation - (float)Math.PI / 2), mod.ProjectileType("ExcaliminiDraw"), projectile.damage, projectile.knockBack, player.whoAmI); } } } }
public override void AI() { Player player = Main.player[projectile.owner]; player.UpdateMaxTurrets(); if (QwertyMethods.ClosestNPC(ref target, maxDistance, projectile.Center, false, player.MinionAttackTargetNPC)) { timer++; projectile.rotation = (target.Center - projectile.Center).ToRotation(); if (timer % reloadTime == 0) { if (timer % (reloadTime * 2) == 0) { projectile.frame = 1; si = 1; } else { projectile.frame = 2; si = -1; } Vector2 shootFrom = projectile.Center + QwertyMethods.PolarVector(12, projectile.rotation) + QwertyMethods.PolarVector(si * 4, projectile.rotation + (float)Math.PI / 2); //if (Main.netMode != 1) { Projectile.NewProjectile(shootFrom, QwertyMethods.PolarVector(1, projectile.rotation), mod.ProjectileType("RiptideStream"), projectile.damage, projectile.knockBack, projectile.owner); } } } else { timer = 0; projectile.frame = 0; } }
public override void AI() { if (projectile.timeLeft == 600) { projectile.rotation = projectile.velocity.ToRotation(); } //int num5 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + (float)projectile.height - 2f), projectile.width, 6, 36, 0f, 0f, 50, default, 1f); Player player = Main.player[projectile.owner]; if (projectile.timeLeft <= finalTime) { if (projectile.width != blastSize) { Vector2 oldCenter = projectile.Center; projectile.width = projectile.height = blastSize; projectile.Center = oldCenter; } projectile.rotation += (float)Math.PI / 10; for (int d = 0; d < 5; d++) { Dust dust = Dust.NewDustPerfect(projectile.Center, 36, QwertyMethods.PolarVector(4, projectile.rotation + ((float)Math.PI * 2 * d) / 5), Scale: .5f); dust.noGravity = true; } projectile.velocity = Vector2.Zero; } else { if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC)) { projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, (target.Center - projectile.Center).ToRotation(), 2f); } projectile.velocity = QwertyMethods.PolarVector(8f, projectile.rotation); Dust dust = Dust.NewDustPerfect(projectile.Center - QwertyMethods.PolarVector(6, projectile.rotation), 36, Vector2.Zero, Scale: .5f); dust.noGravity = true; } }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(mod); drifterCount = player.ownedProjectileCounts[mod.ProjectileType("OrichalcumDrifter")]; if (modPlayer.OrichalcumDrifter) { projectile.timeLeft = 2; } for (int p = 0; p < 1000; p++) { if (Main.projectile[p].type == mod.ProjectileType("OrichalcumDrifter")) { if (p == projectile.whoAmI) { break; } else { identity++; } } } if ((player.Center - projectile.Center).Length() > 750 || flyBack) { flyTo = player.Center; if (Collision.CheckAABBvAABBCollision(player.position, player.Size, projectile.position, projectile.Size)) { flyBack = false; speed = 3; turnSpeed = 2; } else { flyBack = true; speed = 12; turnSpeed = 20; } } else { if (QwertyMethods.ClosestNPC(ref target, maxDistance, projectile.Center, false, player.MinionAttackTargetNPC)) { flyTo = target.Center; } else { if (drifterCount != 0) { projectile.ai[0] = 40f; flyTo = player.Center + QwertyMethods.PolarVector(projectile.ai[0], (2f * (float)Math.PI * identity) / drifterCount); } else { flyTo = player.Center; } } speed = 3; turnSpeed = 2; } flyDirection = QwertyMethods.SlowRotation(flyDirection, (flyTo - projectile.Center).ToRotation(), turnSpeed); projectile.velocity = QwertyMethods.PolarVector(speed, flyDirection); driftTimer += (float)Math.PI / 120; driftVariance = (float)Math.Cos(driftTimer); projectile.velocity += QwertyMethods.PolarVector(driftVariance, flyDirection + (float)Math.PI / 2); projectile.rotation = projectile.velocity.ToRotation(); // Main.NewText((player.Center - projectile.Center).Length()); }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(mod); if (modPlayer.AncientMinion) { projectile.timeLeft = 2; } if (runOnce) { //Main.PlaySound(SoundID.Item8); if (Main.netMode != 2) { moveTo.X = projectile.Center.X; moveTo.Y = projectile.Center.Y; projectile.netUpdate = true; } runOnce = false; } if (QwertyMethods.ClosestNPC(ref target, maxDistance, player.Center, true, player.MinionAttackTargetNPC)) { timer++; if (timer > waitTime + chargeTime) { for (int k = 0; k < 200; k++) { projectile.localNPCImmunity[k] = 0; } for (int i = 0; i < minionRingDustQty; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(minionRingRadius, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-minionRingRadius / 10, theta)); dust.noGravity = true; } if (Main.netMode != 2) { projectile.ai[1] = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); projectile.netUpdate = true; } moveTo = new Vector2(target.Center.X + (float)Math.Cos(projectile.ai[1]) * 100, target.Center.Y + (float)Math.Sin(projectile.ai[1]) * 100); if (Main.netMode != 2) { projectile.netUpdate = true; } justTeleported = true; timer = 0; noTargetTimer = 0; } else if (timer > waitTime) { charging = true; } else { if (timer == 2) { Main.PlaySound(SoundID.Item8); for (int i = 0; i < minionRingDustQty; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(minionRingRadius / 10, theta)); dust.noGravity = true; } } charging = false; } if (charging) { projectile.velocity = new Vector2((float)Math.Cos(projectile.rotation) * chargeSpeed, (float)Math.Sin(projectile.rotation) * chargeSpeed); } else { projectile.Center = new Vector2(moveTo.X, moveTo.Y); projectile.velocity = new Vector2(0, 0); float targetAngle = new Vector2(target.Center.X - projectile.Center.X, target.Center.Y - projectile.Center.Y).ToRotation(); projectile.rotation = targetAngle; } } else { noTargetTimer++; if (noTargetTimer == 2) { Main.PlaySound(SoundID.Item8); for (int i = 0; i < minionRingDustQty; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(minionRingRadius / 10, theta)); dust.noGravity = true; } } if ((projectile.Center - player.Center).Length() > 300) { if (Main.netMode != 2) { projectile.ai[1] = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); projectile.netUpdate = true; } for (int i = 0; i < minionRingDustQty; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(minionRingRadius, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-minionRingRadius / 10, theta)); dust.noGravity = true; } noTargetTimer = 0; moveTo = new Vector2(player.Center.X + (float)Math.Cos(projectile.ai[1]) * 100, player.Center.Y + (float)Math.Sin(projectile.ai[1]) * 100); justTeleported = true; } projectile.Center = moveTo; float targetAngle = new Vector2(player.Center.X - projectile.Center.X, player.Center.Y - projectile.Center.Y).ToRotation(); projectile.rotation = targetAngle; } if (justTeleported) { justTeleported = false; } projectile.frameCounter++; }
public override void AI() { // Slowly remove alpha as it is present if (projectile.alpha > 0) { projectile.alpha -= alphaReduction; } // If alpha gets lower than 0, set it to 0 if (projectile.alpha < 0) { projectile.alpha = 0; } // If ai0 is 0f, run this code. This is the 'movement' code for the javelin as long as it isn't sticking to a target if (!isStickingToTarget) { if (QwertyMethods.ClosestNPC(ref target, 300, projectile.Center)) { float dir = projectile.velocity.ToRotation(); dir = QwertyMethods.SlowRotation(dir, (target.Center - projectile.Center).ToRotation(), 1); projectile.velocity = QwertyMethods.PolarVector(projectile.velocity.Length(), dir); } // Make sure to set the rotation accordingly to the velocity, and add some to work around the sprite's rotation projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians( 135f); // Please notice the MathHelper usage, offset the rotation by 135 degrees (to radians because rotation uses radians) because the sprite's rotation is not aligned! } // This code is ran when the javelin is sticking to a target if (isStickingToTarget) { // These 2 could probably be moved to the ModifyNPCHit hook, but in vanilla they are present in the AI projectile.ignoreWater = true; // Make sure the projectile ignores water projectile.tileCollide = false; // Make sure the projectile doesn't collide with tiles anymore int aiFactor = 15; // Change this factor to change the 'lifetime' of this sticking javelin bool killProj = false; // if true, kill projectile at the end bool hitEffect = false; // if true, perform a hit effect projectile.localAI[0] += 1f; // Every 30 ticks, the javelin will perform a hit effect hitEffect = projectile.localAI[0] % 30f == 0f; int projTargetIndex = (int)targetWhoAmI; if (projectile.localAI[0] >= (float)(60 * aiFactor) || // If it's time for this javelin to die, kill it (projTargetIndex < 0 || projTargetIndex >= 200)) // If the index is past its limits, kill it { killProj = true; } else if (Main.npc[projTargetIndex].active && !Main.npc[projTargetIndex].dontTakeDamage) // If the target is active and can take damage { // Set the projectile's position relative to the target's center projectile.Center = Main.npc[projTargetIndex].Center - projectile.velocity * 2f; projectile.gfxOffY = Main.npc[projTargetIndex].gfxOffY; if (hitEffect) // Perform a hit effect here { Main.npc[projTargetIndex].HitEffect(0, 1.0); } } else // Otherwise, kill the projectile { killProj = true; } if (killProj) // Kill the projectile { projectile.Kill(); } } }
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); }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); shotCounter++; if (modPlayer.SpaceFighter) { projectile.timeLeft = 2; } if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC) && (player.Center - projectile.Center).Length() < 1000) { projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, (target.Center - projectile.Center).ToRotation(), 6); if ((target.Center - projectile.Center).Length() < 300) { if (shotCounter >= 20) { shotCounter = 0; Projectile l = Main.projectile[Projectile.NewProjectile(projectile.Center, QwertyMethods.PolarVector(12f, projectile.rotation), ProjectileID.GreenLaser, projectile.damage, projectile.knockBack, projectile.owner)]; l.magic = false; l.minion = true; //l.scale = .5f; l.penetrate = 1; //l.alpha = 0; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(l); } Main.PlaySound(SoundID.Item12, projectile.position); } } else { Thrust(); } } else { projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, (player.Center - projectile.Center).ToRotation(), 6); if ((player.Center - projectile.Center).Length() < 300) { } else { Thrust(); } } for (int k = 0; k < 1000; k++) { if (Main.projectile[k].type == projectile.type && k != projectile.whoAmI) { if (Collision.CheckAABBvAABBCollision(projectile.position + new Vector2(projectile.width / 4, projectile.height / 4), new Vector2(projectile.width / 2, projectile.height / 2), Main.projectile[k].position + new Vector2(Main.projectile[k].width / 4, Main.projectile[k].height / 4), new Vector2(Main.projectile[k].width / 2, Main.projectile[k].height / 2))) { projectile.velocity += new Vector2((float)Math.Cos((projectile.Center - Main.projectile[k].Center).ToRotation()) * .1f, (float)Math.Sin((projectile.Center - Main.projectile[k].Center).ToRotation()) * .1f); } } } if (projectile.velocity.Length() > maxSpeed) { projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY) * maxSpeed; } }
public override void AI() { bool spinAttack = false; bladeLength = 24 + 16 + 14 * projectile.minionSlots; counter++; if (counter % projectile.localNPCHitCooldown == 0) { turnOffset *= -1; } yetAnotherTrigCounter += (float)Math.PI / 120; Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); if (modPlayer.SwordMinion) { projectile.timeLeft = 2; } if ((player.Center - projectile.Center).Length() > 1000) { returningToPlayer = true; } if ((player.Center - projectile.Center).Length() < 300) { returningToPlayer = false; } Vector2 flyTo = player.Center + new Vector2(-50 * player.direction, -50 - 14 * projectile.minionSlots) + Vector2.UnitY * (float)Math.Sin(yetAnotherTrigCounter) * 20; float turnTo = (float)Math.PI / 2; float speed = 10f; if (returningToPlayer) { speed = (player.Center - projectile.Center).Length() / 30f; } if (QwertyMethods.ClosestNPC(ref target, 800, projectile.Center, false, player.MinionAttackTargetNPC) && !returningToPlayer) { Vector2 difference2 = projectile.Center - target.Center; flyTo = target.Center + QwertyMethods.PolarVector(bladeLength / 2, difference2.ToRotation()); turnTo = (target.Center - projectile.Center).ToRotation(); int nerabyEnemies = 0; foreach (NPC npc in Main.npc) { if (npc.active && npc.chaseable && !npc.dontTakeDamage && !npc.friendly && npc.lifeMax > 5 && !npc.immortal && (npc.Center - projectile.Center).Length() < bladeLength) { nerabyEnemies++; } } if (nerabyEnemies > 2) { spinAttack = true; } if (difference2.Length() < bladeLength) { turnTo += turnOffset; } } Vector2 difference = flyTo - projectile.Center; if (difference.Length() < speed) { projectile.Center = flyTo; projectile.velocity = Vector2.Zero; } else { projectile.velocity = difference.SafeNormalize(Vector2.UnitY) * speed; } if (spinAttack) { projectile.rotation += (float)Math.PI / 15; } else { projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, turnTo, 6); } }
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]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); if (modPlayer.ShieldMinion) { projectile.timeLeft = 2; } for (int p = 0; p < 1000; p++) { if (Main.projectile[p].type == mod.ProjectileType("ShieldMinion") && Main.projectile[p].active && Main.projectile[p].owner == projectile.owner && Main.projectile[p].ai[1] == projectile.ai[1]) { ShieldCount++; } } for (int p = 0; p < 1000; p++) { if (Main.projectile[p].type == mod.ProjectileType("ShieldMinion") && Main.projectile[p].active && Main.projectile[p].owner == projectile.owner && Main.projectile[p].ai[1] == projectile.ai[1]) { if (p == projectile.whoAmI) { break; } else { identity++; } } } projectile.friendly = (projectile.ai[1] == charging); if (projectile.ai[1] != charging) { if (player.velocity.Length() > .1f) { LatestValidVelocity = player.velocity; } float myOffset = (((float)Math.PI / 2) * (float)(identity + 1)) / (ShieldCount + 1) - (float)Math.PI / 4; flyTo = player.Center + QwertyMethods.PolarVector(projectile.ai[1] == guarding ? 120 : -50, (QwertysRandomContent.LocalCursor[projectile.owner] - player.Center).ToRotation() + myOffset); if (flyTo != null && flyTo != Vector2.Zero) { projectile.velocity = (flyTo - projectile.Center) * .1f; } } switch ((int)projectile.ai[1]) { case guarding: projectile.frame = 0; foreach (Projectile OtherProjectile in Main.projectile) { if (OtherProjectile.hostile && OtherProjectile.active && OtherProjectile.velocity != Vector2.Zero && OtherProjectile.damage > 0 && Collision.CheckAABBvAABBCollision(projectile.position, projectile.Size, OtherProjectile.position, OtherProjectile.Size)) { if (OtherProjectile.damage * 2 * (Main.expertMode ? 2 : 1) < projectile.damage) { OtherProjectile.Kill(); } projectile.ai[1] = cooling; chargeTimer = -300; break; } } if (QwertyMethods.ClosestNPC(ref target, 1000, player.Center, true, player.MinionAttackTargetNPC)) { eyeOffset = (target.Center - projectile.Center).SafeNormalize(-Vector2.UnitY); eyeOffset.X *= horizontalEyeMultiploer; eyeOffset.Y *= verticalEyeMultiplier; if ((target.Center - projectile.Center).Length() < 120) { projectile.velocity = QwertyMethods.PolarVector(24, (target.Center - projectile.Center).ToRotation()); projectile.ai[1] = charging; chargeTimer = 10; break; } } else { eyeOffset = Vector2.Zero; } break; case charging: projectile.frame = 0; chargeTimer--; if (chargeTimer <= 0) { projectile.ai[1] = cooling; chargeTimer = -300; } break; case cooling: projectile.frame = 1; chargeTimer++; if (chargeTimer >= 0) { projectile.ai[1] = guarding; } break; } identity = 0; ShieldCount = 0; }
public override void AI() { if (runOnce) { projectile.rotation = projectile.velocity.ToRotation(); runOnce = false; } Player player = Main.player[projectile.owner]; shotCounter++; if (player.HeldItem.GetGlobalItem <ChromeGunToggle>().mode == 3) { projectile.timeLeft = 300; } else if (player.HeldItem.type != mod.ItemType("ChromeShotgunDefault")) { projectile.Kill(); } Vector2 spot = player.Center; if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Center, false, player.MinionAttackTargetNPC)) { spot = target.Center; } Vector2 Difference = (spot - projectile.Center); projectile.rotation = QwertyMethods.SlowRotation(projectile.rotation, Difference.ToRotation(), 5); if (Difference.Length() > 100) { projectile.velocity = Difference *= .02f; } else { projectile.velocity = Vector2.Zero; } for (int i = 0; i < 2; i++) { NPC gunTarget = new NPC(); if (QwertyMethods.ClosestNPC(ref gunTarget, 450, GunPositions[i], false, player.MinionAttackTargetNPC)) { GunRotations[i] = QwertyMethods.SlowRotation(GunRotations[i], (gunTarget.Center - GunPositions[i]).ToRotation() + (float)Math.PI / 2 * (i == 1 ? 1 : -1) - projectile.rotation, 6); if (shotCounter % 30 == i * 15) { int bullet = ProjectileID.Bullet; bool canShoot = true; float speedB = 14f; int weaponDamage = projectile.damage; float kb = projectile.knockBack; player.PickAmmo(QwertyMethods.MakeItemFromID(mod.ItemType("ChromeShotgunDefault")), ref bullet, ref speedB, ref canShoot, ref weaponDamage, ref kb, false); if (canShoot) { Projectile.NewProjectile(GunPositions[i], QwertyMethods.PolarVector(16, GunRotations[i] + projectile.rotation + (float)Math.PI / 2 * (i == 0 ? 1 : -1)), bullet, weaponDamage, kb, projectile.owner); } } } else { GunRotations[i] = QwertyMethods.SlowRotation(GunRotations[i], 0f, 6); } } GunPositions[0] = projectile.Center + QwertyMethods.PolarVector(13, projectile.rotation) + QwertyMethods.PolarVector(14, projectile.rotation + (float)Math.PI / 2); GunPositions[1] = projectile.Center + QwertyMethods.PolarVector(13, projectile.rotation) + QwertyMethods.PolarVector(14, projectile.rotation - (float)Math.PI / 2); }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); if (modPlayer.miniTank) { projectile.timeLeft = 2; } tankCount = player.ownedProjectileCounts[mod.ProjectileType("MiniTank")]; identity = 0; for (int p = 0; p < 1000; p++) { if (Main.projectile[p].type == mod.ProjectileType("MiniTank") && Main.projectile[p].active) { if (p == projectile.whoAmI) { break; } else { identity++; } } } if (returnToPlayer) { projectile.velocity = (player.Top - projectile.Center) * .1f; if ((player.Top - projectile.Center).Length() < 200) { returnToPlayer = false; } projectile.tileCollide = false; } else { if ((player.Center - projectile.Center).Length() > 1500) { returnToPlayer = true; } projectile.tileCollide = true; if (projectile.velocity.Y < terminalVelocity) { projectile.velocity.Y += garvityAcceleration; } gotoX = player.Center.X + -player.direction * (player.width / 2 + spacing + (identity * spacing)); projectile.velocity.X = (gotoX - projectile.Center.X) * .1f; if (Math.Abs(projectile.velocity.X) > maxSpeedX) { projectile.velocity.X = projectile.velocity.X > 0 ? maxSpeedX : -maxSpeedX; } projectile.spriteDirection = projectile.velocity.X > 0 ? 1 : -1; if (QwertyMethods.ClosestNPC(ref target, 1000, projectile.Top, false, player.MinionAttackTargetNPC)) { if (target.Center.Y > projectile.Top.Y) { if (target.Center.X > projectile.Top.X) { aim = 0; } else { aim = (float)Math.PI; } } else { aim = (target.Center - projectile.Top).ToRotation(); } if (shootCounter >= 60) { shootCounter = 0; Projectile.NewProjectile(projectile.Top + QwertyMethods.PolarVector(30, gunRotation), QwertyMethods.PolarVector(10, gunRotation), mod.ProjectileType("MiniTankCannonBallFreindly"), projectile.damage, projectile.knockBack, player.whoAmI); } } else { aim = projectile.spriteDirection == 1 ? 0 : (float)Math.PI; } shootCounter++; gunRotation = QwertyMethods.SlowRotation(gunRotation, aim, 3); if (gunRotation > 0) { if (gunRotation > (float)Math.PI / 2) { gunRotation = (float)Math.PI; } else { gunRotation = 0; } } //projectile.velocity = Collision.TileCollision(projectile.position, projectile.velocity, projectile.width, projectile.height, player.Center.Y > projectile.Bottom.Y, player.Center.Y > projectile.Bottom.Y); } }