Skip to content

Commit

Permalink
fix(Scripts/Karazhan): fixing the Aran drink routine and reset behavi…
Browse files Browse the repository at this point in the history
…or (azerothcore#17849)

* fix(Scripts/Karazhan) Fixed drinking behavior

* fix(Scripts/Karazhan) Cleanup comments

* fix(Scripts/Karazhan) Cleanup whitespace
  • Loading branch information
Amnney authored Dec 10, 2023
1 parent 2f2da61 commit af03611
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions src/server/scripts/EasternKingdoms/Karazhan/boss_shade_of_aran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ struct boss_shade_of_aran : public BossAI
void Reset() override
{
BossAI::Reset();
// Reset the mana of the boss fully before resetting drinking
// If this was omitted, the boss would start drinking on reset if the mana was low on a wipe
me->SetPower(POWER_MANA, me->GetMaxPower(POWER_MANA));
_drinkScheduler.CancelAll();
_lastSuperSpell = 0;

_lastSuperSpell = 0;
_currentNormalSpell = 0;

_drinking = false;
Expand Down Expand Up @@ -203,27 +206,28 @@ struct boss_shade_of_aran : public BossAI
void OnPowerUpdate(Powers /*power*/, int32 /*gain*/, int32 /*updateVal*/, uint32 currentPower) override
{
// Should drink at 10%, need 10% mana for mass polymorph
if (!_hasDrunk && me->GetMaxPower(POWER_MANA) && (currentPower * 100 / me->GetMaxPower(POWER_MANA)) < 13)
if (!_hasDrunk && me->GetMaxPower(POWER_MANA) && (currentPower * 100 / me->GetMaxPower(POWER_MANA)) < 13.5)
{
_drinking = true;
_hasDrunk = true;
me->InterruptNonMeleeSpells(true);
me->RemoveAurasDueToSpell(SPELL_ARCANE_MISSILE);
Talk(SAY_DRINK);
me->SetReactState(REACT_PASSIVE);

// Start drinking after conjuring drinks
_drinkScheduler.Schedule(1s, GROUP_DRINKING, [this](TaskContext)
_drinkScheduler.Schedule(0s, GROUP_DRINKING, [this](TaskContext)
{
me->InterruptNonMeleeSpells(true);
me->RemoveAurasDueToSpell(SPELL_ARCANE_MISSILE);
Talk(SAY_DRINK);
DoCastAOE(SPELL_MASS_POLY);
}).Schedule(2s, GROUP_DRINKING, [this](TaskContext)
// If we set drinking earlier it will break when someone attacks aran while casting poly
_drinking = true;
}).Schedule(3s, GROUP_DRINKING, [this](TaskContext)
{
DoCastSelf(SPELL_CONJURE);
}).Schedule(4s, GROUP_DRINKING, [this](TaskContext)
}).Schedule(6s, GROUP_DRINKING, [this](TaskContext)
{
me->SetStandState(UNIT_STAND_STATE_SIT);
DoCastSelf(SPELL_DRINK);
}).Schedule(10s, GROUP_DRINKING, [this](TaskContext)
}).Schedule(12s, GROUP_DRINKING, [this](TaskContext)
{
me->SetStandState(UNIT_STAND_STATE_STAND);
me->SetReactState(REACT_AGGRESSIVE);
Expand Down Expand Up @@ -303,7 +307,20 @@ struct boss_shade_of_aran : public BossAI
DoCastSelf(SPELL_BLINK_CENTER, true);

std::vector<uint32> superSpells = { SPELL_SUMMON_BLIZZARD, SPELL_AEXPLOSION, SPELL_FLAME_WREATH };
_lastSuperSpell = Acore::Containers::SelectRandomContainerElementIf(superSpells, [&](uint32 superSpell) -> bool { return superSpell != _lastSuperSpell; });

// Workaround for SelectRandomContainerElementIf
std::vector<uint32> allowedSpells;
std::copy_if(superSpells.begin(), superSpells.end(), std::back_inserter(allowedSpells), [&](uint32 superSpell) -> bool { return superSpell != _lastSuperSpell; });
_lastSuperSpell = allowedSpells[urand(0, allowedSpells.size() - 1)];

// SelectRandomContainerElementIf produces unexpected output. Reintroduce when issue is resolved:
// Sample results:
// Selected Super Spell: 3722304989
// superSpells elements : 29969 29973 30004
// _lastSuperSpell = Acore::Containers::SelectRandomContainerElementIf(superSpells, [&](uint32 superSpell) -> bool { return superSpell != _lastSuperSpell; });

me->InterruptNonMeleeSpells(true); // Super spell should have prio over normal spells

switch (_lastSuperSpell)
{
case SPELL_AEXPLOSION:
Expand Down

0 comments on commit af03611

Please sign in to comment.