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;

View File

@@ -74,7 +74,7 @@ public:
{
if (urand(0, 1))
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false))
{
DoCast(target, SPELL_SHADOW_BOLT_RANDOM);
}

View File

@@ -353,7 +353,7 @@ public:
}
case EVENT_TELEPORT_RANDOM:
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false))
{
DoCastSelf(SPELL_HATE_TO_ZERO, true);
DoCast(target, SPELL_TELEPORT_RANDOM);

View File

@@ -214,7 +214,7 @@ struct boss_netherspite : public BossAI
context.Repeat(90s);
}).Schedule(15s, PORTAL_PHASE, [this](TaskContext context)
{
DoCastRandomTarget(SPELL_VOIDZONE, 1, 45.0f, true, true);
DoCastRandomTarget(SPELL_VOIDZONE, 0, 45.0f, true, true, false);
context.Repeat(15s);
});
}

View File

@@ -127,7 +127,7 @@ struct boss_malchezaar : public BossAI
scheduler.Schedule(20s, 30s, [this](TaskContext context)
{
DoCastRandomTarget(SPELL_AMPLIFY_DAMAGE, 1);
DoCastRandomTarget(SPELL_AMPLIFY_DAMAGE, 0, 0.0f, true, false, false);
context.Repeat();
}).Schedule(20s, [this](TaskContext context)
{

View File

@@ -1210,7 +1210,7 @@ struct boss_romulo : public ScriptedAI
_scheduler.Schedule(15s, GROUP_COMBAT, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100, true, false))
{
if (target && !me->HasInArc(M_PI, target))
{

View File

@@ -307,7 +307,7 @@ public:
if (victim && (target->GetGUID() == victim->GetGUID()))
{
me->AddThreat(victim, -1000000); // drop current player, add a ton to second. This should guarantee that we don't end up with both 1 and 2 in a cage...
if (Unit* newTarget = SelectTarget(SelectTargetMethod::MaxThreat, 1, 200.0f)) // search in whole room
if (Unit* newTarget = SelectTarget(SelectTargetMethod::MaxThreat, 0, 200.0f, false, false)) // search in whole room
{
me->AddThreat(newTarget, 1000000);
}

View File

@@ -208,7 +208,7 @@ public:
events.ScheduleEvent(EVENT_CURSE_OF_TONGUES, 20s);
break;
case EVENT_DOMINATE_MIND:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 20.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f, true, false))
{
me->CastSpell(target, SPELL_DOMINATE_MIND, false);
}

View File

@@ -84,7 +84,7 @@ struct boss_akilzon : public BossAI
scheduler.Schedule(10s, 20s, GROUP_STATIC_DISRUPTION, [this](TaskContext context)
{
Unit* target = SelectTarget(SelectTargetMethod::Random, 1);
Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false);
if (!target)
target = me->GetVictim();
if (target)
@@ -99,7 +99,7 @@ struct boss_akilzon : public BossAI
ScheduleTimedEvent(20s, 30s, [&] {
if (scheduler.GetNextGroupOccurrence(GROUP_ELECTRICAL_STORM) > 5s)
DoCastRandomTarget(SPELL_GUST_OF_WIND, 1);
DoCastRandomTarget(SPELL_GUST_OF_WIND, 0, 0.0f, true, false, false);
}, 20s, 30s);
ScheduleTimedEvent(10s, 20s, [&] {

View File

@@ -205,7 +205,7 @@ struct boss_zuljin : public BossAI
if (me->HasAura(SPELL_LYNX_RUSH_HASTE))
return;
DoCastRandomTarget(SPELL_CLAW_RAGE_CHARGE, 1);
DoCastRandomTarget(SPELL_CLAW_RAGE_CHARGE, 0, 0.0f, true, false, true);
}, 15s, 20s);
ScheduleTimedEvent(14s, [&] {

View File

@@ -122,7 +122,7 @@ struct boss_hazzarah : public BossAI
case EVENT_CHAIN_BURN:
if (me->GetPowerPct(POWER_MANA) > 5.f) // totally guessed
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, [&](Unit* u) { return u && !u->IsPet() && u->getPowerType() == POWER_MANA; }))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [&](Unit* u) { return u && !u->IsPet() && u->getPowerType() == POWER_MANA && u != me->GetVictim(); }))
{
DoCast(target, SPELL_CHAIN_BURN);
}

View File

@@ -150,7 +150,7 @@ public:
events.ScheduleEvent(EVENT_VANISH, 38s, 45s);
return;
case EVENT_AMBUSH:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
{
me->NearTeleportTo(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), me->GetOrientation());
DoCast(target, SPELL_AMBUSH, true);

View File

@@ -90,7 +90,7 @@ struct boss_twilight_corrupter : public ScriptedAI
_scheduler
.Schedule(12s, 18s, [this](TaskContext context)
{
DoCastRandomTarget(SPELL_CREATURE_OF_NIGHTMARE, 1, 100.f);
DoCastRandomTarget(SPELL_CREATURE_OF_NIGHTMARE, 0, 100.f, true, false, false);
context.Repeat(35s, 45s);
})
.Schedule(9s, 16s, [this](TaskContext context)

View File

@@ -67,7 +67,7 @@ public:
}).Schedule(25s, 32s, [this](TaskContext context)
{
Talk(SAY_SLEEP);
DoCastRandomTarget(SPELL_SLEEP, 1, 0.0f, true, false, false);
DoCastRandomTarget(SPELL_SLEEP, 0, 0.0f, true, false, false);
context.Repeat(35s, 48s);
}).Schedule(30s, 48s, [this](TaskContext context)
{

View File

@@ -81,7 +81,7 @@ struct boss_lieutenant_drake : public BossAI
context.Repeat(25s);
}).Schedule(1s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 40.0f))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, false, false))
{
DoCast(target, SPELL_EXPLODING_SHOT);
}

