refactor(Core/AI) don't add currentTarget to the front of the SelectTargetList for MaxThreat/Random (#21965)

This commit is contained in:
Tereneckla
2025-05-05 19:17:10 +00:00
committed by GitHub
parent 2772da9bf2
commit a8b982dca8
46 changed files with 71 additions and 77 deletions

View File

@@ -137,14 +137,18 @@ struct PowerUsersSelector : public Acore::unary_function<Unit*, bool>
Powers const _power;
float const _dist;
bool const _playerOnly;
bool const _withTank;
PowerUsersSelector(Unit const* unit, Powers power, float dist, bool playerOnly) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
PowerUsersSelector(Unit const* unit, Powers power, float dist, bool playerOnly, bool withTank = true) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly), _withTank(withTank) { }
bool operator()(Unit const* target) const
{
if (!_me || !target)
return false;
if (!_withTank && target == _me->GetThreatMgr().GetCurrentVictim())
return false;
if (target->getPowerType() != _power)
return false;
@@ -294,18 +298,12 @@ public:
}
else
{
Unit* currentVictim = mgr.GetCurrentVictim();
if (currentVictim)
targetList.push_back(currentVictim);
for (ThreatReference const* ref : mgr.GetSortedThreatList())
{
if (ref->IsOffline())
continue;
Unit* thisTarget = ref->GetVictim();
if (thisTarget != currentVictim)
targetList.push_back(thisTarget);
targetList.push_back(ref->GetVictim());
}
}

View File

@@ -3460,10 +3460,10 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (e.target.hostileRandom.powerType)
{
if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false)))
targets.push_back(u);
}
else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::MaxThreat, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
targets.push_back(u);
}
break;
@@ -3496,10 +3496,10 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (e.target.hostileRandom.powerType)
{
if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly)))
if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, PowerUsersSelector(me, Powers(e.target.hostileRandom.powerType - 1), (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false)))
targets.push_back(u);
}
else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 1, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, true, -e.target.hostileRandom.aura))
else if (Unit* u = me->AI()->SelectTarget(SelectTargetMethod::Random, 0, (float)e.target.hostileRandom.maxDist, e.target.hostileRandom.playerOnly, false, -e.target.hostileRandom.aura))
targets.push_back(u);
}
break;