Core/Entities: Account for creatures that are spawned below ground level when adding flying flags. (Triggers, mostly)

This commit is contained in:
Subv
2012-12-29 14:23:23 -05:00
parent 792edb2880
commit 3d3a8107e0
@@ -437,7 +437,7 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData* data)
float ground = GetPositionZ(); float ground = GetPositionZ();
GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground); GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground);
bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground); bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZ(), ground - 0.05f); // Can be underground too, prevent the falling
if (cInfo->InhabitType & INHABIT_AIR && cInfo->InhabitType & INHABIT_GROUND && isInAir) if (cInfo->InhabitType & INHABIT_AIR && cInfo->InhabitType & INHABIT_GROUND && isInAir)
SetCanFly(true); SetCanFly(true);
@@ -482,7 +482,7 @@ void Creature::Update(uint32 diff)
float ground = GetPositionZ(); float ground = GetPositionZ();
GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground); GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground);
bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground + 0.05f); bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZ(), ground - 0.05f); // Can be underground too, prevent the falling
CreatureTemplate const* cinfo = GetCreatureTemplate(); CreatureTemplate const* cinfo = GetCreatureTemplate();
if (cinfo->InhabitType & INHABIT_AIR && cinfo->InhabitType & INHABIT_GROUND && isInAir) if (cinfo->InhabitType & INHABIT_AIR && cinfo->InhabitType & INHABIT_GROUND && isInAir)
@@ -1574,7 +1574,7 @@ void Creature::setDeathState(DeathState s)
float ground = GetPositionZ(); float ground = GetPositionZ();
GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground); GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground);
bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground); bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZ(), ground - 0.05f); // Can be underground too, prevent the falling
if (cinfo->InhabitType & INHABIT_AIR && cinfo->InhabitType & INHABIT_GROUND && isInAir) if (cinfo->InhabitType & INHABIT_AIR && cinfo->InhabitType & INHABIT_GROUND && isInAir)
SetCanFly(true); SetCanFly(true);