mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Movement: Extend MovePoint with new arguments
* Forced speed * Speed selection mode (walk, run or default) * Distance from target point that is considered close enough to finalize movement
This commit is contained in:
@@ -656,23 +656,17 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
|
||||
Add(new FleeingMovementGenerator<Player>(enemy->GetGUID()));
|
||||
}
|
||||
|
||||
void MotionMaster::MovePoint(uint32 id, Position const& pos, bool generatePath/* = true*/, Optional<float> finalOrient/* = {}*/)
|
||||
void MotionMaster::MovePoint(uint32 id, Position const& pos, bool generatePath/* = true*/, Optional<float> finalOrient/* = {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/)
|
||||
{
|
||||
MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, finalOrient);
|
||||
MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, finalOrient, speed, speedSelectionMode, closeEnoughDistance);
|
||||
}
|
||||
|
||||
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath, Optional<float> finalOrient)
|
||||
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath /*= true*/, Optional<float> finalOrient /*= {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/)
|
||||
{
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
Add(new PointMovementGenerator<Player>(id, x, y, z, generatePath, 0.0f, finalOrient));
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
Add(new PointMovementGenerator<Creature>(id, x, y, z, generatePath, 0.0f, finalOrient));
|
||||
}
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
Add(new PointMovementGenerator(id, x, y, z, generatePath, speed, finalOrient, nullptr, nullptr, speedSelectionMode, closeEnoughDistance));
|
||||
}
|
||||
|
||||
void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance)
|
||||
@@ -733,22 +727,11 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed /*= SPEED_C
|
||||
if (_slot[MOTION_SLOT_CONTROLLED] && _slot[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
|
||||
return;
|
||||
*/
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '{}', charging point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
PointMovementGenerator<Player>* movement = new PointMovementGenerator<Player>(id, x, y, z, generatePath, speed, {}, target, spellEffectExtraData);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_CHARGING;
|
||||
Add(movement);
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '{}', charging point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
PointMovementGenerator<Creature>* movement = new PointMovementGenerator<Creature>(id, x, y, z, generatePath, speed, {}, target, spellEffectExtraData);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_CHARGING;
|
||||
Add(movement);
|
||||
}
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveCharge: '{}', charging point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID().ToString(), id, x, y, z);
|
||||
PointMovementGenerator* movement = new PointMovementGenerator(id, x, y, z, generatePath, speed, {}, target, spellEffectExtraData);
|
||||
movement->Priority = MOTION_PRIORITY_HIGHEST;
|
||||
movement->BaseUnitState = UNIT_STATE_CHARGING;
|
||||
Add(movement);
|
||||
}
|
||||
|
||||
void MotionMaster::MoveCharge(PathGenerator const& path, float speed /*= SPEED_CHARGE*/, Unit const* target /*= nullptr*/,
|
||||
|
||||
@@ -162,8 +162,10 @@ class TC_GAME_API MotionMaster
|
||||
void MoveChase(Unit* target, float dist) { MoveChase(target, ChaseRange(dist)); }
|
||||
void MoveConfused();
|
||||
void MoveFleeing(Unit* enemy, uint32 time = 0);
|
||||
void MovePoint(uint32 id, Position const& pos, bool generatePath = true, Optional<float> finalOrient = {});
|
||||
void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true, Optional<float> finalOrient = {});
|
||||
void MovePoint(uint32 id, Position const& pos, bool generatePath = true, Optional<float> finalOrient = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default, Optional<float> closeEnoughDistance = {});
|
||||
void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true, Optional<float> finalOrient = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default, Optional<float> closeEnoughDistance = {});
|
||||
/*
|
||||
* Makes the unit move toward the target until it is at a certain distance from it. The unit then stops.
|
||||
* Only works in 2D.
|
||||
|
||||
@@ -69,6 +69,19 @@ enum MovementSlot : uint8
|
||||
MAX_MOTION_SLOT
|
||||
};
|
||||
|
||||
enum class MovementWalkRunSpeedSelectionMode
|
||||
{
|
||||
Default,
|
||||
ForceRun,
|
||||
ForceWalk
|
||||
};
|
||||
|
||||
enum class MovementStopReason : uint8
|
||||
{
|
||||
Finished, // Movement finished either by arriving at location or successfully continuing it for requested duration
|
||||
Interrupted
|
||||
};
|
||||
|
||||
enum RotateDirection : uint8
|
||||
{
|
||||
ROTATE_DIRECTION_LEFT = 0,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "Define.h"
|
||||
#include "FactoryHolder.h"
|
||||
#include "MovementDefines.h"
|
||||
#include "ObjectRegistry.h"
|
||||
|
||||
class Creature;
|
||||
@@ -51,15 +52,15 @@ class TC_GAME_API MovementGenerator
|
||||
virtual ~MovementGenerator();
|
||||
|
||||
// on top first update
|
||||
virtual void Initialize(Unit*) = 0;
|
||||
virtual void Initialize(Unit* owner) = 0;
|
||||
// on top reassign
|
||||
virtual void Reset(Unit*) = 0;
|
||||
virtual void Reset(Unit* owner) = 0;
|
||||
// on top on MotionMaster::Update
|
||||
virtual bool Update(Unit*, uint32 diff) = 0;
|
||||
virtual bool Update(Unit* owner, uint32 diff) = 0;
|
||||
// on current top if another movement replaces
|
||||
virtual void Deactivate(Unit*) = 0;
|
||||
virtual void Deactivate(Unit* owner) = 0;
|
||||
// on movement delete
|
||||
virtual void Finalize(Unit*, bool, bool) = 0;
|
||||
virtual void Finalize(Unit* owner, bool active, bool movementInform) = 0;
|
||||
virtual MovementGeneratorType GetMovementGeneratorType() const = 0;
|
||||
|
||||
virtual void UnitSpeedChanged() { }
|
||||
|
||||
@@ -18,20 +18,22 @@
|
||||
#include "PointMovementGenerator.h"
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Player.h"
|
||||
#include "G3DPosition.hpp"
|
||||
#include "MotionMaster.h"
|
||||
#include "MovementDefines.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "PathGenerator.h"
|
||||
#include "World.h"
|
||||
|
||||
//----- Point Movement Generator
|
||||
|
||||
template<class T>
|
||||
PointMovementGenerator<T>::PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, float speed /*= 0.0f*/, Optional<float> finalOrient /*= {}*/,
|
||||
Unit const* faceTarget /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/)
|
||||
PointMovementGenerator::PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, Optional<float> speed /*= {}*/, Optional<float> finalOrient /*= {}*/,
|
||||
Unit const* faceTarget /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
|
||||
Optional<float> closeEnoughDistance /*= {}*/)
|
||||
: _movementId(id), _destination(x, y, z), _speed(speed), _generatePath(generatePath), _finalOrient(finalOrient),
|
||||
i_faceTarget(faceTarget)
|
||||
i_faceTarget(faceTarget), _speedSelectionMode(speedSelectionMode), _closeEnoughDistance(closeEnoughDistance)
|
||||
{
|
||||
this->Mode = MOTION_MODE_DEFAULT;
|
||||
this->Priority = MOTION_PRIORITY_NORMAL;
|
||||
@@ -42,17 +44,15 @@ PointMovementGenerator<T>::PointMovementGenerator(uint32 id, float x, float y, f
|
||||
this->i_spellEffectExtra = std::make_unique<Movement::SpellEffectExtraData>(*spellEffectExtraData);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
MovementGeneratorType PointMovementGenerator<T>::GetMovementGeneratorType() const
|
||||
MovementGeneratorType PointMovementGenerator::GetMovementGeneratorType() const
|
||||
{
|
||||
return POINT_MOTION_TYPE;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::DoInitialize(T* owner)
|
||||
void PointMovementGenerator::Initialize(Unit* owner)
|
||||
{
|
||||
MovementGenerator::RemoveFlag(MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING | MOVEMENTGENERATOR_FLAG_TRANSITORY | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_INITIALIZED);
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING | MOVEMENTGENERATOR_FLAG_TRANSITORY | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INITIALIZED);
|
||||
|
||||
if (_movementId == EVENT_CHARGE_PREPATH)
|
||||
{
|
||||
@@ -62,7 +62,7 @@ void PointMovementGenerator<T>::DoInitialize(T* owner)
|
||||
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
|
||||
{
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
owner->StopMoving();
|
||||
return;
|
||||
}
|
||||
@@ -70,15 +70,50 @@ void PointMovementGenerator<T>::DoInitialize(T* owner)
|
||||
owner->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ(), _generatePath);
|
||||
if (_speed > 0.0f)
|
||||
init.SetVelocity(_speed);
|
||||
[&]()
|
||||
{
|
||||
if (_generatePath)
|
||||
{
|
||||
PathGenerator path(owner);
|
||||
G3D::Vector3 dest = PositionToVector3(_destination);
|
||||
bool result = path.CalculatePath(dest.x, dest.y, dest.z, false);
|
||||
if (result && !(path.GetPathType() & PATHFIND_NOPATH))
|
||||
{
|
||||
if (_closeEnoughDistance)
|
||||
path.ShortenPathUntilDist(dest, *_closeEnoughDistance);
|
||||
|
||||
init.MovebyPath(path.GetPath());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Position dest = _destination;
|
||||
if (_closeEnoughDistance)
|
||||
owner->MovePosition(dest, std::min(*_closeEnoughDistance, dest.GetExactDist(owner)), float(M_PI) + owner->GetRelativeAngle(dest));
|
||||
|
||||
init.MoveTo(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ(), false);
|
||||
}();
|
||||
if (_speed)
|
||||
init.SetVelocity(*_speed);
|
||||
if (i_faceTarget)
|
||||
init.SetFacing(i_faceTarget);
|
||||
if (i_spellEffectExtra)
|
||||
init.SetSpellEffectExtraData(*i_spellEffectExtra);
|
||||
if (_finalOrient)
|
||||
init.SetFacing(*_finalOrient);
|
||||
switch (_speedSelectionMode)
|
||||
{
|
||||
case MovementWalkRunSpeedSelectionMode::Default:
|
||||
break;
|
||||
case MovementWalkRunSpeedSelectionMode::ForceRun:
|
||||
init.SetWalk(false);
|
||||
break;
|
||||
case MovementWalkRunSpeedSelectionMode::ForceWalk:
|
||||
init.SetWalk(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
init.Launch();
|
||||
|
||||
@@ -87,16 +122,14 @@ void PointMovementGenerator<T>::DoInitialize(T* owner)
|
||||
creature->SignalFormationMovement();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::DoReset(T* owner)
|
||||
void PointMovementGenerator::Reset(Unit* owner)
|
||||
{
|
||||
MovementGenerator::RemoveFlag(MOVEMENTGENERATOR_FLAG_TRANSITORY | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_TRANSITORY | MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
|
||||
DoInitialize(owner);
|
||||
Initialize(owner);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool PointMovementGenerator<T>::DoUpdate(T* owner, uint32 /*diff*/)
|
||||
bool PointMovementGenerator::Update(Unit* owner, uint32 /*diff*/)
|
||||
{
|
||||
if (!owner)
|
||||
return false;
|
||||
@@ -105,7 +138,7 @@ bool PointMovementGenerator<T>::DoUpdate(T* owner, uint32 /*diff*/)
|
||||
{
|
||||
if (owner->movespline->Finalized())
|
||||
{
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -113,21 +146,21 @@ bool PointMovementGenerator<T>::DoUpdate(T* owner, uint32 /*diff*/)
|
||||
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
|
||||
{
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
owner->StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((MovementGenerator::HasFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED) && owner->movespline->Finalized()) || (MovementGenerator::HasFlag(MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING) && !owner->movespline->Finalized()))
|
||||
if ((HasFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED) && owner->movespline->Finalized()) || (HasFlag(MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING) && !owner->movespline->Finalized()))
|
||||
{
|
||||
MovementGenerator::RemoveFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED | MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING);
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED | MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING);
|
||||
|
||||
owner->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
init.MoveTo(_destination.GetPositionX(), _destination.GetPositionY(), _destination.GetPositionZ(), _generatePath);
|
||||
if (_speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit
|
||||
init.SetVelocity(_speed);
|
||||
if (_speed) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit
|
||||
init.SetVelocity(*_speed);
|
||||
init.Launch();
|
||||
|
||||
// Call for creature group update
|
||||
@@ -137,56 +170,36 @@ bool PointMovementGenerator<T>::DoUpdate(T* owner, uint32 /*diff*/)
|
||||
|
||||
if (owner->movespline->Finalized())
|
||||
{
|
||||
MovementGenerator::RemoveFlag(MOVEMENTGENERATOR_FLAG_TRANSITORY);
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED);
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_TRANSITORY);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::DoDeactivate(T* owner)
|
||||
void PointMovementGenerator::Deactivate(Unit* owner)
|
||||
{
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::DoFinalize(T* owner, bool active, bool movementInform)
|
||||
void PointMovementGenerator::Finalize(Unit* owner, bool active, bool movementInform)
|
||||
{
|
||||
MovementGenerator::AddFlag(MOVEMENTGENERATOR_FLAG_FINALIZED);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_FINALIZED);
|
||||
if (active)
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
if (movementInform && MovementGenerator::HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED))
|
||||
if (movementInform && HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED))
|
||||
MovementInform(owner);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::MovementInform(T*) { }
|
||||
|
||||
template <>
|
||||
void PointMovementGenerator<Creature>::MovementInform(Creature* owner)
|
||||
void PointMovementGenerator::MovementInform(Unit* owner)
|
||||
{
|
||||
if (owner->AI())
|
||||
owner->AI()->MovementInform(POINT_MOTION_TYPE, _movementId);
|
||||
if (Creature* creature = owner->ToCreature())
|
||||
if (creature->AI())
|
||||
creature->AI()->MovementInform(POINT_MOTION_TYPE, _movementId);
|
||||
}
|
||||
|
||||
template PointMovementGenerator<Player>::PointMovementGenerator(uint32, float, float, float, bool, float, Optional<float>, Unit const*, Movement::SpellEffectExtraData const*);
|
||||
template PointMovementGenerator<Creature>::PointMovementGenerator(uint32, float, float, float, bool, float, Optional<float>, Unit const*, Movement::SpellEffectExtraData const*);
|
||||
template MovementGeneratorType PointMovementGenerator<Player>::GetMovementGeneratorType() const;
|
||||
template MovementGeneratorType PointMovementGenerator<Creature>::GetMovementGeneratorType() const;
|
||||
template void PointMovementGenerator<Player>::DoInitialize(Player*);
|
||||
template void PointMovementGenerator<Creature>::DoInitialize(Creature*);
|
||||
template void PointMovementGenerator<Player>::DoReset(Player*);
|
||||
template void PointMovementGenerator<Creature>::DoReset(Creature*);
|
||||
template bool PointMovementGenerator<Player>::DoUpdate(Player*, uint32);
|
||||
template bool PointMovementGenerator<Creature>::DoUpdate(Creature*, uint32);
|
||||
template void PointMovementGenerator<Player>::DoDeactivate(Player*);
|
||||
template void PointMovementGenerator<Creature>::DoDeactivate(Creature*);
|
||||
template void PointMovementGenerator<Player>::DoFinalize(Player*, bool, bool);
|
||||
template void PointMovementGenerator<Creature>::DoFinalize(Creature*, bool, bool);
|
||||
|
||||
//---- AssistanceMovementGenerator
|
||||
|
||||
void AssistanceMovementGenerator::Finalize(Unit* owner, bool active, bool movementInform)
|
||||
@@ -195,7 +208,7 @@ void AssistanceMovementGenerator::Finalize(Unit* owner, bool active, bool moveme
|
||||
if (active)
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
if (movementInform && HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED))
|
||||
if (movementInform && HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED) && owner->IsCreature())
|
||||
{
|
||||
Creature* ownerCreature = owner->ToCreature();
|
||||
ownerCreature->SetNoCallAssistance(false);
|
||||
|
||||
@@ -28,44 +28,47 @@ namespace Movement
|
||||
struct SpellEffectExtraData;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
class PointMovementGenerator : public MovementGeneratorMedium<T, PointMovementGenerator<T>>
|
||||
class PointMovementGenerator : public MovementGenerator
|
||||
{
|
||||
public:
|
||||
explicit PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, float speed = 0.0f, Optional<float> finalOrient = {},
|
||||
Unit const* faceTarget = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr);
|
||||
explicit PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, Optional<float> speed = {}, Optional<float> finalOrient = {},
|
||||
Unit const* faceTarget = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<float> closeEnoughDistance = {});
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() const override;
|
||||
|
||||
void DoInitialize(T*);
|
||||
void DoReset(T*);
|
||||
bool DoUpdate(T*, uint32);
|
||||
void DoDeactivate(T*);
|
||||
void DoFinalize(T*, bool, bool);
|
||||
void Initialize(Unit* owner) override;
|
||||
void Reset(Unit* owner) override;
|
||||
bool Update(Unit* owner, uint32 diff) override;
|
||||
void Deactivate(Unit* owner) override;
|
||||
void Finalize(Unit* owner, bool active, bool movementInform) override;
|
||||
|
||||
void UnitSpeedChanged() override { PointMovementGenerator<T>::AddFlag(MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING); }
|
||||
void UnitSpeedChanged() override { AddFlag(MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING); }
|
||||
|
||||
uint32 GetId() const { return _movementId; }
|
||||
|
||||
private:
|
||||
void MovementInform(T*);
|
||||
void MovementInform(Unit*);
|
||||
|
||||
uint32 _movementId;
|
||||
Position _destination;
|
||||
float _speed;
|
||||
Optional<float> _speed;
|
||||
bool _generatePath;
|
||||
//! if set then unit will turn to specified _orient in provided _pos
|
||||
Optional<float> _finalOrient;
|
||||
Unit const* i_faceTarget;
|
||||
std::unique_ptr<Movement::SpellEffectExtraData> i_spellEffectExtra;
|
||||
MovementWalkRunSpeedSelectionMode _speedSelectionMode;
|
||||
Optional<float> _closeEnoughDistance;
|
||||
};
|
||||
|
||||
class AssistanceMovementGenerator : public PointMovementGenerator<Creature>
|
||||
class AssistanceMovementGenerator : public PointMovementGenerator
|
||||
{
|
||||
public:
|
||||
explicit AssistanceMovementGenerator(uint32 id, float x, float y, float z) : PointMovementGenerator<Creature>(id, x, y, z, true) { }
|
||||
explicit AssistanceMovementGenerator(uint32 id, float x, float y, float z) : PointMovementGenerator(id, x, y, z, true) { }
|
||||
|
||||
void Finalize(Unit*, bool, bool) override;
|
||||
void Finalize(Unit* owner, bool active, bool movementInform) override;
|
||||
MovementGeneratorType GetMovementGeneratorType() const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ struct boss_lord_marrowgar : public BossAI
|
||||
{
|
||||
if (a->GetMovementGeneratorType() == POINT_MOTION_TYPE)
|
||||
{
|
||||
PointMovementGenerator<Creature> const* pointMovement = dynamic_cast<PointMovementGenerator<Creature> const*>(a);
|
||||
PointMovementGenerator const* pointMovement = dynamic_cast<PointMovementGenerator const*>(a);
|
||||
return pointMovement && pointMovement->GetId() == POINT_TARGET_BONESTORM_PLAYER;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user