Scripts/Naxxramas: Update Patchwerk to new model (#26388)

Co-authored-by: offl <offl@users.noreply.github.com>
(cherry picked from commit 6f0bc11bce)
This commit is contained in:
offl
2021-04-13 10:31:18 +03:00
committed by Shauren
parent d125316d5a
commit 4dce06da7e

View File

@@ -34,7 +34,7 @@ enum Yells
SAY_SLAY = 1,
SAY_DEATH = 2,
EMOTE_BERSERK = 3,
EMOTE_ENRAGE = 4
EMOTE_FRENZY = 4
};
enum Events
@@ -55,139 +55,127 @@ enum HatefulThreatAmounts
HATEFUL_THREAT_AMT = 1000,
};
class boss_patchwerk : public CreatureScript
struct boss_patchwerk : public BossAI
{
public:
boss_patchwerk() : CreatureScript("boss_patchwerk") { }
CreatureAI* GetAI(Creature* creature) const override
boss_patchwerk(Creature* creature) : BossAI(creature, BOSS_PATCHWERK)
{
return GetNaxxramasAI<boss_patchwerkAI>(creature);
Enraged = false;
}
struct boss_patchwerkAI : public BossAI
bool Enraged;
void Reset() override
{
boss_patchwerkAI(Creature* creature) : BossAI(creature, BOSS_PATCHWERK)
_Reset();
instance->DoStopCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
}
void KilledUnit(Unit* /*Victim*/) override
{
if (!(rand32() % 5))
Talk(SAY_SLAY);
}
void JustDied(Unit* /*killer*/) override
{
_JustDied();
Talk(SAY_DEATH);
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Enraged = false;
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_HATEFUL, 1s);
events.ScheduleEvent(EVENT_BERSERK, 6min);
instance->DoStartCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
{
Enraged = false;
}
bool Enraged;
void Reset() override
{
_Reset();
instance->DoStopCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
}
void KilledUnit(Unit* /*Victim*/) override
{
if (!(rand32() % 5))
Talk(SAY_SLAY);
}
void JustDied(Unit* /*killer*/) override
{
_JustDied();
Talk(SAY_DEATH);
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
Enraged = false;
Talk(SAY_AGGRO);
events.ScheduleEvent(EVENT_HATEFUL, 1s);
events.ScheduleEvent(EVENT_BERSERK, 6min);
instance->DoStartCriteriaTimer(CriteriaStartEvent::SendEvent, ACHIEV_MAKE_QUICK_WERK_OF_HIM_STARTING_EVENT);
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
return;
events.Update(diff);
while (uint32 eventId = events.ExecuteEvent())
switch (eventId)
{
switch (eventId)
case EVENT_HATEFUL:
{
case EVENT_HATEFUL:
// Hateful Strike targets the highest non-MT threat in melee range on 10man
// and the higher HP target out of the two highest non-MT threats in melee range on 25man
ThreatReference* secondThreat = nullptr;
ThreatReference* thirdThreat = nullptr;
ThreatManager& mgr = me->GetThreatManager();
Unit* currentVictim = mgr.GetCurrentVictim();
auto list = mgr.GetModifiableThreatList();
auto it = list.begin(), end = list.end();
if (it == end)
{
// Hateful Strike targets the highest non-MT threat in melee range on 10man
// and the higher HP target out of the two highest non-MT threats in melee range on 25man
ThreatReference* secondThreat = nullptr;
ThreatReference* thirdThreat = nullptr;
ThreatManager& mgr = me->GetThreatManager();
Unit* currentVictim = mgr.GetCurrentVictim();
auto list = mgr.GetModifiableThreatList();
auto it = list.begin(), end = list.end();
if (it == end)
{
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
return;
}
if ((*it)->GetVictim() != currentVictim)
secondThreat = *it;
if ((!secondThreat || Is25ManRaid()) && (++it != end && (*it)->IsAvailable()))
{
if ((*it)->GetVictim() != currentVictim)
(secondThreat ? thirdThreat : secondThreat) = *it;
if (!thirdThreat && Is25ManRaid() && (++it != end && (*it)->IsAvailable()))
thirdThreat = *it;
}
Unit* pHatefulTarget = nullptr;
if (!secondThreat)
pHatefulTarget = currentVictim;
else if (!thirdThreat)
pHatefulTarget = secondThreat->GetVictim();
else
pHatefulTarget = (secondThreat->GetVictim()->GetHealth() < thirdThreat->GetVictim()->GetHealth()) ? thirdThreat->GetVictim() : secondThreat->GetVictim();
// add threat to highest threat targets
AddThreat(currentVictim, HATEFUL_THREAT_AMT);
if (secondThreat)
secondThreat->AddThreat(HATEFUL_THREAT_AMT);
if (thirdThreat)
thirdThreat->AddThreat(HATEFUL_THREAT_AMT);
DoCast(pHatefulTarget, SPELL_HATEFUL_STRIKE, true);
events.Repeat(Seconds(1));
break;
EnterEvadeMode(EVADE_REASON_NO_HOSTILES);
return;
}
case EVENT_BERSERK:
DoCast(me, SPELL_BERSERK, true);
Talk(EMOTE_BERSERK);
events.ScheduleEvent(EVENT_SLIME, 2s);
break;
case EVENT_SLIME:
DoCastAOE(SPELL_SLIME_BOLT, true);
events.Repeat(Seconds(2));
break;
if ((*it)->GetVictim() != currentVictim)
secondThreat = *it;
if ((!secondThreat || Is25ManRaid()) && (++it != end && (*it)->IsAvailable()))
{
if ((*it)->GetVictim() != currentVictim)
(secondThreat ? thirdThreat : secondThreat) = *it;
if (!thirdThreat && Is25ManRaid() && (++it != end && (*it)->IsAvailable()))
thirdThreat = *it;
}
Unit* pHatefulTarget = nullptr;
if (!secondThreat)
pHatefulTarget = currentVictim;
else if (!thirdThreat)
pHatefulTarget = secondThreat->GetVictim();
else
pHatefulTarget = (secondThreat->GetVictim()->GetHealth() < thirdThreat->GetVictim()->GetHealth()) ? thirdThreat->GetVictim() : secondThreat->GetVictim();
// add threat to highest threat targets
AddThreat(currentVictim, HATEFUL_THREAT_AMT);
if (secondThreat)
secondThreat->AddThreat(HATEFUL_THREAT_AMT);
if (thirdThreat)
thirdThreat->AddThreat(HATEFUL_THREAT_AMT);
DoCast(pHatefulTarget, SPELL_HATEFUL_STRIKE, true);
events.Repeat(Seconds(1));
break;
}
case EVENT_BERSERK:
DoCast(me, SPELL_BERSERK, true);
Talk(EMOTE_BERSERK);
events.ScheduleEvent(EVENT_SLIME, 2s);
break;
case EVENT_SLIME:
DoCastAOE(SPELL_SLIME_BOLT, true);
events.Repeat(Seconds(2));
break;
}
if (!Enraged && HealthBelowPct(5))
{
DoCast(me, SPELL_FRENZY, true);
Talk(EMOTE_ENRAGE);
Enraged = true;
}
DoMeleeAttackIfReady();
}
};
if (!Enraged && HealthBelowPct(5))
{
DoCast(me, SPELL_FRENZY, true);
Talk(EMOTE_FRENZY);
Enraged = true;
}
DoMeleeAttackIfReady();
}
};
void AddSC_boss_patchwerk()
{
new boss_patchwerk();
RegisterNaxxramasCreatureAI(boss_patchwerk);
}