Core/Movement: Do not set movement flags for creatures based only on their InhabitType, check if they are actually on air/water. newline. Should allow us to fix some problems on ICC and the mmaps branch.

This commit is contained in:
Subv authored and Vincent_Michael committed 2012-12-27 19:31:34 +01:00
1 parent 8b90626e5f
commit 873aa5f2a7
2 files changed
+61 -21

No files matched your search

+25
View File
@@ -17375,6 +17375,31 @@ 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);
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);