diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index dc1de957b..8310000c2 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -465,34 +465,12 @@ void MotionMaster::UpdateFinalDistanceToTarget(float fDistance) top()->UpdateFinalDistance(fDistance); } -// Does almost nothing - just doesn't allows previous movegen interrupt current effect. Can be reused for charge effect -class EffectMovementGenerator : public MovementGenerator -{ -public: - void Initialize(Unit &) {} - void Finalize(Unit &unit) - { - // Since we have no proper states system need restore previous movement. - if (unit.GetTypeId() != TYPEID_PLAYER && unit.isAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_FLEEING)) - { - if (Unit * victim = unit.getVictim()) - unit.GetMotionMaster()->MoveChase(victim); - else - unit.GetMotionMaster()->Initialize(); - } - } - void Interrupt(Unit &) {} - void Reset(Unit &) {} - bool Update(Unit &u, const uint32 &) { return !u.movespline->Finalized(); } - MovementGeneratorType GetMovementGeneratorType() const { return EFFECT_MOTION_TYPE; } -}; - -void MotionMaster::MoveJump(float x, float y, float z, float horizontalSpeed, float max_height) +void MotionMaster::MoveJump(float x, float y, float z, float horizontalSpeed, float max_height, uint32 id) { Movement::MoveSplineInit init(*m_owner); init.MoveTo(x,y,z); init.SetParabolic(max_height,0,false); init.SetVelocity(horizontalSpeed); init.Launch(); - Mutate(new EffectMovementGenerator()); + Mutate(new EffectMovementGenerator(id)); } diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index cb08d4e03..2f38226b7 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -108,7 +108,7 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack void MoveWaypoint(); void MoveTaxiFlight(uint32 path, uint32 pathnode); void MoveDistract(uint32 timeLimit); - void MoveJump(float x, float y, float z, float horizontalSpeed, float max_height); + void MoveJump(float x, float y, float z, float horizontalSpeed, float max_height, uint32 id = 0); MovementGeneratorType GetCurrentMovementGeneratorType() const; diff --git a/src/game/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index 11e47573e..71ba2b7ea 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -119,3 +119,25 @@ void AssistanceMovementGenerator::Finalize(Unit &unit) if (unit.isAlive()) unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)); } + +bool EffectMovementGenerator::Update(Unit &unit, const uint32 &) +{ + return !unit.movespline->Finalized(); +} + +void EffectMovementGenerator::Finalize(Unit &unit) +{ + if (unit.GetTypeId() != TYPEID_UNIT) + return; + + if (((Creature&)unit).AI() && unit.movespline->Finalized()) + ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); + // Need restore previous movement since we have no proper states system + if (unit.isAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_FLEEING)) + { + if (Unit * victim = unit.getVictim()) + unit.GetMotionMaster()->MoveChase(victim); + else + unit.GetMotionMaster()->Initialize(); + } +} diff --git a/src/game/PointMovementGenerator.h b/src/game/PointMovementGenerator.h index 3e9c04116..c98b12896 100644 --- a/src/game/PointMovementGenerator.h +++ b/src/game/PointMovementGenerator.h @@ -58,4 +58,19 @@ class MANGOS_DLL_SPEC AssistanceMovementGenerator void Finalize(Unit &); }; +// Does almost nothing - just doesn't allows previous movegen interrupt current effect. Can be reused for charge effect +class EffectMovementGenerator : public MovementGenerator +{ + public: + explicit EffectMovementGenerator(uint32 Id) : m_Id(Id) {} + void Initialize(Unit &) {} + void Finalize(Unit &unit); + void Interrupt(Unit &) {} + void Reset(Unit &) {} + bool Update(Unit &u, const uint32 &); + MovementGeneratorType GetMovementGeneratorType() const { return EFFECT_MOTION_TYPE; } + private: + uint32 m_Id; +}; + #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 21785d69c..31e9a4841 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 "11755" + #define REVISION_NR "11756" #endif // __REVISION_NR_H__