fix(Core/Spells): Always melee attack target when charge is over. (#7316)

* fix(Core/Spells): Always melee attack target when charge is over.

Fixed #7266

* Update src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp
This commit is contained in:
UltraNix
2021-08-17 20:36:30 +02:00
committed by GitHub
parent dd833a25a6
commit 6b5c3ed04f
5 changed files with 26 additions and 20 deletions

View File

@@ -580,7 +580,7 @@ void MotionMaster::MoveFall(uint32 id /*=0*/, bool addFlagForNPC)
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
}
void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id, const Movement::PointsArray* path, bool generatePath, float orientation /* = 0.0f*/)
void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id, const Movement::PointsArray* path, bool generatePath, float orientation /* = 0.0f*/, ObjectGuid targetGUID /*= ObjectGuid::Empty*/)
{
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
@@ -592,12 +592,12 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id,
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
LOG_DEBUG("movement.motionmaster", "Player (%s) charge point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
Mutate(new PointMovementGenerator<Player>(id, x, y, z, speed, orientation, path, generatePath, generatePath), MOTION_SLOT_CONTROLLED);
Mutate(new PointMovementGenerator<Player>(id, x, y, z, speed, orientation, path, generatePath, generatePath, targetGUID), MOTION_SLOT_CONTROLLED);
}
else
{
LOG_DEBUG("movement.motionmaster", "Creature (%s) charge point (X: %f Y: %f Z: %f)", _owner->GetGUID().ToString().c_str(), x, y, z);
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, speed, orientation, path, generatePath, generatePath), MOTION_SLOT_CONTROLLED);
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, speed, orientation, path, generatePath, generatePath, targetGUID), MOTION_SLOT_CONTROLLED);
}
}

View File

@@ -207,7 +207,7 @@ public:
void MoveTakeoff(uint32 id, Position const& pos, float speed = 0.0f);
void MoveTakeoff(uint32 id, float x, float y, float z, float speed = 0.0f); // pussywizard: added for easy calling by passing 3 floats x, y, z
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, const Movement::PointsArray* path = nullptr, bool generatePath = false, float orientation = 0.0f);
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, const Movement::PointsArray* path = nullptr, bool generatePath = false, float orientation = 0.0f, ObjectGuid targetGUID = ObjectGuid::Empty);
void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ);
void MoveJumpTo(float angle, float speedXY, float speedZ);
void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = 0)

View File

@@ -139,6 +139,11 @@ void PointMovementGenerator<T>::DoFinalize(T* unit)
if (id == EVENT_CHARGE)
{
unit->ClearUnitState(UNIT_STATE_CHARGING);
if (Unit* target = ObjectAccessor::GetUnit(*unit, _chargeTargetGUID))
{
unit->Attack(target, true);
}
}
if (unit->movespline->Finalized())

View File

@@ -14,8 +14,10 @@ template<class T>
class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementGenerator<T> >
{
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) : id(_id),
i_x(_x), i_y(_y), i_z(_z), speed(_speed), i_orientation(orientation), _generatePath(generatePath), _forceDestination(forceDestination)
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)
: id(_id), i_x(_x), i_y(_y), i_z(_z), speed(_speed), i_orientation(orientation), _generatePath(generatePath), _forceDestination(forceDestination),
_chargeTargetGUID(chargeTargetGUID)
{
if (_path)
m_precomputedPath = *_path;
@@ -42,6 +44,7 @@ private:
Movement::PointsArray m_precomputedPath;
bool _generatePath;
bool _forceDestination;
ObjectGuid _chargeTargetGUID;
};
class AssistanceMovementGenerator : public PointMovementGenerator<Creature>