From b37cd85b8490b97dc919f08ce76530d2f8be0ac5 Mon Sep 17 00:00:00 2001
From: Ovalord <1Don7H4v3@m41L.com>
Date: Mon, 19 Feb 2018 17:34:23 +0100
Subject: [PATCH] Scripts/Deadmines: implement "Captain" Cookie encounter
---
.../4.3.4/custom_2018_02_19_01_world.sql | 168 ++++++++
src/server/game/Spells/SpellMgr.cpp | 10 +
.../Deadmines/boss_captain_cookie.cpp | 359 ++++++++++++++++++
.../EasternKingdoms/Deadmines/deadmines.h | 18 +-
.../Deadmines/instance_deadmines.cpp | 76 +++-
.../eastern_kingdoms_script_loader.cpp | 2 +
6 files changed, 631 insertions(+), 2 deletions(-)
create mode 100644 sql/updates/world/4.3.4/custom_2018_02_19_01_world.sql
create mode 100644 src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp
diff --git a/sql/updates/world/4.3.4/custom_2018_02_19_01_world.sql b/sql/updates/world/4.3.4/custom_2018_02_19_01_world.sql
new file mode 100644
index 00000000000..17f69d042a3
--- /dev/null
+++ b/sql/updates/world/4.3.4/custom_2018_02_19_01_world.sql
@@ -0,0 +1,168 @@
+-- Template Updates
+-- "Captain" Cookie
+UPDATE `creature_template` SET `unit_flags`= 33587264, `ScriptName`= 'boss_captain_cookie', `flags_extra`= 0 WHERE `entry`= 47739;
+UPDATE `creature_template` SET `unit_flags`= 33587264, `minlevel`= 87, `maxlevel`= 87, `flags_extra`= 1 WHERE `entry`= 48944;
+-- Cookie's Cauldron
+UPDATE `creature_template` SET `unit_flags`= 2304, `VehicleId`= 1283 WHERE `entry`= 47754;
+-- Food
+UPDATE `creature_template` SET `unit_flags`= 768, `unit_flags2`= 67110912, `npcflag`= 16777216, `flags_extra`= 2 WHERE `entry` IN (48006, 48276, 48294, 48293, 48295, 48296, 48297, 48298, 48300, 48299, 48301, 48302);
+
+-- Texts
+DELETE FROM `creature_text` WHERE `CreatureID`= 45979 AND `GroupID`= 3;
+INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `Comment`) VALUES
+(45979, 3, 0, 'A shadowy figure appears in the ship''s cabin!', 41, 0, 100, 0, 0, 0, 48276, 'General Purpose Bunny JMF to Player');
+
+-- Conditions
+DELETE FROM `conditions` WHERE `SourceEntry`= 89250 AND `SourceTypeOrReferenceId`= 13;
+INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ScriptName`, `Comment`) VALUES
+(13, 1, 89250, 0, 0, 31, 0, 3, 45979, 375838, 0, 0, '', 'Charge - Target General Purpose Bunny');
+
+-- Creature Cookie's Cauldron 47754 SAI
+SET @ENTRY := 47754;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 60, 0, 100, 1, 0, 0, 0, 0, 11, 89251, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "Every 0 and 0 ms (for the first time, timer between 0 and 0 ms) - Self: Cast spell 89251 on Self // ");
+
+-- Spells
+DELETE FROM `spell_script_names` WHERE `ScriptName` IN
+('spell_cookie_throw_food_targeting',
+'spell_cookie_satiated');
+
+INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
+(89268, 'spell_cookie_throw_food_targeting'),
+(89740, 'spell_cookie_throw_food_targeting'),
+(90561, 'spell_cookie_throw_food_targeting'),
+(90582, 'spell_cookie_throw_food_targeting'),
+(90562, 'spell_cookie_throw_food_targeting'),
+(90583, 'spell_cookie_throw_food_targeting'),
+(90563, 'spell_cookie_throw_food_targeting'),
+(90584, 'spell_cookie_throw_food_targeting'),
+(90564, 'spell_cookie_throw_food_targeting'),
+(90585, 'spell_cookie_throw_food_targeting'),
+(90565, 'spell_cookie_throw_food_targeting'),
+(90586, 'spell_cookie_throw_food_targeting'),
+(89267, 'spell_cookie_satiated'),
+(92834, 'spell_cookie_satiated');
+
+-- Template Addons
+DELETE FROM `creature_template_addon` WHERE `entry` IN (48006, 48276, 48294, 48293, 48295, 48296, 48297, 48298, 48300, 48299, 48301, 48302);
+INSERT INTO `creature_template_addon` (`entry`, `auras`) VALUES
+-- Delicious Food
+(48006 ,'89730'),
+(48294 ,'89730'),
+(48296 ,'89730'),
+(48297 ,'89730'),
+(48300 ,'89730'),
+(48301 ,'89730'),
+-- Rooten Food
+(48276, '95513'),
+(48293, '95513'),
+(48295, '95513'),
+(48298, '95513'),
+(48299, '95513'),
+(48302, '95513');
+
+-- Spellclick spells
+DELETE FROM `npc_spellclick_spells` WHERE `npc_entry` IN (48006, 48276, 48294, 48293, 48295, 48296, 48297, 48298, 48300, 48299, 48301, 48302);
+INSERT INTO `npc_spellclick_spells` (`npc_entry`, `spell_id`, `cast_flags`, `user_type`) VALUES
+-- Delicious Food
+(48006, 89267, 3, 0),
+(48294, 89267, 3, 0),
+(48296, 89267, 3, 0),
+(48297, 89267, 3, 0),
+(48300, 89267, 3, 0),
+(48301, 89267, 3, 0),
+-- Rotten Food
+(48276, 89732, 3, 0),
+(48293, 89732, 3, 0),
+(48295, 89732, 3, 0),
+(48298, 89732, 3, 0),
+(48299, 89732, 3, 0),
+(48302, 89732, 3, 0);
+
+-- SAI
+SET @ENTRY := 48302;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48299;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48298;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48295;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48293;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48276;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48301;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48300;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48297;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48296;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48294;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
+
+SET @ENTRY := 48006;
+UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`= @ENTRY;
+DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0;
+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`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
+(@ENTRY, 0, 0, 0, 37, 0, 100, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On AI initialize - Self: Set react state to REACT_PASSIVE // "),
+(@ENTRY, 0, 1, 0, 73, 0, 100, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "On spellclick - Self: Despawn instantly // ");
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index bd1203b96d4..6ffe53aeddb 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -4177,6 +4177,16 @@ void SpellMgr::LoadSpellInfoCorrections()
spellInfo->Effects[EFFECT_0].RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_100_YARDS);
});
+ // "Captain" Coikie
+ // Rotten Aura
+ ApplySpellFix({
+ 89735,
+ 92065,
+ }, [](SpellInfo* spellInfo)
+ {
+ spellInfo->AttributesCu |= SPELL_ATTR0_CU_NO_INITIAL_THREAT;
+ });
+
// END OF DEADMINES SPELLS
//
diff --git a/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp b/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp
new file mode 100644
index 00000000000..7f4a7106b66
--- /dev/null
+++ b/src/server/scripts/EasternKingdoms/Deadmines/boss_captain_cookie.cpp
@@ -0,0 +1,359 @@
+/*
+* Copyright (C) 2008-2017 TrinityCore
+*
+* This program is free software; you can redistribute it and/or modify it
+* under the terms of the GNU General Public License as published by the
+* Free Software Foundation; either version 2 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 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 "ObjectMgr.h"
+#include "ScriptMgr.h"
+#include "ScriptedCreature.h"
+#include "SpellScript.h"
+#include "SpellAuraEffects.h"
+#include "Player.h"
+#include "deadmines.h"
+
+enum Texts
+{
+
+};
+
+enum Spells
+{
+ // "Captain" Cookie
+ SPELL_WHOS_THAT = 89339,
+ SPELL_COOKIES_HAT = 88873,
+ SPELL_COOKIES_CAULDRON = 89250,
+ SPELL_CAULDRON_FIRE = 89252,
+ SPELL_COOKIE_ACHIEVEMENT_AURA = 95650,
+ SPELL_THROW_FOOD_TARGETING_CORN = 89268,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_CORN = 89740,
+ SPELL_THROW_FOOD_TARGETING_MELON = 90561,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_MELON = 90582,
+ SPELL_THROW_FOOD_TARGETING_STEAK = 90562,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_STEAK = 90583,
+ SPELL_THROW_FOOD_TARGETING_MYSTERY_MEAT = 90563,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_MYSTERY_MEAT = 90584,
+ SPELL_THROW_FOOD_TARGETING_LOAF = 90564,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_LOAF = 90585,
+ SPELL_THROW_FOOD_TARGETING_BUN = 90565,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_BUN = 90586,
+
+ // Player
+ SPELL_NAUSEATED = 89732,
+ SPELL_NAUSEATED_HC = 92066
+
+};
+
+enum Events
+{
+ EVENT_MOVE_TO_SUMMON_POS = 1,
+ EVENT_SUMMON_CAULDRON,
+ EVENT_JUMP_INTO_CAULDRON,
+ EVENT_CAULDRON_FIRE,
+ EVENT_THROW_FOOD,
+};
+
+enum Points
+{
+ POINT_CAULDRON_SUMMON = 1
+};
+
+enum FoodTypes
+{
+ FOOD_CORN = 0,
+ FOOD_MELON,
+ FOOD_STEAK,
+ FOOD_MYSTERY_MEAT,
+ FOOD_LOAF,
+ FOOD_BUN,
+};
+
+enum FoodStates
+{
+ FOOD_STATE_DELICIOUS = 0,
+ FOOD_STATE_ROTTEN,
+};
+
+uint32 cornSpells[] =
+{
+ SPELL_THROW_FOOD_TARGETING_CORN,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_CORN
+};
+
+uint32 melonSpells[] =
+{
+ SPELL_THROW_FOOD_TARGETING_MELON,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_MELON
+};
+
+uint32 steakSpells[] =
+{
+ SPELL_THROW_FOOD_TARGETING_STEAK,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_STEAK
+};
+
+uint32 mysteryMeatSpells[] =
+{
+ SPELL_THROW_FOOD_TARGETING_MYSTERY_MEAT,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_MYSTERY_MEAT
+};
+
+uint32 loafSpells[] =
+{
+ SPELL_THROW_FOOD_TARGETING_MYSTERY_MEAT,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_MYSTERY_MEAT
+};
+
+uint32 bunSpells[] =
+{
+ SPELL_THROW_FOOD_TARGETING_BUN,
+ SPELL_THROW_FOOD_TARGETING_ROTTEN_BUN
+};
+
+Position const cookieIntroPos = { -66.23547f, -820.1689f, 40.98766f };
+
+class boss_captain_cookie : public CreatureScript
+{
+ public:
+ boss_captain_cookie() : CreatureScript("boss_captain_cookie") { }
+
+ struct boss_captain_cookieAI : public BossAI
+ {
+ boss_captain_cookieAI(Creature* creature) : BossAI(creature, DATA_CAPTAIN_COOKIE)
+ {
+ Initialize();
+ }
+
+ void Initialize()
+ {
+ _foodState = FOOD_STATE_DELICIOUS;
+ _foodType = RAND(FOOD_CORN, FOOD_BUN);
+ }
+
+ void Reset() override
+ {
+ _Reset();
+ Initialize();
+ DoCastSelf(SPELL_WHOS_THAT, true);
+ DoCastSelf(SPELL_COOKIES_HAT, true);
+ }
+
+ void JustEngagedWith(Unit* /*who*/) override
+ {
+ _JustEngagedWith();
+ instance->SendEncounterUnit(ENCOUNTER_FRAME_ENGAGE, me);
+ me->RemoveAurasDueToSpell(SPELL_WHOS_THAT);
+ me->AttackStop();
+ me->SetReactState(REACT_PASSIVE);
+ me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
+ events.ScheduleEvent(EVENT_MOVE_TO_SUMMON_POS, Milliseconds(1));
+ }
+
+ void JustDied(Unit* /*killer*/) override
+ {
+ _JustDied();
+ instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
+ }
+
+ void EnterEvadeMode(EvadeReason /*why*/) override
+ {
+ _EnterEvadeMode();
+ summons.DespawnAll();
+ instance->SetBossState(DATA_CAPTAIN_COOKIE, FAIL);
+ instance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me);
+ _DespawnAtEvade();
+ }
+
+ void MovementInform(uint32 type, uint32 point) override
+ {
+ if (type != POINT_MOTION_TYPE && type != EFFECT_MOTION_TYPE)
+ return;
+
+ switch (point)
+ {
+ case POINT_CAULDRON_SUMMON:
+ DoCastAOE(SPELL_COOKIES_CAULDRON);
+ events.ScheduleEvent(EVENT_JUMP_INTO_CAULDRON, Seconds(1) + Milliseconds(500));
+ break;
+ default:
+ break;
+ }
+ }
+
+ 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_MOVE_TO_SUMMON_POS:
+ me->GetMotionMaster()->MovePoint(POINT_CAULDRON_SUMMON, cookieIntroPos, false);
+ break;
+ case EVENT_JUMP_INTO_CAULDRON:
+ if (Creature* cauldron = me->FindNearestCreature(NPC_COOKIES_CAULDRON, 15.0f, true))
+ {
+ me->CastSpell(cauldron, VEHICLE_SPELL_RIDE_HARDCODED);
+ events.ScheduleEvent(EVENT_CAULDRON_FIRE, Seconds(2) + Milliseconds(400));
+ }
+ break;
+ case EVENT_CAULDRON_FIRE:
+ DoCastSelf(SPELL_CAULDRON_FIRE, true);
+ DoCastAOE(SPELL_COOKIE_ACHIEVEMENT_AURA, true);
+ events.ScheduleEvent(EVENT_THROW_FOOD, Milliseconds(1));
+ break;
+ case EVENT_THROW_FOOD:
+ {
+ switch (_foodType)
+ {
+ case FOOD_CORN:
+ DoCastAOE(cornSpells[_foodState], true);
+ break;
+ case FOOD_MELON:
+ DoCastAOE(melonSpells[_foodState], true);
+ break;
+ case FOOD_STEAK:
+ DoCastAOE(steakSpells[_foodState], true);
+ break;
+ case FOOD_MYSTERY_MEAT:
+ DoCastAOE(mysteryMeatSpells[_foodState], true);
+ break;
+ case FOOD_LOAF:
+ DoCastAOE(loafSpells[_foodState], true);
+ break;
+ case FOOD_BUN:
+ DoCastAOE(bunSpells[_foodState], true);
+ break;
+ default:
+ break;
+ }
+
+ // Select food when rotten and delicious versions has been thrown
+ if (_foodState == FOOD_STATE_ROTTEN)
+ {
+ // Select next random food and make sure that we will
+ // never get the same food twice
+ uint8 oldFoodType = _foodType;
+ _foodType = RAND(FOOD_CORN, FOOD_BUN);
+ if (_foodType == oldFoodType)
+ _foodType++;
+ if (_foodType > FOOD_BUN)
+ _foodType = FOOD_CORN;
+ }
+
+ _foodState = _foodState == FOOD_STATE_DELICIOUS ? FOOD_STATE_ROTTEN : FOOD_STATE_DELICIOUS;
+ events.Repeat(Seconds(1) + Milliseconds(200), Seconds(2));
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+ private:
+ uint8 _foodState;
+ uint8 _foodType;
+ };
+
+ CreatureAI* GetAI(Creature *creature) const override
+ {
+ return GetDeadminesAI(creature);
+ }
+};
+
+class spell_cookie_throw_food_targeting : public SpellScriptLoader
+{
+ public:
+ spell_cookie_throw_food_targeting() : SpellScriptLoader("spell_cookie_throw_food_targeting") { }
+
+ class spell_cookie_throw_food_targeting_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_cookie_throw_food_targeting_SpellScript);
+
+ void FilterTargets(std::list& targets)
+ {
+ if (targets.empty())
+ return;
+
+ Trinity::Containers::RandomResize(targets, 1);
+ }
+
+ void HandleHit(SpellEffIndex effIndex)
+ {
+ GetCaster()->CastSpell(GetHitUnit(), GetSpellInfo()->Effects[effIndex].BasePoints);
+ }
+
+ void Register() override
+ {
+ OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_cookie_throw_food_targeting_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
+ OnEffectHitTarget += SpellEffectFn(spell_cookie_throw_food_targeting_SpellScript::HandleHit, EFFECT_0, SPELL_EFFECT_DUMMY);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_cookie_throw_food_targeting_SpellScript();
+ }
+};
+
+class spell_cookie_satiated : public SpellScriptLoader
+{
+ public:
+ spell_cookie_satiated() : SpellScriptLoader("spell_cookie_satiated") { }
+
+ class spell_cookie_satiated_SpellScript : public SpellScript
+ {
+ PrepareSpellScript(spell_cookie_satiated_SpellScript);
+
+ bool Validate(SpellInfo const* /*spellInfo*/) override
+ {
+ return ValidateSpellInfo(
+ {
+ SPELL_NAUSEATED,
+ SPELL_NAUSEATED_HC
+ });
+ }
+
+ void HandleHit(SpellEffIndex effIndex)
+ {
+ if (Unit* caster = GetCaster())
+ if (Aura* nauseatedAura = caster->GetAura(GetSpellInfo()->Effects[effIndex].BasePoints))
+ nauseatedAura->ModStackAmount(-1, AURA_REMOVE_BY_DEFAULT, false);
+ }
+
+ void Register() override
+ {
+ OnEffectHitTarget += SpellEffectFn(spell_cookie_satiated_SpellScript::HandleHit, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
+ }
+ };
+
+ SpellScript* GetSpellScript() const override
+ {
+ return new spell_cookie_satiated_SpellScript();
+ }
+};
+
+void AddSC_boss_captain_cookie()
+{
+ new boss_captain_cookie();
+ new spell_cookie_throw_food_targeting();
+ new spell_cookie_satiated();
+}
diff --git a/src/server/scripts/EasternKingdoms/Deadmines/deadmines.h b/src/server/scripts/EasternKingdoms/Deadmines/deadmines.h
index c48e95baa66..bae820e4eff 100644
--- a/src/server/scripts/EasternKingdoms/Deadmines/deadmines.h
+++ b/src/server/scripts/EasternKingdoms/Deadmines/deadmines.h
@@ -51,6 +51,7 @@ enum DMCreatures
BOSS_HELIX_GEARBREAKER = 47296,
BOSS_FOE_REAPER_5000 = 43778,
BOSS_ADMIRAL_RIPSNARL = 47626,
+ BOSS_CAPTAIN_COOKIE = 47739,
// Horde Creatures
NPC_SLINKY_SHARPSHIV = 46906,
@@ -86,7 +87,20 @@ enum DMCreatures
NPC_FOE_REAPER_TARGETING_BUNNY = 47468,
NPC_PROTOTYPE_REAPER = 49208,
NPC_MOLTEN_SLAG = 49229,
- NPC_VAPOR = 47714
+ NPC_VAPOR = 47714,
+ NPC_COOKIES_CAULDRON = 47754,
+ NPC_CORN = 48006,
+ NPC_ROTTEN_CORN = 48276,
+ NPC_MELON = 48294,
+ NPC_ROTTEN_MELON = 48293,
+ NPC_STEAK = 48296,
+ NPC_ROTTEN_STEAK = 48295,
+ NPC_MYSTERY_MEAT = 48297,
+ NPC_ROTTEN_MYSTERY_MEAT = 48298,
+ NPC_LOAF = 48300,
+ NPC_ROTTEN_LOAF = 48299,
+ NPC_BUN = 48301,
+ NPC_ROTTEN_BUN = 48302,
};
enum DMGameObjects
@@ -105,6 +119,8 @@ enum DMSpells
SPELL_FOG = 88768
};
+Position const captainCookieSpawnPos = { -88.13194f, -819.3299f, 39.23453f };
+
template
AI* GetDeadminesAI(Creature* creature)
{
diff --git a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp
index 86a8a5b268c..103fa9726eb 100644
--- a/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp
+++ b/src/server/scripts/EasternKingdoms/Deadmines/instance_deadmines.cpp
@@ -22,12 +22,25 @@
#include "TemporarySummon.h"
#include "WorldPacket.h"
+enum EventIds
+{
+ EVENT_SUMMON_CAPTAIN_COOKIE = 1
+};
+
+enum TextsIds
+{
+ // Id's 0 - 1 used by Foe Reaper 5000
+ // Id 2 used by Defias Cannon
+ SAY_ANNOUNCE_SHADOWY_FIGURE = 3
+};
+
ObjectData const creatureData[] =
{
{ BOSS_GLUBTOK, DATA_GLUBTOK },
{ BOSS_HELIX_GEARBREAKER, DATA_HELIX_GEARBREAKER },
{ BOSS_FOE_REAPER_5000, DATA_FOE_REAPER_5000 },
{ BOSS_ADMIRAL_RIPSNARL, DATA_ADMIRAL_RIPSNARL },
+ { BOSS_CAPTAIN_COOKIE, DATA_CAPTAIN_COOKIE },
{ NPC_LUMBERING_OAF, DATA_LUMBERING_OAF },
{ NPC_FOE_REAPER_TARGETING_BUNNY, DATA_FOE_REAPER_BUNNY },
{ NPC_PROTOTYPE_REAPER, DATA_PROTOTYPE_REAPER },
@@ -65,6 +78,7 @@ class instance_deadmines : public InstanceMapScript
_teamInInstance = 0;
_foeReaper5000Intro = 0;
_IronCladDoorState = 0;
+ _firstCookieSpawn = true;
}
void OnPlayerEnter(Player* player) override
@@ -134,6 +148,21 @@ class instance_deadmines : public InstanceMapScript
if (Creature* ripsnarl = GetCreature(DATA_ADMIRAL_RIPSNARL))
ripsnarl->AI()->JustSummoned(creature);
break;
+ case NPC_CORN:
+ case NPC_ROTTEN_CORN:
+ case NPC_MELON:
+ case NPC_ROTTEN_MELON:
+ case NPC_STEAK:
+ case NPC_ROTTEN_STEAK:
+ case NPC_MYSTERY_MEAT:
+ case NPC_ROTTEN_MYSTERY_MEAT:
+ case NPC_LOAF:
+ case NPC_ROTTEN_LOAF:
+ case NPC_BUN:
+ case NPC_ROTTEN_BUN:
+ if (Creature* cookie = GetCreature(DATA_CAPTAIN_COOKIE))
+ cookie->AI()->JustSummoned(creature);
+ break;
default:
break;
}
@@ -154,6 +183,27 @@ class instance_deadmines : public InstanceMapScript
}
}
+ bool SetBossState(uint32 type, EncounterState state) override
+ {
+ if (!InstanceScript::SetBossState(type, state))
+ return false;
+
+ switch (type)
+ {
+ case DATA_ADMIRAL_RIPSNARL:
+ if (state == DONE)
+ events.ScheduleEvent(EVENT_SUMMON_CAPTAIN_COOKIE, Seconds(10));
+ break;
+ case DATA_CAPTAIN_COOKIE:
+ if (state == FAIL)
+ events.ScheduleEvent(EVENT_SUMMON_CAPTAIN_COOKIE, Seconds(30));
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+
void SetData(uint32 type, uint32 data) override
{
switch (type)
@@ -221,14 +271,38 @@ class instance_deadmines : public InstanceMapScript
}
+ void Update(uint32 diff) override
+ {
+ events.Update(diff);
+
+ while (uint32 eventId = events.ExecuteEvent())
+ {
+ switch (eventId)
+ {
+ case EVENT_SUMMON_CAPTAIN_COOKIE:
+ if (Creature* cookie = instance->SummonCreature(BOSS_CAPTAIN_COOKIE, captainCookieSpawnPos))
+ if (_firstCookieSpawn)
+ {
+ if (Creature* bunny = cookie->FindNearestCreature(NPC_GENERAL_PURPOSE_DUMMY_JMF, 30.0f, true))
+ bunny->AI()->Talk(SAY_ANNOUNCE_SHADOWY_FIGURE);
+ _firstCookieSpawn = false;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
protected:
+ EventMap events;
uint32 _teamInInstance;
uint32 _foeReaper5000Intro;
uint32 _IronCladDoorState;
GuidSet _generalPurposeBunnyJMF2GuidSet;
+ bool _firstCookieSpawn;
};
-
InstanceScript* GetInstanceScript(InstanceMap* map) const override
{
return new instance_deadmines_InstanceMapScript(map);
diff --git a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
index 3d3f12d2490..5c83bfb76aa 100644
--- a/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
+++ b/src/server/scripts/EasternKingdoms/eastern_kingdoms_script_loader.cpp
@@ -73,6 +73,7 @@ void AddSC_boss_glubtok();
void AddSC_boss_helix_gearbreaker();
void AddSC_boss_foe_reaper_5000();
void AddSC_boss_admiral_ripsnarl();
+void AddSC_boss_captain_cookie();
void AddSC_gilneas_c1(); //Gilneas
void AddSC_gnomeregan(); //Gnomeregan
void AddSC_instance_gnomeregan();
@@ -278,6 +279,7 @@ void AddEasternKingdomsScripts()
AddSC_boss_helix_gearbreaker();
AddSC_boss_foe_reaper_5000();
AddSC_boss_admiral_ripsnarl();
+ AddSC_boss_captain_cookie();
AddSC_gilneas_c1(); //Gilneas
AddSC_gnomeregan(); //Gnomeregan
AddSC_instance_gnomeregan();