diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Player.cpp | 22 | ||||
-rw-r--r-- | src/game/Player.h | 2 |
2 files changed, 19 insertions, 5 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; } diff --git a/src/game/Player.h b/src/game/Player.h index 98596974178..0de17a137d2 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1748,7 +1748,7 @@ class MANGOS_DLL_SPEC Player : public Unit Corpse *GetCorpse() const; void SpawnCorpseBones(); void CreateCorpse(); - bool FallGround(bool noDeath = false); + bool FallGround(uint8 FallMode = 0); void KillPlayer(); uint32 GetResurrectionSpellId(); void ResurrectPlayer(float restore_percent, bool applySickness = false); |