Core/Movement: Enable MotionMaster::MoveRandom for players

This commit is contained in:
Shauren
2026-01-04 21:47:46 +01:00
parent fd337aaa4a
commit 12743dd0e7
2 changed files with 10 additions and 8 deletions

View File

@@ -597,13 +597,11 @@ void MotionMaster::MoveRandom(float wanderDistance /*= 0.0f*/, Optional<Millisec
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::ForceWalk*/, MovementSlot slot /*= MOTION_SLOT_DEFAULT*/,
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '{}', started random movement (spawnDist: {})", _owner->GetGUID(), wanderDistance);
if (_owner->GetTypeId() == TYPEID_UNIT)
{
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '{}', started random movement (spawnDist: {})", _owner->GetGUID(), wanderDistance);
Add(new RandomMovementGenerator<Creature>(wanderDistance, duration, speed, speedSelectionMode, std::move(scriptResult)), slot);
}
else if (scriptResult)
scriptResult->SetResult(MovementStopReason::Interrupted);
else
Add(new RandomMovementGenerator<Player>(wanderDistance, duration, speed, speedSelectionMode, std::move(scriptResult)), slot);
}
void MotionMaster::MoveFollow(Unit* target, float dist, Optional<ChaseAngle> angle /*= {}*/, Optional<Milliseconds> duration /*= {}*/, bool ignoreTargetWalk /*= false*/, MovementSlot slot/* = MOTION_SLOT_ACTIVE*/,

View File

@@ -22,6 +22,7 @@
#include "MoveSplineInit.h"
#include "MovementDefines.h"
#include "PathGenerator.h"
#include "Player.h"
#include "Random.h"
template<class T>
@@ -181,7 +182,8 @@ void RandomMovementGenerator<T>::SetRandomLocation(T* owner)
}
// Call for creature group update
owner->SignalFormationMovement();
if constexpr (std::is_base_of_v<Creature, T>)
owner->SignalFormationMovement();
}
template<class T>
@@ -244,8 +246,9 @@ void RandomMovementGenerator<T>::DoFinalize(T* owner, bool active, bool movement
if (movementInform && this->HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED))
{
this->SetScriptResult(MovementStopReason::Finished);
if (owner->IsAIEnabled())
owner->AI()->MovementInform(RANDOM_MOTION_TYPE, 0);
if constexpr (std::is_base_of_v<Creature, T>)
if (owner->IsAIEnabled())
owner->AI()->MovementInform(RANDOM_MOTION_TYPE, 0);
}
}
@@ -271,3 +274,4 @@ MovementGenerator* RandomMovementFactory::Create(Unit* object) const
}
template class RandomMovementGenerator<Creature>;
template class RandomMovementGenerator<Player>;