fix(Scripts/AhnQiraj): Anubisath Defender. (#12725)

* fix(Scripts/AhnQiraj): Anubisath Defender.

Fixes #12449

* Update.

* Update.

* build

Co-authored-by: Angelo Venturini <nefertum.dev@protonmail.com>
This commit is contained in:
UltraNix
2022-08-21 16:01:16 +02:00
committed by GitHub
parent dc4bef94b5
commit 759cb4e93e
3 changed files with 161 additions and 0 deletions

View File

@@ -0,0 +1,156 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "temple_of_ahnqiraj.h"
#include "TaskScheduler.h"
enum Spells
{
SPELL_SHADOW_FROST_REFLECT = 19595,
SPELL_FIRE_ARCANE_REFLECT = 13022,
SPELL_METEOR = 26558,
SPELL_PLAGUE = 26556,
SPELL_SHADOW_STORM = 26555,
SPELL_THUNDERCLAP = 26554,
SPELL_ENRAGE = 14204,
SPELL_EXPLODE = 25699,
SPELL_SUMMON_WARRIOR = 17431,
SPELL_SUMMON_SWARMGUARD = 17430,
SPELL_SUMMON_LARGE_OBSIDIAN_CHUNK = 27630, // Server-side
TALK_ENRAGE = 0
};
struct npc_anubisath_defender : public ScriptedAI
{
npc_anubisath_defender(Creature* creature) : ScriptedAI(creature)
{
}
void Reset() override
{
_scheduler.CancelAll();
_enraged = false;
}
void EnterCombat(Unit* /*who*/) override
{
DoCastSelf(urand(0, 1) ? SPELL_SHADOW_FROST_REFLECT : SPELL_FIRE_ARCANE_REFLECT, true);
if (urand(0, 1))
{
_scheduler.Schedule(6s, 10s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1))
DoCast(target, SPELL_METEOR, true);
context.Repeat(6s, 10s);
});
}
else
{
_scheduler.Schedule(6s, 10s, [this](TaskContext context)
{
if (Unit* target = SelectTarget(SelectTargetMethod::MaxThreat, 1))
DoCast(target, SPELL_PLAGUE, true);
context.Repeat(6s, 10s);
});
}
if (urand(0, 1))
{
_scheduler.Schedule(5s, 8s, [this](TaskContext context)
{
DoCastAOE(SPELL_THUNDERCLAP, true);
context.Repeat(5s, 8s);
});
}
else
{
_scheduler.Schedule(5s, 8s, [this](TaskContext context)
{
DoCastAOE(SPELL_SHADOW_STORM, true);
context.Repeat(5s, 8s);
});
}
if (urand(0, 1))
{
_scheduler.Schedule(3s, 5s, [this](TaskContext context)
{
DoCastSelf(SPELL_SUMMON_WARRIOR, true);
context.Repeat(12s, 16s);
});
}
else
{
_scheduler.Schedule(3s, 5s, [this](TaskContext context)
{
DoCastAOE(SPELL_SUMMON_SWARMGUARD, true);
context.Repeat(12s, 16s);
});
}
}
void JustDied(Unit* /*killer*/) override
{
DoCastSelf(SPELL_SUMMON_LARGE_OBSIDIAN_CHUNK, true);
}
void DamageTaken(Unit* /*doneBy*/, uint32& damage, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) override
{
if (!_enraged && me->HealthBelowPctDamaged(10, damage))
{
_enraged = true;
damage = 0;
if (urand(0, 1))
{
DoCastSelf(SPELL_ENRAGE, true);
Talk(TALK_ENRAGE);
}
else
{
DoCastSelf(SPELL_EXPLODE, true);
}
}
}
void UpdateAI(uint32 diff) override
{
if (!UpdateVictim())
{
return;
}
_scheduler.Update(diff,
std::bind(&ScriptedAI::DoMeleeAttackIfReady, this));
}
private:
TaskScheduler _scheduler;
bool _enraged;
};
void AddSC_temple_of_ahnqiraj()
{
RegisterTempleOfAhnQirajCreatureAI(npc_anubisath_defender);
}

View File

@@ -69,6 +69,7 @@ void AddSC_boss_skeram();
void AddSC_boss_twinemperors();
void AddSC_boss_ouro();
void AddSC_npc_anubisath_sentinel();
void AddSC_temple_of_ahnqiraj();
void AddSC_instance_temple_of_ahnqiraj();
void AddSC_instance_wailing_caverns(); //Wailing caverns
void AddSC_zulfarrak();
@@ -152,6 +153,7 @@ void AddKalimdorScripts()
AddSC_boss_twinemperors();
AddSC_boss_ouro();
AddSC_npc_anubisath_sentinel();
AddSC_temple_of_ahnqiraj();
AddSC_instance_temple_of_ahnqiraj();
AddSC_instance_wailing_caverns(); //Wailing caverns
AddSC_zulfarrak();