refactor(Core/UnitAI): Update target selector (#13169)

* refactor(Core/UnitAI): Update TargetSelector.

Cherry-pick:
*https://github.com/TrinityCore/TrinityCore/pull/19930

Co-authored-by: Treeston <treeston@users.noreply.github.com>

* fix GGC/CLang errors in scripts

* .

* missing a file and fix a script error

* .

* fix path changes dude to a miss click in the second commit

* .

Co-authored-by: Maelthyrr <lynethris@protonmail.ch>
Co-authored-by: Treeston <treeston@users.noreply.github.com>
This commit is contained in:
Maelthyr
2022-12-06 13:27:13 +01:00
committed by GitHub
parent 9fd5b39065
commit 3024bee3ba
27 changed files with 140 additions and 89 deletions

View File

@@ -204,7 +204,7 @@ struct boss_amanitar : public BossAI
}
}
if (SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, -SPELL_MINI))
if (SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true, -SPELL_MINI))
{
DoCastSelf(SPELL_REMOVE_MUSHROOM_POWER, true);
DoCastAOE(SPELL_MINI);

View File

@@ -224,7 +224,7 @@ public:
break;
case EVENT_ENERVATING_BRAND:
for (uint8 i = 0; i < RAID_MODE<uint8>(2, 4, 2, 4); i++)
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, -SPELL_ENERVATING_BRAND))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, true, -SPELL_ENERVATING_BRAND))
me->CastSpell(target, SPELL_ENERVATING_BRAND, true);
events.ScheduleEvent(EVENT_ENERVATING_BRAND, 26000);
break;
@@ -311,7 +311,7 @@ public:
break;
case EVENT_ENERVATING_BRAND:
for (uint8 i = 0; i < RAID_MODE<uint8>(4, 10, 4, 10); i++)
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, -SPELL_ENERVATING_BRAND))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 45.0f, true, true, -SPELL_ENERVATING_BRAND))
me->CastSpell(target, SPELL_ENERVATING_BRAND, true);
_events.ScheduleEvent(EVENT_ENERVATING_BRAND, 26000);
break;

View File

@@ -399,7 +399,7 @@ public:
events.ScheduleEvent(EVENT_METEOR_STRIKE, 40000);
break;
case EVENT_FIERY_COMBUSTION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, -SPELL_TWILIGHT_REALM))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, true, -SPELL_TWILIGHT_REALM))
me->CastSpell(target, SPELL_FIERY_COMBUSTION, false);
events.ScheduleEvent(EVENT_FIERY_COMBUSTION, 25000);
break;
@@ -542,7 +542,7 @@ public:
_events.ScheduleEvent(EVENT_BREATH, urand(10000, 12000));
break;
case EVENT_SOUL_CONSUMPTION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, SPELL_TWILIGHT_REALM))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 100.0f, true, true, SPELL_TWILIGHT_REALM))
me->CastSpell(target, SPELL_SOUL_CONSUMPTION, false);
_events.ScheduleEvent(EVENT_SOUL_CONSUMPTION, 20000);
break;

View File

