Exo Mechs contact damage fairness.

This commit is contained in:
mountaindrew10 committed 2024-02-29 08:20:18 -06:00
1 parent 0914fc8f56
commit 06dd79ead2
6 files changed
+219 -38

No files matched your search

+22 -1
View File
@@ -956,6 +956,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Fly to the right of the target
case (int)Phase.Normal:
// Avoid cheap bullshit
NPC.damage = 0;
// Smooth movement towards the location Apollo is meant to be at
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
@@ -1029,6 +1032,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Charge
case (int)Phase.RocketBarrage:
// Avoid cheap bullshit
NPC.damage = 0;
// Smooth movement towards the location Apollo is meant to be at
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
@@ -1070,6 +1076,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Create telegraph beams between the charge location array positions
case (int)Phase.LineUpChargeCombo:
// Avoid cheap bullshit
NPC.damage = 0;
if (!readyToCharge)
{
// Smooth movement towards the location Apollo is meant to be at
@@ -1131,6 +1140,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
calamityGlobalNPC.newAI[2] += 1f;
if (calamityGlobalNPC.newAI[2] >= timeToLineUpCharge)
{
// Set damage
NPC.damage = NPC.defDamage;
ExoMechsSky.CreateLightningBolt(10);
AIState = (float)Phase.ChargeCombo;
@@ -1144,6 +1156,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Charge to several locations almost instantly (Apollo doesn't teleport here, he's just moving very fast :D)
case (int)Phase.ChargeCombo:
// Set damage
NPC.damage = NPC.defDamage;
// Tell Artemis to not fire lasers for a short time
NPC.ai[3] = 61f;
@@ -1247,6 +1262,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Reset phase and variables
if (calamityGlobalNPC.newAI[2] >= maxCharges - 1)
{
// Avoid cheap bullshit
NPC.damage = 0;
if (Main.zenithWorld && !exoMechdusa)
{
pickNewLocation = NPC.localAI[2] == 0f;
@@ -1284,6 +1302,9 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Phase transition animation, that's all this exists for
case (int)Phase.PhaseTransition:
// Avoid cheap bullshit
NPC.damage = 0;
// Smooth movement towards the location Apollo is meant to be at
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
@@ -1367,7 +1388,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
if (hitboxBotRight < minDist)
minDist = hitboxBotRight;
return minDist <= 100f && NPC.Opacity == 1f && AIState == (float)Phase.ChargeCombo;
return minDist <= 100f && NPC.Opacity == 1f;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
+22 -1
View File
@@ -730,6 +730,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Fly to the left of the target
case (int)Phase.Normal:
// Avoid cheap bullshit
NPC.damage = 0;
if (!stopRotatingAndSlowDown)
{
// Set charge variable to default
@@ -865,6 +868,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
}
else
{
// Set damage
NPC.damage = NPC.defDamage;
// Charge until a certain distance is reached and then return to normal phase
SoundEngine.PlaySound(ChargeSound, NPC.Center);
AIState = (float)Phase.Charge;
@@ -883,6 +889,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Charge
case (int)Phase.Charge:
// Set damage
NPC.damage = NPC.defDamage;
// Allow the charge flash to happen
shouldDoChargeFlash = true;
@@ -890,6 +899,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
calamityGlobalNPC.newAI[2] += 1f;
if (calamityGlobalNPC.newAI[2] >= chargeDuration)
{
// Avoid cheap bullshit
NPC.damage = 0;
// Decelerate
NPC.velocity *= decelerationVelocityMult;
@@ -907,6 +919,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Laser shotgun barrage
case (int)Phase.LaserShotgun:
// Avoid cheap bullshit
NPC.damage = 0;
// Smooth movement towards the location Artemis is meant to be at
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
@@ -967,6 +982,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Fly above target, fire deathray and move in a circle around the target
case (int)Phase.Deathray:
// Avoid cheap bullshit
NPC.damage = 0;
// Fly above, stop doing this if in the proper position
// Stop rotating and spin around a target point
if ((destination - NPC.Center).Length() < spinLocationDistance || calamityGlobalNPC.newAI[2] > 0f)
@@ -1184,6 +1202,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Phase transition animation, that's all this exists for
case (int)Phase.PhaseTransition:
// Avoid cheap bullshit
NPC.damage = 0;
// Smooth movement towards the location Artemis is meant to be at
CalamityUtils.SmoothMovement(NPC, movementDistanceGateValue, distanceFromDestination, baseVelocity, 0f, false);
@@ -1261,7 +1282,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
if (hitboxBotRight < minDist)
minDist = hitboxBotRight;
return minDist <= 100f && NPC.Opacity == 1f && AIState == (float)Phase.Charge;
return minDist <= 100f && NPC.Opacity == 1f;
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position)
+54 -12
View File
@@ -169,7 +169,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
// Set vulnerable to false by default
vulnerable = false;
CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)NPC.ai[2]].Calamity();
NPC head = Main.npc[(int)NPC.ai[2]];
CalamityGlobalNPC calamityGlobalNPC_Head = head.Calamity();
bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
@@ -470,7 +471,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
SmokeDrawer.Update();
Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target];
Player player = Main.player[head.target];
Vector2 npcCenter = NPC.Center;
float targetCenterX = player.Center.X;
@@ -482,31 +483,72 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
targetCenterX -= npcCenter.X;
targetCenterY -= npcCenter.Y;
float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
float newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X;
targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y;
npcCenter = NPC.Center;
targetCenterX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X;
targetCenterY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y;
}
catch { }
NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2;
distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
distanceFromTarget = (distanceFromTarget - NPC.width) / distanceFromTarget;
targetCenterX *= distanceFromTarget;
targetCenterY *= distanceFromTarget;
newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
newPosition = (newPosition - NPC.width) / newPosition;
targetCenterX *= newPosition;
targetCenterY *= newPosition;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetCenterX;
NPC.position.Y = NPC.position.Y + targetCenterY;
NPC.position.X += targetCenterX;
NPC.position.Y += targetCenterY;
if (targetCenterX < 0f)
NPC.spriteDirection = -1;
else if (targetCenterX > 0f)
NPC.spriteDirection = 1;
}
bool speedUp = head.localAI[3] < 180f;
// Distance from target
float distanceFromTarget = Vector2.Distance(head.Center, speedUp ? (player.Center + new Vector2(0f, 2400f)) : player.Center);
// Increase speed if too far from target
float increaseSpeedMult = 1f;
float increaseSpeedGateValue = 600f;
if (distanceFromTarget > increaseSpeedGateValue)
{
float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f);
increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount);
}
// Velocity and turn speed values
float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f);
float baseVelocity = 10f * baseVelocityMult;
// Increase top velocity if target is dead or if Thanatos is uncoiling
if (player.dead || speedUp)
baseVelocity *= 4f;
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
baseVelocity *= 1.15f;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = baseVelocity * 0.25f;
float minimalDamageVelocity = baseVelocity * 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 CanHitPlayer(Player target, ref int cooldownSlot)
+54 -12
View File
@@ -167,7 +167,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
// Set vulnerable to false by default
vulnerable = false;
CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)NPC.ai[2]].Calamity();
NPC head = Main.npc[(int)NPC.ai[2]];
CalamityGlobalNPC calamityGlobalNPC_Head = head.Calamity();
bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
@@ -470,7 +471,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
SmokeDrawer.Update();
Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target];
Player player = Main.player[head.target];
Vector2 npcCenter = NPC.Center;
float targetCenterX = player.Center.X;
@@ -482,33 +483,74 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
targetCenterX -= npcCenter.X;
targetCenterY -= npcCenter.Y;
float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
float newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X;
targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y;
npcCenter = NPC.Center;
targetCenterX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X;
targetCenterY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2;
distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
distanceFromTarget = (distanceFromTarget - NPC.width) / distanceFromTarget;
targetCenterX *= distanceFromTarget;
targetCenterY *= distanceFromTarget;
newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
newPosition = (newPosition - NPC.width) / newPosition;
targetCenterX *= newPosition;
targetCenterY *= newPosition;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetCenterX;
NPC.position.Y = NPC.position.Y + targetCenterY;
NPC.position.X += targetCenterX;
NPC.position.Y += targetCenterY;
if (targetCenterX < 0f)
NPC.spriteDirection = -1;
else if (targetCenterX > 0f)
NPC.spriteDirection = 1;
}
bool speedUp = head.localAI[3] < 180f;
// Distance from target
float distanceFromTarget = Vector2.Distance(head.Center, speedUp ? (player.Center + new Vector2(0f, 2400f)) : player.Center);
// Increase speed if too far from target
float increaseSpeedMult = 1f;
float increaseSpeedGateValue = 600f;
if (distanceFromTarget > increaseSpeedGateValue)
{
float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f);
increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount);
}
// Velocity and turn speed values
float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f);
float baseVelocity = 10f * baseVelocityMult;
// Increase top velocity if target is dead or if Thanatos is uncoiling
if (player.dead || speedUp)
baseVelocity *= 4f;
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
baseVelocity *= 1.15f;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = baseVelocity * 0.25f;
float minimalDamageVelocity = baseVelocity * 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 CanHitPlayer(Player target, ref int cooldownSlot)
+13
View File
@@ -1010,6 +1010,19 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
}
}
}
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = baseVelocity * 0.25f;
float minimalDamageVelocity = baseVelocity * 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);
}
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot)
+54 -12
View File
@@ -167,7 +167,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
// Set vulnerable to false by default
vulnerable = false;
CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)NPC.ai[2]].Calamity();
NPC head = Main.npc[(int)NPC.ai[2]];
CalamityGlobalNPC calamityGlobalNPC_Head = head.Calamity();
bool invisiblePhase = calamityGlobalNPC_Head.newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune;
NPC.dontTakeDamage = Main.npc[(int)NPC.ai[2]].dontTakeDamage;
@@ -468,7 +469,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
SmokeDrawer.Update();
Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechWorm].target];
Player player = Main.player[head.target];
Vector2 npcCenter = NPC.Center;
float targetCenterX = player.Center.X;
@@ -480,33 +481,74 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos
targetCenterX -= npcCenter.X;
targetCenterY -= npcCenter.Y;
float distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
float newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
if (NPC.ai[1] > 0f && NPC.ai[1] < Main.npc.Length)
{
try
{
npcCenter = new Vector2(NPC.position.X + NPC.width * 0.5f, NPC.position.Y + NPC.height * 0.5f);
targetCenterX = Main.npc[(int)NPC.ai[1]].position.X + (Main.npc[(int)NPC.ai[1]].width / 2) - npcCenter.X;
targetCenterY = Main.npc[(int)NPC.ai[1]].position.Y + (Main.npc[(int)NPC.ai[1]].height / 2) - npcCenter.Y;
npcCenter = NPC.Center;
targetCenterX = Main.npc[(int)NPC.ai[1]].Center.X - npcCenter.X;
targetCenterY = Main.npc[(int)NPC.ai[1]].Center.Y - npcCenter.Y;
}
catch
{
}
NPC.rotation = (float)Math.Atan2(targetCenterY, targetCenterX) + MathHelper.PiOver2;
distanceFromTarget = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
distanceFromTarget = (distanceFromTarget - NPC.width) / distanceFromTarget;
targetCenterX *= distanceFromTarget;
targetCenterY *= distanceFromTarget;
newPosition = (float)Math.Sqrt(targetCenterX * targetCenterX + targetCenterY * targetCenterY);
newPosition = (newPosition - NPC.width) / newPosition;
targetCenterX *= newPosition;
targetCenterY *= newPosition;
NPC.velocity = Vector2.Zero;
NPC.position.X = NPC.position.X + targetCenterX;
NPC.position.Y = NPC.position.Y + targetCenterY;
NPC.position.X += targetCenterX;
NPC.position.Y += targetCenterY;
if (targetCenterX < 0f)
NPC.spriteDirection = -1;
else if (targetCenterX > 0f)
NPC.spriteDirection = 1;
}
bool speedUp = head.localAI[3] < 180f;
// Distance from target
float distanceFromTarget = Vector2.Distance(head.Center, speedUp ? (player.Center + new Vector2(0f, 2400f)) : player.Center);
// Increase speed if too far from target
float increaseSpeedMult = 1f;
float increaseSpeedGateValue = 600f;
if (distanceFromTarget > increaseSpeedGateValue)
{
float distanceAmount = MathHelper.Clamp((distanceFromTarget - increaseSpeedGateValue) / (CalamityGlobalNPC.CatchUpDistance350Tiles - increaseSpeedGateValue), 0f, 1f);
increaseSpeedMult = MathHelper.Lerp(1f, 3.5f, distanceAmount);
}
// Velocity and turn speed values
float baseVelocityMult = (shouldGetBuffedByBerserkPhase ? 0.15f : 0f) + (bossRush ? 1.25f : death ? 1.2f : revenge ? 1.175f : expertMode ? 1.15f : 1.1f);
float baseVelocity = 10f * baseVelocityMult;
// Increase top velocity if target is dead or if Thanatos is uncoiling
if (player.dead || speedUp)
baseVelocity *= 4f;
else
baseVelocity *= increaseSpeedMult;
if (Main.getGoodWorld)
baseVelocity *= 1.15f;
// Calculate contact damage based on velocity
float minimalContactDamageVelocity = baseVelocity * 0.25f;
float minimalDamageVelocity = baseVelocity * 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 CanHitPlayer(Player target, ref int cooldownSlot)