View File

@@ -57,7 +57,7 @@ struct boss_kurinnaxx : public BossAI
context.Repeat(8s, 10s);
}).Schedule(5s, 15s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.f, true, false))
{
target->CastSpell(target, SPELL_SAND_TRAP, true, nullptr, nullptr, me->GetGUID());
}

View File

@@ -50,16 +50,10 @@ struct npc_hivezara_stinger : public ScriptedAI
scheduler.Schedule(5s, [this](TaskContext context)
{
Unit* target = SelectTarget(SelectTargetMethod::Random, 1, [&](Unit* u)
{
return u && !u->IsPet() && u->IsWithinDist2d(me, 20.f) && u->HasAura(SPELL_HIVEZARA_CATALYST);
});
Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f, true, false, SPELL_HIVEZARA_CATALYST);
if (!target)
{
target = SelectTarget(SelectTargetMethod::Random, 1, [&](Unit* u)
{
return u && !u->IsPet() && u->IsWithinDist2d(me, 20.f);
});
target = SelectTarget(SelectTargetMethod::Random, 0, 20.0f, true, false);
}
if (target)

View File

@@ -98,7 +98,7 @@ struct boss_fankriss : public BossAI
})
.Schedule(15s, 20s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false))
{
uint32 spellId = Acore::Containers::SelectRandomContainerElement(entangleSpells);
DoCast(target, spellId);

View File

@@ -115,7 +115,7 @@ struct boss_sartura : public BossAI
switch (eventId)
{
case EVENT_SARTURA_WHIRLWIND:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false))
{
me->GetThreatMgr().ResetAllThreat();
me->AddThreat(target, 1000.0f);
@@ -199,7 +199,7 @@ struct npc_sartura_royal_guard : public ScriptedAI
switch (eventid)
{
case EVENT_GUARD_WHIRLWIND:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false))
{
me->GetThreatMgr().ResetAllThreat();
me->AddThreat(target, 1000.0f);

View File

@@ -98,7 +98,7 @@ struct npc_anubisath_defender : public ScriptedAI
{
scheduler.Schedule(6s, 10s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 0.0f, false, false))
DoCast(target, SPELL_PLAGUE, true);
context.Repeat(6s, 10s);
});

View File

@@ -852,7 +852,7 @@ struct boss_sartharion_dragonAI : public BossAI
if (isCalledBySartharion)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1, 500, true))
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 500, true, false))
{
AttackStart(target);
}

View File

@@ -396,7 +396,7 @@ public:
events.ScheduleEvent(EVENT_METEOR_STRIKE, 40s);
break;
case EVENT_FIERY_COMBUSTION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, true, -SPELL_TWILIGHT_REALM))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false, -SPELL_TWILIGHT_REALM))
me->CastSpell(target, SPELL_FIERY_COMBUSTION, false);
events.ScheduleEvent(EVENT_FIERY_COMBUSTION, 25s);
break;
@@ -539,7 +539,7 @@ public:
_events.ScheduleEvent(EVENT_BREATH, 10s, 12s);
break;
case EVENT_SOUL_CONSUMPTION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, true, SPELL_TWILIGHT_REALM))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false, SPELL_TWILIGHT_REALM))
me->CastSpell(target, SPELL_SOUL_CONSUMPTION, false);
_events.ScheduleEvent(EVENT_SOUL_CONSUMPTION, 20s);
break;

