From 8f589dcdd07da0f9eac20402756494ee67b5ecdc Mon Sep 17 00:00:00 2001 From: Subv Date: Fri, 28 Dec 2012 13:53:44 -0500 Subject: Core/Entities: Add a delta to the ground level difference for removing the flying movementflags when landing. --- src/server/game/Entities/Unit/Unit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5c0435f77b5..a9376dca351 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17381,7 +17381,7 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel float ground = z; GetMap()->GetWaterOrGroundLevel(x, y, z, &ground); - bool isInAir = G3D::fuzzyGt(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) -- cgit v1.2.3 From 3ad9dafdb683fb7a4cdc98770cbe6fce97aa95ec Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 29 Dec 2012 04:01:46 +0100 Subject: Core/Entities: Update movement flags for flying/swimming creatures on Creature::Update --- src/server/game/Entities/Creature/Creature.cpp | 17 +++++++++++++++++ src/server/game/Entities/Unit/Unit.cpp | 25 ------------------------- 2 files changed, 17 insertions(+), 25 deletions(-) (limited to 'src') 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: diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a9376dca351..62df8c2049c 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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); -- cgit v1.2.3