66 _timer.Reset(overrideTimer);
82 if (!owner || !owner->
IsAlive())
88 if (_wanderDistance == 0.f)
92 _wanderSteps =
urand(2, 10);
127 float distance = _wanderDistance > 0.1f ?
frand(0.1f, _wanderDistance) : _wanderDistance;
128 float angle =
frand(0.f,
static_cast<float>(
M_PI * 2));
141 _path = std::make_unique<PathGenerator>(owner);
142 _path->SetPathLengthLimit(30.0f);
155 if (_path->GetPathLength() < 0.1f)
186 _timer.Reset(splineDuration);
191 _wanderSteps =
urand(2, 10);
207 if (!owner || !owner->
IsAlive())
215 _duration->Update(diff);
216 if (_duration->Passed())
236 SetRandomLocation(owner);
@ MOVEMENTGENERATOR_FLAG_TIMED_PAUSED
@ MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING
@ MOVEMENTGENERATOR_FLAG_PAUSED
@ MOVEMENTGENERATOR_FLAG_DEACTIVATED
@ MOVEMENTGENERATOR_FLAG_FINALIZED
@ MOVEMENTGENERATOR_FLAG_TRANSITORY
@ MOVEMENTGENERATOR_FLAG_INTERRUPTED
@ MOVEMENTGENERATOR_FLAG_INFORM_ENABLED
@ MOVEMENTGENERATOR_FLAG_INITIALIZED
@ MOVEMENTGENERATOR_FLAG_SPEED_UPDATE_PENDING
std::optional< T > Optional
Optional helper class to wrap optional values within.
float frand(float min, float max)
uint32 urand(uint32 min, uint32 max)
@ UNIT_STATE_ROAMING_MOVE
@ UNIT_STATE_LOST_CONTROL
virtual void MovementInform(uint32, uint32)
void SignalFormationMovement()
float GetWanderDistance() const
CreatureMovementData const & GetMovementTemplate() const
bool IsMovementPreventedByCasting() const override
void SetWalk(bool enable)
void MovebyPath(PointsArray const &path, int32 pointId=0)
void SetRandomLocation(T *)
Optional< TimeTracker > _duration
void Pause(uint32 timer) override
MovementGeneratorType GetMovementGeneratorType() const override
void DoFinalize(T *, bool, bool)
void Resume(uint32 overrideTimer) override
bool DoUpdate(T *, uint32)
RandomMovementGenerator(float distance=0.0f, Optional< Milliseconds > duration={})
void ClearUnitState(uint32 f)
void AddUnitState(uint32 f)
bool SetWalk(bool enable)
bool HasUnitState(const uint32 f) const
std::unique_ptr< Movement::MoveSpline > movespline
bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
CreatureRandomMovementType GetRandom() const
constexpr float GetPositionX() const
constexpr float GetPositionY() const
constexpr void GetPosition(float &x, float &y) const
constexpr float GetPositionZ() const