View File

@@ -123,7 +123,7 @@ public:
events.ScheduleEvent(EVENT_ECK_SPIT, 10s);
break;
case EVENT_ECK_SPRING:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 30.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 30.0f, true, false))
{
me->GetThreatMgr().ResetAllThreat();
me->AddThreat(target, 500.0f);

View File

@@ -207,7 +207,7 @@ public:
return;
}
events.ScheduleEvent(EVENT_IMPALING_CHARGE, 21s);
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false))
{
me->CastSpell(target, SPELL_IMPALING_CHARGE, false);
impaledList.insert(target->GetGUID());

View File

@@ -358,7 +358,7 @@ public:
void JustSummoned(Creature* summon) override
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false))
summon->AI()->AttackStart(target);
//if (IsHeroic())
@@ -468,7 +468,7 @@ public:
switch (action)
{
case ACTION_MARK_OF_THE_FALLEN_CHAMPION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_MARK_OF_THE_FALLEN_CHAMPION))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false, -SPELL_MARK_OF_THE_FALLEN_CHAMPION))
{
++_fallenChampionCastCount;
me->CastSpell(target, SPELL_MARK_OF_THE_FALLEN_CHAMPION, false);

View File

@@ -857,7 +857,7 @@ public:
events.Repeat(9s, 13s);
break;
case EVENT_SPELL_ADHERENT_CURSE_OF_TORPOR:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
me->CastSpell(target, SPELL_CURSE_OF_TORPOR, false);
events.Repeat(9s, 13s);
break;

View File

@@ -482,7 +482,7 @@ class spell_marrowgar_coldflame : public SpellScript
void SelectTarget(std::list<WorldObject*>& targets)
{
targets.clear();
Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 1, -1.0f, true,true, -SPELL_IMPALED); // -1.0f as it takes into account object size
Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, -1.0f, true, false, -SPELL_IMPALED); // -1.0f as it takes into account object size
if (!target)
target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true); // if only tank or noone outside of boss' model
if (!target)

View File

@@ -209,7 +209,7 @@ public:
bool operator()(Unit const* target) const
{
if (!me || !target || !target->IsPlayer())
if (!me || !target || !target->IsPlayer() || target == me->GetThreatMgr().GetCurrentVictim())
return false;
if (me->IsWithinCombatRange(target, 7.0f))
@@ -640,7 +640,7 @@ public:
}
else
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, MalleableGooSelector(me)))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, MalleableGooSelector(me)))
{
Talk(EMOTE_MALLEABLE_GOO);
me->CastSpell(target, SPELL_MALLEABLE_GOO, true);

View File

@@ -627,7 +627,7 @@ public:
switch (eventId)
{
case EVENT_DEATH_PLAGUE:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_RECENTLY_INFECTED))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false, -SPELL_RECENTLY_INFECTED))
{
Talk(EMOTE_DEATH_PLAGUE_WARNING, target);
DoCast(target, SPELL_DEATH_PLAGUE);
@@ -1161,7 +1161,7 @@ public:
Talk(SAY_SVALNA_AGGRO);
break;
case EVENT_IMPALING_SPEAR:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_IMPALING_SPEAR))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false, -SPELL_IMPALING_SPEAR))
{
DoCast(me, SPELL_AETHER_SHIELD);
me->AddAura(70203, me);
@@ -1347,7 +1347,7 @@ public:
Events.ScheduleEvent(EVENT_ARNATH_SMITE, 4s, 7s);
break;
case EVENT_ARNATH_DOMINATE_MIND:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_DOMINATE_MIND))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false, -SPELL_DOMINATE_MIND))
DoCast(target, SPELL_DOMINATE_MIND);
Events.ScheduleEvent(EVENT_ARNATH_DOMINATE_MIND, 28s, 37s);
break;
@@ -1425,7 +1425,7 @@ public:
Events.ScheduleEvent(EVENT_BRANDON_JUDGEMENT_OF_COMMAND, 8s, 13s);
break;
case EVENT_BRANDON_HAMMER_OF_BETRAYAL:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, false))
DoCast(target, SPELL_HAMMER_OF_BETRAYAL);
Events.ScheduleEvent(EVENT_BRANDON_HAMMER_OF_BETRAYAL, 45s, 60s);
break;
@@ -1552,12 +1552,12 @@ public:
Events.ScheduleEvent(EVENT_RUPERT_FEL_IRON_BOMB, 15s, 20s);
break;
case EVENT_RUPERT_MACHINE_GUN:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
DoCast(target, SPELL_MACHINE_GUN);
Events.ScheduleEvent(EVENT_RUPERT_MACHINE_GUN, 25s, 30s);
break;
case EVENT_RUPERT_ROCKET_LAUNCH:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
DoCast(target, SPELL_ROCKET_LAUNCH);
Events.ScheduleEvent(EVENT_RUPERT_ROCKET_LAUNCH, 10s, 15s);
break;

