diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index a400440a21..8218d98617 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1387,10 +1387,10 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCID.SkeletronHead) { - if (CalamityWorld.death) + /*if (CalamityWorld.death) npc.lifeMax = (int)(npc.lifeMax * 0.65); else - npc.lifeMax = (int)(npc.lifeMax * 0.9); + npc.lifeMax = (int)(npc.lifeMax * 0.9);*/ npc.npcSlots = 12f; } @@ -5918,23 +5918,24 @@ namespace CalamityMod.NPCs } } } - + // Telegraph for slaps else if (npc.type == NPCID.SkeletronHand) { float beginTelegraphGateValue = SkeletronAI.HandSlapGateValue - SkeletronAI.HandSlapTelegraphTime; - if (npc.ai[3] > beginTelegraphGateValue) + if (newAI[2] > beginTelegraphGateValue) { - float colorScale = MathHelper.Clamp((npc.ai[3] - beginTelegraphGateValue) / SkeletronAI.HandSlapTelegraphTime, 0f, 1f); + float colorScale = MathHelper.Clamp((newAI[2] - beginTelegraphGateValue) / SkeletronAI.HandSlapTelegraphTime, 0f, 1f); Color drawColor2 = new Color(150, 150, 150, 0) * colorScale; Vector2 halfSize = npc.frame.Size() / 2; SpriteEffects spriteEffects = SpriteEffects.None; if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; + Vector2 glowOffset = Vector2.UnitY * 8f; for (int i = 0; i < 2; i++) { - spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY), npc.frame, + spriteBatch.Draw(TextureAssets.Npc[npc.type].Value, npc.Center - screenPos + new Vector2(0, npc.gfxOffY) - glowOffset, npc.frame, drawColor2, npc.rotation, halfSize, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs index ff4a0c1177..4e3087153a 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/EyeOfCthulhuAI.cs @@ -174,7 +174,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.rotation = eyeRotation; Vector2 servantSpawnVelocity = npc.SafeDirectionTo(Main.player[npc.target].Center) * servantAndProjectileVelocity; - Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity * 10f; + Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; int maxServants = 4; bool spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; if (spawnServant) @@ -334,7 +334,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.getGoodWorld) servantSpawnVelocity *= 3f; - Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity * 10f; + Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; if (Main.netMode != NetmodeID.MultiplayerClient) { int servantSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu, 0, 0f, 0f, enrageScale); @@ -752,7 +752,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[2] % servantSpawnGateValue == 0f && shootProjectile && npc.ai[2] <= servantSpawnGateValue * maxServantSpawnsPerAttack) { Vector2 servantSpawnVelocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * servantAndProjectileVelocity; - Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity * 10f; + Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; int maxServants = death ? (finalPhaseDeath ? 1 : penultimatePhaseDeath ? 2 : 3) : (finalPhaseRev ? 2 : 4); bool spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; diff --git a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs index 7ea4a8117f..3973db0fc2 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/QueenBeeAI.cs @@ -643,7 +643,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.SimpleFlyMovement(idealVelocity, stingerAttackAccel); // Go to a random phase - float numStingerShots = phase6 ? 7f : phase2 ? 10f : 15f; + float numStingerShots = phase6 ? 5f : phase2 ? 8f : 15f; if (npc.ai[1] > stingerAttackTimer * numStingerShots) { npc.ai[0] = -1f; @@ -679,7 +679,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - // Stinger arcs above the player, followed by a dash + // Stinger arcs above the player else if (npc.ai[0] == 5f) { // Avoid cheap bullshit @@ -726,7 +726,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float stingerSpeed = (phase6 ? 5f : 4f) + 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 numProj = death ? (phase6 ? 5 : phase5 ? 10 : 15) : (phase6 ? 4 : phase5 ? 8 : 12); int spread = phase6 ? 30 : phase5 ? 50 : 60; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) diff --git a/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs index 86dc576935..960dccf31e 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/SkeletronAI.cs @@ -13,6 +13,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { public const float HandSlapGateValue = 300f; public const float HandSlapTelegraphTime = 120f; + public const float HandSwipeDistance = 960f; // 60 tiles public static bool BuffedSkeletronAI(NPC npc, Mod mod) { @@ -26,20 +27,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Phases - // Begin teleporting and firing spreads of skulls phase + // Begin firing spreads of skulls phase bool phase2 = lifeRatio < 0.85f; // Begin using a more dangerous charge attack, similar to Dreadnautilus, rather than the regular spin charge and fire a spread of Chaos Balls at the end of it phase bool phase3 = lifeRatio < 0.7f; - // Spawn a new set of hands and fire skulls from hands at the start of each slap phase + // Spawn a new set of hands and fire skulls from hands at the end of each slap phase bool respawnHands = lifeRatio < 0.5f; - // Fire skulls during charge attack and spin in place while firing a random spread of homing skulls phase - bool phase4 = lifeRatio < 0.35f; + // Fire giant cursed skull projectiles during charge attack and spin away while firing skull projectiles before charging phase (yes, these curse you if you get hit) + bool phase4 = lifeRatio < 0.3f; - // Rapid teleport and charge phase (the idle phase no longer occurs here) - bool phase5 = lifeRatio < 0.15f; + // Rapid teleport and charge, stop using idle phase + bool phase5 = lifeRatio < 0.1f; // Set defense npc.defense = npc.defDefense; @@ -68,7 +69,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (respawnHands && calamityGlobalNPC.newAI[0] == 0f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f) { calamityGlobalNPC.newAI[0] = 1f; - SoundEngine.PlaySound(SoundID.Roar with { Pitch = SoundID.Roar.Pitch - 0.25f }, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoar with { Pitch = SoundID.ForceRoar.Pitch - 0.25f }, npc.Center); SpawnHands(); npc.netUpdate = true; @@ -127,7 +128,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.dayTime && !bossRush && npc.ai[1] != 3f && npc.ai[1] != 2f) { npc.ai[1] = 2f; - SoundEngine.PlaySound(SoundID.Roar, npc.Center); + SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); } // Hand count @@ -147,45 +148,52 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses switch (numHandsAlive) { case 0: - numProj = Main.getGoodWorld ? 26 : death ? 16 : 12; + numProj = Main.getGoodWorld ? 36 : death ? 12 : 8; spread = MathHelper.ToRadians(Main.getGoodWorld ? 180 : death ? 90 : 82); headSpinVelocityMult = bossRush ? 12f : 6f; break; case 1: - numProj = Main.getGoodWorld ? 20 : death ? 12 : 8; + numProj = Main.getGoodWorld ? 27 : death ? 9 : 6; spread = MathHelper.ToRadians(Main.getGoodWorld ? 150 : death ? 76 : 68); headSpinVelocityMult = bossRush ? 10f : 5f; break; case 2: - numProj = Main.getGoodWorld ? 17 : death ? 10 : 6; + numProj = Main.getGoodWorld ? 18 : death ? 6 : 4; spread = MathHelper.ToRadians(Main.getGoodWorld ? 140 : death ? 70 : 62); headSpinVelocityMult = bossRush ? 9f : 4.5f; break; case 3: - numProj = Main.getGoodWorld ? 14 : death ? 8 : 4; + numProj = Main.getGoodWorld ? 15 : death ? 5 : 3; spread = MathHelper.ToRadians(Main.getGoodWorld ? 130 : death ? 64 : 56); headSpinVelocityMult = bossRush ? 8f : 4f; break; case 4: - numProj = Main.getGoodWorld ? 11 : death ? 6 : 4; + numProj = Main.getGoodWorld ? 12 : death ? 4 : 3; spread = MathHelper.ToRadians(Main.getGoodWorld ? 120 : 56); headSpinVelocityMult = bossRush ? 7f : 3.5f; break; } + if (death) + headSpinVelocityMult *= 1.25f; + // Hand DR, scale DR up if the hands are still alive as Skeletron's HP lowers npc.chaseable = handsDead; - calamityGlobalNPC.DR = !handsDead ? MathHelper.Lerp(0.5f, 0.9999f, respawnHands ? (0.5f - lifeRatio) / 0.5f : 2f - lifeRatio / 0.5f) : 0.05f; + float minDR = 0.05f; + float maxDR = 0.9999f; + calamityGlobalNPC.DR = !handsDead ? (float)Math.Sqrt(MathHelper.Lerp(minDR, maxDR, respawnHands ? (0.5f - lifeRatio) / 0.5f : 2f - lifeRatio / 0.5f)) : minDR; calamityGlobalNPC.unbreakableDR = !handsDead; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = !handsDead; - // Teleport - if (handsDead || phase2) + // Teleport while not despawning + if (npc.ai[1] != 3f) { + int dustType = 181; + // Post-teleport if (npc.ai[3] == -60f) { @@ -193,10 +201,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses SoundEngine.PlaySound(SoundID.Item66, npc.Center); - // Fire magic bolt after teleport + // Fire skulls after teleport if (Main.netMode != NetmodeID.MultiplayerClient) { - float skullSpeed = death ? 6f : 5f; + float skullSpeed = death ? 7.2f : 6f; int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); @@ -219,7 +227,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int i = 0; i < numProj; i++) { offsetAngle = startAngle + deltaAngle * i; - int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), center.X, center.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, -2f, 0f); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), center.X, center.Y, baseSpeed * (float)Math.Sin(offsetAngle), baseSpeed * (float)Math.Cos(offsetAngle), type, damage, 0f, Main.myPlayer, -2f); Main.projectile[proj].timeLeft = 300; } @@ -229,9 +237,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Teleport dust for (int m = 0; m < 30; m++) { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[teleportDust].noGravity = true; - Main.dust[teleportDust].velocity.X = Main.dust[teleportDust].velocity.X * 2f; + Main.dust[teleportDust].velocity.X *= 2f; } } @@ -245,7 +253,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses int ai3 = (int)npc.ai[3]; // 0 to 30, and -60 bool emitDust = false; - if (ai3 >= 300 && calamityGlobalNPC.newAI[2] == 0f && calamityGlobalNPC.newAI[3] == 0f) + int teleportGateValue = phase5 ? 180 : 300; + if (ai3 >= teleportGateValue && calamityGlobalNPC.newAI[2] == 0f && calamityGlobalNPC.newAI[3] == 0f) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -253,9 +262,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 skullTargetDirection = Main.player[npc.target].Center - skullFaceDirection; Point skullTileCoords = npc.Center.ToTileCoordinates(); Point targetTileCoords = Main.player[npc.target].Center.ToTileCoordinates(); - int randomTeleportOffset = 26; + int randomTeleportOffset = 32 - (int)Math.Ceiling(MathHelper.Lerp(0f, 16f, 1f - lifeRatio)); int skullPositionOffset = 4; - int targetPositionOffset = 22; + int targetPositionOffset = randomTeleportOffset - 4; int teleportTries = 0; bool targetTooFar = false; @@ -284,54 +293,52 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses for (int m = 0; m < 5; m++) { Vector2 position = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); - int teleportDust = Dust.NewDust(position, npc.width, npc.height, 27, 0f, 0f, 200, default, 2f); + int teleportDust = Dust.NewDust(position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 2f); Main.dust[teleportDust].noGravity = true; } } - if (ai3 >= 390) + if (ai3 >= teleportGateValue + 90) { emitDust = true; } - else if (ai3 >= 330) + else if (ai3 >= teleportGateValue + 30) { - if (Main.rand.Next(310, ai3 + 1) >= 325) + if (Main.rand.Next(teleportGateValue + 10, ai3 + 1) >= teleportGateValue + 25) emitDust = true; } + if (emitDust) { - int dust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 1.5f); + int dust = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 1.5f); Main.dust[dust].noGravity = true; } // Teleport - if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[3] >= 420f) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[3] >= teleportGateValue + 120) { // Teleport dust for (int m = 0; m < 30; m++) { - int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, 27, 0f, 0f, 200, default, 3f); + int teleportDust = Dust.NewDust(npc.position, npc.width, npc.height, dustType, 0f, 0f, 100, default, 3f); Main.dust[teleportDust].noGravity = true; - Main.dust[teleportDust].velocity.X = Main.dust[teleportDust].velocity.X * 2f; + Main.dust[teleportDust].velocity.X *= 2f; } // New location npc.Center = new Vector2(calamityGlobalNPC.newAI[2], calamityGlobalNPC.newAI[3]); npc.velocity = Vector2.Zero; npc.ai[3] = -60f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; + calamityGlobalNPC.newAI[2] = calamityGlobalNPC.newAI[3] = 0f; npc.SyncExtraAI(); npc.netUpdate = true; } } - else - npc.ai[3] = 0f; // Skull shooting - if (handsDead && npc.ai[1] == 0f) + if (handsDead && npc.ai[1] == 0f && !phase4) { - float skullProjFrequency = bossRush ? 10f : phase2 ? (60f - (death ? 30f * (1f - lifeRatio) : 0f)) : 75f; + float skullProjFrequency = bossRush ? 10f : phase2 ? (32f - (death ? 22.5f * (1f - lifeRatio) : 0f)) : 40f; if (Main.getGoodWorld) skullProjFrequency *= 0.8f; skullProjFrequency = (float)Math.Ceiling(skullProjFrequency); @@ -341,28 +348,20 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses Vector2 skullFiringPos = npc.Center; float skullProjTargetX = Main.player[npc.target].Center.X - skullFiringPos.X; float skullProjTargetY = Main.player[npc.target].Center.Y - skullFiringPos.Y; - // Ozzatron: noticed this is unused. Leaving as-is for minimal touch. - float skullProjTargetDist = (float)Math.Sqrt(skullProjTargetX * skullProjTargetX + skullProjTargetY * skullProjTargetY); if (Collision.CanHit(skullFiringPos, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { float skullProjSpeed = phase2 ? (5f + (death ? 3f * (1f - lifeRatio) : 0f)) : 4f; - skullProjTargetX = Main.player[npc.target].Center.X - skullFiringPos.X; - skullProjTargetY = Main.player[npc.target].Center.Y - skullFiringPos.Y; - skullProjTargetDist = (float)Math.Sqrt(skullProjTargetX * skullProjTargetX + skullProjTargetY * skullProjTargetY); - skullProjTargetDist = skullProjSpeed / skullProjTargetDist; - skullProjTargetX *= skullProjTargetDist; - skullProjTargetY *= skullProjTargetDist; int spread2 = bossRush ? 100 : 50; Vector2 skullProjDirection = new Vector2(skullProjTargetX + Main.rand.Next(-spread2, spread2 + 1) * 0.01f, skullProjTargetY + Main.rand.Next(-spread2, spread2 + 1) * 0.01f); skullProjDirection.Normalize(); skullProjDirection *= skullProjSpeed; skullProjDirection += npc.velocity; - skullProjTargetX = skullProjDirection.X; - skullProjTargetY = skullProjDirection.Y; + skullFiringPos += skullProjDirection * 5f; + int type = ProjectileID.Skull; int damage = npc.GetProjectileDamage(type); - skullFiringPos += skullProjDirection * 5f; - int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos.X, skullFiringPos.Y, skullProjTargetX, skullProjTargetY, type, damage, 0f, Main.myPlayer, -1f, 0f); + + int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), skullFiringPos, skullProjDirection, type, damage, 0f, Main.myPlayer, -1f); Main.projectile[skullProjectile].timeLeft = 300; npc.netUpdate = true; @@ -379,8 +378,9 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses calamityGlobalNPC.newAI[1] += 1f; float phaseChangeRateBoost = 3f * (1f - lifeRatio); npc.ai[2] += 1f + phaseChangeRateBoost; - float chargePhaseGateValue = 600f; - bool canCharge = Vector2.Distance(Main.player[npc.target].Center, npc.Center) >= 320f; // 20 tile distance + float chargePhaseGateValue = phase5 ? 24f : phase4 ? 120f : 600f; + float canChargeDistance = phase3 ? 640f : 320f; // 20 tile distance, 40 tile distance in phase 3 + bool canCharge = Vector2.Distance(Main.player[npc.target].Center, npc.Center) >= canChargeDistance; bool charge = npc.ai[2] >= chargePhaseGateValue && canCharge; if (charge) { @@ -418,7 +418,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses { if (!canCharge) { - float maxAcceleration = headXAcceleration + headYAcceleration + (npc.ai[2] - moveAwayGateValue) * 0.001f; + float maxAcceleration = headXAcceleration + headYAcceleration + (npc.ai[2] - moveAwayGateValue) * (phase5 ? 0.002f : 0.001f); npc.velocity += Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * -maxAcceleration; float maxVelocity = (headXTopSpeed + headYTopSpeed + (npc.ai[2] - moveAwayGateValue) * 0.01f) / 2f; if (npc.velocity.Length() > maxVelocity) @@ -428,7 +428,39 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } - npc.rotation = npc.velocity.X / 15f; + // Spin in phase 4 and fire homing skulls outward (skull firing direction varies based on Skeletron's rotation) + if (phase4) + { + npc.rotation += npc.direction * 0.3f; + + if (npc.localAI[0] == 0f) + { + npc.localAI[0] = 1f; + npc.SyncVanillaLocalAI(); + + SoundEngine.PlaySound(SoundID.ForceRoar, npc.Center); + } + + // Spawn projectiles + float skullProjFrequency = death ? 8f : 16f; + if (calamityGlobalNPC.newAI[1] % skullProjFrequency == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 240f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float skullProjSpeed = headSpinVelocityMult * 0.66f; + Vector2 initialProjectileVelocity = Main.rand.NextVector2CircularEdge(skullProjSpeed, skullProjSpeed); + int type = ProjectileID.Skull; + int damage = npc.GetProjectileDamage(type); + int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, -1f); + Main.projectile[skullProjectile].timeLeft = 300; + } + } + } + } + else + npc.rotation = npc.velocity.X / 15f; return false; } @@ -533,14 +565,38 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.defense -= 10; - float phaseChangeRateBoost = 0.5f * (1f - lifeRatio); + float phaseChangeRateBoost = phase3 ? 0f : 1f - (lifeRatio - 0.7f) / 0.3f; npc.ai[2] += 1f + phaseChangeRateBoost; calamityGlobalNPC.newAI[1] += 1f; if (calamityGlobalNPC.newAI[1] == 2f) - SoundEngine.PlaySound(SoundID.Roar, npc.Center); + SoundEngine.PlaySound(phase4 ? SoundID.ForceRoarPitched : SoundID.ForceRoar, npc.Center); - if (npc.ai[2] >= 300f) + // Shoot shadowflames (giant cursed skull projectiles) while charging in phase 4 + if (phase4) + { + float shadowFlameGateValue = death ? 20f : 30f; + int shadowFlameLimit = death ? 3 : 2; + if (calamityGlobalNPC.newAI[1] % shadowFlameGateValue == 0f && calamityGlobalNPC.newAI[1] < shadowFlameGateValue * shadowFlameLimit) + { + // Spawn projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float shadowFlameProjectileSpeed = death ? 5f : 4f; + Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * shadowFlameProjectileSpeed; + int type = ProjectileID.Shadowflames; + int damage = npc.GetProjectileDamage(type); + int shadowFlameProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer); + Main.projectile[shadowFlameProjectile].timeLeft = 600; + } + } + } + } + + float dashPhaseTime = 300f; + if (npc.ai[2] >= dashPhaseTime) { if (Main.getGoodWorld) { @@ -567,6 +623,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } + if (phase3) + { + // Spawn projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int chargeSkullAmt = death ? 5 : 3; + int chargeSkullSpread = death ? 80 : 60; + float rotation = MathHelper.ToRadians(spread); + float skullProjSpeed = phase4 ? (6f + (death ? 2f * ((0.35f - lifeRatio) / 0.35f) : 0f)) : 4f; + Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; + int type = ProjectileID.Skull; + int damage = npc.GetProjectileDamage(type); + for (int k = 0; k < chargeSkullAmt + 1; k++) + { + Vector2 perturbedSpeed = initialProjectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, k / (float)(chargeSkullAmt - 1))); + int proj = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center - perturbedSpeed.SafeNormalize(Vector2.UnitY) * 5f, initialProjectileVelocity + perturbedSpeed, type, damage, 0f, Main.myPlayer, -1f); + Main.projectile[proj].timeLeft = 300; + } + } + } + npc.ai[2] = 0f; npc.ai[1] = 0f; calamityGlobalNPC.newAI[1] = 0f; @@ -577,6 +654,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } npc.rotation += npc.direction * 0.3f; + Vector2 headSpinPos = npc.Center; float headSpinTargetX = Main.player[npc.target].Center.X - headSpinPos.X; float headSpinTargetY = Main.player[npc.target].Center.Y - headSpinPos.Y; @@ -584,22 +662,40 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Increase speed while charging npc.damage = (int)(npc.defDamage * 1.3); - float velocityBoost = 2f - lifeRatio; + float velocityBoost = MathHelper.Lerp(0f, 3f, 1f - lifeRatio); if (handsDead || bossRush) headSpinVelocityMult += velocityBoost; - if (headSpinTargetDist > 150f) + if (!phase3) { - float baseDistanceVelocityMult = 1f + MathHelper.Clamp((headSpinTargetDist - 150f) * 0.0015f, 0.05f, 1.5f); - headSpinVelocityMult *= baseDistanceVelocityMult; + float headSpeedIncreaseDist = 160f; + if (headSpinTargetDist > headSpeedIncreaseDist) + { + float baseDistanceVelocityMult = 1f + MathHelper.Clamp((headSpinTargetDist - headSpeedIncreaseDist) * 0.0015f, 0.05f, 1.5f); + headSpinVelocityMult *= baseDistanceVelocityMult; + } } if (Main.getGoodWorld) headSpinVelocityMult *= 1.3f; headSpinTargetDist = headSpinVelocityMult / headSpinTargetDist; - npc.velocity.X = headSpinTargetX * headSpinTargetDist; - npc.velocity.Y = headSpinTargetY * headSpinTargetDist; + Vector2 headSpinVelocity = new Vector2(headSpinTargetX, headSpinTargetY) * headSpinTargetDist; + + if (phase3) + { + // Dash directly towards the target until within 15 tiles of the target, and then continue in the same direction + float altDashPhaseTime = dashPhaseTime * (death ? 0.9f : 0.85f); + if (npc.ai[2] < altDashPhaseTime) + { + if (npc.Center.Distance(Main.player[npc.target].Center) > 240f || npc.ai[2] == 1f + phaseChangeRateBoost) + npc.velocity = headSpinVelocity.SafeNormalize(Vector2.UnitY) * (headSpinVelocityMult * 2f) + npc.Center.DirectionTo(Main.player[npc.target].Center) * 2f; + else + npc.ai[2] = altDashPhaseTime; + } + } + else + npc.velocity = headSpinVelocity; } // Daytime enrage @@ -621,6 +717,16 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Despawn else if (npc.ai[1] == 3f) { + // Disable teleports + if (npc.ai[3] != 0f || calamityGlobalNPC.newAI[2] != 0f || calamityGlobalNPC.newAI[3] != 0f) + { + npc.ai[3] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.SyncExtraAI(); + npc.netUpdate = true; + } + // Avoid cheap bullshit npc.damage = 0; @@ -716,12 +822,22 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } } else - skeletronLifeRatio = Main.npc[(int)npc.ai[1]].life / Main.npc[(int)npc.ai[1]].lifeMax; + skeletronLifeRatio = Main.npc[(int)npc.ai[1]].life / (float)Main.npc[(int)npc.ai[1]].lifeMax; + + // Fire skulls from hands at the end of each slap phase + bool phase2 = skeletronLifeRatio < 0.5f; + + // Fire skulls on a timer + bool phase3 = skeletronLifeRatio < 0.15f; float velocityMultiplier = MathHelper.Lerp(death ? 0.5f : 0.7f, 1f, skeletronLifeRatio); float velocityIncrement = MathHelper.Lerp(0.2f, death ? 0.6f : 0.45f, 1f - skeletronLifeRatio); float handSwipeVelocity = MathHelper.Lerp(16f, death ? 28f : 22f, 1f - skeletronLifeRatio); - if (npc.ai[2] == 0f || npc.ai[2] == 3f) + float handSwipeDuration = HandSwipeDistance / handSwipeVelocity; + float slapGateValue = HandSlapGateValue; + float slapTimerIncrement = MathHelper.Lerp(1f, death ? 3f : 2f, 1f - skeletronLifeRatio); + + if (npc.ai[2] == 0f || npc.ai[2] == 3f || phase3) { // Avoid cheap bullshit npc.damage = 0; @@ -729,8 +845,27 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) npc.timeLeft = 10; - if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) + if (Main.npc[(int)npc.ai[1]].ai[1] != 0f || phase3) { + // Spawn projectiles + if (phase3 && npc.ai[3] > slapGateValue) + { + npc.ai[3] += 1f; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projectileGateValue = death ? 30f : 60f; + if (phase3 && npc.ai[3] % projectileGateValue == 0f && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float skullProjSpeed = handSwipeVelocity * 0.1f; + Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; + int type = ProjectileID.Skull; + int damage = npc.GetProjectileDamage(type); + int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, -1f); + Main.projectile[skullProjectile].timeLeft = 300; + } + } + } + float maxX = (bossRush ? 4f : death ? 6f : 7f) * velocityMultiplier; float maxY = (bossRush ? 3f : death ? 4.5f : 5f) * velocityMultiplier; @@ -771,13 +906,28 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses } else { - npc.ai[3] += MathHelper.Lerp(1f, death ? 3f : 2f, 1f - skeletronLifeRatio); - float slapGateValue = HandSlapGateValue; - if (npc.ai[3] >= slapGateValue) + if (calamityGlobalNPC.newAI[3] == 1f) { - npc.ai[2] += 1f; - npc.ai[3] = slapGateValue; - npc.netUpdate = true; + calamityGlobalNPC.newAI[2] += slapTimerIncrement; + npc.ai[3] += slapTimerIncrement; + if (npc.ai[3] >= slapGateValue) + { + npc.ai[2] += 1f; + npc.ai[3] = calamityGlobalNPC.newAI[2] = slapGateValue; + calamityGlobalNPC.newAI[3] = 0f; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + } + else + { + calamityGlobalNPC.newAI[2] -= slapTimerIncrement * 2f; + if (calamityGlobalNPC.newAI[2] <= 0f) + { + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 1f; + npc.SyncExtraAI(); + } } float maxX = (bossRush ? 4f : death ? 6f : 7f) * velocityMultiplier; @@ -824,8 +974,10 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses float handIdleYPos = Main.npc[(int)npc.ai[1]].Top.Y + 230f - handCurrentPos.Y; float handIdleDist = (float)Math.Sqrt(handIdleXPos * handIdleXPos + handIdleYPos * handIdleYPos); npc.rotation = (float)Math.Atan2(handIdleYPos, handIdleXPos) + MathHelper.PiOver2; + return false; } + if (npc.ai[2] == 1f) { // Avoid cheap bullshit @@ -851,13 +1003,8 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); npc.ai[2] = 2f; - handCurrentPosition = npc.Center; - handDrawbackXPos = Main.player[npc.target].Center.X - handCurrentPosition.X; - handDrawbackYPos = Main.player[npc.target].Center.Y - handCurrentPosition.Y; - handDrawbackDist = (float)Math.Sqrt(handDrawbackXPos * handDrawbackXPos + handDrawbackYPos * handDrawbackYPos); - handDrawbackDist = handSwipeVelocity / handDrawbackDist; - npc.velocity.X = handDrawbackXPos * handDrawbackDist; - npc.velocity.Y = handDrawbackYPos * handDrawbackDist; + npc.ai[3] = 0f; + npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; npc.netUpdate = true; } } @@ -866,11 +1013,26 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses // Set damage npc.damage = npc.defDamage; - if (npc.Top.Y > Main.player[npc.target].Top.Y || npc.velocity.Y < 0f || npc.velocity == Vector2.Zero) + npc.ai[3] += 1f; + if (npc.ai[3] >= handSwipeDuration || Vector2.Distance(Main.npc[(int)npc.ai[1]].Center, npc.Center) > HandSwipeDistance) { npc.ai[2] = 3f; npc.ai[3] = 0f; npc.netUpdate = true; + + // Spawn projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (phase2 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float skullProjSpeed = handSwipeVelocity * 0.33f; + Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; + int type = ProjectileID.Skull; + int damage = npc.GetProjectileDamage(type); + int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, -1f); + Main.projectile[skullProjectile].timeLeft = 300; + } + } } } else if (npc.ai[2] == 4f) @@ -898,24 +1060,37 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses npc.TargetClosest(); npc.ai[2] = 5f; - handStrikeCurrentPos = npc.Center; - handStrikeXPos = Main.player[npc.target].Center.X - handStrikeCurrentPos.X; - handStrikeYPos = Main.player[npc.target].Center.Y - handStrikeCurrentPos.Y; - handStrikeDist = (float)Math.Sqrt(handStrikeXPos * handStrikeXPos + handStrikeYPos * handStrikeYPos); - handStrikeDist = handSwipeVelocity / handStrikeDist; - npc.velocity.X = handStrikeXPos * handStrikeDist; - npc.velocity.Y = handStrikeYPos * handStrikeDist; + npc.ai[3] = 0f; + npc.velocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * handSwipeVelocity; npc.netUpdate = true; } } - else if (npc.ai[2] == 5f && ((npc.velocity.X > 0f && npc.Center.X > Main.player[npc.target].Center.X) || (npc.velocity.X < 0f && npc.Center.X < Main.player[npc.target].Center.X) || npc.velocity == Vector2.Zero)) + else if (npc.ai[2] == 5f) { // Set damage npc.damage = npc.defDamage; - npc.ai[2] = 0f; - npc.ai[3] = 0f; - npc.netUpdate = true; + npc.ai[3] += 1f; + if (npc.ai[3] >= handSwipeDuration || Vector2.Distance(Main.npc[(int)npc.ai[1]].Center, npc.Center) > HandSwipeDistance) + { + npc.ai[2] = 0f; + npc.ai[3] = 0f; + npc.netUpdate = true; + + // Spawn projectiles + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (phase2 && Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 160f && Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) + { + float skullProjSpeed = handSwipeVelocity * 0.33f; + Vector2 initialProjectileVelocity = npc.Center.DirectionTo(Main.player[npc.target].Center) * skullProjSpeed; + int type = ProjectileID.Skull; + int damage = npc.GetProjectileDamage(type); + int skullProjectile = Projectile.NewProjectile(npc.GetSource_FromAI(), npc.Center, initialProjectileVelocity, type, damage, 0f, Main.myPlayer, -1f); + Main.projectile[skullProjectile].timeLeft = 300; + } + } + } } return false; @@ -955,7 +1130,7 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses int damage = 2500; int projType = ProjectileID.Skull; source += offset * 5f; - int skull = Projectile.NewProjectile(npc.GetSource_FromAI(), source, velocity, projType, damage, 0f, Main.myPlayer, -1f, 0f); + int skull = Projectile.NewProjectile(npc.GetSource_FromAI(), source, velocity, projType, damage, 0f, Main.myPlayer, -1f); Main.projectile[skull].timeLeft = 300; } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 69e4ca6756..c9987a56b6 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -287,6 +287,8 @@ namespace CalamityMod.Projectiles if (projectile.type == ProjectileID.Skull && (projectile.ai[0] == 0f || projectile.ai[0] == -2f)) { + bool fromRevSkeletron = projectile.ai[0] == -2f; + if (projectile.alpha > 0) projectile.alpha -= 75; @@ -297,21 +299,23 @@ namespace CalamityMod.Projectiles if (projectile.frame > 2) projectile.frame = 0; - // Accelerate if fired in a spread from Skeletron - if (projectile.ai[0] == -2f) + // Accelerate if fired in a spread from Skeletron in Rev+ + if (fromRevSkeletron) { - if (projectile.velocity.Length() < 15f) + float maxVelocity = (CalamityWorld.death || BossRushEvent.BossRushActive) ? 18f : 15f; + if (projectile.velocity.Length() < maxVelocity) { projectile.velocity *= 1.02f; - if (projectile.velocity.Length() > 15f) + if (projectile.velocity.Length() > maxVelocity) { projectile.velocity.Normalize(); - projectile.velocity *= 12f; + projectile.velocity *= maxVelocity; } } } - for (int num172 = 0; num172 < 2; num172++) + int numDust = fromRevSkeletron ? 1 : 2; + for (int i = 0; i < numDust; i++) { Dust flame = Dust.NewDustDirect(new Vector2(projectile.position.X + 4f, projectile.position.Y + 4f), projectile.width - 8, projectile.height - 8, 6, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default(Color), 2f); flame.position -= projectile.velocity * 2f; @@ -409,6 +413,40 @@ namespace CalamityMod.Projectiles return false; } + // This has 2 extra updates, dust was reduced because of this fact + else if (projectile.type == ProjectileID.Shadowflames) + { + float spawnDustGateValue = 2f * projectile.MaxUpdates; + if (projectile.localAI[0] == spawnDustGateValue) + { + SoundEngine.PlaySound(SoundID.Item8, projectile.Center); + for (int i = 0; i < 20; i++) + { + int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 181, 0f, 0f, 100); + Main.dust[dust].velocity *= 3f; + Main.dust[dust].velocity += projectile.velocity * 0.75f; + Main.dust[dust].scale *= 1.2f; + Main.dust[dust].noGravity = true; + } + } + + projectile.localAI[0] += 1f; + if (projectile.localAI[0] > spawnDustGateValue) + { + for (int i = 0; i < 2; i++) + { + int dust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 181, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100); + Main.dust[dust].velocity *= 0.6f; + Main.dust[dust].scale *= 1.4f; + Main.dust[dust].noGravity = true; + } + } + + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + + return false; + } + else if (projectile.type == ProjectileID.BloodShot) { if (projectile.localAI[0] == 0f)