refactor(Core/ScriptedAI): few improvements with threat methods (#13146)

improve threat scripts

Co-authored-by: Maelthyrr <lynethris@protonmail.ch>
This commit is contained in:
Maelthyr
2022-11-12 13:29:28 +01:00
committed by GitHub
parent 758ed35db3
commit c1c9dc6105
50 changed files with 100 additions and 73 deletions

View File

@@ -429,7 +429,7 @@ public:
{
case SPELL_CLAW_N:
case SPELL_CLAW_H:
DoResetThreat();
DoResetThreatList();
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 30.0f))
{
me->AddThreat(target, 100.0f);

View File

@@ -927,7 +927,7 @@ public:
Player* player = itr->GetSource();
if( player && me->IsInRange(player, 8.0f, 25.0f, false) )
{
DoResetThreat();
DoResetThreatList();
me->AddThreat(player, 5.0f);
me->CastSpell(player, SPELL_INTERCEPT, false);
break;

View File

@@ -767,7 +767,7 @@ public:
me->RemoveAllAuras();
}
DoZoneInCombat();
DoResetThreat();
DoResetThreatList();
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 250.0f, true) )
{
if (!next)

View File

@@ -336,7 +336,7 @@ public:
case EVENT_SPELL_FEL_STEAK:
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 44.0f, true) )
{
DoResetThreat();
DoResetThreatList();
me->AddThreat(target, 50000.0f);
me->CastSpell(target, SPELL_FEL_STEAK_MORPH, true);
me->CastSpell(target, SPELL_FEL_STEAK, true);

View File

@@ -593,7 +593,7 @@ struct boss_jormungarAI : public ScriptedAI
}
me->UpdatePosition(Locs[LOC_CENTER].GetPositionX() + cos(angle)*dist, Locs[LOC_CENTER].GetPositionY() + std::sin(angle)*dist, me->GetPositionZ(), me->GetOrientation(), true);
me->StopMovingOnCurrentPos();
DoResetThreat();
DoResetThreatList();
events.RescheduleEvent(EVENT_EMERGE, 6000);
}

View File

@@ -971,7 +971,7 @@ public:
case EVENT_SHADOW_STEP:
if (Unit* target = SelectTargetFromPlayerList(100.0f, 0, true))
{
DoResetThreat();
DoResetThreatList();
me->AddThreat(target, 5000.0f);
AttackStart(target);
me->CastSpell(target, SPELL_SHADOW_STEP, false);

View File

@@ -305,7 +305,7 @@ public:
Unit* unit = ObjectAccessor::GetUnit((*me), (*itr)->getUnitGuid());
if (unit && DoGetThreat(unit))
DoModifyThreatPercent(unit, -100);
DoModifyThreatByPercent(unit, -100);
}
Talk(SAY_PHASE_2);

View File

@@ -383,7 +383,7 @@ public:
me->CastSpell(me, SPELL_WEAK_RADIATING_OOZE, true);
events.Reset();
events.ScheduleEvent(EVENT_STICKY_OOZE, 5000);
DoResetThreat();
DoResetThreatList();
me->SetInCombatWithZone();
if (TempSummon* ts = me->ToTempSummon())
if (Unit* summoner = ts->GetSummonerUnit())
@@ -468,7 +468,7 @@ public:
me->CastSpell(me, SPELL_GREEN_ABOMINATION_HITTIN__YA_PROC, true);
events.Reset();
events.ScheduleEvent(EVENT_STICKY_OOZE, 5000);
DoResetThreat();
DoResetThreatList();
me->SetInCombatWithZone();
if (Player* p = me->SelectNearestPlayer(100.0f))
AttackStart(p);

View File

@@ -1777,7 +1777,7 @@ public:
c->NearTeleportTo(myPos.GetPositionX(), myPos.GetPositionY(), myPos.GetPositionZ(), myPos.GetOrientation());
const ThreatContainer::StorageType me_tl = me->GetThreatMgr().GetThreatList();
const ThreatContainer::StorageType target_tl = c->GetThreatMgr().GetThreatList();
DoResetThreat();
DoResetThreatList();
for (ThreatContainer::StorageType::const_iterator iter = target_tl.begin(); iter != target_tl.end(); ++iter)
me->GetThreatMgr().AddThreat((*iter)->getTarget(), (*iter)->GetThreat());

