*Extend and comment the Player::FallGround function, it can now cause damage if required.
--HG-- branch : trunk
This commit is contained in:
+18
-4
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user