From c9083a6d37cf7949f14d2c044d3794ca293dbf0d Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Tue, 23 Jan 2024 04:57:44 -0600 Subject: [PATCH] Rev+ Queen Bee madness --- NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs | 365 ++++++++---------- Projectiles/CalamityGlobalProjectile.cs | 233 +++++------ 2 files changed, 272 insertions(+), 326 deletions(-) diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs index 1a5f067d3a..80dbf4c190 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs @@ -87,20 +87,23 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Phases // Become more aggressive and start firing double stingers (triple in death mode) phase - bool phase2 = lifeRatio < 0.8f; + bool phase2 = lifeRatio < 0.85f; - // Begin launching beehives instead of bees phase, spawn hornets in death mode - bool phase3 = lifeRatio < 0.6f; + // Begin launching beehives instead of bees phase + bool phase3 = lifeRatio < 0.7f; - // Stop spawning bees from ass, spawn bees while charging and become more aggressive phase - bool phase4 = lifeRatio < 0.3f; + // Stop spawning bees from ass and start performing stinger arcs + diagonal dashes, spawn bees while charging and become more aggressive phase + bool phase4 = lifeRatio < 0.5f; + + // Perform many shorter-range dashes and use stinger arc in two possible directions phase + bool phase5 = lifeRatio < 0.3f; // Triple stinger (quintuple in death mode) bombardment phase - bool phase5 = lifeRatio < 0.1f; + bool phase6 = lifeRatio < 0.1f; // Despawn float distanceFromTarget = Vector2.Distance(npc.Center, Main.player[npc.target].Center); - if (npc.ai[0] != 5f) + if (npc.ai[0] != 6f) { if (npc.timeLeft < 60) npc.timeLeft = 60; @@ -108,7 +111,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[0] = 4f; } if (Main.player[npc.target].dead) - npc.ai[0] = 5f; + npc.ai[0] = 6f; // Adjust slowing debuff immunity bool immuneToSlowingDebuffs = npc.ai[0] == 0f; @@ -132,7 +135,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Despawn phase - if (npc.ai[0] == 5f) + if (npc.ai[0] == 6f) { // Avoid cheap bullshit npc.damage = 0; @@ -175,13 +178,18 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { int phase; - do phase = Main.rand.Next(4); + int maxRandom = phase4 ? 5 : 4; + do phase = Main.rand.Next(maxRandom); while (phase == npc.ai[1] || phase == 1 || (phase == 2 && phase4)); + // 5 is stinger arc and charge + if (phase == 4) + phase = 5; + npc.TargetClosest(); npc.ai[0] = phase; npc.ai[1] = 0f; - npc.ai[2] = 0f; + npc.ai[2] = (phase == 5 && phase5) ? (Main.rand.NextBool() ? 1f : -1f) : phase == 5 ? 1f : 0f; } } @@ -189,17 +197,11 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses else if (npc.ai[0] == 0f) { // Charging distance from player - int chargeDistanceX = 450; - if (phase4) - chargeDistanceX = 650; - else if (phase2) - chargeDistanceX = 550; + int chargeDistanceX = phase6 ? 750 : phase5 ? 350 : phase4 ? 650 : phase2 ? 550 : 450; chargeDistanceX -= (int)(100f * enrageScale); // Number of charges - int chargeAmt = (int)Math.Ceiling(2f + enrageScale); - if (phase4) - chargeAmt++; + int chargeAmt = (int)Math.Ceiling((phase6 ? 2f : phase5 ? 4f : phase4 ? 3f : 2f) + enrageScale); // Switch to a random phase if chargeAmt has been exceeded if (npc.ai[1] > (2 * chargeAmt) && npc.ai[1] % 2f == 0f) @@ -212,13 +214,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Charge velocity - float speed = 16f; - if (phase2) - speed += 8f; - if (phase4) - speed += 8f; - - speed += 8f * enrageScale; + float speed = (phase6 ? 30f : phase5 ? 14f : phase4 ? 25f : phase2 ? 20f : 15f) + 8f * enrageScale; // Line up and initiate charge if (npc.ai[1] % 2f == 0f) @@ -227,13 +223,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.damage = 0; // Initiate charge - float chargeDistanceY = 20f; - chargeDistanceY += 20f * enrageScale; + float chargeDistanceY = phase6 ? 100f : phase4 ? 50f : 20f; + chargeDistanceY += 50f * enrageScale; if (death) chargeDistanceY += MathHelper.Lerp(0f, 100f, 1f - lifeRatio); - float distanceFromTargetX = Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))); - float distanceFromTargetY = Math.Abs(npc.position.Y + (npc.height / 2) - (Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2))); + float distanceFromTargetX = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); + float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y); if (distanceFromTargetY < chargeDistanceY && distanceFromTargetX >= chargeDistanceX) { // Set damage @@ -245,9 +241,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[2] = 0f; // Get target location - Vector2 beeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float targetXDist = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - beeLocation.X; - float targetYDist = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - beeLocation.Y; + Vector2 beeLocation = npc.Center; + float targetXDist = Main.player[npc.target].Center.X - beeLocation.X; + float targetYDist = Main.player[npc.target].Center.Y - beeLocation.Y; float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); targetDistance = speed / targetDistance; npc.velocity.X = targetXDist * targetDistance; @@ -266,22 +262,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Velocity variables npc.localAI[0] = 0f; float chargeVelocity = 12f; - float chargeAcceleration = 0.15f; + float chargeAcceleration = 0.2f; if (phase2) { chargeVelocity += 3f; - chargeAcceleration += 0.125f; + chargeAcceleration += 0.1f; } if (phase4) { chargeVelocity += 3f; - chargeAcceleration += 0.125f; + chargeAcceleration += 0.1f; } chargeVelocity += 3f * enrageScale; chargeAcceleration += 0.5f * enrageScale; // Velocity calculations - if (npc.position.Y + (npc.height / 2) < Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2)) + if (npc.Center.Y < Main.player[npc.target].Center.Y) npc.velocity.Y += chargeAcceleration; else npc.velocity.Y -= chargeAcceleration; @@ -293,7 +289,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (distanceFromTargetX > chargeDistanceX + 100f) npc.velocity.X += chargeAcceleration * 2f * npc.direction; - else if (distanceFromTargetX < chargeDistanceX) + else if (distanceFromTargetX < chargeDistanceX + 20f) npc.velocity.X -= chargeAcceleration * 2f * npc.direction; else npc.velocity.X *= 0.8f; @@ -329,12 +325,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Get which side of the player the boss is on int chargeDirection = 1; - if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + (Main.player[npc.target].width / 2)) + if (npc.Center.X < Main.player[npc.target].Center.X) chargeDirection = -1; // If boss is in correct position, slow down, if not, reset bool shouldCharge = false; - if (npc.direction == chargeDirection && Math.Abs(npc.position.X + (npc.width / 2) - (Main.player[npc.target].position.X + (Main.player[npc.target].width / 2))) > chargeDistanceX) + if (npc.direction == chargeDirection && Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) > chargeDistanceX) { npc.ai[2] = 1f; shouldCharge = true; @@ -355,7 +351,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.velocity.X = speed * npc.direction; calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] > 90f) + if (calamityGlobalNPC.newAI[0] > (phase5 ? 9f : 90f)) { npc.SyncExtraAI(); npc.velocity.X *= 1.01f; @@ -442,22 +438,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; + // Direction float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; // Get target location - float beeAttackAccel = death ? 0.2f : 0.15f; - Vector2 beeAttackPosition = npc.Center; - bool canHitTarget = Collision.CanHit(beeAttackPosition, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + float beeAttackAccel = death ? 0.3f : 0.24f; + float beeAttackSpeed = 12f + enrageScale * 3f; + bool canHitTarget = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); float distanceAboveTarget = !canHitTarget ? 0f : 320f; - float beeAttackTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - beeAttackPosition.X; - float beeAttackTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - distanceAboveTarget - beeAttackPosition.Y; - float beeAttackTargetDist = (float)Math.Sqrt(beeAttackTargetX * beeAttackTargetX + beeAttackTargetY * beeAttackTargetY); + Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * distanceAboveTarget; + Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * beeAttackSpeed; // Go to bee spawn phase calamityGlobalNPC.newAI[0] += 1f; - if ((beeAttackTargetDist < 400f && canHitTarget) || calamityGlobalNPC.newAI[0] >= 180f) + if ((Vector2.Distance(npc.Center, hoverDestination) < 400f && canHitTarget) || calamityGlobalNPC.newAI[0] >= 180f) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -467,31 +463,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses return false; } - // Velocity calculations - if (npc.velocity.X < beeAttackTargetX) - { - npc.velocity.X += beeAttackAccel; - if (npc.velocity.X < 0f && beeAttackTargetX > 0f) - npc.velocity.X += beeAttackAccel; - } - else if (npc.velocity.X > beeAttackTargetX) - { - npc.velocity.X -= beeAttackAccel; - if (npc.velocity.X > 0f && beeAttackTargetX < 0f) - npc.velocity.X -= beeAttackAccel; - } - if (npc.velocity.Y < beeAttackTargetY) - { - npc.velocity.Y += beeAttackAccel; - if (npc.velocity.Y < 0f && beeAttackTargetY > 0f) - npc.velocity.Y += beeAttackAccel; - } - else if (npc.velocity.Y > beeAttackTargetY) - { - npc.velocity.Y -= beeAttackAccel; - if (npc.velocity.Y > 0f && beeAttackTargetY < 0f) - npc.velocity.Y -= beeAttackAccel; - } + npc.SimpleFlyMovement(idealVelocity, beeAttackAccel); } // Bee spawn phase @@ -503,11 +475,13 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.localAI[0] = 0f; // Get target location and spawn bees from ass - Vector2 beeSpawnLocation = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - Vector2 queenBeeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float beeSpawnTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - queenBeeLocation.X; - float beeSpawnTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - queenBeeLocation.Y; - float beeSpawnTargetDist = (float)Math.Sqrt(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY); + float beeAttackHoverSpeed = 16f + enrageScale * 4f; + float beeAttackHoverAccel = death ? 0.4f : 0.3f; + Vector2 beeSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + Vector2 beeSpawnCollisionLocation = new Vector2(beeSpawnLocation.X, beeSpawnLocation.Y - 30f); + bool canHitTarget = Collision.CanHit(beeSpawnCollisionLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : 320f); + Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * beeAttackHoverSpeed; // Bee spawn timer npc.ai[1] += 1f; @@ -522,7 +496,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.ai[1] += 1f; bool spawnBee = false; - float beeSpawnCheck = (phase3 ? 60f : 15f) - (phase3 ? 24f : 6f) * enrageScale; + float beeSpawnCheck = (phase3 ? 45f : 15f) - (phase3 ? 18f : 6f) * enrageScale; if (npc.ai[1] > beeSpawnCheck) { npc.ai[1] = 0f; @@ -543,19 +517,6 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (phase3 && !Main.zenithWorld) { Projectile.NewProjectile(npc.GetSource_FromAI(), beeSpawnLocation, (Main.player[npc.target].Center - beeSpawnLocation).SafeNormalize(Vector2.UnitY), ProjectileID.BeeHive, 0, 0f, Main.myPlayer, 0f, 0f, 1f); - - if (death) - { - int spawnType = Main.rand.Next(NPCID.Bee, NPCID.BeeSmall + 1); - int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)beeSpawnLocation.X, (int)beeSpawnLocation.Y, spawnType); - Main.npc[spawn].velocity = Main.player[npc.target].Center - npc.Center; - Main.npc[spawn].velocity.Normalize(); - Main.npc[spawn].velocity *= 5f; - Main.npc[spawn].ai[2] = enrageScale; - Main.npc[spawn].ai[3] = 1f; - Main.npc[spawn].localAI[0] = 60f; - Main.npc[spawn].netUpdate = true; - } } else { @@ -584,43 +545,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Velocity calculations if target is too far away - if (beeSpawnTargetDist > 400f || !Collision.CanHit(new Vector2(beeSpawnLocation.X, beeSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - float beeAttackHoverSpeed = death ? 17.5f : 14f; - float beeAttackHoverAccel = death ? 0.2f : 0.15f; - queenBeeLocation = beeSpawnLocation; - beeSpawnTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - queenBeeLocation.X; - beeSpawnTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - queenBeeLocation.Y; - beeSpawnTargetDist = (float)Math.Sqrt(beeSpawnTargetX * beeSpawnTargetX + beeSpawnTargetY * beeSpawnTargetY); - beeSpawnTargetDist = beeAttackHoverSpeed / beeSpawnTargetDist; - - if (npc.velocity.X < beeSpawnTargetX) - { - npc.velocity.X += beeAttackHoverAccel; - if (npc.velocity.X < 0f && beeSpawnTargetX > 0f) - npc.velocity.X += beeAttackHoverAccel; - } - else if (npc.velocity.X > beeSpawnTargetX) - { - npc.velocity.X -= beeAttackHoverAccel; - if (npc.velocity.X > 0f && beeSpawnTargetX < 0f) - npc.velocity.X -= beeAttackHoverAccel; - } - if (npc.velocity.Y < beeSpawnTargetY) - { - npc.velocity.Y += beeAttackHoverAccel; - if (npc.velocity.Y < 0f && beeSpawnTargetY > 0f) - npc.velocity.Y += beeAttackHoverAccel; - } - else if (npc.velocity.Y > beeSpawnTargetY) - { - npc.velocity.Y -= beeAttackHoverAccel; - if (npc.velocity.Y > 0f && beeSpawnTargetY < 0f) - npc.velocity.Y -= beeAttackHoverAccel; - } - } + if (Vector2.Distance(beeSpawnLocation, hoverDestination) > 400f || !canHitTarget) + npc.SimpleFlyMovement(idealVelocity, beeAttackHoverAccel); else - npc.velocity *= (death ? 0.85f : 0.9f); + npc.velocity *= (death ? 0.8f : 0.85f); // Face the correct direction float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; @@ -644,32 +572,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Avoid cheap bullshit npc.damage = 0; + // Direction + float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; + // Get target location and shoot from ass - Vector2 stingerSpawnLocation = new Vector2(npc.position.X + (npc.width / 2) + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); - Vector2 stingerQueenBeeLocation = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float stingerAttackTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - stingerQueenBeeLocation.X; - float stingerAttackTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - (phase4 ? 400f : phase2 ? 350f : 300f) - stingerQueenBeeLocation.Y; - float stingerAttackTargetDist = (float)Math.Sqrt(stingerAttackTargetX * stingerAttackTargetX + stingerAttackTargetY * stingerAttackTargetY); + float stingerAttackSpeed = 16f + enrageScale * 4f; + float stingerAttackAccel = phase6 ? 0.32f : 0.24f; + if (enrageScale > 0f) + stingerAttackAccel = MathHelper.Lerp(phase6 ? 0.4f : 0.32f, phase6 ? 0.8f : 0.64f, enrageScale / maxEnrageScale); + + Vector2 stingerSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * (!canHitTarget ? 0f : phase4 ? 400f : phase2 ? 360f : 320f); + Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * stingerAttackSpeed; npc.ai[1] += 1f; - int stingerAttackTimer = phase5 ? 30 : phase2 ? 25 : 20; - stingerAttackTimer -= (int)Math.Ceiling((phase5 ? 12f : phase2 ? 10f : 8f) * enrageScale); + int stingerAttackTimer = phase6 ? 40 : phase2 ? 30 : 20; + stingerAttackTimer -= (int)Math.Ceiling((phase6 ? 16f : phase2 ? 12f : 8f) * enrageScale); if (stingerAttackTimer < 5) stingerAttackTimer = 5; // Fire stingers - if (npc.ai[1] % stingerAttackTimer == (stingerAttackTimer - 1) && npc.position.Y + npc.height < Main.player[npc.target].position.Y && Collision.CanHit(stingerSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + if (npc.ai[1] % stingerAttackTimer == (stingerAttackTimer - 1) && npc.Bottom.Y < Main.player[npc.target].Top.Y && Collision.CanHit(stingerSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { SoundEngine.PlaySound(SoundID.Item17, stingerSpawnLocation); if (Main.netMode != NetmodeID.MultiplayerClient) { - float stingerSpeed = 5f; - if (phase3) - stingerSpeed += 1f; - stingerSpeed += 2f * enrageScale; - - float stingerTargetX = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - stingerSpawnLocation.X; - float stingerTargetY = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - stingerSpawnLocation.Y; + float stingerSpeed = (phase3 ? 6f : 5f) + 2f * enrageScale; + float stingerTargetX = Main.player[npc.target].Center.X - stingerSpawnLocation.X; + float stingerTargetY = Main.player[npc.target].Center.Y - stingerSpawnLocation.Y; float stingerTargetDist = (float)Math.Sqrt(stingerTargetX * stingerTargetX + stingerTargetY * stingerTargetY); stingerTargetDist = stingerSpeed / stingerTargetDist; stingerTargetX *= stingerTargetDist; @@ -683,7 +616,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (phase2) { - int numExtraStingers = death ? (phase5 ? 4 : 2) : (phase5 ? 2 : 1); + int numExtraStingers = death ? (phase6 ? 4 : 2) : (phase6 ? 2 : 1); for (int i = 0; i < numExtraStingers; i++) { projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation + Main.rand.NextVector2CircularEdge(16f, 16f) * (i + 1), stingerVelocity * (0.75f * (i * 0.2f + 1)), type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, (Main.zenithWorld && phase3) ? Main.player[npc.target].position.Y : 0f); @@ -695,77 +628,12 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } // Movement calculations - float stingerAttackAccel = phase5 ? 0.16f : 0.12f; - stingerAttackAccel += 0.1f * enrageScale; - if (!Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) - { - stingerAttackAccel = phase5 ? 0.2f : 0.16f; - if (enrageScale > 0f) - stingerAttackAccel = MathHelper.Lerp(phase5 ? 0.2f : 0.16f, phase5 ? 0.4f : 0.32f, enrageScale / maxEnrageScale); - - stingerQueenBeeLocation = stingerSpawnLocation; - stingerAttackTargetX = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - stingerQueenBeeLocation.X; - stingerAttackTargetY = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - stingerQueenBeeLocation.Y; - - if (npc.velocity.X < stingerAttackTargetX) - { - npc.velocity.X += stingerAttackAccel; - if (npc.velocity.X < 0f && stingerAttackTargetX > 0f) - npc.velocity.X += stingerAttackAccel; - } - else if (npc.velocity.X > stingerAttackTargetX) - { - npc.velocity.X -= stingerAttackAccel; - if (npc.velocity.X > 0f && stingerAttackTargetX < 0f) - npc.velocity.X -= stingerAttackAccel; - } - if (npc.velocity.Y < stingerAttackTargetY) - { - npc.velocity.Y += stingerAttackAccel; - if (npc.velocity.Y < 0f && stingerAttackTargetY > 0f) - npc.velocity.Y += stingerAttackAccel; - } - else if (npc.velocity.Y > stingerAttackTargetY) - { - npc.velocity.Y -= stingerAttackAccel; - if (npc.velocity.Y > 0f && stingerAttackTargetY < 0f) - npc.velocity.Y -= stingerAttackAccel; - } - } - else if (stingerAttackTargetDist > 80f) - { - float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; - npc.direction = playerLocation < 0 ? 1 : -1; - npc.spriteDirection = npc.direction; - - if (npc.velocity.X < stingerAttackTargetX) - { - npc.velocity.X += stingerAttackAccel; - if (npc.velocity.X < 0f && stingerAttackTargetX > 0f) - npc.velocity.X += stingerAttackAccel * 2f; - } - else if (npc.velocity.X > stingerAttackTargetX) - { - npc.velocity.X -= stingerAttackAccel; - if (npc.velocity.X > 0f && stingerAttackTargetX < 0f) - npc.velocity.X -= stingerAttackAccel * 2f; - } - if (npc.velocity.Y < stingerAttackTargetY) - { - npc.velocity.Y += stingerAttackAccel; - if (npc.velocity.Y < 0f && stingerAttackTargetY > 0f) - npc.velocity.Y += stingerAttackAccel * 2f; - } - else if (npc.velocity.Y > stingerAttackTargetY) - { - npc.velocity.Y -= stingerAttackAccel; - if (npc.velocity.Y > 0f && stingerAttackTargetY < 0f) - npc.velocity.Y -= stingerAttackAccel * 2f; - } - } + if (Vector2.Distance(stingerSpawnLocation, hoverDestination) > 40f || !canHitTarget) + npc.SimpleFlyMovement(idealVelocity, stingerAttackAccel); // Go to a random phase - if (npc.ai[1] > stingerAttackTimer * 15f && !phase5) + float numStingerShots = phase6 ? 7f : phase2 ? 10f : 15f; + if (npc.ai[1] > stingerAttackTimer * numStingerShots) { npc.ai[0] = -1f; npc.ai[1] = 3f; @@ -800,6 +668,77 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } + // Stinger arcs above the player, followed by a dash + else if (npc.ai[0] == 5f) + { + // Avoid cheap bullshit + npc.damage = 0; + + // Direction + float playerLocation = npc.Center.X - Main.player[npc.target].Center.X; + npc.direction = playerLocation < 0 ? 1 : -1; + npc.spriteDirection = npc.direction; + + // Get target location and shoot spreads from ass + float stingerAttackSpeed = 20f + enrageScale * 4f; + float stingerAttackAccel = phase6 ? 0.7f : 0.5f; + if (enrageScale > 0f) + stingerAttackAccel = MathHelper.Lerp(phase6 ? 0.9f : 0.7f, phase6 ? 2.4f : 1.8f, enrageScale / maxEnrageScale); + + float numStingerArcs = phase6 ? 3f : phase5 ? 2f : 1f; + float phaseLimit = phase6 ? 180f : phase5 ? 150f : 120f; + float stingerAttackTimer = phaseLimit / (numStingerArcs + 1); + + float maxDistance = 480f; + float xLocationScale = MathHelper.Lerp(-maxDistance, maxDistance, npc.ai[1] / phaseLimit) * npc.ai[2]; + Vector2 stingerSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); + bool canHitTarget = Collision.CanHit(new Vector2(stingerSpawnLocation.X, stingerSpawnLocation.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); + Vector2 hoverDestination = Main.player[npc.target].Center + Vector2.UnitX * xLocationScale * 1.25f - Vector2.UnitY * maxDistance; + Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * stingerAttackSpeed; + + // Fire stingers + bool canFireStingers = stingerSpawnLocation.Y < Main.player[npc.target].Top.Y - maxDistance * 0.8f || !canHitTarget; + if (canFireStingers) + { + npc.ai[1] += 1f; + if (npc.ai[1] % stingerAttackTimer == 0f && npc.ai[1] != 0f && npc.ai[1] != phaseLimit) + { + SoundEngine.PlaySound(SoundID.Item17, stingerSpawnLocation); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float stingerSpeed = (phase6 ? 5f : 4f) + 2f * enrageScale; + Vector2 projectileVelocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * stingerSpeed; + int type = Main.zenithWorld ? ModContent.ProjectileType() : ProjectileID.QueenBeeStinger; + int numProj = phase6 ? 5 : phase5 ? 10 : 15; + int spread = phase6 ? 30 : phase5 ? 50 : 60; + float rotation = MathHelper.ToRadians(spread); + for (int i = 0; i < numProj; i++) + { + Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); + int projectile = Projectile.NewProjectile(npc.GetSource_FromAI(), stingerSpawnLocation + Vector2.Normalize(perturbedSpeed) * 10f, perturbedSpeed, type, Main.zenithWorld ? 25 : npc.GetProjectileDamage(type), 0f, Main.myPlayer, 0f, Main.player[npc.target].position.Y); + Main.projectile[projectile].timeLeft = 600; + Main.projectile[projectile].extraUpdates = 1; + + if (!Main.zenithWorld) + Main.projectile[projectile].tileCollide = false; + } + } + } + } + + // Movement calculations + npc.SimpleFlyMovement(idealVelocity, stingerAttackAccel); + + // Go to a random phase + if (npc.ai[1] >= phaseLimit) + { + npc.ai[0] = -1f; + npc.ai[1] = 4f; + npc.ai[2] = 0f; + npc.netUpdate = true; + } + } + if (Main.netMode == NetmodeID.Server) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, npc.whoAmI, 0f, 0f, 0f, 0, 0, 0); diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index e47ec9f098..c918b56bd9 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -478,6 +478,12 @@ namespace CalamityMod.Projectiles else if (projectile.type == ProjectileID.QueenBeeStinger) { + if (projectile.ai[1] != 0f) + { + if (projectile.position.Y > projectile.ai[1]) + projectile.tileCollide = true; + } + if (Main.rand.NextBool()) Dust.NewDustDirect(projectile.position - projectile.velocity, projectile.width, projectile.height, 147, 0f, 0f, 0, default(Color), 0.9f).noGravity = true; @@ -551,6 +557,119 @@ namespace CalamityMod.Projectiles return false; } + else if (projectile.type == ProjectileID.CultistBossLightningOrb) + { + if (NPC.AnyNPCs(NPCID.CultistBoss)) + { + if (projectile.localAI[1] == 0f) + { + SoundEngine.PlaySound(SoundID.Item121, projectile.position); + projectile.localAI[1] = 1f; + } + + if (projectile.ai[0] < 180f) + { + projectile.alpha -= 5; + if (projectile.alpha < 0) + projectile.alpha = 0; + } + else + { + projectile.alpha += 5; + if (projectile.alpha > 255) + { + projectile.alpha = 255; + projectile.Kill(); + return false; + } + } + + ref float reference = ref projectile.ai[0]; + ref float reference46 = ref reference; + float num15 = reference; + reference46 = num15 + 1f; + + if (projectile.ai[0] % 30f == 0f && projectile.ai[0] < 180f && Main.netMode != NetmodeID.MultiplayerClient) + { + int maxTargets = 2; + int[] array6 = new int[maxTargets]; + Vector2[] array7 = new Vector2[maxTargets]; + int num731 = 0; + float num732 = 2000f; + + for (int num733 = 0; num733 < Main.maxPlayers; num733++) + { + if (!Main.player[num733].active || Main.player[num733].dead) + continue; + + Vector2 center9 = Main.player[num733].Center; + float num734 = Vector2.Distance(center9, projectile.Center); + if (num734 < num732 && Collision.CanHit(projectile.Center, 1, 1, center9, 1, 1)) + { + array6[num731] = num733; + array7[num731] = center9; + int num34 = num731 + 1; + num731 = num34; + if (num34 >= array7.Length) + break; + } + } + + for (int num735 = 0; num735 < num731; num735++) + { + Vector2 vector52 = array7[num735] + Main.player[array6[num735]].velocity * 40f - projectile.Center; + float ai = Main.rand.Next(100); + Vector2 vector53 = Vector2.Normalize(vector52.RotatedByRandom(MathHelper.PiOver4)) * 7f; + Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, vector53, 466, projectile.damage, 0f, Main.myPlayer, vector52.ToRotation(), ai); + } + } + + Lighting.AddLight(projectile.Center, 0.4f, 0.85f, 0.9f); + + if (++projectile.frameCounter >= 4) + { + projectile.frameCounter = 0; + if (++projectile.frame >= Main.projFrames[projectile.type]) + projectile.frame = 0; + } + + if (projectile.alpha >= 150 || !(projectile.ai[0] < 180f)) + return false; + + for (int num736 = 0; num736 < 1; num736++) + { + float num737 = (float)Main.rand.NextDouble() * 1f - 0.5f; + if (num737 < -0.5f) + num737 = -0.5f; + if (num737 > 0.5f) + num737 = 0.5f; + + Vector2 value40 = new Vector2(-projectile.width * 0.2f * projectile.scale, 0f).RotatedBy(num737 * MathHelper.TwoPi).RotatedBy(projectile.velocity.ToRotation()); + Dust zap = Dust.NewDustDirect(projectile.Center - Vector2.One * 5f, 10, 10, 226, (0f - projectile.velocity.X) / 3f, (0f - projectile.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); + zap.position = projectile.Center + value40; + zap.velocity = Vector2.Normalize(zap.position - projectile.Center) * 2f; + zap.noGravity = true; + } + + for (int num739 = 0; num739 < 1; num739++) + { + float num740 = (float)Main.rand.NextDouble() * 1f - 0.5f; + if (num740 < -0.5f) + num740 = -0.5f; + if (num740 > 0.5f) + num740 = 0.5f; + + Vector2 value41 = new Vector2(-projectile.width * 0.6f * projectile.scale, 0f).RotatedBy(num740 * MathHelper.TwoPi).RotatedBy(projectile.velocity.ToRotation()); + Dust zap = Dust.NewDustDirect(projectile.Center - Vector2.One * 5f, 10, 10, 226, (0f - projectile.velocity.X) / 3f, (0f - projectile.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); + zap.velocity = Vector2.Zero; + zap.position = projectile.Center + value41; + zap.noGravity = true; + } + + return false; + } + } + else if (projectile.type == ProjectileID.Starfury) { if (projectile.timeLeft > 75) @@ -1733,118 +1852,6 @@ namespace CalamityMod.Projectiles projectile.velocity *= 1.01f; } - else if (projectile.type == ProjectileID.CultistBossLightningOrb && BossRushEvent.BossRushActive) - { - if (NPC.AnyNPCs(NPCID.CultistBoss)) - { - if (projectile.localAI[1] == 0f) - { - SoundEngine.PlaySound(SoundID.Item121, projectile.position); - projectile.localAI[1] = 1f; - } - - if (projectile.ai[0] < 180f) - { - projectile.alpha -= 5; - if (projectile.alpha < 0) - projectile.alpha = 0; - } - else - { - projectile.alpha += 5; - if (projectile.alpha > 255) - { - projectile.alpha = 255; - projectile.Kill(); - return false; - } - } - - ref float reference = ref projectile.ai[0]; - ref float reference46 = ref reference; - float num15 = reference; - reference46 = num15 + 1f; - - if (projectile.ai[0] % 30f == 0f && projectile.ai[0] < 180f && Main.netMode != NetmodeID.MultiplayerClient) - { - int[] array6 = new int[5]; - Vector2[] array7 = new Vector2[5]; - int num731 = 0; - float num732 = 2000f; - - for (int num733 = 0; num733 < 255; num733++) - { - if (!Main.player[num733].active || Main.player[num733].dead) - continue; - - Vector2 center9 = Main.player[num733].Center; - float num734 = Vector2.Distance(center9, projectile.Center); - if (num734 < num732 && Collision.CanHit(projectile.Center, 1, 1, center9, 1, 1)) - { - array6[num731] = num733; - array7[num731] = center9; - int num34 = num731 + 1; - num731 = num34; - if (num34 >= array7.Length) - break; - } - } - - for (int num735 = 0; num735 < num731; num735++) - { - Vector2 vector52 = array7[num735] + Main.player[array6[num735]].velocity * 40f - projectile.Center; - float ai = Main.rand.Next(100); - Vector2 vector53 = Vector2.Normalize(vector52.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, vector53, 466, projectile.damage, 0f, Main.myPlayer, vector52.ToRotation(), ai); - } - } - - Lighting.AddLight(projectile.Center, 0.4f, 0.85f, 0.9f); - - if (++projectile.frameCounter >= 4) - { - projectile.frameCounter = 0; - if (++projectile.frame >= Main.projFrames[projectile.type]) - projectile.frame = 0; - } - - if (projectile.alpha >= 150 || !(projectile.ai[0] < 180f)) - return false; - - for (int num736 = 0; num736 < 1; num736++) - { - float num737 = (float)Main.rand.NextDouble() * 1f - 0.5f; - if (num737 < -0.5f) - num737 = -0.5f; - if (num737 > 0.5f) - num737 = 0.5f; - - Vector2 value40 = new Vector2(-projectile.width * 0.2f * projectile.scale, 0f).RotatedBy(num737 * MathHelper.TwoPi).RotatedBy(projectile.velocity.ToRotation()); - Dust zap = Dust.NewDustDirect(projectile.Center - Vector2.One * 5f, 10, 10, 226, (0f - projectile.velocity.X) / 3f, (0f - projectile.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); - zap.position = projectile.Center + value40; - zap.velocity = Vector2.Normalize(zap.position - projectile.Center) * 2f; - zap.noGravity = true; - } - - for (int num739 = 0; num739 < 1; num739++) - { - float num740 = (float)Main.rand.NextDouble() * 1f - 0.5f; - if (num740 < -0.5f) - num740 = -0.5f; - if (num740 > 0.5f) - num740 = 0.5f; - - Vector2 value41 = new Vector2(-projectile.width * 0.6f * projectile.scale, 0f).RotatedBy(num740 * MathHelper.TwoPi).RotatedBy(projectile.velocity.ToRotation()); - Dust zap = Dust.NewDustDirect(projectile.Center - Vector2.One * 5f, 10, 10, 226, (0f - projectile.velocity.X) / 3f, (0f - projectile.velocity.Y) / 3f, 150, Color.Transparent, 0.7f); - zap.velocity = Vector2.Zero; - zap.position = projectile.Center + value41; - zap.noGravity = true; - } - - return false; - } - } - else if (projectile.type == ProjectileID.CultistBossIceMist) { if (projectile.localAI[1] == 0f) @@ -3139,7 +3146,7 @@ namespace CalamityMod.Projectiles { if (Main.netMode != NetmodeID.MultiplayerClient) { - int beeAmt = Main.rand.Next(2, 5); + int beeAmt = Main.rand.Next(2, 4); int availableAmountOfNPCsToSpawnUpToSlot = NPC.GetAvailableAmountOfNPCsToSpawnUpToSlot(beeAmt); for (int i = 0; i < availableAmountOfNPCsToSpawnUpToSlot; i++) {