View File

@@ -173,7 +173,7 @@ public:
events.Repeat(20s);
break;
case EVENT_MUTATING_INJECTION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, true, -SPELL_MUTATING_INJECTION))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, false, -SPELL_MUTATING_INJECTION))
{
me->CastSpell(target, SPELL_MUTATING_INJECTION, false);
}

View File

@@ -382,7 +382,7 @@ public:
events.Repeat(25s);
break;
case EVENT_FROST_BLAST:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, RAID_MODE(1, 0), 0, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0, true, RAID_MODE(false, true)))
{
me->CastSpell(target, SPELL_FROST_BLAST, false);
}
@@ -392,7 +392,7 @@ public:
case EVENT_CHAINS:
for (uint8 i = 0; i < 3; ++i)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 200, true, true, -SPELL_CHAINS_OF_KELTHUZAD))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 200, true, false, -SPELL_CHAINS_OF_KELTHUZAD))
{
me->CastSpell(target, SPELL_CHAINS_OF_KELTHUZAD, true);
}

View File

@@ -143,7 +143,7 @@ class boss_archavon : public CreatureScript
events.Repeat(15s);
break;
case EVENT_CHOKING_CLOUD:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
{
DoCast(target, RAID_MODE(SPELL_CRUSHING_LEAP_10, SPELL_CRUSHING_LEAP_25), true); //10y ~ 80y, ignore range
}

View File

@@ -124,7 +124,7 @@ struct boss_anzu : public BossAI
scheduler.DelayAll(3s);
}).Schedule(8s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 45.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 9, 45.0f, true, false))
{
DoCast(target, SPELL_CYCLONE);
}

View File

@@ -103,9 +103,9 @@ struct boss_talon_king_ikiss : public BossAI
}).Schedule(8s, [this](TaskContext context)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_POLYMORPH);
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, [&](Unit* target) -> bool
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [&](Unit* target) -> bool
{
return target && !target->IsImmunedToSpell(spellInfo);
return target && !target->IsImmunedToSpell(spellInfo) && target != me->GetThreatMgr().GetCurrentVictim();
}))
{
DoCast(target, SPELL_POLYMORPH);

View File

@@ -99,7 +99,7 @@ struct boss_gurtogg_bloodboil : public BossAI
}, 15s);
ScheduleTimedEvent(1min, [&] {
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 40.0f, true))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 40.0f, true, false))
{
me->RemoveAurasByType(SPELL_AURA_MOD_TAUNT);
me->RemoveAurasDueToSpell(SPELL_ACIDIC_WOUND);

View File

@@ -65,9 +65,11 @@ enum Misc
struct ShadowOfDeathSelector
{
Unit const* _tank;
ShadowOfDeathSelector(Unit const* tank) : _tank(tank) {}
bool operator()(Unit const* target) const
{
return target && !target->HasAura(SPELL_SHADOW_OF_DEATH) && !target->HasAura(SPELL_POSSESS_SPIRIT_IMMUNE);
return target && !target->HasAura(SPELL_SHADOW_OF_DEATH) && !target->HasAura(SPELL_POSSESS_SPIRIT_IMMUNE) && target != _tank;
}
};
@@ -113,7 +115,7 @@ struct boss_teron_gorefiend : public BossAI
ScheduleTimedEvent(10s, [&]
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, ShadowOfDeathSelector()))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, ShadowOfDeathSelector(me->GetThreatMgr().GetCurrentVictim())))
me->CastSpell(target, SPELL_SHADOW_OF_DEATH, false);
}, 30s, 50s);

View File

