diff --git a/data/sql/updates/db_world/2023_06_16_00.sql b/data/sql/updates/db_world/2023_06_16_00.sql new file mode 100644 index 000000000..e97d6be2c --- /dev/null +++ b/data/sql/updates/db_world/2023_06_16_00.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_11_02 -> 2023_06_16_00 +-- +UPDATE `creature_template` SET `flags_extra` = `flags_extra`|128 WHERE `entry`=17552; + diff --git a/data/sql/updates/db_world/2023_06_16_01.sql b/data/sql/updates/db_world/2023_06_16_01.sql new file mode 100644 index 000000000..196c2ac91 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_16_01.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_16_00 -> 2023_06_16_01 +-- +UPDATE `creature_template` SET `flags_extra` = `flags_extra`|128 WHERE `entry`=20654; + diff --git a/data/sql/updates/db_world/2023_06_16_02.sql b/data/sql/updates/db_world/2023_06_16_02.sql new file mode 100644 index 000000000..29de8424b --- /dev/null +++ b/data/sql/updates/db_world/2023_06_16_02.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_16_01 -> 2023_06_16_02 +-- +UPDATE `creature_template` SET `mechanic_immune_mask` = `mechanic_immune_mask`|1|2|8|16|64|128|1024|2048|4096|8192|65536|8388608|536870912 WHERE `entry`=20993; + diff --git a/data/sql/updates/db_world/2023_06_17_00.sql b/data/sql/updates/db_world/2023_06_17_00.sql new file mode 100644 index 000000000..66371a2cc --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_00.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_16_02 -> 2023_06_17_00 +-- +DELETE FROM `game_event_gameobject` WHERE `eventEntry` = 1 AND `guid` = 28242; +INSERT INTO `game_event_gameobject` (`eventEntry`,`guid`) VALUES (1, 28242); diff --git a/data/sql/updates/db_world/2023_06_17_01.sql b/data/sql/updates/db_world/2023_06_17_01.sql new file mode 100644 index 000000000..04c927a76 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_01.sql @@ -0,0 +1,5 @@ +-- DB update 2023_06_17_00 -> 2023_06_17_01 +-- +DELETE FROM `creature_loot_template` WHERE `Entry` = 20521 AND `Item` IN (27424, 27428, 27430); -- removing 3 normal items from HC Skarlock +DELETE FROM `creature_loot_template` WHERE `Entry` = 20531 AND `Item` IN (27433, 27434, 27440); -- removing 3 normal items from HC Epoch Hunter +DELETE FROM `creature_loot_template` WHERE `Entry` = 20535 AND `Item` IN (27417, 27423); -- removing 2 normal items from HC Captain Drake diff --git a/data/sql/updates/db_world/2023_06_17_02.sql b/data/sql/updates/db_world/2023_06_17_02.sql new file mode 100644 index 000000000..27cc35e2d --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_02.sql @@ -0,0 +1,7 @@ +-- DB update 2023_06_17_01 -> 2023_06_17_02 +-- +UPDATE `gameobject` SET `spawnMask` = `spawnMask`&~2 WHERE `guid`=9890 AND `id` = 184465; + +DELETE FROM `gameobject` WHERE `guid` = 9891 AND `id` = 184849; +INSERT INTO `gameobject` (`guid`, `id`, `map`, `zoneId`, `areaId`, `spawnMask`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`, `VerifiedBuild`) VALUES +(9891, 184849, 554, 3849, 3849, 2, 222.543, 70.6106, -0.00479339, 4.67748, -0.719339, 0.694659, 7200, 255, 1, 46924); diff --git a/data/sql/updates/db_world/2023_06_17_03.sql b/data/sql/updates/db_world/2023_06_17_03.sql new file mode 100644 index 000000000..bb7557025 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_03.sql @@ -0,0 +1,5 @@ +-- DB update 2023_06_17_02 -> 2023_06_17_03 +-- +DELETE FROM `smart_scripts` WHERE (`entryorguid` = 16704) AND `source_type` = 0 AND `id` =5; +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(16704, 0, 5, 0, 0, 0, 100, 0, 13350, 21000, 20700, 39250, 0, 11, 23601, 64, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 'Shattered Hand Sharpshooter - In Combat - Cast \'Scatter Shot\''); diff --git a/data/sql/updates/db_world/2023_06_17_04.sql b/data/sql/updates/db_world/2023_06_17_04.sql new file mode 100644 index 000000000..fd84bf804 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_04.sql @@ -0,0 +1,9 @@ +-- DB update 2023_06_17_03 -> 2023_06_17_04 +-- +DELETE FROM `spell_proc_event` WHERE `entry` IN (27997, 33511, 33522, 33510, 24256); +INSERT INTO `spell_proc_event` (`entry`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `procFlags`, `procEx`, `procPhase`, `ppmRate`, `CustomChance`, `Cooldown`) VALUES +(27997,0,0,0,0,0,0,0,0,0,0,50000), +(33511,0,0,0,0,0,0,0,0,0,0,17000), +(33522,0,0,0,0,0,0,0,0,0,0,25000), +(33510,0,0,0,0,0,0,0,0,0,0,25000), +(24256,0,0,0,0,0,0,0,0,0,0,240000); diff --git a/data/sql/updates/db_world/2023_06_17_05.sql b/data/sql/updates/db_world/2023_06_17_05.sql new file mode 100644 index 000000000..4d38dbc2f --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_05.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_17_04 -> 2023_06_17_05 +-- Fix Disable LOS from the Spell 26522 (Lunar Fortune) -- +DELETE FROM `disables` WHERE `sourceType`=0 AND `entry`=26522; +INSERT INTO `disables` (`sourceType`, `entry`, `flags`, `params_0`, `params_1`, `comment`) VALUES (0, 26522, 64, '', '', 'Disable LOS for Lunar Fortune'); diff --git a/data/sql/updates/db_world/2023_06_17_06.sql b/data/sql/updates/db_world/2023_06_17_06.sql new file mode 100644 index 000000000..bb927d3c1 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_06.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_17_05 -> 2023_06_17_06 +-- +UPDATE `quest_template` SET `AllowableRaces` = 1101 WHERE `ID` IN (9494, 9492); +UPDATE `quest_template` SET `AllowableRaces` = 690 WHERE `ID` = 9495; diff --git a/data/sql/updates/db_world/2023_06_17_07.sql b/data/sql/updates/db_world/2023_06_17_07.sql new file mode 100644 index 000000000..3b8601fdd --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_07.sql @@ -0,0 +1,6 @@ +-- DB update 2023_06_17_06 -> 2023_06_17_07 +-- +DELETE FROM `smart_scripts` WHERE `entryorguid`=173 AND `source_type`=2; +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(173, 2, 0, 1, 46, 0, 100, 0, 0, 0, 0, 0, 0, 12, 2056, 3, 300000, 0, 0, 0, 8, 0, 0, 0, 0, 1077, 1539, 28.89, 0, 'Areatrigger - On Trigger - Summon Creature \'Ravenclaw Apparition\' (The Dead Fields)'), +(173, 2, 1, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 15, 437, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 'Areatrigger - Linked - Quest Credit \'The Dead Fields\''); diff --git a/data/sql/updates/db_world/2023_06_17_08.sql b/data/sql/updates/db_world/2023_06_17_08.sql new file mode 100644 index 000000000..13e1e46ed --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_08.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_17_07 -> 2023_06_17_08 +-- +UPDATE `creature_template` SET `mechanic_immune_mask` = `mechanic_immune_mask`|1|2|8|16|64|1024|2048|4096|8192|65536|8388608|536870912 WHERE `entry`=22930; + diff --git a/data/sql/updates/db_world/2023_06_17_09.sql b/data/sql/updates/db_world/2023_06_17_09.sql new file mode 100644 index 000000000..3d5fb622e --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_09.sql @@ -0,0 +1,18 @@ +-- DB update 2023_06_17_08 -> 2023_06_17_09 +-- +-- Antu'Sul (Zul'Farrak) +DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = 8127); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(8127, 0, 0, 0, 0, 0, 75, 0, 5000, 5000, 17000, 17000, 0, 11, 8376, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - In Combat - Cast Earthgrab Totem'), +(8127, 0, 1, 0, 0, 0, 75, 0, 13000, 13000, 17000, 17000, 0, 11, 11899, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - In Combat - Cast Healing Ward'), +(8127, 0, 2, 3, 4, 0, 100, 0, 0, 0, 0, 0, 0, 11, 11894, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - On Aggro - Cast Antu\'sul\'s Minion'), +(8127, 0, 3, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - On Aggro - Say Line 1'), +(8127, 0, 4, 0, 0, 0, 100, 0, 5000, 5000, 12000, 14000, 0, 11, 16006, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - In Combat - Cast Chain Lightning'), +(8127, 0, 5, 0, 0, 0, 100, 0, 3000, 3000, 9000, 11000, 0, 11, 15501, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - In Combat - Cast Earth Shock'), +(8127, 0, 6, 0, 38, 0, 100, 0, 1, 1, 0, 0, 0, 49, 0, 0, 0, 0, 0, 0, 21, 100, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - On Data Set 1 1 - Start Attacking'), +(8127, 0, 7, 8, 2, 0, 100, 1, 0, 75, 0, 0, 0, 11, 11894, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - Between 0-75% Health - Cast Antu\'sul\'s Minion'), +(8127, 0, 8, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - Between 0-75% Health - Say Line 2'), +(8127, 0, 9, 10, 2, 0, 100, 1, 0, 25, 0, 0, 0, 11, 11894, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - Between 0-25% Health - Cast Antu\'sul\'s Minion'), +(8127, 0, 10, 0, 61, 0, 100, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - Between 0-25% Health - Say Line 0'), +(8127, 0, 11, 0, 2, 0, 100, 1, 0, 20, 0, 0, 0, 11, 11895, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Antu\'sul - Between 0-20% Health - Cast Healing Wave of Antu\'sul'), +(8127, 0, 12, 0, 25, 0, 100, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 9, 8156, 0, 500, 1, 0, 0, 0, 0, 'Antu\'sul - On Reset - Despawn Summons'); diff --git a/data/sql/updates/db_world/2023_06_17_10.sql b/data/sql/updates/db_world/2023_06_17_10.sql new file mode 100644 index 000000000..614958499 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_10.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_17_09 -> 2023_06_17_10 +-- +UPDATE `quest_template` SET `RequiredNpcOrGoCount1`=10 WHERE `ID`=182; + diff --git a/data/sql/updates/db_world/2023_06_17_11.sql b/data/sql/updates/db_world/2023_06_17_11.sql new file mode 100644 index 000000000..891cd97d1 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_11.sql @@ -0,0 +1,3 @@ +-- DB update 2023_06_17_10 -> 2023_06_17_11 +-- +UPDATE `creature_template` SET `minlevel` = 71, `maxlevel` = 71 WHERE (`entry` = 20525); diff --git a/data/sql/updates/db_world/2023_06_17_12.sql b/data/sql/updates/db_world/2023_06_17_12.sql new file mode 100644 index 000000000..e41f8604e --- /dev/null +++ b/data/sql/updates/db_world/2023_06_17_12.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_17_11 -> 2023_06_17_12 +-- +UPDATE `creature_template` SET `unit_flags` = `unit_flags`|33554432 WHERE `entry`=22380; + diff --git a/data/sql/updates/db_world/2023_06_18_00.sql b/data/sql/updates/db_world/2023_06_18_00.sql new file mode 100644 index 000000000..3ce2979b9 --- /dev/null +++ b/data/sql/updates/db_world/2023_06_18_00.sql @@ -0,0 +1,4 @@ +-- DB update 2023_06_17_12 -> 2023_06_18_00 +-- +UPDATE `creature_template` SET `mechanic_immune_mask` = `mechanic_immune_mask`|33554432 WHERE `entry` IN (18732,20653); + diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 7146fea21..5149e6a49 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -718,6 +718,27 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...) SendPacket(&data); } +void WorldSession::SendAreaTriggerMessage(uint32 entry, ...) +{ + char const* format = GetAcoreString(entry); + if (format) + { + va_list ap; + char szStr[1024]; + szStr[0] = '\0'; + + va_start(ap, entry); + vsnprintf(szStr, 1024, format, ap); + va_end(ap); + + uint32 length = strlen(szStr) + 1; + WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 4 + length); + data << length; + data << szStr; + SendPacket(&data); + } +} + void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) { uint32 triggerId; diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 94d328dfe..68ef554d4 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -679,6 +679,8 @@ QuestItemList* Loot::FillQuestLoot(Player* player) { LootItem& item = quest_items[i]; + sScriptMgr->OnBeforeFillQuestLootItem(player, item); + // Quest item is not free for all and is already assigned to another player // or player doesn't need it if (item.is_blocked || !item.AllowedForPlayer(player, sourceWorldObjectGUID)) diff --git a/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp b/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp index 76f1b069e..308a83e4b 100644 --- a/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp +++ b/src/server/game/Scripting/ScriptDefines/PlayerScript.cpp @@ -590,6 +590,14 @@ void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid }); } +void ScriptMgr::OnBeforeFillQuestLootItem(Player* player, LootItem& item) +{ + ExecuteScript([&](PlayerScript* script) + { + script->OnBeforeFillQuestLootItem(player, item); + }); +} + void ScriptMgr::OnStoreNewItem(Player* player, Item* item, uint32 count) { ExecuteScript([&](PlayerScript* script) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index ad64a88f2..4c0be23e4 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -1183,6 +1183,9 @@ public: //After looting item virtual void OnLootItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, ObjectGuid /*lootguid*/) { } + //Before looting item + virtual void OnBeforeFillQuestLootItem(Player* /*player*/, LootItem& /*item*/) { } + //After looting item (includes master loot). virtual void OnStoreNewItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/) { } @@ -2331,6 +2334,7 @@ public: /* PlayerScript */ void GetCustomArenaPersonalRating(Player const* player, uint8 slot, uint32& rating) const; void OnGetMaxPersonalArenaRatingRequirement(Player const* player, uint32 minSlot, uint32& maxArenaRating) const; void OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid); + void OnBeforeFillQuestLootItem(Player* player, LootItem& item); void OnStoreNewItem(Player* player, Item* item, uint32 count); void OnCreateItem(Player* player, Item* item, uint32 count); void OnQuestRewardItem(Player* player, Item* item, uint32 count); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index feccb23a7..556d1f71f 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -369,6 +369,7 @@ public: void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName* declinedName); void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0); void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3); + void SendAreaTriggerMessage(uint32 entry, ...); void SendSetPhaseShift(uint32 phaseShift); void SendQueryTimeResponse(); diff --git a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp index b7ec0db34..077dbd977 100644 --- a/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/MagtheridonsLair/boss_magtheridon.cpp @@ -55,27 +55,9 @@ enum Spells SPELL_DEBRIS_DAMAGE = 30631 }; -enum Events +enum Groups { - EVENT_EMOTE1 = 1, - EVENT_EMOTE2 = 2, - EVENT_EMOTE3 = 3, - EVENT_ENTER_COMBAT = 4, - EVENT_RECENTLY_SPOKEN = 5, - - EVENT_CLEAVE = 10, - EVENT_BLAST_NOVA = 11, - EVENT_BLAZE = 12, - EVENT_ENRAGE = 13, - EVENT_QUAKE = 14, - EVENT_CHECK_HEALTH = 15, - EVENT_COLLAPSE_CEIL = 16, - EVENT_COLLAPSE_DAMAGE = 17, - EVENT_DEBRIS = 18, - - EVENT_RANDOM_TAUNT = 30, - EVENT_CHECK_GRASP = 31, - EVENT_CANCEL_GRASP_CHECK = 32 + GROUP_INTERRUPT_CHECK = 0 }; class DealDebrisDamage : public BasicEvent @@ -102,28 +84,69 @@ public: struct boss_magtheridonAI : public BossAI { - boss_magtheridonAI(Creature* creature) : BossAI(creature, TYPE_MAGTHERIDON) { } - - EventMap events2; + boss_magtheridonAI(Creature* creature) : BossAI(creature, TYPE_MAGTHERIDON) + { + scheduler.SetValidator([this] + { + return !me->HasUnitState(UNIT_STATE_CASTING); + }); + } void Reset() override { - events2.Reset(); - events2.ScheduleEvent(EVENT_RANDOM_TAUNT, 90000); _Reset(); + _currentPhase = 0; + _recentlySpoken = false; + scheduler.Schedule(90s, [this](TaskContext context) + { + Talk(SAY_TAUNT); + context.Repeat(90s); + }); me->CastSpell(me, SPELL_SHADOW_CAGE, true); me->SetReactState(REACT_PASSIVE); me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE); me->SetImmuneToPC(true); + + ScheduleHealthCheckEvent(30, [&] { + _currentPhase = 1; + Talk(SAY_PHASE3); + me->GetMotionMaster()->Clear(); + scheduler.DelayAll(18s); + scheduler.Schedule(8s, [this](TaskContext /*context*/) + { + DoCastSelf(SPELL_CAMERA_SHAKE, true); + instance->SetData(DATA_COLLAPSE, GO_STATE_ACTIVE); + }).Schedule(15s, [this](TaskContext /*context*/) + { + DoCastSelf(SPELL_COLLAPSE_DAMAGE, true); + me->resetAttackTimer(); + me->GetMotionMaster()->MoveChase(me->GetVictim()); + _currentPhase = 0; + scheduler.Schedule(20s, [this](TaskContext context) + { + if (Unit* target = SelectTarget(SelectTargetMethod::Random)) + { + target->CastSpell(target, SPELL_DEBRIS_VISUAL, true, nullptr, nullptr, me->GetGUID()); + me->m_Events.AddEvent(new DealDebrisDamage(*me, target->GetGUID()), me->m_Events.CalculateTime(5000)); + } + context.Repeat(20s); + }); + }); + }); } - void KilledUnit(Unit* /*victim*/) override + void KilledUnit(Unit* /*victim*/) override { - if (events.GetNextEventTime(EVENT_RECENTLY_SPOKEN) == 0) + if(!_recentlySpoken) { - events.ScheduleEvent(EVENT_RECENTLY_SPOKEN, 5000); Talk(SAY_SLAY); + _recentlySpoken = true; } + + scheduler.Schedule(5s, [this](TaskContext /*context*/) + { + _recentlySpoken = false; + }); } void JustDied(Unit* /*killer*/) override @@ -132,135 +155,84 @@ public: Talk(SAY_DEATH); } - void MoveInLineOfSight(Unit* /*who*/) override { } - void JustEngagedWith(Unit* /*who*/) override { - events2.Reset(); _JustEngagedWith(); - events.ScheduleEvent(EVENT_EMOTE1, 0); - events.ScheduleEvent(EVENT_EMOTE2, 60000); - events.ScheduleEvent(EVENT_EMOTE3, 120000); - events.ScheduleEvent(EVENT_ENTER_COMBAT, 123000); + Talk(SAY_EMOTE_BEGIN); + + scheduler.Schedule(60s, [this](TaskContext /*context*/) + { + Talk(SAY_EMOTE_NEARLY); + }).Schedule(120s, [this](TaskContext /*context*/) + { + Talk(SAY_EMOTE_FREE); + }).Schedule(123s, [this](TaskContext /*context*/) + { + me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); + me->SetImmuneToPC(false); + me->SetReactState(REACT_AGGRESSIVE); + instance->SetData(DATA_ACTIVATE_CUBES, 1); + me->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE); + + scheduler.Schedule(9s, [this](TaskContext context) + { + DoCastVictim(SPELL_CLEAVE); + context.Repeat(10s); + }).Schedule(10s, [this](TaskContext context) + { + me->CastCustomSpell(SPELL_BLAZE, SPELLVALUE_MAX_TARGETS, 1); + context.Repeat(30s); + }).Schedule(40s, [this](TaskContext context) + { + me->CastSpell(me, SPELL_QUAKE); //needs fixes with custom spell + scheduler.Schedule(7s, [this](TaskContext /*context*/) + { + DoCastSelf(SPELL_BLAST_NOVA); + + scheduler.Schedule(50ms, GROUP_INTERRUPT_CHECK, [this](TaskContext context) + { + if (me->GetAuraCount(SPELL_SHADOW_GRASP_VISUAL) == 5) + { + Talk(SAY_BANISH); + me->InterruptNonMeleeSpells(true); + scheduler.CancelGroup(GROUP_INTERRUPT_CHECK); + } + context.Repeat(50ms); + }).Schedule(12s, GROUP_INTERRUPT_CHECK, [this](TaskContext /*context*/) + { + scheduler.CancelGroup(GROUP_INTERRUPT_CHECK); + }); + }); + context.Repeat(50s); + }).Schedule(1320s, [this](TaskContext /*context*/) + { + DoCastSelf(SPELL_BERSERK, true); + }); + }); } void UpdateAI(uint32 diff) override { - events2.Update(diff); - switch (events2.ExecuteEvent()) - { - case EVENT_RANDOM_TAUNT: - Talk(SAY_TAUNT); - events2.ScheduleEvent(EVENT_RANDOM_TAUNT, 90000); - break; - case EVENT_CHECK_GRASP: - if (me->GetAuraCount(SPELL_SHADOW_GRASP_VISUAL) == 5) - { - Talk(SAY_BANISH); - me->InterruptNonMeleeSpells(true); - break; - } - events2.ScheduleEvent(EVENT_CHECK_GRASP, 0); - break; - } - if (!UpdateVictim()) return; - events.Update(diff); - if (me->HasUnitState(UNIT_STATE_CASTING)) - return; + scheduler.Update(diff); - switch (events.ExecuteEvent()) + if (_currentPhase != 1) { - case EVENT_EMOTE1: - Talk(SAY_EMOTE_BEGIN); - break; - case EVENT_EMOTE2: - Talk(SAY_EMOTE_NEARLY); - break; - case EVENT_EMOTE3: - Talk(SAY_EMOTE_FREE); - Talk(SAY_FREE); - break; - case EVENT_ENTER_COMBAT: - me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE); - me->SetImmuneToPC(false); - me->SetReactState(REACT_AGGRESSIVE); - events.ScheduleEvent(EVENT_CLEAVE, 9000); - events.ScheduleEvent(EVENT_BLAZE, 10000); - events.ScheduleEvent(EVENT_QUAKE, 40000); - events.ScheduleEvent(EVENT_CHECK_HEALTH, 500); - events.ScheduleEvent(EVENT_ENRAGE, 22 * MINUTE * IN_MILLISECONDS); - - instance->SetData(DATA_ACTIVATE_CUBES, 1); - me->RemoveAurasDueToSpell(SPELL_SHADOW_CAGE); - break; - case EVENT_CLEAVE: - me->CastSpell(me->GetVictim(), SPELL_CLEAVE, false); - events.ScheduleEvent(EVENT_CLEAVE, 10000); - break; - case EVENT_BLAST_NOVA: - me->CastSpell(me, SPELL_BLAST_NOVA, false); - events.ScheduleEvent(EVENT_CANCEL_GRASP_CHECK, 12000); - events2.ScheduleEvent(EVENT_CHECK_GRASP, 0); - break; - case EVENT_BLAZE: - me->CastCustomSpell(SPELL_BLAZE, SPELLVALUE_MAX_TARGETS, 1); - events.ScheduleEvent(EVENT_BLAZE, 30000); - break; - case EVENT_ENRAGE: - me->CastSpell(me, SPELL_BERSERK, true); - break; - case EVENT_CANCEL_GRASP_CHECK: - events2.Reset(); - break; - case EVENT_QUAKE: - me->CastSpell(me, SPELL_QUAKE, false); - events.ScheduleEvent(EVENT_BLAST_NOVA, 7000); - events.ScheduleEvent(EVENT_QUAKE, 50000); - break; - case EVENT_CHECK_HEALTH: - if (me->HealthBelowPct(30)) - { - Talk(SAY_PHASE3); - events.SetPhase(1); - events.DelayEvents(18000); - events.ScheduleEvent(EVENT_COLLAPSE_CEIL, 8000); - events.ScheduleEvent(EVENT_COLLAPSE_DAMAGE, 15000); - break; - } - events.ScheduleEvent(EVENT_CHECK_HEALTH, 500); - break; - case EVENT_COLLAPSE_CEIL: - me->CastSpell(me, SPELL_CAMERA_SHAKE, true); - instance->SetData(DATA_COLLAPSE, GO_STATE_ACTIVE); - break; - case EVENT_COLLAPSE_DAMAGE: - me->CastSpell(me, SPELL_COLLAPSE_DAMAGE, true); - me->resetAttackTimer(); - events.SetPhase(0); - events.ScheduleEvent(EVENT_DEBRIS, 20000); - break; - case EVENT_DEBRIS: - if (Unit* target = SelectTarget(SelectTargetMethod::Random)) - { - target->CastSpell(target, SPELL_DEBRIS_VISUAL, true, nullptr, nullptr, me->GetGUID()); - me->m_Events.AddEvent(new DealDebrisDamage(*me, target->GetGUID()), me->m_Events.CalculateTime(5000)); - } - events.ScheduleEvent(EVENT_DEBRIS, 20000); - break; - } - - if (!events.IsInPhase(1)) DoMeleeAttackIfReady(); + } } + private: + bool _recentlySpoken; + uint8 _currentPhase; }; CreatureAI* GetAI(Creature* creature) const override { return GetMagtheridonsLairAI(creature); } + }; class spell_magtheridon_blaze : public SpellScriptLoader