diff --git a/data/sql/updates/pending_db_world/rev_1660400285204352500.sql b/data/sql/updates/pending_db_world/rev_1660400285204352500.sql new file mode 100644 index 000000000..5e426e77e --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1660400285204352500.sql @@ -0,0 +1,3 @@ +-- +UPDATE `creature_template` SET `ScriptName`='npc_anubisath_defender', `AiName`='' WHERE `entry`=15277; +DELETE FROM `smart_scripts` WHERE `entryorguid`=15277 AND `source_type`=0; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp new file mode 100644 index 000000000..9b319ed4c --- /dev/null +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp @@ -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 . + */ + +#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); +} diff --git a/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp b/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp index e628322e3..f605fa16b 100644 --- a/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp +++ b/src/server/scripts/Kalimdor/kalimdor_script_loader.cpp @@ -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();