diff options
| author | Subv <s.v.h21@hotmail.com> | 2012-12-29 04:01:46 +0100 |
|---|---|---|
| committer | Vincent_Michael <Vincent_Michael@gmx.de> | 2012-12-29 04:01:55 +0100 |
| commit | 3ad9dafdb683fb7a4cdc98770cbe6fce97aa95ec (patch) | |
| tree | 278b61c1677e9eb3133b2a7e85343d3816bc80d7 /src/server/game/Entities/Creature | |
| parent | 8f589dcdd07da0f9eac20402756494ee67b5ecdc (diff) | |
Core/Entities: Update movement flags for flying/swimming creatures on Creature::Update
Diffstat (limited to 'src/server/game/Entities/Creature')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 00ef3d32a06..650d904db47 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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: |
