Merge pull request #33 from liyunfan1223/move_backwards

Add MovePointBackwards in MotionMaster.h
This commit is contained in:
Yunfan Li
2024-12-29 21:24:02 +08:00
committed by GitHub
4 changed files with 29 additions and 2 deletions

View File

@@ -909,6 +909,25 @@ void MotionMaster::MoveKnockbackFromForPlayer(float srcX, float srcY, float spee
init.Launch();
Mutate(new EffectMovementGenerator(0), MOTION_SLOT_CONTROLLED);
}
// Similar to MovePoint except setting orientationInversed
void MotionMaster::MovePointBackwards(uint32 id, float x, float y, float z, bool generatePath, bool forceDestination, MovementSlot slot, float orientation /* = 0.0f*/)
{
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
return;
if (_owner->IsPlayer())
{
LOG_DEBUG("movement.motionmaster", "Player ({}) targeted point (Id: {} X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
Mutate(new PointMovementGenerator<Player>(id, x, y, z, 0.0f, orientation, nullptr, generatePath, forceDestination, ObjectGuid::Empty, true), slot);
}
else
{
LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted point (ID: {} X: {} Y: {} Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, 0.0f, orientation, nullptr, generatePath, forceDestination, ObjectGuid::Empty, true), slot);
}
}
#endif
void MotionMaster::propagateSpeedChange()

View File

@@ -239,6 +239,7 @@ public:
void MoveRotate(uint32 time, RotateDirection direction);
#ifdef MOD_PLAYERBOTS
void MoveKnockbackFromForPlayer(float srcX, float srcY, float speedXY, float speedZ);
void MovePointBackwards(uint32 id, float x, float y, float z, bool generatePath = true, bool forceDestination = true, MovementSlot slot = MOTION_SLOT_ACTIVE, float orientation = 0.0f);
#endif
[[nodiscard]] MovementGeneratorType GetCurrentMovementGeneratorType() const;
[[nodiscard]] MovementGeneratorType GetMotionSlotType(int slot) const;

View File

@@ -47,6 +47,10 @@ void PointMovementGenerator<T>::DoInitialize(T* unit)
i_recalculateSpeed = false;
Movement::MoveSplineInit init(unit);
/// Added by mod-playerbots
if (_orientationInversed)
init.SetOrientationInversed();
/// End added
if (m_precomputedPath.size() > 2) // pussywizard: for charge
init.MovebyPath(m_precomputedPath);
else if (_generatePath)

View File

@@ -26,9 +26,9 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG
{
public:
PointMovementGenerator(uint32 _id, float _x, float _y, float _z, float _speed = 0.0f, float orientation = 0.0f, const Movement::PointsArray* _path = nullptr,
bool generatePath = false, bool forceDestination = false, ObjectGuid chargeTargetGUID = ObjectGuid::Empty)
bool generatePath = false, bool forceDestination = false, ObjectGuid chargeTargetGUID = ObjectGuid::Empty, bool orientationInversed = false)
: id(_id), i_x(_x), i_y(_y), i_z(_z), speed(_speed), i_orientation(orientation), _generatePath(generatePath), _forceDestination(forceDestination),
_chargeTargetGUID(chargeTargetGUID)
_chargeTargetGUID(chargeTargetGUID), _orientationInversed(orientationInversed)
{
if (_path)
m_precomputedPath = *_path;
@@ -56,6 +56,9 @@ private:
bool _generatePath;
bool _forceDestination;
ObjectGuid _chargeTargetGUID;
/// Added by mod-playerbots
bool _orientationInversed;
/// End added
};
class AssistanceMovementGenerator : public PointMovementGenerator<Creature>