Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MovePointBackwards in MotionMaster.h #33

Merged
merged 1 commit into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/server/game/Movement/MotionMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Movement/MotionMaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ class MotionMaster //: private std::stack<MovementGenerator *>
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,6 +56,9 @@ class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementG
bool _generatePath;
bool _forceDestination;
ObjectGuid _chargeTargetGUID;
/// Added by mod-playerbots
bool _orientationInversed;
/// End added
};

class AssistanceMovementGenerator : public PointMovementGenerator<Creature>
Expand Down
Loading