@@ -211,12 +211,12 @@ public:
events.RepeatEvent(urand(10000, 15000));
break;
case EVENT_SPELL_FEL_LIGHTNING:
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true) )
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true) )
me->CastSpell(target, SPELL_FEL_LIGHTNING, false);
events.RepeatEvent(urand(10000, 15000));
break;
case EVENT_SPELL_INCINERATE_FLESH:
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true) )
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true) )
{
Talk(EMOTE_INCINERATE, target);
Talk(SAY_INCINERATE);
@@ -230,7 +230,7 @@ public:
events.RepeatEvent(urand(25000, 45000));
break;
case EVENT_SPELL_LEGION_FLAME:
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true) )
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true) )
{
Talk(EMOTE_LEGION_FLAME, target);
me->CastSpell(target, SPELL_LEGION_FLAME, false);

View File

@@ -465,7 +465,7 @@ public:
switch (action)
{
case ACTION_MARK_OF_THE_FALLEN_CHAMPION:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, -SPELL_MARK_OF_THE_FALLEN_CHAMPION))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_MARK_OF_THE_FALLEN_CHAMPION))
{
++_fallenChampionCastCount;
me->CastSpell(target, SPELL_MARK_OF_THE_FALLEN_CHAMPION, false);

View File

@@ -235,7 +235,7 @@ public:
{
std::list<Unit*> targets;
uint32 minTargets = RAID_MODE<uint32>(3, 8, 3, 8);
SelectTargetList(targets, minTargets, SelectTargetMethod::Random, -5.0f, true);
SelectTargetList(targets, minTargets, SelectTargetMethod::Random, 0, -5.0f, true);
float minDist = 0.0f;
if (targets.size() >= minTargets)
minDist = -5.0f;

View File

@@ -445,7 +445,7 @@ public:
count = 3;
std::list<Unit*> targets;
SelectTargetList(targets, NonTankTargetSelector(me, true), count, SelectTargetMethod::Random);
SelectTargetList(targets, count, SelectTargetMethod::Random, 0, NonTankTargetSelector(me, true));
if (!targets.empty())
for (std::list<Unit*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
me->CastSpell(*itr, SPELL_SUMMON_SHADE, true);

View File

@@ -479,7 +479,7 @@ public:
void SelectTarget(std::list<WorldObject*>& targets)
{
targets.clear();
Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 1, -1.0f, true, -SPELL_IMPALED); // -1.0f as it takes into account object size
Unit* target = GetCaster()->GetAI()->SelectTarget(SelectTargetMethod::Random, 1, -1.0f, true,true, -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

@@ -548,7 +548,7 @@ public:
case EVENT_SLIME_PUDDLE:
{
std::list<Unit*> targets;
SelectTargetList(targets, 2, SelectTargetMethod::Random, 0.0f, true);
SelectTargetList(targets, 2, SelectTargetMethod::Random, 0, 0.0f, true);
if (!targets.empty())
for (std::list<Unit*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
me->CastSpell(*itr, SPELL_SLIME_PUDDLE_TRIGGER, true);
@@ -634,7 +634,7 @@ public:
if (Is25ManRaid())
{
std::list<Unit*> targets;
SelectTargetList(targets, MalleableGooSelector(me), (IsHeroic() ? 3 : 2), SelectTargetMethod::Random);
SelectTargetList(targets, (IsHeroic() ? 3 : 2), SelectTargetMethod::Random, 0, MalleableGooSelector(me));
if (!targets.empty())
{

View File

@@ -315,7 +315,7 @@ public:
{
std::list<Unit*> targets;
uint32 minTargets = RAID_MODE<uint32>(3, 8, 3, 8);
SelectTargetList(targets, minTargets, SelectTargetMethod::Random, -5.0f, true);
SelectTargetList(targets, minTargets, SelectTargetMethod::Random, 0, -5.0f, true);
float minDist = 0.0f;
if (targets.size() >= minTargets)
minDist = -5.0f;

View File

@@ -625,7 +625,7 @@ public:
switch (eventId)
{
case EVENT_DEATH_PLAGUE:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, -SPELL_RECENTLY_INFECTED))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_RECENTLY_INFECTED))
{
Talk(EMOTE_DEATH_PLAGUE_WARNING, target);
DoCast(target, SPELL_DEATH_PLAGUE);
@@ -1175,7 +1175,7 @@ public:
Talk(SAY_SVALNA_AGGRO);
break;
case EVENT_IMPALING_SPEAR:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, -SPELL_IMPALING_SPEAR))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_IMPALING_SPEAR))
{
DoCast(me, SPELL_AETHER_SHIELD);
me->AddAura(70203, me);
@@ -1361,7 +1361,7 @@ public:
Events.ScheduleEvent(EVENT_ARNATH_SMITE, urand(4000, 7000));
break;
case EVENT_ARNATH_DOMINATE_MIND:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, -SPELL_DOMINATE_MIND))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0.0f, true, true, -SPELL_DOMINATE_MIND))
DoCast(target, SPELL_DOMINATE_MIND);
Events.ScheduleEvent(EVENT_ARNATH_DOMINATE_MIND, urand(28000, 37000));
break;

View File

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

View File

@@ -427,7 +427,7 @@ public:
case EVENT_CHAINS:
for (uint8 i = 0; i < 3; ++i)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 200, true, -SPELL_CHAINS_OF_KELTHUZAD))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 200, true, true, -SPELL_CHAINS_OF_KELTHUZAD))
{
me->CastSpell(target, SPELL_CHAINS_OF_KELTHUZAD, true);
}

View File

@@ -201,7 +201,7 @@ public:
Talk(EMOTE_WEB_WRAP);
for (uint8 i = 0; i < RAID_MODE(1, 2); ++i)
{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0, true, -SPELL_WEB_WRAP))
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 1, 0, true, true, -SPELL_WEB_WRAP))
{
target->RemoveAura(RAID_MODE(SPELL_WEB_SPRAY_10, SPELL_WEB_SPRAY_25));
uint8 pos = urand(0, 2);

View File

@@ -1505,7 +1505,7 @@ public:
{
uint8 i = 0;
std::list<Unit*> drakes;
c->AI()->SelectTargetList(drakes, (c->GetMap()->GetSpawnMode() == 0 ? 1 : 3), SelectTargetMethod::Random, 0.0f, false, 57403 /*only drakes have this aura*/);
c->AI()->SelectTargetList(drakes, (c->GetMap()->GetSpawnMode() == 0 ? 1 : 3), SelectTargetMethod::Random, 0, 0.0f, false, true, 57403 /*only drakes have this aura*/);
for (std::list<Unit*>::iterator itr = drakes.begin(); itr != drakes.end() && i < 3; ++itr)
{
DrakeGUID[i++] = (*itr)->GetGUID();

View File

@@ -197,7 +197,7 @@ public:
events.RepeatEvent(urand(4000, 5000));
break;
case EVENT_FROST_TOMB:
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true) )
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.0f, true, true) )
if( !target->HasAura(SPELL_FROST_TOMB_AURA) )
{
Talk(SAY_FROST_TOMB_EMOTE, target);