mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Entities: Update movement flags for flying/swimming creatures on Creature::Update
This commit is contained in:
@@ -478,6 +478,23 @@ void Creature::Update(uint32 diff)
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
}
|
||||
|
||||
// Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
|
||||
float ground = GetPositionZ();
|
||||
GetMap()->GetWaterOrGroundLevel(GetPositionX(), GetPositionY(), GetPositionZ(), &ground);
|
||||
|
||||
bool isInAir = G3D::fuzzyGt(GetPositionZ(), ground + 0.05f);
|
||||
CreatureTemplate const* cinfo = GetCreatureTemplate();
|
||||
|
||||
if (cinfo->InhabitType & INHABIT_AIR && cinfo->InhabitType & INHABIT_GROUND && isInAir)
|
||||
SetCanFly(true);
|
||||
else if (cinfo->InhabitType & INHABIT_AIR && isInAir)
|
||||
SetDisableGravity(true);
|
||||
else
|
||||
{
|
||||
SetCanFly(false);
|
||||
SetDisableGravity(false);
|
||||
}
|
||||
|
||||
switch (m_deathState)
|
||||
{
|
||||
case JUST_RESPAWNED:
|
||||
|
||||
@@ -17375,31 +17375,6 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
else if (turn)
|
||||
UpdateOrientation(orientation);
|
||||
|
||||
if (Creature* creature = ToCreature())
|
||||
{
|
||||
// Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
|
||||
float ground = z;
|
||||
GetMap()->GetWaterOrGroundLevel(x, y, z, &ground);
|
||||
|
||||
bool isInAir = G3D::fuzzyGt(z, ground + 0.05f);
|
||||
CreatureTemplate const* cinfo = creature->GetCreatureTemplate();
|
||||
|
||||
if (cinfo->InhabitType & INHABIT_AIR && cinfo->InhabitType & INHABIT_GROUND && isInAir)
|
||||
SetCanFly(true);
|
||||
else if (cinfo->InhabitType & INHABIT_AIR && isInAir)
|
||||
SetDisableGravity(true);
|
||||
else
|
||||
{
|
||||
SetCanFly(false);
|
||||
SetDisableGravity(false);
|
||||
}
|
||||
|
||||
if (cinfo->InhabitType & INHABIT_WATER && GetMap()->IsInWater(x, y, z))
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
else
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
}
|
||||
|
||||
// code block for underwater state update
|
||||
UpdateUnderwaterState(GetMap(), x, y, z);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user