View File

@@ -254,7 +254,7 @@ public:
StartBalconyPhase();
break;
case EVENT_BLINK:
DoResetThreat();
DoResetThreatList();
me->CastSpell(me, RAID_MODE(SPELL_CRIPPLE_10, SPELL_CRIPPLE_25), false);
me->CastSpell(me, SPELL_BLINK, true);
Talk(EMOTE_BLINK);

View File

@@ -835,7 +835,7 @@ public:
_flyTargetGUID.Clear();
me->RemoveAura(SPELL_LIGHTNING_TENDRILS);
me->RemoveAura(61883);
DoResetThreat();
DoResetThreatList();
break;
case EVENT_ENRAGE:
Talk(SAY_BRUNDIR_BERSERK);

View File

@@ -412,7 +412,7 @@ public:
if (_feralRushTimer >= 6000)
{
DoResetThreat();
DoResetThreatList();
if (!UpdateVictim())
return;

View File

@@ -1184,7 +1184,7 @@ public:
break;
case EVENT_DETONATING_LASHER_FLAME_LASH:
me->CastSpell(me->GetVictim(), SPELL_FLAME_LASH, false);
DoResetThreat();
DoResetThreatList();
if (Unit* target = SelectTargetFromPlayerList(80))
AttackStart(target);
else

View File

@@ -1033,7 +1033,7 @@ public:
break;
case 4:
me->SetReactState(REACT_AGGRESSIVE);
DoResetThreat();
DoResetThreatList();
Phase = 4;
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
if (Unit* target = SelectTargetFromPlayerList(75.0f))
@@ -1613,7 +1613,7 @@ public:
break;
case 4:
me->SetReactState(REACT_AGGRESSIVE);
DoResetThreat();
DoResetThreatList();
Phase = 4;
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
if (Unit* target = SelectTargetFromPlayerList(75.0f))

View File

@@ -518,7 +518,7 @@ public:
Talk(EMOTE_PERMA_GROUND);
me->SetControlled(false, UNIT_STATE_ROOT);
me->DisableRotate(false);
DoResetThreat();
DoResetThreatList();
Unit* target = SelectTarget(SelectTargetMethod::MaxDistance, 0, 0.0, true);
if (!target)
target = me->SelectNearestPlayer(200.0f);

View File

@@ -552,7 +552,7 @@ public:
summons.DoAction(ACTION_SIF_JOIN_FIGHT, pred);
}
DoResetThreat();
DoResetThreatList();
if (Player* player = GetArenaPlayer())
me->AddThreat(player, 1000.0f);
}

View File

@@ -1511,7 +1511,7 @@ public:
{
if (who && damagetype == DIRECT_DAMAGE)
{
DoResetThreat();
DoResetThreatList();
me->AddThreat(who, 100000);
AttackStart(who);
me->InterruptNonMeleeSpells(false);
@@ -1539,7 +1539,7 @@ public:
return;
me->CastSpell(me, SPELL_DIMINISH_POWER, false);
DoResetThreat();
DoResetThreatList();
}
};
};

View File

@@ -198,7 +198,7 @@ public:
case EVENT_SHARVALD_CHARGE:
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, (IsHeroic() ? 100.0f : 30.0f), true))
{
ScriptedAI::DoResetThreat();
DoResetThreatList();
me->AddThreat(target, 10000.0f);
me->CastSpell(target, SPELL_CHARGE, false);
}

View File

@@ -123,7 +123,7 @@ public:
break;
case EVENT_SPELL_ARCANE_VACUUM:
me->CastSpell((Unit*)nullptr, SPELL_ARCANE_VACUUM, false);
DoResetThreat();
DoResetThreatList();
me->SetControlled(true, UNIT_STATE_ROOT);
me->setAttackTimer(BASE_ATTACK, 3000);
events.RepeatEvent(30000);