mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[9065] Implement motionmaster function UpdateFinalDistanceToTarget()
To update a creatures distance to it's target without creating a new movement generator. Note it can only be used where creature is using TargetedMovementGenerator. Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
441aa50bad
commit
3c2327e6e0
6 changed files with 30 additions and 1 deletions
|
|
@ -463,3 +463,12 @@ bool MotionMaster::GetDestination(float &x, float &y, float &z)
|
|||
|
||||
return top()->GetDestination(x,y,z);
|
||||
}
|
||||
|
||||
void MotionMaster::UpdateFinalDistanceToTarget(float fDistance)
|
||||
{
|
||||
if (!empty())
|
||||
{
|
||||
if (top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE)
|
||||
top()->UpdateFinalDistance(fDistance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,9 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
|
|||
|
||||
void propagateSpeedChange();
|
||||
|
||||
// will only work in MMgens where we have a target (TARGETED_MOTION_TYPE)
|
||||
void UpdateFinalDistanceToTarget(float fDistance);
|
||||
|
||||
bool GetDestination(float &x, float &y, float &z);
|
||||
private:
|
||||
void Mutate(MovementGenerator *m); // use Move* functions instead
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ class MANGOS_DLL_SPEC MovementGenerator
|
|||
|
||||
virtual void unitSpeedChanged() { }
|
||||
|
||||
virtual void UpdateFinalDistance(float fDistance) { }
|
||||
|
||||
virtual bool GetDestination(float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,19 @@ void TargetedMovementGenerator<Creature>::Initialize(Creature &owner)
|
|||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
template<>
|
||||
void TargetedMovementGenerator<Player>::UpdateFinalDistance(float fDistance)
|
||||
{
|
||||
// nothing to do for Player
|
||||
}
|
||||
|
||||
template<>
|
||||
void TargetedMovementGenerator<Creature>::UpdateFinalDistance(float fDistance)
|
||||
{
|
||||
i_offset = fDistance;
|
||||
i_recalculateTravel = true;
|
||||
}
|
||||
|
||||
template<>
|
||||
void TargetedMovementGenerator<Player>::Initialize(Player &owner)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ class MANGOS_DLL_SPEC TargetedMovementGenerator
|
|||
}
|
||||
|
||||
void unitSpeedChanged() { i_recalculateTravel=true; }
|
||||
void UpdateFinalDistance(float fDistance);
|
||||
|
||||
private:
|
||||
|
||||
void _setTargetLocation(T &);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9064"
|
||||
#define REVISION_NR "9065"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue