mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-14 16:03:45 +00:00
feat(Core/Unit): New helpers for UnitFlag and UnitFlag2 (#11227)
This commit is contained in:
@@ -242,7 +242,7 @@ void MotionMaster::MoveIdle()
|
||||
void MotionMaster::MoveRandom(float wanderDistance)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT)
|
||||
@@ -265,7 +265,7 @@ void MotionMaster::MoveTargetedHome()
|
||||
{
|
||||
_owner->ClearUnitState(UNIT_STATE_EVADE);
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
LOG_DEBUG("movement.motionmaster", "Pet or controlled creature ({}) targeting home", _owner->GetGUID().ToString());
|
||||
@@ -285,7 +285,7 @@ void MotionMaster::MoveTargetedHome()
|
||||
void MotionMaster::MoveConfused()
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -304,7 +304,7 @@ void MotionMaster::MoveChase(Unit* target, std::optional<ChaseRange> dist, std:
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
// ignore movement request if target not exist
|
||||
if (!target || target == _owner || _owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (!target || target == _owner || _owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
//_owner->ClearUnitState(UNIT_STATE_FOLLOW);
|
||||
@@ -372,7 +372,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
// ignore movement request if target not exist
|
||||
if (!target || target == _owner || _owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (!target || target == _owner || _owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle, MovementSlo
|
||||
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath, bool forceDestination, MovementSlot slot, float orientation /* = 0.0f*/)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -413,7 +413,7 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate
|
||||
void MotionMaster::MoveSplinePath(Movement::PointsArray* path)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -429,7 +429,7 @@ void MotionMaster::MoveSplinePath(Movement::PointsArray* path)
|
||||
void MotionMaster::MoveLand(uint32 id, Position const& pos, float speed /* = 0.0f*/)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
float x, y, z;
|
||||
@@ -459,7 +459,7 @@ void MotionMaster::MoveLand(uint32 id, float x, float y, float z, float speed /*
|
||||
void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, float speed /* = 0.0f*/)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
float x, y, z;
|
||||
@@ -549,7 +549,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float spee
|
||||
void MotionMaster::MoveFall(uint32 id /*=0*/, bool addFlagForNPC)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
// use larger distance for vmap height search than in most other cases
|
||||
@@ -590,7 +590,7 @@ void MotionMaster::MoveFall(uint32 id /*=0*/, bool addFlagForNPC)
|
||||
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))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE)
|
||||
@@ -611,7 +611,7 @@ void MotionMaster::MoveCharge(float x, float y, float z, float speed, uint32 id,
|
||||
void MotionMaster::MoveSeekAssistance(float x, float y, float z)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -631,7 +631,7 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z)
|
||||
void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
|
||||
{
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -651,7 +651,7 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time)
|
||||
return;
|
||||
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -700,7 +700,7 @@ void MotionMaster::MoveDistract(uint32 timer)
|
||||
return;
|
||||
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
/*if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -752,7 +752,7 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable)
|
||||
return;
|
||||
|
||||
// Xinef: do not allow to move with UNIT_FLAG_DISABLE_MOVE
|
||||
if (_owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
return;
|
||||
|
||||
//We set waypoint movement as new default movement generator
|
||||
|
||||
@@ -94,7 +94,7 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
|
||||
i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
|
||||
DoUpdate(unit, 1);
|
||||
|
||||
unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit->SetUnitFlag(UNIT_FLAG_CONFUSED);
|
||||
unit->AddUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ bool ConfusedMovementGenerator<T>::DoUpdate(T* unit, uint32 diff)
|
||||
template<>
|
||||
void ConfusedMovementGenerator<Player>::DoFinalize(Player* unit)
|
||||
{
|
||||
unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit->RemoveUnitFlag(UNIT_FLAG_CONFUSED);
|
||||
unit->ClearUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE);
|
||||
unit->StopMoving();
|
||||
}
|
||||
@@ -171,7 +171,7 @@ void ConfusedMovementGenerator<Player>::DoFinalize(Player* unit)
|
||||
template<>
|
||||
void ConfusedMovementGenerator<Creature>::DoFinalize(Creature* unit)
|
||||
{
|
||||
unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
unit->RemoveUnitFlag(UNIT_FLAG_CONFUSED);
|
||||
unit->ClearUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE);
|
||||
if (unit->GetVictim())
|
||||
unit->SetTarget(unit->GetVictim()->GetGUID());
|
||||
|
||||
@@ -277,7 +277,7 @@ void FleeingMovementGenerator<T>::DoInitialize(T* owner)
|
||||
if (!owner)
|
||||
return;
|
||||
|
||||
owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner->SetUnitFlag(UNIT_FLAG_FLEEING);
|
||||
owner->AddUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE);
|
||||
|
||||
_Init(owner);
|
||||
@@ -323,14 +323,14 @@ void FleeingMovementGenerator<Player>::_Init(Player* )
|
||||
template<>
|
||||
void FleeingMovementGenerator<Player>::DoFinalize(Player* owner)
|
||||
{
|
||||
owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner->RemoveUnitFlag(UNIT_FLAG_FLEEING);
|
||||
owner->ClearUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE);
|
||||
}
|
||||
|
||||
template<>
|
||||
void FleeingMovementGenerator<Creature>::DoFinalize(Creature* owner)
|
||||
{
|
||||
owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner->RemoveUnitFlag(UNIT_FLAG_FLEEING);
|
||||
owner->ClearUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE);
|
||||
if (owner->GetVictim())
|
||||
owner->SetTarget(owner->GetVictim()->GetGUID());
|
||||
@@ -376,7 +376,7 @@ template bool FleeingMovementGenerator<Creature>::DoUpdate(Creature*, uint32);
|
||||
|
||||
void TimedFleeingMovementGenerator::Finalize(Unit* owner)
|
||||
{
|
||||
owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
owner->RemoveUnitFlag(UNIT_FLAG_FLEEING);
|
||||
owner->ClearUnitState(UNIT_STATE_FLEEING | UNIT_STATE_FLEEING_MOVE);
|
||||
if (owner->GetVictim())
|
||||
owner->SetTarget(owner->GetVictim()->GetGUID());
|
||||
|
||||
@@ -39,7 +39,7 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
|
||||
}
|
||||
|
||||
if (!owner->HasSwimmingFlagOutOfCombat())
|
||||
owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SWIMMING);
|
||||
owner->RemoveUnitFlag(UNIT_FLAG_SWIMMING);
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::DoReset(Creature*)
|
||||
|
||||
@@ -280,7 +280,7 @@ bool RandomMovementGenerator<Creature>::DoUpdate(Creature* creature, const uint3
|
||||
}
|
||||
|
||||
// xinef: if we got disable move flag, do not remove default generator - just prevent movement
|
||||
if (creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE))
|
||||
if (creature->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
{
|
||||
_nextMoveTime.Reset(0); // Expire the timer
|
||||
creature->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
@@ -264,7 +264,7 @@ void ChaseMovementGenerator<T>::MovementInform(T* owner)
|
||||
static Optional<float> GetVelocity(Unit* owner, Unit* target, G3D::Vector3 const& dest, bool playerPet)
|
||||
{
|
||||
Optional<float> speed = {};
|
||||
if (!owner->IsInCombat() && !owner->IsVehicle() && !owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) &&
|
||||
if (!owner->IsInCombat() && !owner->IsVehicle() && !owner->HasUnitFlag(UNIT_FLAG_POSSESSED) &&
|
||||
(owner->IsPet() || owner->IsGuardian() || owner->GetGUID() == target->GetCritterGUID() || owner->GetCharmerOrOwnerGUID() == target->GetGUID()))
|
||||
{
|
||||
UnitMoveType moveType = Movement::SelectSpeedType(target->GetUnitMovementFlags());
|
||||
|
||||
@@ -316,7 +316,7 @@ void FlightPathMovementGenerator::DoFinalize(Player* player)
|
||||
|
||||
// xinef: this should be cleaned by CleanupAfterTaxiFlight(); function!
|
||||
player->Dismount();
|
||||
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||
player->RemoveUnitFlag(UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||
|
||||
if (player->m_taxi.empty())
|
||||
{
|
||||
@@ -337,7 +337,7 @@ void FlightPathMovementGenerator::DoReset(Player* player)
|
||||
{
|
||||
player->getHostileRefMgr().setOnlineOfflineState(false);
|
||||
player->AddUnitState(UNIT_STATE_IN_FLIGHT);
|
||||
player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||
player->SetUnitFlag(UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||
|
||||
Movement::MoveSplineInit init(player);
|
||||
uint32 end = GetPathAtMapEnd();
|
||||
|
||||
Reference in New Issue
Block a user