This commit is contained in:
IbanPlay committed 2022-03-24 02:37:36 +01:00
commit 57abe0e8f8
8 files changed
+55 -250

No files matched your search

+25 -3
View File
@@ -5634,10 +5634,32 @@ namespace CalamityMod.NPCs
}
}
}
#endregion
#endregion
#region Astral things
public static void DoHitDust(NPC npc, int hitDirection, int dustType = 5, float xSpeedMult = 1f, int numHitDust = 5, int numDeathDust = 20)
#region Smooth Movement
public static void SmoothMovement(NPC npc, float movementDistanceGateValue, Vector2 distanceFromDestination, float baseVelocity)
{
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
}
#endregion
#region Astral things
public static void DoHitDust(NPC npc, int hitDirection, int dustType = 5, float xSpeedMult = 1f, int numHitDust = 5, int numDeathDust = 20)
{
for (int k = 0; k < 5; k++)
{
+8 -64
View File
@@ -953,22 +953,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Fly to the right of the target
case (int)Phase.Normal:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Apollo is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
// Default animation for 60 frames and then go to telegraph animation
// newAI[3] tells Apollo what animation state it's currently in
@@ -1039,22 +1025,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Charge
case (int)Phase.RocketBarrage:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue2 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity2 = distanceFromDestination.Length();
float minVelocityCap2 = baseVelocity;
if (minVelocity2 > minVelocityCap2)
minVelocity2 = minVelocityCap2;
// Max velocity
Vector2 maxVelocity2 = distanceFromDestination / 24f;
float maxVelocityCap2 = minVelocityCap2 * 3f;
if (maxVelocity2.Length() > maxVelocityCap2)
maxVelocity2 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap2;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity2, maxVelocity2, lerpValue2);
// Smooth movement towards the location Apollo is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
calamityGlobalNPC.newAI[2] += 1f;
if (calamityGlobalNPC.newAI[2] % (rocketPhaseDuration / numRockets) == 0f && canFire)
@@ -1090,22 +1062,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
if (!readyToCharge)
{
// Inverse lerp returns the percentage of progress between A and B
float lerpValue3 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity3 = distanceFromDestination.Length();
float minVelocityCap3 = baseVelocity;
if (minVelocity3 > minVelocityCap3)
minVelocity3 = minVelocityCap3;
// Max velocity
Vector2 maxVelocity3 = distanceFromDestination / 24f;
float maxVelocityCap3 = minVelocityCap3 * 3f;
if (maxVelocity3.Length() > maxVelocityCap3)
maxVelocity3 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap3;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity3, maxVelocity3, lerpValue3);
// Smooth movement towards the location Apollo is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
}
else
{
@@ -1299,22 +1257,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Phase transition animation, that's all this exists for
case (int)Phase.PhaseTransition:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue4 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity4 = distanceFromDestination.Length();
float minVelocityCap4 = baseVelocity;
if (minVelocity4 > minVelocityCap4)
minVelocity4 = minVelocityCap4;
// Max velocity
Vector2 maxVelocity4 = distanceFromDestination / 24f;
float maxVelocityCap4 = minVelocityCap4 * 3f;
if (maxVelocity4.Length() > maxVelocityCap4)
maxVelocity4 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap4;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity4, maxVelocity4, lerpValue4);
// Smooth movement towards the location Apollo is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
// Shoot lens gore at the target at the proper time
if (calamityGlobalNPC.newAI[2] == lensPopTime)
+2 -17
View File
@@ -640,22 +640,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
// Fly above the target
case (int)Phase.Normal:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Ares is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
if (shouldGetBuffedByBerserkPhase)
{
@@ -732,7 +718,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
int totalProjectiles = malice ? 12 : death ? 10 : revenge ? 9 : expertMode ? 8 : 6;
float radians = MathHelper.TwoPi / totalProjectiles;
Vector2 laserSpawnPoint = new Vector2(npc.Center.X, npc.Center.Y);
bool normalLaserRotation = npc.localAI[0] % 2f == 0f;
float velocity = 6f;
double angleA = radians * 0.5;
+2 -17
View File
@@ -455,23 +455,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
EnergyDrawer.Update();
// Movement
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Ares Gauss Nuke is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false;
+6 -48
View File
@@ -374,22 +374,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
// Do nothing, rotate to aim at the target and fly in place
case (int)Phase.Nothing:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Ares Laser Cannon is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
calamityGlobalNPC.newAI[1] += 1f;
if (calamityGlobalNPC.newAI[1] >= deathrayPhaseGateValue)
@@ -410,22 +396,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration - 100f && !fireNormalLasers)
Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/CrystylCharge"), npc.Center);
// Inverse lerp returns the percentage of progress between A and B
float lerpValue2 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity2 = distanceFromDestination.Length();
float minVelocityCap2 = baseVelocity;
if (minVelocity2 > minVelocityCap2)
minVelocity2 = minVelocityCap2;
// Max velocity
Vector2 maxVelocity2 = distanceFromDestination / 24f;
float maxVelocityCap2 = minVelocityCap2 * 3f;
if (maxVelocity2.Length() > maxVelocityCap2)
maxVelocity2 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap2;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity2, maxVelocity2, lerpValue2);
// Smooth movement towards the location Ares Laser Cannon is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
// Set frames to deathray charge up frames, which begin on frame 12
if (calamityGlobalNPC.newAI[2] == 1f)
@@ -449,22 +421,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
// Fire regular Thanatos lasers if Ares is in deathray phase, otherwise, fire deathray
if (fireNormalLasers)
{
// Inverse lerp returns the percentage of progress between A and B
float lerpValue3 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity3 = distanceFromDestination.Length();
float minVelocityCap3 = baseVelocity;
if (minVelocity3 > minVelocityCap3)
minVelocity3 = minVelocityCap3;
// Max velocity
Vector2 maxVelocity3 = distanceFromDestination / 24f;
float maxVelocityCap3 = minVelocityCap3 * 3f;
if (maxVelocity3.Length() > maxVelocityCap3)
maxVelocity3 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap3;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity3, maxVelocity3, lerpValue3);
// Smooth movement towards the location Ares Laser Cannon is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
// Fire Thanatos lasers
int numLasers = enraged ? 9 : lastMechAlive ? 3 : 2;
+2 -17
View File
@@ -455,23 +455,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
EnergyDrawer.Update();
// Movement
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Ares Plasma Flamethrower is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false;
+2 -17
View File
@@ -449,23 +449,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
EnergyDrawer.Update();
// Movement
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Ares Tesla Cannon is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
}
public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false;
+8 -67
View File
@@ -586,9 +586,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
}
}
// Destination variables
Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination) * baseVelocity;
// Duration of deathray spin to do a full circle
// Normal = 120, Expert = 104, Rev = 96, Death = 88, Malice = 72
float spinTime = 120f - 320f * (baseVelocityMult - 1.25f);
@@ -657,22 +654,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Set charge variable to default
chargeVelocityNormalized = default;
// Inverse lerp returns the percentage of progress between A and B
float lerpValue2 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity2 = distanceFromDestination.Length();
float minVelocityCap2 = baseVelocity;
if (minVelocity2 > minVelocityCap2)
minVelocity2 = minVelocityCap2;
// Max velocity
Vector2 maxVelocity2 = distanceFromDestination / 24f;
float maxVelocityCap2 = minVelocityCap2 * 3f;
if (maxVelocity2.Length() > maxVelocityCap2)
maxVelocity2 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap2;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity2, maxVelocity2, lerpValue2);
// Smooth movement towards the location Artemis is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
}
else
{
@@ -829,22 +812,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Laser shotgun barrage
case (int)Phase.LaserShotgun:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity = distanceFromDestination.Length();
float minVelocityCap = baseVelocity;
if (minVelocity > minVelocityCap)
minVelocity = minVelocityCap;
// Max velocity
Vector2 maxVelocity = distanceFromDestination / 24f;
float maxVelocityCap = minVelocityCap * 3f;
if (maxVelocity.Length() > maxVelocityCap)
maxVelocity = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue);
// Smooth movement towards the location Artemis is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
// Fire lasers
int numSpreads = lastMechAlive ? 3 : 2;
@@ -1040,22 +1009,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
}
else
{
// Inverse lerp returns the percentage of progress between A and B
float lerpValue3 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity3 = distanceFromDestination.Length();
float minVelocityCap3 = baseVelocity;
if (minVelocity3 > minVelocityCap3)
minVelocity3 = minVelocityCap3;
// Max velocity
Vector2 maxVelocity3 = distanceFromDestination / 24f;
float maxVelocityCap3 = minVelocityCap3 * 3f;
if (maxVelocity3.Length() > maxVelocityCap3)
maxVelocity3 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap3;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity3, maxVelocity3, lerpValue3);
// Smooth movement towards the location Artemis is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
}
// Reset phase and variables
@@ -1105,22 +1060,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Phase transition animation, that's all this exists for
case (int)Phase.PhaseTransition:
// Inverse lerp returns the percentage of progress between A and B
float lerpValue4 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true);
// Min velocity
float minVelocity4 = distanceFromDestination.Length();
float minVelocityCap4 = baseVelocity;
if (minVelocity4 > minVelocityCap4)
minVelocity4 = minVelocityCap4;
// Max velocity
Vector2 maxVelocity4 = distanceFromDestination / 24f;
float maxVelocityCap4 = minVelocityCap4 * 3f;
if (maxVelocity4.Length() > maxVelocityCap4)
maxVelocity4 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap4;
npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity4, maxVelocity4, lerpValue4);
// Smooth movement towards the location Artemis is meant to be at
CalamityGlobalNPC.SmoothMovement(npc, movementDistanceGateValue, distanceFromDestination, baseVelocity);
// Shoot lens gore at the target at the proper time
if (calamityGlobalNPC.newAI[2] == lensPopTime)