void Thrust() { projectile.velocity += QwertyMethods.PolarVector(-.1f, projectile.velocity.ToRotation()); projectile.velocity += QwertyMethods.PolarVector(.2f, projectile.rotation); Dust d = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(-8, projectile.rotation) + QwertyMethods.PolarVector(12, projectile.rotation + (float)Math.PI / 2), 6); d.noGravity = true; d.noLight = true; d = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(-8, projectile.rotation) + QwertyMethods.PolarVector(-12, projectile.rotation + (float)Math.PI / 2), 6); d.noGravity = true; d.noLight = true; }
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()); } } } }
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() { projectile.frameCounter++; if (projectile.frameCounter % 30 == 0) { projectile.frame++; if (projectile.frame >= 2) { projectile.frame = 0; } } timer++; if (timer > 30) { //Player player = Main.player[projectile.owner]; if (Main.netMode != 1) { for (int i = 0; i < 255; i++) { if (Main.player[i].active && (projectile.Center - Main.player[i].Center).Length() < closest) { closest = (projectile.Center - Main.player[i].Center).Length(); projectile.ai[0] = (Main.player[i].Center - projectile.Center).ToRotation(); projectile.netUpdate = true; } } } projectile.velocity += new Vector2((float)Math.Cos(projectile.ai[0]) * missileAcceleration, (float)Math.Sin(projectile.ai[0]) * missileAcceleration); if (projectile.velocity.Length() > topSpeed) { projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY) * 10; } } //int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("AncientGlow"), 0, 0, 0, default(Color), .4f); Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(26, projectile.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(Main.rand.Next(-6, 6), projectile.rotation), mod.DustType("AncientGlow")); closest = 10000; }
public override void AI() { Player player = Main.player[projectile.owner]; projectile.width = 150; projectile.height = 150; Main.PlaySound(SoundID.Item62, projectile.position); for (int i = 0; i < 400; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(Main.rand.Next(2, 20), theta)); dust.noGravity = true; } }
public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { if (player.itemAnimation < player.itemAnimationMax - 5) { player.itemAnimation = 0; useCounter = 10; if (player.GetModPlayer <QwertyPlayer>().throwReduction > Main.rand.NextFloat()) { item.stack--; } float swordLength = item.Size.Length() * item.scale; float r = player.direction == 1 ? player.itemRotation - (float)Math.PI / 4 : player.itemRotation + 5 * (float)Math.PI / 4; if (player.gravDir == -1) { r += MathHelper.PiOver2 * player.direction; } for (int p = 0; p < 20; p++) { float distance = Main.rand.NextFloat(swordLength); Projectile g = Main.projectile[Projectile.NewProjectile(player.MountedCenter + new Vector2((float)Math.Cos(r), (float)Math.Sin(r)) * distance, QwertyMethods.PolarVector(8, Main.rand.NextFloat(-1, 1) * (float)Math.PI), mod.ProjectileType("GlassBulletShard"), (int)(item.damage * .7f), item.knockBack, player.whoAmI)]; g.thrown = true; g.ranged = false; } } }
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { Rectangle mF = new Rectangle(0, missileGlowFrame * 36, 20, 36); /* * spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMachineEquipedMissile"), new Vector2(npc.Center.X - Main.screenPosition.X, npc.Center.Y - Main.screenPosition.Y), * new Rectangle(missileGlowFrame * 392, missileFrame*380, 392, 380), drawColor, npc.rotation, * new Vector2(npc.width * 0.5f, npc.height * 0.5f), 1f, SpriteEffects.None, 0f); * spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMachineEquipedMissile_Glow"), new Vector2(npc.Center.X - Main.screenPosition.X, npc.Center.Y - Main.screenPosition.Y), * new Rectangle(missileGlowFrame * 392, missileFrame * 380, 392, 380), Color.White, npc.rotation, * new Vector2(npc.width * 0.5f, npc.height * 0.5f), 1f, SpriteEffects.None, 0f);*/ spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMissile"), npc.Center - Main.screenPosition + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(MissileOffset.Y, npc.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(-missileReloadCounter / 2, npc.rotation + angle), mF, drawColor, npc.rotation + (float)Math.PI / 2 + angle, new Vector2(mF.Width * 0.5f, mF.Height * 0.5f), 1f, SpriteEffects.None, 0f); spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMissile"), npc.Center - Main.screenPosition + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(-MissileOffset.Y, npc.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(-missileReloadCounter / 2, npc.rotation - angle), mF, drawColor, npc.rotation + (float)Math.PI / 2 - angle, new Vector2(mF.Width * 0.5f, mF.Height * 0.5f), 1f, SpriteEffects.None, 0f); spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMissile_Glow"), npc.Center - Main.screenPosition + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(MissileOffset.Y, npc.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(-missileReloadCounter / 2, npc.rotation + angle), mF, Color.White, npc.rotation + (float)Math.PI / 2 + angle, new Vector2(mF.Width * 0.5f, mF.Height * 0.5f), 1f, SpriteEffects.None, 0f); spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMissile_Glow"), npc.Center - Main.screenPosition + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(-MissileOffset.Y, npc.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(-missileReloadCounter / 2, npc.rotation - angle), mF, Color.White, npc.rotation + (float)Math.PI / 2 - angle, new Vector2(mF.Width * 0.5f, mF.Height * 0.5f), 1f, SpriteEffects.None, 0f); spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMachine"), npc.Center - Main.screenPosition, npc.frame, drawColor, npc.rotation, new Vector2(npc.width * 0.5f, npc.height * 0.5f), 1f, SpriteEffects.None, 0f); spriteBatch.Draw(mod.GetTexture("NPCs/AncientMachine/AncientMachine_Glow"), npc.Center - Main.screenPosition, npc.frame, Color.White, npc.rotation, new Vector2(npc.width * 0.5f, npc.height * 0.5f), 1f, SpriteEffects.None, 0f); return(false); }
public override void AI() { npc.TargetClosest(false); Player player = Main.player[npc.target]; BladeStart = npc.Center + QwertyMethods.PolarVector(HiltLength / 2, npc.rotation + (float)Math.PI / 2); BladeTip = npc.Center + QwertyMethods.PolarVector((HiltLength / 2) + BladeLength, npc.rotation + (float)Math.PI / 2); if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead) { npc.velocity = new Vector2(0f, -40f); if (npc.timeLeft > 10) { npc.timeLeft = 10; } activeCheck = true; return; } } else { activeCheck = false; timer++; //Dust.NewDustPerfect(BladeStart + QwertyMethods.PolarVector(BladeLength / 2, npc.rotation + (float)Math.PI / 2), DustID.Fire); //npc.rotation = npc.velocity.ToRotation(); if (npc.ai[3] == 0) { if (npc.ai[2] < 6) { if (!rocketMode) { npc.rotation = QwertyMethods.SlowRotation(npc.rotation, npc.velocity.ToRotation(), 4); } if (timer == 1) { finishSwing = false; toHitSpot2 = false; rocketMode = false; thrust = false; preSwingPlayerDirection = (npc.Center - player.Center).ToRotation(); preSwingPlayerDistance = (player.Center - npc.Center).Length(); directionOfAcceleration = preSwingPlayerDirection + (float)Math.PI / 4; hitSpot = QwertyMethods.PolarVector(BladeLength, preSwingPlayerDirection) + player.Center; hitSpot2 = QwertyMethods.PolarVector(BladeLength, preSwingPlayerDirection + (float)Math.PI / 2) + player.Center; postSwingSpot = QwertyMethods.PolarVector(1200, preSwingPlayerDirection + (float)Math.PI / 2) + player.Center; npc.rotation = preSwingPlayerDirection + (float)Math.PI; //npc.velocity = QwertyMethods.PolarVector(intialBoost, directionOfAcceleration); //npc.velocity -= QwertyMethods.PolarVector(10, directionOfAcceleration + (float)Math.PI / 2); } //Dust.NewDustPerfect(hitSpot, DustID.Fire); //Dust.NewDustPerfect(postSwingSpot, DustID.Fire); //Dust.NewDustPerfect(QwertyMethods.PolarVector(preSwingPlayerDistance, preSwingPlayerDirection) + player.Center, DustID.Fire); if (finishSwing) { npc.velocity = (postSwingSpot - npc.Center) * acceleration; if ((npc.Center - postSwingSpot).Length() < 100 || rocketMode) { if ((npc.Center - player.Center).Length() < 1100) { rocketMode = true; float goTo = ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2); goTo = QwertyMethods.PolarVector(1, goTo).ToRotation(); npc.rotation = QwertyMethods.PolarVector(1, npc.rotation).ToRotation(); if (Math.Abs(npc.rotation - goTo) < MathHelper.ToRadians(8) || thrust) { thrust = true; npc.velocity = QwertyMethods.PolarVector(25, npc.rotation + (float)Math.PI / 2); } else { npc.rotation = QwertyMethods.SlowRotation(npc.rotation, goTo, 4); //Main.NewText(MathHelper.ToDegrees(Math.Abs(npc.rotation - ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2)))); //Main.NewText(npc.rotation + ", " + goTo); } } else { finishSwing = false; timer = 0; } } } else if (toHitSpot2) { npc.velocity = (hitSpot2 - npc.Center) * acceleration; if ((npc.Center - hitSpot2).Length() < 100) { if (Main.netMode != 1) { finishSwing = true; npc.netUpdate = true; } npc.ai[2]++; } } else { npc.velocity = (hitSpot - npc.Center) * acceleration; if ((npc.Center - hitSpot).Length() < 100) { toHitSpot2 = true; } } if (npc.velocity.Length() > maxSpeed && !thrust) { npc.velocity = npc.velocity.SafeNormalize(-Vector2.UnitY) * maxSpeed; } } else { if (Main.netMode != 1) { npc.ai[2] = 0; npc.ai[3] = Main.rand.Next(attackCount - 1); if (npc.ai[3] >= 0) { npc.ai[3]++; } npc.netUpdate = true; } } } else if (npc.ai[3] == 1) { if (attack2Timer == 0) { preSwingPlayerDirection = (npc.Center - player.Center).ToRotation(); rotationSpeed = ((float)Math.PI / 1000) * 15f; } hitSpot = QwertyMethods.PolarVector(BladeLength / 2, preSwingPlayerDirection) + player.Center; if (attack2Timer < 60) { npc.rotation = preSwingPlayerDirection - (float)Math.PI / 2; rotationSpeed = ((float)Math.PI / 1000) * 15f; } else { npc.rotation += rotationSpeed * rotationDirection; } if (attack2Timer > 600) { npc.velocity = ((hitSpot + QwertyMethods.PolarVector(1000, -preSwingPlayerDirection)) - npc.Center) * acceleration; if (attack2Timer > 620) { attack2Timer = 0; if (Main.netMode != 1) { npc.ai[3] = Main.rand.Next(attackCount - 1); if (npc.ai[3] >= 1) { npc.ai[3]++; } npc.netUpdate = true; } } } else { npc.velocity = (hitSpot - npc.Center) * acceleration; } attack2Timer++; } else if (npc.ai[3] == 2) { //Main.NewText(attack3Timer); if (attack3Counter < 8) { if (attack3Timer == 0) { if (Main.netMode != 1) { npc.Center = QwertyMethods.PolarVector(1200, Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI)) + player.Center; preSwingPlayerDirection = (npc.Center - player.Center).ToRotation(); npc.rotation = preSwingPlayerDirection + (float)Math.PI / 2; npc.netUpdate = true; if (attack3Counter == 2 || attack3Counter == 5) { Vector2 Spawn = QwertyMethods.PolarVector(300, npc.rotation - (float)Math.PI / 2) + npc.Center; Spawn.Y += 168; NPC.NewNPC((int)Spawn.X, (int)Spawn.Y, mod.NPCType("BladeMinion"), ai0: npc.rotation); } } } else { npc.rotation = preSwingPlayerDirection + (float)Math.PI / 2; npc.velocity = QwertyMethods.PolarVector(20, npc.rotation + (float)Math.PI / 2); /* * float goTo = ((npc.Center - player.Center).ToRotation() + (float)Math.PI / 2); * goTo = QwertyMethods.PolarVector(1, goTo).ToRotation(); * npc.rotation = QwertyMethods.PolarVector(1, npc.rotation).ToRotation(); * Main.NewText(Math.Abs(npc.rotation - goTo) > (float)Math.PI / 2); */ } attack3Timer++; if ((npc.Center - player.Center).Length() > 1300) { attack3Timer = 0; attack3Counter++; } } else { if (Main.netMode != 1) { npc.Center = QwertyMethods.PolarVector(1200, Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI)) + player.Center; preSwingPlayerDirection = (npc.Center - player.Center).ToRotation(); npc.netUpdate = true; } attack3Counter = 0; if (Main.netMode != 1) { npc.ai[3] = Main.rand.Next(attackCount - 1); if (npc.ai[3] >= 2) { npc.ai[3]++; } npc.netUpdate = true; } } } /* * if (Main.netMode == 1) * { * Main.NewText("client: " + npc.Center); * } * * * if (Main.netMode == 2) // Server * { * NetMessage.BroadcastChatMessage(Terraria.Localization.NetworkText.FromLiteral("Server: " + npc.Center), Color.Black); * } */ } }
public override void OnHitByItem(Player player, Item item, int damage, float knockback, bool crit) { if (Main.netMode == 0) { npc.width = 698; npc.height = 698; npc.position -= CollisionOffset; } if (npc.ai[3] == 1) { float c = 0; if (Collision.CheckAABBvLineCollision(player.position, player.Size, BladeStart + QwertyMethods.PolarVector(BladeLength / 2, npc.rotation + (float)Math.PI / 2), BladeStart + QwertyMethods.PolarVector(BladeLength / 2, npc.rotation + (float)Math.PI / 2) + -rotationDirection * QwertyMethods.PolarVector(300, npc.rotation), BladeLength, ref c)) { if (rotationSpeed < (float)Math.PI / 1000f * 35) { rotationSpeed += (float)Math.PI / 1000f * 5; } rotationDirection *= -1; } } }
public override void AI() { npc.GetGlobalNPC <FortressNPCGeneral>().fortressNPC = true; if (runOnce) { switch (Main.rand.Next(3)) { case 0: spawnChildren = true; break; case 1: Point origin = npc.Center.ToTileCoordinates(); Point point; for (int s = 0; s < 200; s++) { if (npc.Top.ToTileCoordinates().X - 10 < 0) { break; } if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Up(2), new GenCondition[] { new Conditions.IsSolid() }), out point)) { npc.position.Y--; origin = npc.Center.ToTileCoordinates(); } else { flipped = true; break; } } break; } if (!flipped) { Point origin = npc.Center.ToTileCoordinates(); Point point; while (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(4), new GenCondition[] { new Conditions.IsSolid() }), out point)) { npc.position.Y++; origin = npc.Center.ToTileCoordinates(); } } runOnce = false; } if (preSetTimer > 0) { preSetTimer--; npc.dontTakeDamage = true; npc.velocity = Vector2.Zero; float d = Main.rand.NextFloat() * (float)Math.PI * 2; Dust dusty = Dust.NewDustPerfect(npc.position + new Vector2(Main.rand.Next(npc.width), Main.rand.Next(npc.height)) + QwertyMethods.PolarVector(30f, d + (float)Math.PI), mod.DustType("FortressDust"), QwertyMethods.PolarVector(3f, d), Scale: .5f); dusty.noGravity = true; if (preSetTimer == 0 && spawnChildren) { int children = Main.rand.Next(3); for (int i = 0; i < children; i++) { NPC.NewNPC((int)npc.Center.X + Main.rand.Next(-40, 41), (int)npc.Center.Y, mod.NPCType("YoungTile")); } } } else { if (frame == 0) { npc.dontTakeDamage = true; } else { npc.dontTakeDamage = false; } if (flipped) { gravity = 0f; npc.rotation = (float)Math.PI; Player player = Main.player[npc.target]; npc.TargetClosest(true); if (Collision.CheckAABBvLineCollision(player.position, player.Size, npc.Center, npc.Center + new Vector2(0, 1000)) && Collision.CanHit(npc.Center, 0, 0, player.Center, 0, 0)) { flipped = false; timer = 63; jump = true; npc.velocity.Y = 9; } } else { npc.rotation = 0f; gravity = .3f; float worldSizeModifier = (float)(Main.maxTilesX / 4200); worldSizeModifier *= worldSizeModifier; //small =1 //medium =2.25 //large =4 float num2 = (float)((double)(npc.position.Y / 16f - (60f + 10f * worldSizeModifier)) / (Main.worldSurface / 6.0)); if ((double)num2 < 0.25) { num2 = 0.25f; } if (num2 > 1f) { num2 = 1f; } gravity *= num2; jumpSpeedY = gravity * -35; //Main.NewText("gravity: " +gravity); //Main.NewText("jump: " +jumpSpeedY); Player player = Main.player[npc.target]; npc.TargetClosest(true); //Main.NewText(Math.Abs(player.Center.X - npc.Center.X)); if (Math.Abs(player.Center.X - npc.Center.X) < aggroDistance && Math.Abs(player.Bottom.Y - npc.Bottom.Y) < aggroDistanceY) { jumpSpeedX = Math.Abs(player.Center.X - npc.Center.X) / 70 * (npc.confused ? -1 : 1); timer++; if (timer > 30) { frame = 3; if (!jump) { if (player.Center.X > npc.Center.X) { npc.velocity.X = jumpSpeedX; npc.velocity.Y = jumpSpeedY; } else { npc.velocity.X = -jumpSpeedX; npc.velocity.Y = jumpSpeedY; } jump = true; } } else if (timer > 20) { frame = 1; } else if (timer > 10) { frame = 2; } else { frame = 1; } } else if (!jump) { frame = 0; timer = 0; } if (npc.collideX) { npc.velocity.X *= -1; } if (timer > 62 && npc.collideY) { npc.velocity.X = 0; npc.velocity.Y = 0; jump = false; timer = 0; } npc.velocity.Y += gravity; } } }
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() { 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 bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D missile = mod.GetTexture("Items/Weapons/MiscSummons/AshMissile"); for (int i = 0; i < missileCounters.Length; i++) { spriteBatch.Draw(missile, projectile.Center + QwertyMethods.PolarVector(2f, projectile.rotation) + QwertyMethods.PolarVector(missileLoadPosition * (float)missileCounters[i] / missileTime * (i == 0 ? 1 : -1), projectile.rotation + (float)Math.PI / 2) - Main.screenPosition, missile.Frame(), lightColor, projectile.rotation, missile.Size() * .5f, 1f, SpriteEffects.None, 0); } return(true); }
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 bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float p = 0; return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), (projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(-13, HeadPos.ToRotation()), (projectile.Center + HeadOffPos) + QwertyMethods.PolarVector(28, HeadPos.ToRotation()), 34, ref p ) || Collision.CheckAABBvAABBCollision(targetHitbox.TopLeft(), targetHitbox.Size(), (projectile.Center + HeadOffPos), new Vector2(1, 1))); }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(); 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 PostUpdateMiscEffects() { if (controlled) { player.noKnockback = true; //player.Hitbox.Height = 30; player.GetModPlayer <ShapeShifterPlayer>().noDraw = true; player.GetModPlayer <ShapeShifterPlayer>().drawTankCannon = true; Mount mount = player.mount; player.GetModPlayer <ShapeShifterPlayer>().morphed = true; player.GetModPlayer <ShapeShifterPlayer>().overrideWidth = 150; //player.height = 30; player.noItems = true; player.statDefense = 40 + player.GetModPlayer <ShapeShifterPlayer>().morphDef; Vector2 shootFrom = player.Top; shootFrom.Y -= 4; float pointAt = (QwertysRandomContent.LocalCursor[player.whoAmI] - shootFrom).ToRotation(); if (QwertysRandomContent.LocalCursor[player.whoAmI].Y > player.Top.Y) { if (QwertysRandomContent.LocalCursor[player.whoAmI].X > player.Top.X) { pointAt = 0; } else { pointAt = (float)Math.PI; } } player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation = QwertyMethods.SlowRotation(player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation, pointAt, 3); //Main.NewText(player.GetModPlayer<ShapeShifterPlayer>(mod).tankCannonRotation); if (player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation > 0) { if (player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation > (float)Math.PI / 2) { player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation = (float)Math.PI; } else { player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation = 0; } } if (shotCooldown > 0) { shotCooldown--; } if (player.whoAmI == Main.myPlayer && Main.mouseLeft && !player.HasBuff(mod.BuffType("MorphSickness")) && shotCooldown == 0) { shotCooldown = 26; Projectile.NewProjectile(shootFrom + QwertyMethods.PolarVector(112, player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation), QwertyMethods.PolarVector(16, player.GetModPlayer <ShapeShifterPlayer>(mod).tankCannonRotation), mod.ProjectileType("TankCannonBallFreindly"), (int)(TankShift.dmg * player.GetModPlayer <ShapeShifterPlayer>().morphDamage), TankShift.kb, player.whoAmI); } if (player.controlJump && player.GetModPlayer <TankComPantsEffects>().effect&& flightTime < 120) { Main.PlaySound(SoundID.Item24, player.position); if (player.velocity.Y > -2) { player.velocity.Y = -2f; flightTime++; } for (int num104 = 0; num104 < 2; num104++) { int type3 = 6; float scale2 = 2.5f; int alpha2 = 100; if (num104 == 0) { int num105 = Dust.NewDust(new Vector2(player.Center.X + ((player.width / 2 - 15) * player.direction), player.position.Y + (float)player.height - 10f), 8, 8, type3, 0f, 0f, alpha2, default(Color), scale2); Main.dust[num105].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); Main.dust[num105].noGravity = true; Main.dust[num105].velocity.Y = Main.dust[num105].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; } else { int num106 = Dust.NewDust(new Vector2(player.Center.X + ((player.width / 2 - 15) * -player.direction), player.position.Y + (float)player.height - 10f), 8, 8, type3, 0f, 0f, alpha2, default(Color), scale2); Main.dust[num106].shader = GameShaders.Armor.GetSecondaryShader(player.cShoe, player); Main.dust[num106].noGravity = true; Main.dust[num106].velocity.Y = Main.dust[num106].velocity.Y * 1f + 2f * player.gravDir - player.velocity.Y * 0.3f; } } } if (player.velocity.Y == 0 && player.oldVelocity.Y == 0) { flightTime = 0; } } }
public override void AI() { Player player = Main.player[projectile.owner]; projectile.frameCounter++; if (projectile.frameCounter % 30 == 0) { projectile.frame++; if (projectile.frame >= 2) { projectile.frame = 0; } } timer++; if (timer > 30) { //Player player = Main.player[projectile.owner]; for (int k = 0; k < 200; k++) { possibleTarget = Main.npc[k]; distance = (possibleTarget.Center - player.Center).Length(); if (distance < maxDistance && possibleTarget.active && !possibleTarget.dontTakeDamage && !possibleTarget.friendly && possibleTarget.lifeMax > 5 && !possibleTarget.immortal && Collision.CanHit(projectile.Center, 0, 0, possibleTarget.Center, 0, 0)) { target = Main.npc[k]; foundTarget = true; maxDistance = (target.Center - player.Center).Length(); } } if (foundTarget) { projectile.velocity += QwertyMethods.PolarVector(missileAcceleration, (target.Center - projectile.Center).ToRotation()); if (projectile.velocity.Length() > topSpeed) { projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY) * topSpeed; } } } //int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("AncientGlow"), 0, 0, 0, default(Color), .4f); Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(26, projectile.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(Main.rand.Next(-6, 6), projectile.rotation), mod.DustType("AncientGlow")); maxDistance = 10000; }
public override void AI() { missileFlashCounter++; if (missileFlashCounter > 60) { missileFlashCounter = 0; } else if (missileFlashCounter > 30) { missileGlowFrame = 1; } else { missileGlowFrame = 0; } if (missileReloadCounter > 0) { missileReloadCounter--; } //Main.NewText(npc.Size); //Main.NewText(npc.scale); if (npc.life < npc.lifeMax / 2 && Main.expertMode) { angry = true; } switchTime = (int)(((float)npc.life / (float)npc.lifeMax) * 60) + 90; Player player = Main.player[npc.target]; npc.TargetClosest(true); if (runOnce) { if (Main.netMode != 1) { npc.ai[0] = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); npc.netUpdate = true; } runOnce = false; moveTo = new Vector2(player.Center.X + (float)Math.Cos(npc.ai[0]) * 700, player.Center.Y + (float)Math.Sin(npc.ai[0]) * 400); } AI_Timer++; AI_Timer2++; if (Main.expertMode) { #region exerpt aggression damage = 20; #endregion } if (!player.active || player.dead) { npc.TargetClosest(false); player = Main.player[npc.target]; if (!player.active || player.dead) { npc.velocity = new Vector2(0f, 10f); if (npc.timeLeft > 10) { npc.timeLeft = 10; } return; } } float targetAngle = new Vector2(player.Center.X - npc.Center.X, player.Center.Y - npc.Center.Y).ToRotation(); npc.rotation = targetAngle; /* * if( AI_Timer<6) * { * Vector2 teleTo = new Vector2(player.Center.X + 400f, player.Center.Y + -400f ); * npc.position = (teleTo); * } */ if (AI_Timer > switchTime) { moveCount++; //Main.NewText(moveCount); for (int i = 0; i < RingDustQty; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(npc.Center + QwertyMethods.PolarVector(RingRadius, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-RingRadius / 10, theta)); dust.noGravity = true; } if (Main.netMode != 1) { npc.ai[0] = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); npc.netUpdate = true; } moveTo = new Vector2(player.Center.X + (float)Math.Cos(npc.ai[0]) * 700, player.Center.Y + (float)Math.Sin(npc.ai[0]) * 400); if (Main.netMode != 1) { npc.ai[2] = moveTo.X; npc.ai[3] = moveTo.Y; npc.netUpdate = true; } justTeleported = true; AI_Timer = 0; AI_Timer2 = 0; } if (moveCount >= 3) { #region special attacks npc.velocity = new Vector2(0, 0); if (AI_Timer == switchTime / 2) { if (Main.netMode != 1) { npc.ai[1] = Main.rand.Next(3); npc.netUpdate = true; /* * NPC.NewNPC((int)(player.Center.X + 565.7f), (int)npc.Center.Y, mod.NPCType("AncientMinion")); * NPC.NewNPC((int)(player.Center.X + -565.7f), (int)npc.Center.Y, mod.NPCType("AncientMinion")); * * if (Main.expertMode) * { * NPC.NewNPC((int)npc.Center.X, (int)(player.Center.Y + -565.7f), mod.NPCType("AncientMinion")); * NPC.NewNPC((int)npc.Center.X, (int)(player.Center.Y + 565.7f), mod.NPCType("AncientMinion")); * } */ } if (npc.ai[1] == 0) { Main.PlaySound(25, npc.position, 0); for (int r = 0; r < 5; r++) { if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos((npc.rotation + r * (float)Math.PI / 8) - (float)Math.PI / 4) * orbSpeed, (float)Math.Sin((npc.rotation + r * (float)Math.PI / 8) - (float)Math.PI / 4) * orbSpeed, mod.ProjectileType("AncientEnergy"), damage, 3f, Main.myPlayer); } } } if (npc.ai[1] == 1) { Main.PlaySound(25, npc.position, 0); missileReloadCounter = 60; if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(MissileOffset.Y, npc.rotation + (float)Math.PI / 2), QwertyMethods.PolarVector(orbSpeed, npc.rotation + angle), mod.ProjectileType("AncientMissile"), damage, 3f, Main.myPlayer); Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(-MissileOffset.Y, npc.rotation + (float)Math.PI / 2), QwertyMethods.PolarVector(orbSpeed, npc.rotation - angle), mod.ProjectileType("AncientMissile"), damage, 3f, Main.myPlayer); } } if (npc.ai[1] == 2) { if (Main.netMode != 1) { float d = new Vector2(player.Center.X - npc.Center.X, player.Center.Y - npc.Center.Y).ToRotation(); Vector2 pos = npc.Center + QwertyMethods.PolarVector(200, npc.rotation) + QwertyMethods.PolarVector(100, npc.rotation + (float)Math.PI / 2); NPC.NewNPC((int)pos.X, (int)pos.Y, mod.NPCType("AncientMinion"), 0, npc.whoAmI); pos = npc.Center + QwertyMethods.PolarVector(200, npc.rotation) + QwertyMethods.PolarVector(-100, npc.rotation + (float)Math.PI / 2); NPC.NewNPC((int)pos.X, (int)pos.Y, mod.NPCType("AncientMinion"), 0, npc.whoAmI); if (angry) { pos = npc.Center + QwertyMethods.PolarVector(100, npc.rotation) + QwertyMethods.PolarVector(-200, npc.rotation + (float)Math.PI / 2); NPC.NewNPC((int)pos.X, (int)pos.Y, mod.NPCType("AncientMinion"), 0, npc.whoAmI); pos = npc.Center + QwertyMethods.PolarVector(100, npc.rotation) + QwertyMethods.PolarVector(200, npc.rotation + (float)Math.PI / 2); NPC.NewNPC((int)pos.X, (int)pos.Y, mod.NPCType("AncientMinion"), 0, npc.whoAmI); } } } } if (AI_Timer == 3 * switchTime / 4) { if (angry) { if (npc.ai[1] == 0) { Main.PlaySound(25, npc.position, 0); for (int r = 0; r < 4; r++) { if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos((npc.rotation + r * (float)Math.PI / 6) - (float)Math.PI / 4) * orbSpeed, (float)Math.Sin((npc.rotation + r * (float)Math.PI / 6) - (float)Math.PI / 4) * orbSpeed, mod.ProjectileType("AncientEnergy"), damage, 3f, Main.myPlayer); } } } if (npc.ai[1] == 1) { Main.PlaySound(25, npc.position, 0); missileReloadCounter = 60; if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(MissileOffset.Y, npc.rotation + (float)Math.PI / 2), QwertyMethods.PolarVector(orbSpeed, npc.rotation + angle), mod.ProjectileType("AncientMissile"), damage, 3f, Main.myPlayer); Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(MissileOffset.X, npc.rotation) + QwertyMethods.PolarVector(-MissileOffset.Y, npc.rotation + (float)Math.PI / 2), QwertyMethods.PolarVector(orbSpeed, npc.rotation - angle), mod.ProjectileType("AncientMissile"), damage, 3f, Main.myPlayer); } } } moveCount = -1; } #endregion } else { if (AI_Timer == switchTime / 2) { Main.PlaySound(25, npc.position, 0); if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center, new Vector2((float)Math.Cos((npc.rotation)), (float)Math.Sin(npc.rotation)) * orbSpeed, mod.ProjectileType("AncientEnergy"), damage, 3f, Main.myPlayer); } } if (AI_Timer == 3 * switchTime / 4 && angry) { Main.PlaySound(25, npc.position, 0); if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center, new Vector2((float)Math.Cos((npc.rotation)), (float)Math.Sin(npc.rotation)) * orbSpeed, mod.ProjectileType("AncientEnergy"), damage, 3f, Main.myPlayer); } } } //npc.velocity = (moveTo - npc.Center) * .02f; npc.Center = new Vector2(npc.ai[2], npc.ai[3]); if (justTeleported) { Main.PlaySound(SoundID.Item8, npc.position); for (int i = 0; i < RingDustQty; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(npc.Center, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(RingRadius / 10, theta)); dust.noGravity = true; } justTeleported = false; } }
public override void AI() { Player player = Main.player[projectile.owner]; QwertyPlayer modPlayer = player.GetModPlayer <QwertyPlayer>(mod); 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 >= 40) { 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); } }
void ADI(int amount, Vector2 position) { for (int i = 0; i < amount; i++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(position, mod.DustType("AncientGlow"), QwertyMethods.PolarVector(Main.rand.Next(amount / 200, amount / 20), theta)); dust.noGravity = true; } }
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 HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { Vector2 pos = npc.Center + QwertyMethods.PolarVector(98, npc.rotation) + QwertyMethods.PolarVector(120, npc.rotation + (float)Math.PI / 2); Gore gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_1"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(98, npc.rotation) + QwertyMethods.PolarVector(120, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_2"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(144, npc.rotation) + QwertyMethods.PolarVector(67, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_3"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(144, npc.rotation) + QwertyMethods.PolarVector(-67, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_4"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(102, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_5"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(-102, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_6"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_7"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-15, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_8"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-154, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_9"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(77, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_10"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(166, npc.rotation) + QwertyMethods.PolarVector(0, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_11"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-65, npc.rotation) + QwertyMethods.PolarVector(79, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_12"), 1f)]; gore.rotation = npc.rotation; pos = npc.Center + QwertyMethods.PolarVector(-65, npc.rotation) + QwertyMethods.PolarVector(-79, npc.rotation + (float)Math.PI / 2); gore = Main.gore[Gore.NewGore(pos, npc.velocity, mod.GetGoreSlot("Gores/Debris_13"), 1f)]; gore.rotation = npc.rotation; } }
public override void PostUpdateMiscEffects() { if (controlled) { player.noFallDmg = true; player.GetModPlayer <ShapeShifterPlayer>().noDraw = true; player.GetModPlayer <ShapeShifterPlayer>().hovercraft = true; Mount mount = player.mount; player.GetModPlayer <ShapeShifterPlayer>().morphed = true; player.GetModPlayer <ShapeShifterPlayer>().overrideWidth = 40; //player.height = 30; player.noItems = true; hoverDrift += (float)Math.PI / 60; player.statDefense = 14 + player.GetModPlayer <ShapeShifterPlayer>().morphDef; if ((player.controlUp || player.controlJump) && hoverHeight < maxHoverHeight) { hoverHeight++; } else if (player.controlDown && hoverHeight > minHoverHeight) { hoverHeight--; } for (; currentHeight < (maxHoverHeight + 10); currentHeight++) { if (!Collision.CanHit(player.Center, 0, 0, player.Center + new Vector2(0, currentHeight), 0, 0)) { break; } } hoverTo = hoverHeight + (float)Math.Sin(hoverDrift) * 16; //player.velocity.Y = ( currentHeight-hoverHeight) * .1f; if (Math.Abs(currentHeight - hoverTo) > hoverSpeed * 4) { if (currentHeight - hoverTo > 0) { player.velocity.Y = hoverSpeed; hoverSpeed = 6f; } if (currentHeight - hoverTo < 0) { player.velocity.Y = -hoverSpeed; hoverSpeed = 6f; } } else { player.velocity.Y = (currentHeight - hoverTo) * .1f; } Vector2 shootFrom = player.Top; shootFrom.Y += 8; float pointAt = (QwertysRandomContent.LocalCursor[player.whoAmI] - shootFrom).ToRotation(); player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation = QwertyMethods.SlowRotation(player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation, pointAt, 3); //Main.NewText(player.GetModPlayer<ShapeShifterPlayer>().tankCannonRotation); if (shotCooldown > 0) { shotCooldown--; } if (player.whoAmI == Main.myPlayer && Main.mouseLeft && !player.HasBuff(mod.BuffType("MorphSickness")) && shotCooldown == 0) { shotCooldown = 12; Projectile p = Main.projectile[Projectile.NewProjectile(shootFrom + QwertyMethods.PolarVector(19, player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation), QwertyMethods.PolarVector(12, player.GetModPlayer <ShapeShifterPlayer>().tankCannonRotation), ProjectileID.GreenLaser, (int)(HovercraftShift.dmg * player.GetModPlayer <ShapeShifterPlayer>().morphDamage), HovercraftShift.kb, player.whoAmI)]; p.magic = false; p.GetGlobalProjectile <MorphProjectile>().morph = true; p.penetrate = 1; p.alpha = 0; if (Main.netMode == 1) { QwertysRandomContent.UpdateProjectileClass(p); } Main.PlaySound(SoundID.Item12, player.Center); } currentHeight = 0; //reset hoverTo = 0; hoverSpeed = 3f; } }
public override void AI() { if (projectile.alpha > 0) { //projectile.alpha -= (int)(255f / 180f); projectile.alpha -= 4; } else { projectile.alpha = 0; } projectile.scale = .5f + (.5f * 1 - (projectile.alpha / 255f)); for (int d = 0; d < projectile.alpha / 30; d++) { float theta = Main.rand.NextFloat(-(float)Math.PI, (float)Math.PI); Dust dust = Dust.NewDustPerfect(projectile.Center + QwertyMethods.PolarVector(25, theta), mod.DustType("AncientGlow"), QwertyMethods.PolarVector(-6, theta) + projectile.velocity); dust.scale = .5f; dust.alpha = 255; } projectile.frameCounter++; if (projectile.frameCounter > 10) { if (projectile.frame == 1) { projectile.frame = 0; } else { projectile.frame = 1; } projectile.frameCounter = 0; } dustTimer++; if (dustTimer > 5) { int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, mod.DustType("AncientGlow"), 0, 0, 0, default(Color), .2f); dustTimer = 0; } }
public override void AI() { Player player = Main.player[projectile.owner]; if (runOnce) { reloadTime = player.inventory[player.selectedItem].useTime; runOnce = false; } projectile.timeLeft = 10; timer++; var modPlayer = player.GetModPlayer <QwertyPlayer>(); bool firing = player.channel && player.HasAmmo(QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol), true) && !player.noItems && !player.CCed; int Ammo = 14; float speed = 14f; int weaponDamage = player.GetWeaponDamage(player.inventory[player.selectedItem]); direction = (Main.MouseWorld - player.Center).ToRotation(); float weaponKnockback = player.inventory[player.selectedItem].knockBack; if (firing) { ///////////////////////////////////// copied from vanilla drill/chainsaw AI Vector2 vector24 = Main.player[projectile.owner].RotatedRelativePoint(Main.player[projectile.owner].MountedCenter, true); if (Main.myPlayer == projectile.owner) { if (Main.player[projectile.owner].channel) { float num264 = Main.player[projectile.owner].inventory[Main.player[projectile.owner].selectedItem].shootSpeed * projectile.scale; Vector2 vector25 = vector24; float num265 = (float)Main.mouseX + Main.screenPosition.X - vector25.X; float num266 = (float)Main.mouseY + Main.screenPosition.Y - vector25.Y; if (Main.player[projectile.owner].gravDir == -1f) { num266 = (float)(Main.screenHeight - Main.mouseY) + Main.screenPosition.Y - vector25.Y; } float num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); num267 = (float)Math.Sqrt((double)(num265 * num265 + num266 * num266)); num267 = num264 / num267; num265 *= num267; num266 *= num267; if (num265 != projectile.velocity.X || num266 != projectile.velocity.Y) { projectile.netUpdate = true; } projectile.velocity.X = num265; projectile.velocity.Y = num266; } else { projectile.Kill(); } } if (projectile.velocity.X > 0f) { Main.player[projectile.owner].ChangeDir(1); } else if (projectile.velocity.X < 0f) { Main.player[projectile.owner].ChangeDir(-1); } projectile.spriteDirection = projectile.direction; Main.player[projectile.owner].ChangeDir(projectile.direction); Main.player[projectile.owner].heldProj = projectile.whoAmI; Main.player[projectile.owner].itemTime = 2; Main.player[projectile.owner].itemAnimation = 2; projectile.position.X = vector24.X - (float)(projectile.width / 2); projectile.position.Y = vector24.Y - (float)(projectile.height / 2); projectile.rotation = (float)(Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.5700000524520874); if (Main.player[projectile.owner].direction == 1) { Main.player[projectile.owner].itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } else { Main.player[projectile.owner].itemRotation = (float)Math.Atan2((double)(projectile.velocity.Y * (float)projectile.direction), (double)(projectile.velocity.X * (float)projectile.direction)); } projectile.velocity.X = projectile.velocity.X * (1f + (float)Main.rand.Next(-3, 4) * 0.01f); if (Main.rand.Next(6) == 0) { int num268 = Dust.NewDust(projectile.position + projectile.velocity * (float)Main.rand.Next(6, 10) * 0.1f, projectile.width, projectile.height, 31, 0f, 0f, 80, default(Color), 1.4f); Dust dust51 = Main.dust[num268]; dust51.position.X = dust51.position.X - 4f; Main.dust[num268].noGravity = true; Dust dust3 = Main.dust[num268]; dust3.velocity *= 0.2f; Main.dust[num268].velocity.Y = -(float)Main.rand.Next(7, 13) * 0.15f; return; } /////////////////////////////// if (!player.HasBuff(mod.BuffType("TrexMountB"))) { player.velocity.X = 0; float VelYOld = player.velocity.Y; player.velocity.Y = (float)Math.Abs(VelYOld); } if (timer >= reloadTime) { VarA = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarB = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarC = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarD = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); VarE = direction + MathHelper.ToRadians(Main.rand.Next(-100, 101) / 10); float shellShift = MathHelper.ToRadians(-50); SVarA = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarB = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarC = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarD = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); SVarE = shellShift + MathHelper.ToRadians(Main.rand.Next(-100, 301) / 10); float SspeedA = .05f * Main.rand.Next(15, 41); float SspeedB = .05f * Main.rand.Next(15, 41); float SspeedC = .05f * Main.rand.Next(15, 41); float SspeedD = .05f * Main.rand.Next(15, 41); float SspeedE = .05f * Main.rand.Next(15, 41); Main.PlaySound(SoundID.Item11, projectile.Center); Item sItem = QwertyMethods.MakeItemFromID(ItemID.FlintlockPistol); sItem.damage = weaponDamage; player.PickAmmo(sItem, ref Ammo, ref speed, ref firing, ref weaponDamage, ref weaponKnockback, Main.rand.Next(0, 2) == 0); if (player.whoAmI == Main.myPlayer) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarA) * speed, (float)Math.Sin(VarA) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarA) * SspeedA * -player.direction, (float)Math.Sin(SVarA) * SspeedA, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); if (reloadTime < 32) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarB) * speed, (float)Math.Sin(VarB) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarB) * SspeedB * -player.direction, (float)Math.Sin(SVarB) * SspeedB, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } if (reloadTime < 28) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarC) * speed, (float)Math.Sin(VarC) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarC) * SspeedC * -player.direction, (float)Math.Sin(SVarC) * SspeedC, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } if (reloadTime < 24) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarD) * speed, (float)Math.Sin(VarD) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarD) * SspeedD * -player.direction, (float)Math.Sin(SVarD) * SspeedD, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } if (reloadTime < 20) { Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(VarE) * speed, (float)Math.Sin(VarE) * speed, Ammo, weaponDamage, weaponKnockback, Main.myPlayer); Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)Math.Cos(SVarE) * SspeedE * -player.direction, (float)Math.Sin(SVarE) * SspeedE, mod.ProjectileType("Shell"), 0, 0, Main.myPlayer); } } if (reloadTime > 3) { reloadTime -= 1; } timer = 0; } } else { modPlayer.usingVulcan = false; reloadTime = player.inventory[player.selectedItem].useTime; projectile.Kill(); } }
public override void AI() { if (Main.expertMode) { projDamge = npc.damage / 4; } else { projDamge = npc.damage / 2; } npc.TargetClosest(true); Player player = Main.player[npc.target]; if (runOnce) { if (npc.ai[0] == 0) { npc.ai[0] = -1; } runOnce = false; } if (npc.ai[0] == -1) { for (int n = 0; n < 200; n++) { if (Main.npc[n].type == mod.NPCType("Hydra")) { npc.ai[0] = n; break; } } } if (npc.ai[0] != -1 || Main.npc[(int)npc.ai[0]].type != mod.NPCType("Hydra")) { Body = Main.npc[(int)npc.ai[0]]; int headCount = 0; int whichHeadAmI = 0; for (int n = 0; n < 200; n++) { if (Main.npc[n].type == mod.NPCType("HydraHead") && Main.npc[n].active && Main.npc[n].ai[0] == npc.ai[0]) { if (Main.npc[n].Center.X < npc.Center.X || (Main.npc[n].Center.X == npc.Center.X && n < npc.whoAmI)) { whichHeadAmI++; } headCount++; } } float rotationOffset = (headSpread * (((float)whichHeadAmI + 1) / ((float)headCount + 1))) - headSpread / 2f; Vector2 offSet = QwertyMethods.PolarVector(400, -(float)Math.PI / 2 + rotationOffset); offSet.X *= 1.5f; flyTo = Body.Center + offSet; npc.velocity = (flyTo - npc.Center) * .1f; if (attacking && attackTimer == 0) { if (beamAttack) { laser.Kill(); laser = null; } if (Main.netMode != 1) { if (!beamAttack) { Projectile.NewProjectile(npc.Center + QwertyMethods.PolarVector(50, npc.rotation), QwertyMethods.PolarVector(5, npc.rotation), mod.ProjectileType("HydraBreath"), projDamge, 0f, Main.myPlayer); } } attacking = false; beamAttack = false; } if (attackTimer < 60) { attackTimer++; } else { if (Main.rand.Next(20) == 0 && Main.netMode != 1) { attacking = true; if (Main.rand.NextFloat(10) < Math.Abs(player.velocity.X) && ((npc.Center.X > player.Center.X && player.velocity.X > 0) || (npc.Center.X < player.Center.X && player.velocity.X < 0))) { beamAttack = true; attackTimer = -beamTime; rotateTo = (float)Math.PI / 2; } else { rotateTo = (player.Center - npc.Center).ToRotation() + (Main.rand.NextFloat(1, -1) * (float)Math.PI / 8); attackTimer = -shotWarming; } npc.netUpdate = true; } } if (beamAttack) { if (attackTimer < -beamTime / 2) { float dir = npc.rotation + Main.rand.NextFloat(-1, 1) * (float)Math.PI / 4; Dust.NewDustPerfect(npc.Center + QwertyMethods.PolarVector(50, npc.rotation), mod.DustType("HydraBeamGlow"), QwertyMethods.PolarVector(6, dir)); } else if (attackTimer == -beamTime / 2) { laser = Main.projectile[Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, mod.ProjectileType("HydraBeamT"), (int)(projDamge * 1.5f), 3f, Main.myPlayer, npc.whoAmI, 420)]; } else { npc.velocity = Vector2.Zero; } } if (!attacking) { rotateTo = (player.Center - npc.Center).ToRotation(); if (laser != null) { if (laser.active) { laser.Kill(); laser = null; } } } npc.rotation = QwertyMethods.SlowRotation(npc.rotation, rotateTo, 4); if (!Body.active || Body.type != mod.NPCType("Hydra")) { npc.life = 0; npc.checkDead(); } if (Body.dontTakeDamage) { attacking = false; beamAttack = false; } } else { npc.life = 0; npc.checkDead(); } }
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 bool?Colliding(Rectangle projHitbox, Rectangle targetHitbox) { float point = 0f; return(Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + QwertyMethods.PolarVector(bladeLength, projectile.rotation), 14f, ref point) || Collision.CheckAABBvAABBCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projHitbox.TopLeft(), projHitbox.Size())); }
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { orbitalCounter += (float)Math.PI / 60; if (Math.Cos(orbitalCounter) > 0) { Vector2 orbitalLocation = projectile.Center + QwertyMethods.PolarVector(lengthDown, projectile.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(orbitRadius * (float)Math.Sin(orbitalCounter), projectile.rotation); drawOrbital(spriteBatch, drawColor, orbitalLocation); drawArrowCore(spriteBatch, drawColor); orbitalLocation = projectile.Center + QwertyMethods.PolarVector(lengthDown, projectile.rotation + (float)Math.PI / 2) - QwertyMethods.PolarVector(orbitRadius * (float)Math.Sin(orbitalCounter), projectile.rotation); drawOrbital(spriteBatch, drawColor, orbitalLocation); } else { Vector2 orbitalLocation = projectile.Center + QwertyMethods.PolarVector(lengthDown, projectile.rotation + (float)Math.PI / 2) - QwertyMethods.PolarVector(orbitRadius * (float)Math.Sin(orbitalCounter), projectile.rotation); drawOrbital(spriteBatch, drawColor, orbitalLocation); drawArrowCore(spriteBatch, drawColor); orbitalLocation = projectile.Center + QwertyMethods.PolarVector(lengthDown, projectile.rotation + (float)Math.PI / 2) + QwertyMethods.PolarVector(orbitRadius * (float)Math.Sin(orbitalCounter), projectile.rotation); drawOrbital(spriteBatch, drawColor, orbitalLocation); } return(false); }