@@ -91,7 +91,7 @@ struct boss_najentus : public BossAI
ScheduleTimedEvent(21s, [&]
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
{
DoCast(target, SPELL_IMPALING_SPINE);
target->CastSpell(target, SPELL_SUMMON_IMPALING_SPINE, true);

View File

@@ -73,7 +73,7 @@ struct boss_mekgineer_steamrigger : public BossAI
context.Repeat(35100ms, 54100ms);
}).Schedule(6050ms, 17650ms, [this](TaskContext context)
{
if (DoCastRandomTarget(SPELL_SAW_BLADE, 1) != SPELL_CAST_OK)
if (DoCastRandomTarget(SPELL_SAW_BLADE, 0, 0.0f, true, false, false) != SPELL_CAST_OK)
{
DoCastVictim(SPELL_SAW_BLADE);
}

View File

@@ -100,7 +100,7 @@ struct boss_the_black_stalker : public BossAI
void JustSummoned(Creature* summon) override
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
summon->AI()->AttackStart(target);
else if (me->GetVictim())
summon->AI()->AttackStart(me->GetVictim());

View File

@@ -95,7 +95,7 @@ struct boss_gruul : public BossAI
context.Repeat(39900ms, 55700ms);
}).Schedule(5600ms, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1, 5.0f))
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 0, 5.0f, false, false))
{
DoCast(target, SPELL_HURTFUL_STRIKE);
}

View File

@@ -169,7 +169,7 @@ struct boss_warbringer_omrogg : public BossAI
context.Schedule(200ms, GROUP_NON_BURNING_PHASE, [this](TaskContext context)
{
DoResetThreatList();
if (Unit* newTarget = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* newTarget = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
me->AddThreat(newTarget, 2250.f);
HandleHeadTalk(SAY_ON_BEATDOWN);
context.Schedule(1200ms, GROUP_NON_BURNING_PHASE, [this](TaskContext /*context*/)
@@ -199,7 +199,7 @@ struct boss_warbringer_omrogg : public BossAI
context.Schedule(2200ms, [this](TaskContext context)
{
DoResetThreatList();
if (Unit* newTarget = SelectTarget(SelectTargetMethod::Random, 1))
if (Unit* newTarget = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, false, false))
me->AddThreat(newTarget, 2250.f);
me->SetReactState(REACT_AGGRESSIVE);
context.Schedule(4850ms, 8500ms, GROUP_BURNING_PHASE, [this](TaskContext context)

View File

@@ -115,7 +115,7 @@ struct boss_pathaleon_the_calculator : public BossAI
context.Repeat(15s);
}).Schedule(10s, 15s, [this](TaskContext context)
{
if (DoCastRandomTarget(SPELL_DOMINATION, 1, 50.0f) == SPELL_CAST_OK)
if (DoCastRandomTarget(SPELL_DOMINATION, 0, 50.0f, true, false, false) == SPELL_CAST_OK)
{
Talk(SAY_DOMINATION);
}

View File

@@ -92,7 +92,7 @@ struct boss_harbinger_skyriss : public BossAI
context.Repeat(25s);
}).Schedule(30s, [this](TaskContext context)
{
if (DoCastRandomTarget(SPELL_DOMINATION, 1, 30.0f) == SPELL_CAST_OK)
if (DoCastRandomTarget(SPELL_DOMINATION, 0, 30.0f, true, false, false) == SPELL_CAST_OK)
{
Talk(SAY_MIND);
}

View File

@@ -75,7 +75,7 @@ struct boss_thorngrin_the_tender : public BossAI
scheduler.Schedule(6s, [this](TaskContext context)
{
if (DoCastRandomTarget(SPELL_SACRIFICE, 1) == SPELL_CAST_OK)
if (DoCastRandomTarget(SPELL_SACRIFICE, 0, 0.0f, true, false, false) == SPELL_CAST_OK)
{
Talk(SAY_CAST_SACRIFICE);
}

View File

@@ -80,7 +80,7 @@ struct boss_doomwalker : public ScriptedAI
context.Repeat(10s, 25s);
}).Schedule(10s, 30s, [this](TaskContext context)
{
DoCastRandomTarget(SPELL_CHAIN_LIGHTNING, 1);
DoCastRandomTarget(SPELL_CHAIN_LIGHTNING, 0, 0.0f, true, false, false);
context.Repeat(7s, 27s);
}).Schedule(25s, 35s, [this](TaskContext context)
{