diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index fe3493e67..ff6b7f782 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -121,23 +121,30 @@ enum Misc POINT_CHANNEL_STEELBREAKER = 1 }; +static uint8 CountAliveBosses(InstanceScript* instance) +{ + uint8 count = 0; + if (!instance) + return count; + + for (uint8 i = 0; i < 3; ++i) + if (Creature* boss = instance->GetCreature(DATA_STEELBREAKER + i)) + if (boss->IsAlive()) + ++count; + + return count; +} + bool IsEncounterComplete(InstanceScript* pInstance, Creature* me) { if (!pInstance || !me) return false; for (uint8 i = 0; i < 3; ++i) - { - if (Creature* boss = pInstance->GetCreature(DATA_STEELBREAKER + i)) - { - if (boss->IsAlive()) - return false; - continue; - } - else + if (!pInstance->GetCreature(DATA_STEELBREAKER + i)) return false; - } - return true; + + return CountAliveBosses(pInstance) == 0; } void RespawnAssemblyOfIron(InstanceScript* pInstance, Creature* me) @@ -550,6 +557,7 @@ struct boss_stormcaller_brundir : public ScriptedAI void Reset() override { + SetInvincibility(false); me->SetLootMode(0); RespawnAssemblyOfIron(pInstance, me); @@ -667,6 +675,26 @@ struct boss_stormcaller_brundir : public ScriptedAI me->CastSpell(me, SPELL_LIGHTNING_CHANNEL_PRE, true); } + void OnSpellCast(SpellInfo const* spellInfo) override + { + // When Overload begins, prevent Brundir from dying unless he is the last boss alive + if (spellInfo->Id == SPELL_OVERLOAD && CountAliveBosses(pInstance) > 1) + SetInvincibility(true); + } + + void OnChannelFinished(SpellInfo const* spellInfo) override + { + if (spellInfo->Id == SPELL_OVERLOAD) + SetInvincibility(false); + } + + void OnSpellFailed(SpellInfo const* spellInfo) override + { + // Also lift invincibility if the channel is somehow interrupted + if (spellInfo->Id == SPELL_OVERLOAD) + SetInvincibility(false); + } + void UpdateAI(uint32 diff) override { if (!me->IsInCombat() && me->GetReactState() == REACT_AGGRESSIVE)