diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 4ae1dda603..0850635512 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -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; } } diff --git a/Items/Accessories/ShieldoftheOcean.cs b/Items/Accessories/ShieldoftheOcean.cs index e7da8e9be9..cacb484ead 100644 --- a/Items/Accessories/ShieldoftheOcean.cs +++ b/Items/Accessories/ShieldoftheOcean.cs @@ -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++) { diff --git a/NPCs/CalamityTileCollisionHarmNPC.cs b/NPCs/CalamityTileCollisionHarmNPC.cs index 0b284ba080..0e1c4d420a 100644 --- a/NPCs/CalamityTileCollisionHarmNPC.cs +++ b/NPCs/CalamityTileCollisionHarmNPC.cs @@ -25,7 +25,10 @@ namespace CalamityMod.NPCs private float terminalVelocityForFullFallDamage = 0; private bool CheckTiles = false; private Vector2 ForcedVel = Vector2.Zero; - private bool DontDealDamage = false; + /// + /// Set to true if you only want the npc to receive forced velocity and not receive damage. + /// + 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 } /// - /// 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. /// /// The npc to apply fall damage to /// The player applying fall damage to the npc /// The maximum fall damage taken by the npc once they hit the ground /// The downwards velocity necessary to recieve the full fall damage. By default 10, the npc max fall speed /// Will check for tiles in the collision instead of velocity - 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; + } + + /// + /// Sets up a NPC to recieve forced velocity in a direction. + /// + /// The npc to apply velocity to + /// The player applying velocity to the npc + /// The velocity being applied to the npc + /// Will check for tiles in the collision instead of velocity + 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(), 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(), impactDamage, 0f, attacker.whoAmI, npc.whoAmI); @@ -151,6 +174,7 @@ namespace CalamityMod.NPCs } PotentialEnergyDamage = 0; + ForceVelocityOnly = false; } OlderVelocity = OldVelocity;