Changes from feedback
This commit is contained in:
1 parent
b40def24e8
commit
e087faaea6
3 files changed
+39
-15
No files matched your search
@@ -3451,12 +3451,9 @@ namespace CalamityMod.CalPlayer
|
||||
}
|
||||
else if (shieldOfTheOcean && shieldOfTheOceanParry == 0)
|
||||
{
|
||||
//if (!Player.HasCooldown(ParryCooldown.ID))
|
||||
{
|
||||
GeneralScreenShakePower = 2f;
|
||||
SoundEngine.PlaySound(ShieldoftheOcean.TriggerSound, Player.Center);
|
||||
shieldOfTheOceanParry = ShieldoftheOcean.ParryTime;
|
||||
}
|
||||
GeneralScreenShakePower = 2f;
|
||||
SoundEngine.PlaySound(ShieldoftheOcean.TriggerSound, Player.Center);
|
||||
shieldOfTheOceanParry = ShieldoftheOcean.ParryTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,10 @@ namespace CalamityMod.Items.Accessories
|
||||
npc.MoveNPC(Vector2.Normalize(shoveVelocity), shoveVelocity.Length(), true);
|
||||
|
||||
int scaledFallDamage = ShoveFallBaseDamage * (Main.masterMode ? 3 : Main.expertMode ? 2 : 1) * (Main.zenithWorld ? 10 : 1);
|
||||
npc.FlungNPC().ApplyCollisionDamage(npc, player, scaledFallDamage, shoveVelocity * 0.5f, 5f, true, !empowered);
|
||||
if (empowered)
|
||||
npc.FlungNPC().ApplyCollisionDamage(npc, player, scaledFallDamage, shoveVelocity * 0.5f, 5f, true);
|
||||
else
|
||||
npc.FlungNPC().ApplyForcedVelocity(npc, player, shoveVelocity * 0.5f, true);
|
||||
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,10 @@ namespace CalamityMod.NPCs
|
||||
private float terminalVelocityForFullFallDamage = 0;
|
||||
private bool CheckTiles = false;
|
||||
private Vector2 ForcedVel = Vector2.Zero;
|
||||
private bool DontDealDamage = false;
|
||||
/// <summary>
|
||||
/// Set to true if you only want the npc to receive forced velocity and not receive damage.
|
||||
/// </summary>
|
||||
private bool ForceVelocityOnly = false;
|
||||
private bool hitVoid = false;
|
||||
private Player attacker;
|
||||
private int packetTimer = 0;
|
||||
@@ -44,7 +47,7 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
}
|
||||
|
||||
public bool FallDamageSusceptible => PotentialEnergyDamage > 0;
|
||||
public bool FallDamageSusceptible => PotentialEnergyDamage > 0 || ForceVelocityOnly;
|
||||
|
||||
public override bool InstancePerEntity => true;
|
||||
|
||||
@@ -68,14 +71,14 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up a NPC to recieve fall damage when they hit the ground.
|
||||
/// Sets up a NPC to recieve forced velocity in a direction and receive fall damage when they hit the ground.
|
||||
/// </summary>
|
||||
/// <param name="npc">The npc to apply fall damage to</param>
|
||||
/// <param name="player">The player applying fall damage to the npc</param>
|
||||
/// <param name="potentialDamage">The maximum fall damage taken by the npc once they hit the ground</param>
|
||||
/// <param name="terminalVelocityForFullDamage">The downwards velocity necessary to recieve the full fall damage. By default 10, the npc max fall speed</param>
|
||||
/// <param name="checkTiles">Will check for tiles in the collision instead of velocity</param>
|
||||
public void ApplyCollisionDamage(NPC npc, Player player, int potentialDamage, Vector2 forcedVel, float terminalVelocityForFullDamage = 10f, bool checkTiles = false, bool dontDealDamage = false)
|
||||
public void ApplyCollisionDamage(NPC npc, Player player, int potentialDamage, Vector2 forcedVel, float terminalVelocityForFullDamage = 10f, bool checkTiles = false)
|
||||
{
|
||||
//NPCs that don't collide with tiles simply don't get fall damage, lol.
|
||||
if (npc.noTileCollide)
|
||||
@@ -88,7 +91,27 @@ namespace CalamityMod.NPCs
|
||||
CheckTiles = checkTiles;
|
||||
ForcedVel = forcedVel;
|
||||
attacker = player;
|
||||
DontDealDamage = dontDealDamage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up a NPC to recieve forced velocity in a direction.
|
||||
/// </summary>
|
||||
/// <param name="npc">The npc to apply velocity to</param>
|
||||
/// <param name="player">The player applying velocity to the npc</param>
|
||||
/// <param name="forcedVel">The velocity being applied to the npc</param>
|
||||
/// <param name="checkTiles">Will check for tiles in the collision instead of velocity</param>
|
||||
public void ApplyForcedVelocity(NPC npc, Player player, Vector2 forcedVel, bool checkTiles = false)
|
||||
{
|
||||
// NPCs that don't collide with tiles simply don't get velocity, lol.
|
||||
if (npc.noTileCollide)
|
||||
return;
|
||||
|
||||
OldVelocity = npc.velocity;
|
||||
OlderVelocity = npc.velocity;
|
||||
CheckTiles = checkTiles;
|
||||
ForcedVel = forcedVel;
|
||||
attacker = player;
|
||||
ForceVelocityOnly = true;
|
||||
}
|
||||
|
||||
public override void PostAI(NPC npc)
|
||||
@@ -101,7 +124,7 @@ namespace CalamityMod.NPCs
|
||||
|
||||
if (Collision.SolidCollision(npc.Center, (int)(npc.width * 0.5f), (int)(npc.height * 0.5f)) || !WorldGen.InWorld(npc.Center.ToTileCoordinates().X, npc.Center.ToTileCoordinates().Y, 40))
|
||||
{
|
||||
if (!DontDealDamage)
|
||||
if (!ForceVelocityOnly)
|
||||
{
|
||||
int wallImpactDamage = (int)(PotentialEnergyDamage * Math.Clamp(oldVelocity / terminalVelocityForFullFallDamage, 0f, 1f));
|
||||
Projectile wallImpact = Projectile.NewProjectileDirect(attacker.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), wallImpactDamage, 0f, attacker.whoAmI, npc.whoAmI);
|
||||
@@ -109,10 +132,10 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
|
||||
PotentialEnergyDamage = 0;
|
||||
ForceVelocityOnly = false;
|
||||
hitVoid = false;
|
||||
}
|
||||
|
||||
oldVelocity = npc.velocity.Length();
|
||||
npc.Center += ForcedVel;
|
||||
ForcedVel *= 0.995f;
|
||||
if (packetTimer % 30 == 0)
|
||||
@@ -143,7 +166,7 @@ namespace CalamityMod.NPCs
|
||||
//If the npc hit a tile/Came to a stop after falling
|
||||
if (newVerticalVelocity == 0 && oldVerticalVelocity > 0) //Collision.SolidCollision(npc.Center, npc.width, npc.height))
|
||||
{
|
||||
if (!DontDealDamage)
|
||||
if (!ForceVelocityOnly)
|
||||
{
|
||||
int impactDamage = (int)(PotentialEnergyDamage * Math.Clamp(olderVerticalVelocity / terminalVelocityForFullFallDamage, 0f, 1f));
|
||||
Projectile impact = Projectile.NewProjectileDirect(attacker.GetSource_FromThis(), npc.Center, Vector2.Zero, ModContent.ProjectileType<DirectStrike>(), impactDamage, 0f, attacker.whoAmI, npc.whoAmI);
|
||||
@@ -151,6 +174,7 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
|
||||
PotentialEnergyDamage = 0;
|
||||
ForceVelocityOnly = false;
|
||||
}
|
||||
|
||||
OlderVelocity = OldVelocity;
|
||||
|
||||
Reference in new issue
Block a user