diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index 34787537fd..c1d09537c0 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -507,7 +507,7 @@ namespace CalamityMod { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 270 } }, { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 270 } }, - { ModContent.NPCType(), new int[] { 150, 300, 330, 348, 450 } }, + { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, { ModContent.NPCType(), new int[] { 130, 260, 288, 304, 390 } }, { ModContent.NPCType(), new int[] { 180, 360, 396, 418, 540 } }, diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs index 1ed51c21d5..8475e88f09 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs @@ -403,14 +403,47 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.alpha = 0; } - // Velocity and movement - float scourgeMaxSpeed = 5f; - float scourgeAcceleration = 0.08f; Vector2 scourgePosition = npc.Center; Vector2 predictionVector = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? Main.player[npc.target].velocity * 20f : Vector2.Zero; float scourgeTargetX = player.Center.X + predictionVector.X; float scourgeTargetY = player.Center.Y + predictionVector.Y; + // Velocity and movement + float scourgeMaxSpeed = 5f; + float scourgeAcceleration = 0.08f; + if (calamityGlobalNPC.newAI[0] == 1f) + { + scourgeMaxSpeed = revenge ? 14.4f : 12f; + scourgeAcceleration = revenge ? 0.18f : 0.15f; + if (expertMode) + { + scourgeMaxSpeed += 2.4f * (1f - lifeRatio); + scourgeAcceleration += 0.03f * (1f - lifeRatio); + } + scourgeMaxSpeed += 3f * enrageScale; + scourgeAcceleration += 0.06f * enrageScale; + if (death || getFuckedAI) + { + scourgeMaxSpeed += 5f; + scourgeAcceleration -= getFuckedAI ? 0f : 0.03f; + scourgeMaxSpeed += Vector2.Distance(player.Center, npc.Center) * 0.001f; + scourgeAcceleration += Vector2.Distance(player.Center, npc.Center) * 0.000045f; + } + + // Increase acceleration after spiral attack + if (npc.localAI[3] > 0f) + { + float accelerationMultiplier = MathHelper.Lerp(1f, 2f, npc.localAI[3] / colorFadeTimeAfterSpiral); + scourgeAcceleration *= accelerationMultiplier; + } + + if (Main.getGoodWorld) + { + scourgeMaxSpeed *= 1.15f; + scourgeAcceleration *= 1.15f; + } + } + if (head && !doSpiral) { if (calamityGlobalNPC.newAI[0] != 1f) @@ -425,39 +458,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } } - if (calamityGlobalNPC.newAI[0] == 1f) - { - scourgeMaxSpeed = revenge ? 14.4f : 12f; - scourgeAcceleration = revenge ? 0.18f : 0.15f; - if (expertMode) - { - scourgeMaxSpeed += 2.4f * (1f - lifeRatio); - scourgeAcceleration += 0.03f * (1f - lifeRatio); - } - scourgeMaxSpeed += 3f * enrageScale; - scourgeAcceleration += 0.06f * enrageScale; - if (death || getFuckedAI) - { - scourgeMaxSpeed += 5f; - scourgeAcceleration -= getFuckedAI ? 0f : 0.03f; - scourgeMaxSpeed += Vector2.Distance(player.Center, npc.Center) * 0.001f; - scourgeAcceleration += Vector2.Distance(player.Center, npc.Center) * 0.000045f; - } - - // Increase acceleration after spiral attack - if (npc.localAI[3] > 0f) - { - float accelerationMultiplier = MathHelper.Lerp(1f, 2f, npc.localAI[3] / colorFadeTimeAfterSpiral); - scourgeAcceleration *= accelerationMultiplier; - } - - if (Main.getGoodWorld) - { - scourgeMaxSpeed *= 1.15f; - scourgeAcceleration *= 1.15f; - } - } - float scourgeHigherSpeed = scourgeMaxSpeed * 1.3f; float scourgeLowerSpeed = scourgeMaxSpeed * 0.7f; float scourgeSpeed = npc.velocity.Length(); @@ -600,8 +600,8 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Calculate contact damage based on velocity if (!nonHostile) { - float minimalContactDamageVelocity = 3f; - float minimalDamageVelocity = 6f; + float minimalContactDamageVelocity = scourgeMaxSpeed * 0.25f; + float minimalDamageVelocity = scourgeMaxSpeed * 0.5f; if (head) { if (npc.velocity.Length() <= minimalContactDamageVelocity) diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs index 4455300f28..a20bb786e2 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/AstrumDeusAI.cs @@ -310,6 +310,12 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; + if (!head) + { + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + } + // Alpha effects if ((head || Main.npc[(int)npc.ai[1]].alpha < 128) && !npc.dontTakeDamage) { @@ -320,7 +326,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } // Check if other segments are still alive, if not, die - if (npc.type != ModContent.NPCType()) + if (!head) { bool shouldDespawn = true; int headType = ModContent.NPCType(); @@ -350,6 +356,11 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.netSpam = 9; } } + else + { + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + } // Direction if (npc.velocity.X < 0f) @@ -404,6 +415,18 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } } + float segmentVelocity = deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; + + float segmentVelocityBoost = 5f * (1f - lifeRatio); + segmentVelocity += segmentVelocityBoost; + segmentVelocity += 4f * enrageScale; + + if (revenge) + { + float revMultiplier = 1.1f; + segmentVelocity *= revMultiplier; + } + if (head) { int headTilePositionX = (int)(npc.position.X / 16f) - 1; @@ -477,7 +500,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.localAI[1] = 0f; // Despawn - float fallSpeed = deathModeEnragePhase_Head ? 19f : death ? 17.5f : 16f; if (player.dead) { shouldFly = false; @@ -485,7 +507,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.velocity.Y -= velocity; if ((double)npc.position.Y < Main.topWorld + 16f) { - fallSpeed = deathModeEnragePhase_Head ? 38f : death ? 35f : 32f; + segmentVelocity *= 2f; npc.velocity.Y -= velocity; } @@ -510,10 +532,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } } - float fallSpeedBoost = 5f * (1f - lifeRatio); - fallSpeed += fallSpeedBoost; - fallSpeed += 4f * enrageScale; - // Speed and movement float speedBoost = death ? (0.1f * (1f - lifeRatio)) : (0.13f * (1f - lifeRatio)); float turnSpeedBoost = death ? (0.18f * (1f - lifeRatio)) : (0.2f * (1f - lifeRatio)); @@ -533,7 +551,6 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs float revMultiplier = 1.1f; speed *= revMultiplier; turnSpeed *= revMultiplier; - fallSpeed *= revMultiplier; } speed *= increaseSpeedMore ? 2f : increaseSpeed ? 1.5f : 1f; @@ -558,19 +575,19 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (!shouldFly) { npc.velocity.Y += 0.15f; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; + if (npc.velocity.Y > segmentVelocity) + npc.velocity.Y = segmentVelocity; // This bool exists to stop the strange wiggle behavior when worms are falling down - bool slowXVelocity = Math.Abs(npc.velocity.X) > fallSpeed; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.4) + bool slowXVelocity = Math.Abs(npc.velocity.X) > segmentVelocity; + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4) { if (npc.velocity.X < 0f) npc.velocity.X -= speed * 1.1f; else npc.velocity.X += speed * 1.1f; } - else if (npc.velocity.Y == fallSpeed) + else if (npc.velocity.Y == segmentVelocity) { if (slowXVelocity) { @@ -600,7 +617,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs float deusTargetDist = (float)Math.Sqrt(deusTargetX * deusTargetX + deusTargetY * deusTargetY); float deusAbsoluteTargetX = Math.Abs(deusTargetX); float deusAbsoluteTargetY = Math.Abs(deusTargetY); - float deusTimeToReachTarget = fallSpeed / deusTargetDist; + float deusTimeToReachTarget = segmentVelocity / deusTargetDist; deusTargetX *= deusTimeToReachTarget; deusTargetY *= deusTimeToReachTarget; @@ -611,7 +628,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs { speedUpWhileFlying = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < fallSpeed) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < segmentVelocity) npc.velocity *= 1.1f; } @@ -619,14 +636,14 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs { speedUpWhileFlying = true; - if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) + if (Math.Abs(npc.velocity.X) < segmentVelocity / 2f) { if (npc.velocity.X == 0f) npc.velocity.X -= npc.direction; npc.velocity.X *= 1.1f; } - else if (npc.velocity.Y > -fallSpeed) + else if (npc.velocity.Y > -segmentVelocity) npc.velocity.Y -= speed; } } @@ -661,7 +678,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs else if (npc.velocity.Y > deusTargetY) npc.velocity.Y -= speed; - if (Math.Abs(deusTargetY) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f))) + if (Math.Abs(deusTargetY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && deusTargetX < 0f) || (npc.velocity.X < 0f && deusTargetX > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed * 2f; @@ -669,7 +686,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.velocity.Y -= speed * 2f; } - if (Math.Abs(deusTargetX) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f))) + if (Math.Abs(deusTargetX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && deusTargetY < 0f) || (npc.velocity.Y < 0f && deusTargetY > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += speed * 2f; @@ -684,7 +701,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs else if (npc.velocity.X > deusTargetX) npc.velocity.X -= speed * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed; @@ -699,7 +716,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs else if (npc.velocity.Y > deusTargetY) npc.velocity.Y -= speed * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += speed; @@ -900,8 +917,8 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Calculate contact damage based on velocity if (!doNotDealDamage) { - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float minimalContactDamageVelocity = segmentVelocity * 0.25f; + float minimalDamageVelocity = segmentVelocity * 0.5f; if (head) { if (npc.velocity.Length() <= minimalContactDamageVelocity) diff --git a/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs index c33f213484..5884578c91 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/BumblebirbAI.cs @@ -148,8 +148,13 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs calamityGlobalNPC.DR = (phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !bossRush)) ? (bossRush ? 0.99f : 0.55f) : 0.1f; calamityGlobalNPC.CurrentlyIncreasingDefenseOrDR = phaseSwitchPhase || npc.ai[0] == 5f || (enrageScale == 3f && !bossRush); + int reducedSetDamage = (int)(npc.defDamage * 0.5f); + if (phaseSwitchPhase) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.velocity.X < 0f) npc.direction = -1; else if (npc.velocity.X > 0f) @@ -182,7 +187,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs Vector2 ai0 = npc.Center - fireFrom; float ai = Main.rand.Next(100); Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.defDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); } } } @@ -229,7 +234,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs Vector2 ai0 = npc.Center - fireFrom; float ai = Main.rand.Next(100); Vector2 velocity = Vector2.Normalize(ai0.RotatedByRandom(MathHelper.PiOver4)) * 7f; - Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.damage, 0f, Main.myPlayer, ai0.ToRotation(), ai); + Projectile.NewProjectile(npc.GetSource_FromAI(), fireFrom.X, fireFrom.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), npc.defDamage, 0f, Main.myPlayer, ai0.ToRotation(), ai); } } } @@ -275,6 +280,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Phase switch if (npc.ai[0] == 0f) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.Center.X < player.Center.X - 2f) npc.direction = 1; if (npc.Center.X > player.Center.X + 2f) @@ -512,6 +520,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Fly to target else if (npc.ai[0] == 1f) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.velocity.X < 0f) npc.direction = -1; else if (npc.velocity.X > 0f) @@ -548,6 +559,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Fly towards target quickly else if (npc.ai[0] == 2f) { + // Set reduced damage + npc.damage = reducedSetDamage; + if (npc.target < 0 || !player.active || player.dead) { npc.TargetClosest(); @@ -609,6 +623,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Line up charge else if (npc.ai[0] == 3f) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.velocity.X < 0f) npc.direction = -1; else @@ -651,6 +668,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Prepare to charge else if (npc.ai[0] == 3.1f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.rotation = (npc.rotation * rotationMult * 0.5f + npc.velocity.X * rotationAmt * 0.85f) / 5f; Vector2 follyChargePrepareTargetDirection = player.Center - npc.Center; @@ -671,6 +691,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[1] += 1f; if (npc.ai[1] > 10f) { + // Set damage + npc.damage = npc.defDamage; + npc.velocity = follyChargePrepareTargetDirection; if (npc.velocity.X < 0f) @@ -694,6 +717,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Charge else if (npc.ai[0] == 3.2f) { + // Set damage + npc.damage = npc.defDamage; + npc.ai[2] += 0.0333333351f; float velocity = 28f + (enrageScale - 1f) * 4f; npc.velocity.X = (velocity + npc.ai[2]) * npc.ai[1]; @@ -734,6 +760,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Birb spawn else if (npc.ai[0] == 4f) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.ai[1] == 0f) { Vector2 destination2 = player.Center + new Vector2(0f, -200f); @@ -839,6 +868,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Spit homing aura sphere else if (npc.ai[0] == 5f) { + // Avoid cheap bullshit + npc.damage = 0; + // Velocity npc.velocity *= 0.98f; npc.rotation = (npc.rotation * rotationMult + npc.velocity.X * rotationAmt) / 10f; @@ -950,6 +982,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.ai[0] == -1f) { + // Avoid cheap bullshit + npc.damage = 0; + Vector2 swarmerDespawnVelMult = new Vector2(0f, -8f); npc.velocity = (npc.velocity * 21f + swarmerDespawnVelMult) / 10f; return; @@ -957,6 +992,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (npc.ai[0] == 0f) { + // Avoid cheap bullshit + npc.damage = 0; + npc.TargetClosest(true); npc.spriteDirection = npc.direction; @@ -973,7 +1011,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs float swarmerIdleSpeed = (bossMinion ? 9f : 7f) + swarmerIdleTargetDist.Length() / 100f + npc.ai[1] / 15f; swarmerIdleTargetDist.Normalize(); swarmerIdleTargetDist *= swarmerIdleSpeed; - npc.velocity = (npc.velocity * 29F + swarmerIdleTargetDist) / 30F; + npc.velocity = (npc.velocity * 29f + swarmerIdleTargetDist) / 30f; if (Main.getGoodWorld && !Main.zenithWorld) npc.velocity *= 1.15f; } @@ -993,6 +1031,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs { if (npc.ai[0] == 1f) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.target < 0 || !Main.player[npc.target].active || Main.player[npc.target].dead) npc.TargetClosest(true); @@ -1028,8 +1069,12 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs return; } + if (npc.ai[0] == 2f) { + // Avoid cheap bullshit + npc.damage = 0; + if (npc.velocity.X < 0f) npc.direction = -1; else if (npc.velocity.X > 0f) @@ -1058,6 +1103,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.ai[1] += 1f; if (npc.ai[1] > 10f) { + // Set damage + npc.damage = npc.defDamage; + npc.velocity = swarmerDecelerateTargetDist; if (Main.getGoodWorld && !Main.zenithWorld) npc.velocity *= 1.15f; @@ -1073,6 +1121,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } else if (npc.ai[0] == 2.1f) { + // Set damage + npc.damage = npc.defDamage; + if (npc.velocity.X < 0f) npc.direction = -1; else if (npc.velocity.X > 0f) @@ -1083,7 +1134,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs npc.velocity *= 1.01f; npc.ai[1] += 1f; - if (npc.ai[1] > 30) + if (npc.ai[1] > 30f) { if (!Collision.SolidCollision(npc.position, npc.width, npc.height)) { @@ -1093,7 +1144,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs return; } - if (npc.ai[1] > 60) + if (npc.ai[1] > 60f) { npc.ai[0] = 1f; npc.ai[1] = 0f; diff --git a/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs index a8443b0180..6f7fa5b9bd 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/CeaselessVoidAI.cs @@ -139,6 +139,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Move closer to the target before trying to succ if (movingDuringSuccPhase) { + // Avoid cheap bullshit + npc.damage = 0; + if (Vector2.Distance(npc.Center, player.Center) > 320f || !Collision.CanHit(npc.Center, 1, 1, player.Center, 1, 1)) Movement(true); else @@ -146,6 +149,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } else { + // Set damage + npc.damage = npc.defDamage; + // Use this to generate more and more dust in final phase float finalPhaseDustRatio = 1f; if (succSoHardThatYouDie) @@ -368,6 +374,9 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs } else { + // Avoid cheap bullshit + npc.damage = 0; + Movement(false); // Count up all Dark Energy HP values diff --git a/NPCs/DesertScourge/DesertNuisanceBody.cs b/NPCs/DesertScourge/DesertNuisanceBody.cs index 92ff70e6ce..9b547a3971 100644 --- a/NPCs/DesertScourge/DesertNuisanceBody.cs +++ b/NPCs/DesertScourge/DesertNuisanceBody.cs @@ -53,6 +53,9 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -127,8 +130,9 @@ namespace CalamityMod.NPCs.DesertScourge } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float maxChaseSpeed = 16f; + float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; + float minimalDamageVelocity = maxChaseSpeed * 0.5f; float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); if (bodyAndTailVelocity <= minimalContactDamageVelocity) { diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index 7f7fbe4ba1..4548b0547a 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -119,6 +119,9 @@ namespace CalamityMod.NPCs.DesertScourge } } + if (NPC.life > Main.npc[(int)NPC.ai[0]].life) + NPC.life = Main.npc[(int)NPC.ai[0]].life; + int tilePositionX = (int)(NPC.position.X / 16f) - 1; int tileWidthPosX = (int)((NPC.position.X + (float)NPC.width) / 16f) + 2; int tilePositionY = (int)(NPC.position.Y / 16f) - 1; @@ -358,8 +361,8 @@ namespace CalamityMod.NPCs.DesertScourge } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; + float minimalDamageVelocity = maxChaseSpeed * 0.5f; if (NPC.velocity.Length() <= minimalContactDamageVelocity) { NPC.damage = (int)(NPC.defDamage * 0.5f); diff --git a/NPCs/DesertScourge/DesertNuisanceTail.cs b/NPCs/DesertScourge/DesertNuisanceTail.cs index 9f30444825..9a1024b6e8 100644 --- a/NPCs/DesertScourge/DesertNuisanceTail.cs +++ b/NPCs/DesertScourge/DesertNuisanceTail.cs @@ -53,6 +53,9 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -127,8 +130,9 @@ namespace CalamityMod.NPCs.DesertScourge } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float maxChaseSpeed = 16f; + float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; + float minimalDamageVelocity = maxChaseSpeed * 0.5f; float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); if (bodyAndTailVelocity <= minimalContactDamageVelocity) { diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index d891751247..eead0992e7 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -70,6 +70,9 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -144,8 +147,9 @@ namespace CalamityMod.NPCs.DesertScourge } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float maxChaseSpeed = 16f; + float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; + float minimalDamageVelocity = maxChaseSpeed * 0.5f; float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); if (bodyAndTailVelocity <= minimalContactDamageVelocity) { diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index ea8153fdf4..3ea0f23ec2 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -252,6 +252,9 @@ namespace CalamityMod.NPCs.DesertScourge } } + if (NPC.life > Main.npc[(int)NPC.ai[0]].life) + NPC.life = Main.npc[(int)NPC.ai[0]].life; + if (expertMode) { if (NPC.Calamity().newAI[2] < 180f) @@ -604,8 +607,8 @@ namespace CalamityMod.NPCs.DesertScourge } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; + float minimalDamageVelocity = maxChaseSpeed * 0.5f; if (NPC.velocity.Length() <= minimalContactDamageVelocity) { NPC.damage = (int)(NPC.defDamage * 0.5f); diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index a777de86f5..f71f79fe64 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -68,6 +68,9 @@ namespace CalamityMod.NPCs.DesertScourge if (NPC.ai[2] > 0f) NPC.realLife = (int)NPC.ai[2]; + if (NPC.life > Main.npc[(int)NPC.ai[1]].life) + NPC.life = Main.npc[(int)NPC.ai[1]].life; + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -142,8 +145,9 @@ namespace CalamityMod.NPCs.DesertScourge } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float maxChaseSpeed = 16f; + float minimalContactDamageVelocity = maxChaseSpeed * 0.25f; + float minimalDamageVelocity = maxChaseSpeed * 0.5f; float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); if (bodyAndTailVelocity <= minimalContactDamageVelocity) { diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs index fec7c759ce..415690acef 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianCommander.cs @@ -392,6 +392,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[0] == 0f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Face the target if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) { @@ -623,6 +626,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[0] == 1f) { + // Set damage + NPC.damage = NPC.defDamage; + // Face the target if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) { @@ -657,6 +663,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[0] == 2f) { + // Set damage + NPC.damage = NPC.defDamage; + // Face the direction of the charge if (Math.Sign(NPC.velocity.X) != 0) NPC.spriteDirection = -Math.Sign(NPC.velocity.X); @@ -722,6 +731,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[0] == 3f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Face the direction of the charge if (Math.Sign(NPC.velocity.X) != 0) NPC.spriteDirection = -Math.Sign(NPC.velocity.X); @@ -751,6 +763,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[0] == 4f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Face the target if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) { @@ -866,6 +881,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians } else if (NPC.ai[0] == 5f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Face the target if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) { diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs index eaa234e79f..234d303aaa 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianDefender.cs @@ -406,6 +406,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (NPC.ai[0] == 0f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Face the target if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) { @@ -475,6 +478,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Throw rocks, charge, summon holy bombs and shoot molten blasts else if (NPC.ai[0] == 1f) { + // Avoid cheap bullshit + NPC.damage = 0; + // Face the target if (Math.Abs(NPC.Center.X - player.Center.X) > 10f) { @@ -569,6 +575,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge at target if (NPC.ai[1] >= 0f) { + // Set damage + NPC.damage = NPC.defDamage; + NPC.ai[0] = 2f; NPC.ai[1] = 0f; NPC.netUpdate = true; @@ -599,6 +608,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge at the target and spawn holy bombs else if (NPC.ai[0] == 2f) { + // Set damage + NPC.damage = NPC.defDamage; + if (Math.Sign(NPC.velocity.X) != 0) NPC.spriteDirection = -Math.Sign(NPC.velocity.X); NPC.spriteDirection = Math.Sign(NPC.velocity.X); @@ -664,6 +676,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Slow down and pause for a bit else if (NPC.ai[0] == 3f) { + // Avoid cheap bullshit + NPC.damage = 0; + if (Math.Sign(NPC.velocity.X) != 0) NPC.spriteDirection = -Math.Sign(NPC.velocity.X); NPC.spriteDirection = Math.Sign(NPC.velocity.X); diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs index a54ef8069d..0ed89d36ba 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianHealer.cs @@ -124,6 +124,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians { CalamityGlobalNPC.doughnutBossHealer = NPC.whoAmI; + // Avoid cheap bullshit + NPC.damage = 0; + Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 1.1f, 0.9f, 0f); if (CalamityGlobalNPC.doughnutBoss < 0 || !Main.npc[CalamityGlobalNPC.doughnutBoss].active) diff --git a/NPCs/ProfanedGuardians/ProfanedRocks.cs b/NPCs/ProfanedGuardians/ProfanedRocks.cs index 4919b3fdf2..4a446c56b7 100644 --- a/NPCs/ProfanedGuardians/ProfanedRocks.cs +++ b/NPCs/ProfanedGuardians/ProfanedRocks.cs @@ -104,7 +104,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Stay invincile while the commander and defender are swapping sides and don't deal damage to avoid unfair hits if (Main.npc[CalamityGlobalNPC.doughnutBossDefender].localAI[3] == 1f) { - NPC.damage = 0; NPC.dontTakeDamage = true; NPC.Opacity -= 0.01f; @@ -117,7 +116,6 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Stay invincible for 100 frames to avoid being instantly killed and don't deal damage to avoid unfair hits else if (NPC.Opacity < 1f) { - NPC.damage = 0; NPC.dontTakeDamage = true; NPC.Opacity += 0.01f; @@ -127,12 +125,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians NPC.scale = MathHelper.Lerp(0.05f, 1f, NPC.Opacity); } else - { - NPC.damage = NPC.defDamage; NPC.dontTakeDamage = false; - } - Lighting.AddLight((int)((NPC.position.X + (NPC.width / 2)) / 16f), (int)((NPC.position.Y + (NPC.height / 2)) / 16f), 0.7f * NPC.Opacity, 0.55f * NPC.Opacity, 0f); + Lighting.AddLight((int)(NPC.Center.X / 16f), (int)(NPC.Center.Y / 16f), 0.7f * NPC.Opacity, 0.55f * NPC.Opacity, 0f); // Set time left just in case something dumb happens with despawning if (NPC.timeLeft < 1800) @@ -162,6 +157,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Fall down after some time and blow up if inside tiles if (NPC.Calamity().newAI[0] == -3f) { + // Set damage + NPC.damage = NPC.defDamage; + // Accelerate towards final velocity Vector2 finalVelocity = new Vector2(NPC.Calamity().newAI[2], NPC.Calamity().newAI[3]); if (NPC.velocity.Length() < finalVelocity.Length()) @@ -198,6 +196,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Charge else if (NPC.Calamity().newAI[0] == -2f) { + // Set damage + NPC.damage = NPC.defDamage; + // Start off slow Vector2 finalVelocity = NPC.SafeDirectionTo(player.Center, -Vector2.UnitY) * chargeSpeed; if (CalamityWorld.LegendaryMode && revenge) @@ -214,6 +215,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians // Rotate else { + // Avoid cheap bullshit + NPC.damage = 0; + // Push away from each other in Death and Boss Rush if (death) { @@ -267,6 +271,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians return; } + // Avoid cheap bullshit + NPC.damage = 0; + // Distance from Defender Guardian double maxDistance = bossRush ? 360D : death ? 340D : revenge ? 330D : expertMode ? 320D : MinMaxDistance; double rateOfChangeIncrease = (maxDistance / MinMaxDistance) - 1D; diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index f7ca2181ed..e6074c5bb1 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -90,13 +90,21 @@ namespace CalamityMod.NPCs.Signus Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.3f, 0.3f, 0.3f); NPC.alpha -= 3; - if (NPC.alpha < 0) + if (NPC.alpha <= 0) { + // Set damage + NPC.damage = NPC.defDamage; + NPC.alpha = 0; int lightDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, 204, 0f, 0f, 0, default, 0.25f); Main.dust[lightDust].velocity *= 0.1f; Main.dust[lightDust].noGravity = true; } + else + { + // Avoid cheap bullshit + NPC.damage = 0; + } bool revenge = CalamityWorld.revenge; float playerDistNormMult = revenge ? 24f : 22f; diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 2de9e35a39..713ec09eab 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -137,8 +137,6 @@ namespace CalamityMod.NPCs.Signus bool phase3 = lifeRatio < 0.5f; bool phase4 = lifeRatio < 0.33f; - NPC.damage = NPC.defDamage; - // Get a target if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead || !Main.player[NPC.target].active) NPC.TargetClosest(); @@ -223,6 +221,9 @@ namespace CalamityMod.NPCs.Signus if (NPC.ai[0] <= 2f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.rotation = NPC.velocity.X * 0.04f; float playerLocation = vectorCenter.X - player.Center.X; NPC.direction = playerLocation < 0f ? 1 : -1; @@ -271,6 +272,9 @@ namespace CalamityMod.NPCs.Signus } else if (NPC.ai[0] == 0f) { + // Avoid cheap bullshit + NPC.damage = 0; + if (Main.netMode != NetmodeID.MultiplayerClient) { NPC.localAI[1] += bossRush ? 1.5f : 1f; @@ -445,6 +449,9 @@ namespace CalamityMod.NPCs.Signus } else if (NPC.ai[0] == 3f) { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.rotation = NPC.velocity.X * 0.04f; float playerLocation = vectorCenter.X - player.Center.X; NPC.direction = playerLocation < 0f ? 1 : -1; @@ -609,6 +616,9 @@ namespace CalamityMod.NPCs.Signus if (calamityGlobalNPC.newAI[0] == 0f) // Line up the charge { + // Avoid cheap bullshit + NPC.damage = 0; + float velocity = bossRush ? 18f : revenge ? 16f : expertMode ? 15f : 14f; if (expertMode) velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); @@ -644,11 +654,17 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 1f) // Pause before charge { + // Avoid cheap bullshit + NPC.damage = 0; + NPC.velocity *= 0.8f; NPC.ai[1] += 1f; if (NPC.ai[1] >= 5f) { + // Set damage + NPC.damage = NPC.defDamage; + calamityGlobalNPC.newAI[0] = 2f; NPC.netUpdate = true; @@ -665,6 +681,9 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 2f) // Charging { + // Set damage + NPC.damage = NPC.defDamage; + if (Main.netMode != NetmodeID.MultiplayerClient) { bool buffed = false; @@ -715,6 +734,9 @@ namespace CalamityMod.NPCs.Signus } else if (calamityGlobalNPC.newAI[0] == 3f) // Slow down after charging and reset { + // Avoid cheap bullshit + NPC.damage = 0; + if (stealthTimer >= maxStealth) { stealthTimer = 0; diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index f765fe5fb4..5bb8a8b4d2 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -236,6 +236,21 @@ namespace CalamityMod.NPCs.StormWeaver else if (targetX > 0f) NPC.spriteDirection = 1; } + + // Calculate contact damage based on velocity + float velocity = (phase2 ? 12f : 10f) + (bossRush ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); + float minimalContactDamageVelocity = velocity * 0.25f; + float minimalDamageVelocity = velocity * 0.5f; + float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); + if (bodyAndTailVelocity <= minimalContactDamageVelocity) + { + NPC.damage = 0; + } + else + { + float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); + NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index c880a6ca64..4f33417791 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -245,10 +245,9 @@ namespace CalamityMod.NPCs.StormWeaver for (int i = 0; i < Main.maxNPCs; i++) { if (!Main.npc[i].active) - { npcCounts++; - } } + totalLength = npcCounts - 20; } @@ -767,6 +766,19 @@ namespace CalamityMod.NPCs.StormWeaver } } + // Calculate contact damage based on velocity + float minimalContactDamageVelocity = velocity * 0.25f; + float minimalDamageVelocity = velocity * 0.5f; + if (NPC.velocity.Length() <= minimalContactDamageVelocity) + { + NPC.damage = (int)(NPC.defDamage * 0.5f); + } + else + { + float velocityDamageScalar = MathHelper.Clamp((NPC.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); + NPC.damage = (int)MathHelper.Lerp(NPC.defDamage * 0.5f, NPC.defDamage, velocityDamageScalar); + } + NPC.rotation = (float)Math.Atan2(NPC.velocity.Y, NPC.velocity.X) + MathHelper.PiOver2; if (phase4) diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 4a065628fd..d887531908 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -105,6 +105,8 @@ namespace CalamityMod.NPCs.StormWeaver NPC.life = Main.npc[(int)NPC.ai[1]].life; bool bossRush = BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || bossRush; + bool revenge = CalamityWorld.revenge || bossRush; // Shed armor bool phase2 = NPC.life / (float)NPC.lifeMax < 0.8f; @@ -228,6 +230,21 @@ namespace CalamityMod.NPCs.StormWeaver else if (targetX > 0f) NPC.spriteDirection = 1; } + + // Calculate contact damage based on velocity + float velocity = (phase2 ? 12f : 10f) + (bossRush ? 3f : revenge ? 1.5f : expertMode ? 1f : 0f); + float minimalContactDamageVelocity = velocity * 0.25f; + float minimalDamageVelocity = velocity * 0.5f; + float bodyAndTailVelocity = (NPC.position - NPC.oldPosition).Length(); + if (bodyAndTailVelocity <= minimalContactDamageVelocity) + { + NPC.damage = 0; + } + else + { + float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); + NPC.damage = (int)MathHelper.Lerp(0f, NPC.defDamage, velocityDamageScalar); + } } public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs index bfb2dff935..2b946d496d 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DestroyerAI.cs @@ -338,6 +338,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + if (npc.type == NPCID.TheDestroyer) + { + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + } + else + { + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + } + int tilePosX = (int)(npc.position.X / 16f) - 1; int tileWidthPosX = (int)((npc.position.X + npc.width) / 16f) + 2; int tilePosY = (int)(npc.position.Y / 16f) - 1; @@ -411,7 +422,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[1] = 0f; // Despawn - float fallSpeed = masterMode ? 20f : 16f; + float segmentVelocity = masterMode ? 20f : 16f; if (player.dead) { shouldFly = false; @@ -420,7 +431,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.position.Y > Main.worldSurface * 16.0) { npc.velocity.Y += 2f; - fallSpeed *= 2f; + segmentVelocity *= 2f; } if (npc.position.Y > Main.rockLayer * 16.0) @@ -433,9 +444,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - float fallSpeedBoost = death ? 6.5f * (1f - lifeRatio) : 5f * (1f - lifeRatio); - fallSpeed += fallSpeedBoost; - fallSpeed += 4f * enrageScale; + float segmentVelocityBoost = death ? 6.5f * (1f - lifeRatio) : 5f * (1f - lifeRatio); + segmentVelocity += segmentVelocityBoost; + segmentVelocity += 4f * enrageScale; // Speed and movement float speedBoost = death ? (0.14f * (1f - lifeRatio)) : (0.1f * (1f - lifeRatio)); @@ -516,19 +527,19 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (masterMode && npc.velocity.Y > 0f) npc.velocity.Y += 0.05f; - if (npc.velocity.Y > fallSpeed) - npc.velocity.Y = fallSpeed; + if (npc.velocity.Y > segmentVelocity) + npc.velocity.Y = segmentVelocity; // This bool exists to stop the strange wiggle behavior when worms are falling down bool slowXVelocity = Math.Abs(npc.velocity.X) > speed; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.4) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.4) { if (npc.velocity.X < 0f) npc.velocity.X -= speed * 1.1f; else npc.velocity.X += speed * 1.1f; } - else if (npc.velocity.Y == fallSpeed) + else if (npc.velocity.Y == segmentVelocity) { if (slowXVelocity) { @@ -570,7 +581,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses targetTileDist = (float)Math.Sqrt(targetTilePosX * targetTilePosX + targetTilePosY * targetTilePosY); float absoluteTilePosX = Math.Abs(targetTilePosX); float absoluteTilePosY = Math.Abs(targetTilePosY); - float tileToReachTarget = fallSpeed / targetTileDist; + float tileToReachTarget = segmentVelocity / targetTileDist; targetTilePosX *= tileToReachTarget; targetTilePosY *= tileToReachTarget; @@ -581,7 +592,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { flyWyvernMovement = true; - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < fallSpeed) + if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < segmentVelocity) npc.velocity *= 1.1f; } @@ -589,14 +600,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { flyWyvernMovement = true; - if (Math.Abs(npc.velocity.X) < fallSpeed / 2f) + if (Math.Abs(npc.velocity.X) < segmentVelocity / 2f) { if (npc.velocity.X == 0f) npc.velocity.X -= npc.direction; npc.velocity.X *= 1.1f; } - else if (npc.velocity.Y > -fallSpeed) + else if (npc.velocity.Y > -segmentVelocity) npc.velocity.Y -= speed; } } @@ -629,14 +640,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (npc.velocity.Y > targetTilePosY) npc.velocity.Y -= speed; - if (Math.Abs(targetTilePosY) < fallSpeed * 0.2 && ((npc.velocity.X > 0f && targetTilePosX < 0f) || (npc.velocity.X < 0f && targetTilePosX > 0f))) + if (Math.Abs(targetTilePosY) < segmentVelocity * 0.2 && ((npc.velocity.X > 0f && targetTilePosX < 0f) || (npc.velocity.X < 0f && targetTilePosX > 0f))) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed * 2f; else npc.velocity.Y -= speed * 2f; } - if (Math.Abs(targetTilePosX) < fallSpeed * 0.2 && ((npc.velocity.Y > 0f && targetTilePosY < 0f) || (npc.velocity.Y < 0f && targetTilePosY > 0f))) + if (Math.Abs(targetTilePosX) < segmentVelocity * 0.2 && ((npc.velocity.Y > 0f && targetTilePosY < 0f) || (npc.velocity.Y < 0f && targetTilePosY > 0f))) { if (npc.velocity.X > 0f) npc.velocity.X += speed * 2f; @@ -651,7 +662,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (npc.velocity.X > targetTilePosX) npc.velocity.X -= speed * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) { if (npc.velocity.Y > 0f) npc.velocity.Y += speed; @@ -666,7 +677,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else if (npc.velocity.Y > targetTilePosY) npc.velocity.Y -= speed * 1.1f; - if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < fallSpeed * 0.5) + if ((Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y)) < segmentVelocity * 0.5) { if (npc.velocity.X > 0f) npc.velocity.X += speed; @@ -716,8 +727,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float minimalContactDamageVelocity = segmentVelocity * 0.25f; + float minimalDamageVelocity = segmentVelocity * 0.5f; if (npc.type == NPCID.TheDestroyer) { if (npc.velocity.Length() <= minimalContactDamageVelocity) @@ -895,6 +906,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + if (npc.type == NPCID.TheDestroyer) + { + if (npc.life > Main.npc[(int)npc.ai[0]].life) + npc.life = Main.npc[(int)npc.ai[0]].life; + } + else + { + if (npc.life > Main.npc[(int)npc.ai[1]].life) + npc.life = Main.npc[(int)npc.ai[1]].life; + } + int num13 = (int)(npc.position.X / 16f) - 1; int num14 = (int)((npc.position.X + (float)npc.width) / 16f) + 2; int num15 = (int)(npc.position.Y / 16f) - 1; @@ -1231,8 +1253,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 4f; - float minimalDamageVelocity = 8f; + float minimalContactDamageVelocity = num18 * 0.25f; + float minimalDamageVelocity = num18 * 0.5f; if (npc.type == NPCID.TheDestroyer) { if (npc.velocity.Length() <= minimalContactDamageVelocity) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index f49cb093f5..c3bb222f26 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -633,8 +633,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 3f; - float minimalDamageVelocity = 6f; + float minimalContactDamageVelocity = segmentVelocity * 0.25f; + float minimalDamageVelocity = segmentVelocity * 0.5f; if (npc.type == NPCID.EaterofWorldsHead) { if (npc.velocity.Length() <= minimalContactDamageVelocity) @@ -1133,8 +1133,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Calculate contact damage based on velocity - float minimalContactDamageVelocity = 2.5f; - float minimalDamageVelocity = 5f; + float minimalContactDamageVelocity = num52 * 0.25f; + float minimalDamageVelocity = num52 * 0.5f; if (npc.type == NPCID.EaterofWorldsHead) { if (npc.velocity.Length() <= minimalContactDamageVelocity)