*Extend and comment the Player::FallGround function, it can now cause damage if required.

--HG--
branch : trunk
This commit is contained in:
maximius
2009-09-26 12:26:02 -07:00
parent e2017fcf5d
commit ff9a2f6ba1
2 changed files with 19 additions and 5 deletions
+18 -4
View File
@@ -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
View File
@@ -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);