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

@@ -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
}