diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 682a67085..18be37114 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -592,10 +592,6 @@ void Creature::Update(uint32 update_diff, uint32 diff) RegenerateAll(update_diff); break; } - case CORPSE_FALLING: - { - SetDeathState(CORPSE); - } default: break; } @@ -1480,9 +1476,8 @@ void Creature::SetDeathState(DeathState s) UpdateSpeed(MOVE_RUN, false); } - // return, since we promote to CORPSE_FALLING. CORPSE_FALLING is promoted to CORPSE at next update. - if (CanFly() && FallGround()) - return; + if (CanFly()) + i_motionMaster.MoveFall(); Unit::SetDeathState(CORPSE); } @@ -1517,35 +1512,6 @@ void Creature::SetDeathState(DeathState s) } } -bool Creature::FallGround() -{ - // Only if state is JUST_DIED. CORPSE_FALLING is set below and promoted to CORPSE later - if (getDeathState() != JUST_DIED) - return false; - - // use larger distance for vmap height search than in most other cases - float tz = GetTerrain()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true, MAX_FALL_DISTANCE); - - if (tz <= INVALID_HEIGHT) - { - DEBUG_LOG("FallGround: creature %u at map %u (x: %f, y: %f, z: %f), not able to retrive a proper GetHeight (z: %f).", - GetEntry(), GetMap()->GetId(), GetPositionX(), GetPositionX(), GetPositionZ(), tz); - return false; - } - - // Abort too if the ground is very near - if (fabs(GetPositionZ() - tz) < 0.1f) - return false; - - Unit::SetDeathState(CORPSE_FALLING); - - Movement::MoveSplineInit init(*this); - init.MoveTo(GetPositionX(),GetPositionY(),tz); - init.SetFall(); - init.Launch(); - return true; -} - void Creature::Respawn() { RemoveCorpse(); diff --git a/src/game/Creature.h b/src/game/Creature.h index 317de63f3..d6ff27c2d 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -582,7 +582,6 @@ class MANGOS_DLL_SPEC Creature : public Unit const char* GetNameForLocaleIdx(int32 locale_idx) const; void SetDeathState(DeathState s); // overwrite virtual Unit::SetDeathState - bool FallGround(); bool LoadFromDB(uint32 guid, Map *map); void SaveToDB(); diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 7c708e95f..d2d666bb4 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -480,3 +480,25 @@ void MotionMaster::MoveJump(float x, float y, float z, float horizontalSpeed, fl init.Launch(); Mutate(new EffectMovementGenerator(id)); } + +void MotionMaster::MoveFall() +{ + // use larger distance for vmap height search than in most other cases + float tz = m_owner->GetTerrain()->GetHeight(m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ(), true, MAX_FALL_DISTANCE); + if (tz <= INVALID_HEIGHT) + { + DEBUG_LOG("MotionMaster::MoveFall: unit %u at map %u (x: %f, y: %f, z: %f), not able to retrive a proper GetHeight (z: %f).", + m_owner->GetMap()->GetId(), m_owner->GetPositionX(), m_owner->GetPositionX(), m_owner->GetPositionZ(), tz); + return; + } + + // Abort too if the ground is very near + if (fabs(m_owner->GetPositionZ() - tz) < 0.1f) + return; + + Movement::MoveSplineInit init(*m_owner); + init.MoveTo(m_owner->GetPositionX(),m_owner->GetPositionY(),tz); + init.SetFall(); + init.Launch(); + Mutate(new EffectMovementGenerator(0)); +} diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index 2f38226b7..1023c0323 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -109,6 +109,7 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack void MoveTaxiFlight(uint32 path, uint32 pathnode); void MoveDistract(uint32 timeLimit); void MoveJump(float x, float y, float z, float horizontalSpeed, float max_height, uint32 id = 0); + void MoveFall(); MovementGeneratorType GetCurrentMovementGeneratorType() const; diff --git a/src/game/Unit.h b/src/game/Unit.h index bcd7a91cf..a9e944f5e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -376,7 +376,6 @@ enum DeathState CORPSE = 2, // corpse state, for player this also meaning that player not leave corpse DEAD = 3, // for creature despawned state (corpse despawned), for player CORPSE/DEAD not clear way switches (FIXME), and use m_deathtimer > 0 check for real corpse state JUST_ALIVED = 4, // temporary state at resurrection, for creature auto converted to ALIVE, for player at next update call - CORPSE_FALLING = 5 // corpse state in case when corpse still falling to ground }; // internal state flags for some auras and movement generators, other. diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index efbf94549..225f741dc 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11825" + #define REVISION_NR "11826" #endif // __REVISION_NR_H__