From c8cd2c597a1e7a255062a627f794300dd16d7150 Mon Sep 17 00:00:00 2001 From: Skjalf <47818697+Nyeriah@users.noreply.github.com> Date: Tue, 9 Nov 2021 17:40:50 -0300 Subject: [PATCH] fix(Scripts/LBRS): Quartermaster Zigris (#9077) --- .../rev_1636434085380352700.sql | 4 + .../BlackrockSpire/blackrock_spire.h | 2 + .../boss_quartermaster_zigris.cpp | 151 ++++++++++++++++++ .../eastern_kingdoms_script_loader.cpp | 2 + 4 files changed, 159 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1636434085380352700.sql create mode 100644 src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_quartermaster_zigris.cpp diff --git a/data/sql/updates/pending_db_world/rev_1636434085380352700.sql b/data/sql/updates/pending_db_world/rev_1636434085380352700.sql new file mode 100644 index 000000000..378a67e5d --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1636434085380352700.sql @@ -0,0 +1,4 @@ +INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1636434085380352700'); + +UPDATE `creature_template` SET `ScriptName` = 'boss_quartermaster_zigris', `AIName` = '' WHERE `entry` = 9736; +DELETE FROM `smart_scripts` WHERE `source_type` = 0 AND `entryorguid` = 9736; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h index f724d5272..88f36015c 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/blackrock_spire.h @@ -145,4 +145,6 @@ inline AI* GetBlackrockSpireAI(T* obj) return GetInstanceAI(obj, BRSScriptName); } +#define RegisterBlackrockSpireCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetBlackrockSpireAI) + #endif diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_quartermaster_zigris.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_quartermaster_zigris.cpp new file mode 100644 index 000000000..d8f6bdc5d --- /dev/null +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockSpire/boss_quartermaster_zigris.cpp @@ -0,0 +1,151 @@ +/* + * 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 "blackrock_spire.h" +#include "ScriptedCreature.h" +#include "SpellInfo.h" + +enum Spells +{ + SPELL_SHOOT = 16496, + SPELL_STUNBOMB = 16497, + SPELL_HEALING_POTION = 15504, + SPELL_HOOKEDNET = 15609 +}; + +enum Events +{ + EVENT_STUN_BOMB = 1, + EVENT_HOOKED_NET, + EVENT_SHOOT +}; + +struct boss_quartermaster_zigris : public BossAI +{ + boss_quartermaster_zigris(Creature* creature) : BossAI(creature, DATA_QUARTERMASTER_ZIGRIS) + { + _hasDrunkPotion = false; + } + + void Reset() override + { + _Reset(); + SetCombatMovement(false); + _hasDrunkPotion = false; + } + + void EnterCombat(Unit* who) override + { + BossAI::EnterCombat(who); + events.ScheduleEvent(EVENT_STUN_BOMB, 16000); + events.ScheduleEvent(EVENT_HOOKED_NET, 14000); + events.ScheduleEvent(EVENT_SHOOT, 1000); + } + + void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*effType*/, SpellSchoolMask /*schoolMask*/) override + { + if (!_hasDrunkPotion && me->HealthBelowPctDamaged(50, damage)) + { + _hasDrunkPotion = true; + DoCastSelf(SPELL_HEALING_POTION, true); + } + } + + void JustDied(Unit* /*killer*/) override + { + _JustDied(); + } + + void SpellHitTarget(Unit* /*target*/, const SpellInfo* spellInfo) override + { + if (spellInfo->Id == SPELL_STUNBOMB || spellInfo->Id == SPELL_HOOKEDNET) + { + if (me->IsWithinMeleeRange(me->GetVictim())) + { + me->GetMotionMaster()->MoveBackwards(me->GetVictim(), 10.0f); + } + } + } + + void UpdateAI(uint32 diff) override + { + if (!UpdateVictim()) + { + return; + } + + events.Update(diff); + + if (me->HasUnitState(UNIT_STATE_CASTING)) + { + return; + } + + while (uint32 eventId = events.ExecuteEvent()) + { + switch (eventId) + { + case EVENT_STUN_BOMB: + DoCastVictim(SPELL_STUNBOMB); + events.ScheduleEvent(EVENT_STUN_BOMB, 14000); + break; + case EVENT_HOOKED_NET: + if (me->IsWithinMeleeRange(me->GetVictim())) + { + DoCastVictim(SPELL_HOOKEDNET); + events.RepeatEvent(16000); + } + else + { + events.RepeatEvent(3000); + } + break; + case EVENT_SHOOT: + if (!me->IsWithinMeleeRange(me->GetVictim()) && me->IsWithinLOSInMap(me->GetVictim())) + { + DoCastVictim(SPELL_SHOOT); + me->GetMotionMaster()->Clear(); + SetCombatMovement(false); + } + else if (!me->IsWithinLOSInMap(me->GetVictim())) + { + SetCombatMovement(true); + me->GetMotionMaster()->Clear(); + me->GetMotionMaster()->MoveChase(me->GetVictim()); + } + events.RepeatEvent(2000); + break; + } + + if (me->HasUnitState(UNIT_STATE_CASTING)) + { + return; + } + } + + DoMeleeAttackIfReady(); + } + + private: + bool _hasDrunkPotion; +}; + +void AddSC_boss_quartermasterzigris() +{ + RegisterBlackrockSpireCreatureAI(boss_quartermaster_zigris); +} diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp index f0fef63a5..f2616220a 100644 --- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp +++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp @@ -44,6 +44,7 @@ void AddSC_boss_gyth(); void AddSC_boss_rend_blackhand(); void AddSC_boss_urok_doomhowl(); void AddSC_boss_solakar_flamewreath(); +void AddSC_boss_quartermasterzigris(); void AddSC_instance_blackrock_spire(); void AddSC_boss_razorgore(); //Blackwing lair void AddSC_boss_vaelastrasz(); @@ -183,6 +184,7 @@ void AddEasternKingdomsScripts() AddSC_boss_solakar_flamewreath(); AddSC_boss_rend_blackhand(); AddSC_boss_urok_doomhowl(); + AddSC_boss_quartermasterzigris(); AddSC_instance_blackrock_spire(); AddSC_boss_razorgore(); //Blackwing lair AddSC_boss_vaelastrasz();