aboutsummaryrefslogtreecommitdiff
path: root/src/game/Player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r--src/game/Player.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index ee4acd372d3..d901ac45476 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -4442,20 +4442,34 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
}
}
-bool Player::FallGround(bool noDeath/* = false*/)
+/**
+ * FallMode = 0 implies that the player is dying, or already dead, and the proper death state will be set.
+ * = 1 simply causes the player to plummet towards the ground, and not suffer any damage.
+ * = 2 causes the player to plummet towards the ground, and causes falling damage, regardless
+ * of any auras that might of prevented fall damage.
+ */
+bool Player::FallGround(uint8 FallMode)
{
// Let's abort after we called this function one time
- if (getDeathState() == DEAD_FALLING && !noDeath)
+ if (getDeathState() == DEAD_FALLING && FallMode == 0)
return false;
float x, y, z;
GetPosition(x, y, z);
float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
- if (fabs(ground_Z - z) < 0.1f)
+ float z_diff = 0.0f;
+ if ((z_diff = fabs(ground_Z - z)) < 0.1f)
return false;
+ // Below formula for falling damage is from Player::HandleFall
+ if(FallMode == 2 && z_diff >= 14.57f)
+ {
+ uint32 damage = std::min(GetMaxHealth(), (uint32)((0.018f*z_diff-0.2426f)*GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL)));
+ if(damage > 0) EnvironmentalDamage(DAMAGE_FALL, damage);
+ }
+
GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND);
- if(!noDeath) Unit::setDeathState(DEAD_FALLING);
+ if(FallMode == 0) Unit::setDeathState(DEAD_FALLING);
return true;
}