diff --git a/sql/migrations/20171120021353_world.sql b/sql/migrations/20171120021353_world.sql new file mode 100644 index 000000000..0a25b357e --- /dev/null +++ b/sql/migrations/20171120021353_world.sql @@ -0,0 +1,88 @@ +DROP PROCEDURE IF EXISTS add_migration; +delimiter ?? +CREATE PROCEDURE `add_migration`() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20171120021353'); +IF v=0 THEN +INSERT INTO `migrations` VALUES ('20171120021353'); +-- Add your query below. + +-- fix Maraudon scepter activate object +DELETE FROM `spell_script_target` WHERE `entry`=21127; +INSERT INTO `spell_script_target` (`entry`, `type`, `targetEntry`) VALUES (21127,0,178386); + +-- remove party flag from 7046: The Scepter of Celebras +UPDATE `quest_template` SET `QuestFlags`=0 WHERE `entry`=7046; + +-- add missing npc text +DELETE FROM `npc_text` WHERE `ID`=6374; +INSERT INTO `npc_text` (`ID`, `BroadcastTextID0`, `Probability0`) VALUES (6374, 8927, 1); + +-- Add gossip and spawn for 13716: Celebras the Redeemed +UPDATE `creature_template` SET `gossip_menu_id`=5349, `npcflag`=3 WHERE `entry`=13716; +DELETE FROM `creature` WHERE `guid`=55105; +INSERT INTO `creature` (`guid`,`id`,`map`,`modelid`,`equipment_id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`currentwaypoint`,`curhealth`,`curmana`,`DeathState`,`MovementType`,`spawnFlags`) VALUES +(55105,13716,349,0,0,726.106,77.9764,-86.5913,6.0,60,0,0,6602,0,0,0,1); + +-- set instance script for Maraudon +UPDATE `map_template` SET `ScriptName`='instance_maraudon' WHERE `entry`=349; + +-- Gossip for Celebras the Redeemed +DELETE FROM `gossip_menu` WHERE `entry` BETWEEN 5349 AND 5358; +DELETE FROM `gossip_menu_option` WHERE `menu_id` BETWEEN 5349 AND 5358; +DELETE FROM `conditions` WHERE `condition_entry` BETWEEN 53490 AND 53509; +DELETE FROM `gossip_scripts` WHERE id=53500; + +-- Default +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5349, 6354, 0); + +-- 7046 is available +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53490, 19, 7046, 0); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5349, 6375, 53490); + +-- 7046 is completed or rewarded +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53491, 9, 7046, 2); +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53492, 8, 7046, 0); +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53493, -2, 53491, 53492); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5349, 6373, 53493); + +-- Lost scepter +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53500, 24, 17191, 1); +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53501, -1, 53492, 53500); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `action_script_id`, `condition_id`) VALUES (5349, 0, 0, 'Celebras, I lost my Scepter...', 1, 1, 5350, 53500, 53501); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5350, 6374, 0); +INSERT INTO `gossip_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `comments`) VALUES (53500, 3, 15, 21939, 0, 'Celebras the Redeemed: Create Scepter of Celebras'); + +-- 7044 is incomplete +INSERT INTO `conditions` (`condition_entry`, `type`, `value1`, `value2`) VALUES (53502, 9, 7044, 1); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `condition_id`) VALUES (5349, 1, 0, 'How can I find the two parts of your scepter?', 1, 1, 5351, 53502); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5351, 6384, 0); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`) VALUES (5351, 0, 0, 'Why didn\'t Lord Vyletongue unite both parts of the scepter into one?', 1, 1, 5358); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5358, 6385, 0); + +-- 7046 is rewarded +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `condition_id`) VALUES (5349, 2, 0, 'Please explain how the scepter works.', 1, 1, 5352, 53492); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5352, 6377, 0); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`) VALUES (5352, 0, 0, 'I don\'t quite understand...', 1, 1, 5353); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5353, 6378, 0); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`) VALUES (5353, 0, 0, 'No, really, I still don\'t understand...', 1, 1, 5354); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5354, 6379, 0); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`, `condition_id`) VALUES (5349, 3, 0, 'Please tell me more about Maraudon.', 1, 1, 5355, 53492); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5355, 6380, 0); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`) VALUES (5355, 3, 0, 'Please tell me more about Zaetar.', 1, 1, 5356); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5356, 6381, 0); +INSERT INTO `gossip_menu_option` (`menu_id`, `id`, `option_icon`, `option_text`, `option_id`, `npc_option_npcflag`, `action_menu_id`) VALUES (5356, 3, 0, 'Tell me more about the history of Remulos and Zaetar.', 1, 1, 5357); +INSERT INTO `gossip_menu` (`entry`, `text_id`, `condition_id`) VALUES (5357, 6393, 0); + +-- Move waypoint wait times from script to DB for celebras_spirit script +UPDATE `script_waypoint` SET `waittime`=8000 WHERE `entry`=13716 AND `pointid`=1; +UPDATE `script_waypoint` SET `waittime`=4000 WHERE `entry`=13716 AND `pointid`=5; +UPDATE `script_waypoint` SET `waittime`=3000 WHERE `entry`=13716 AND `pointid`=9; + +-- End of migration. +END IF; +END?? +delimiter ; +CALL add_migration(); +DROP PROCEDURE IF EXISTS add_migration; diff --git a/src/scripts/ScriptLoader.cpp b/src/scripts/ScriptLoader.cpp index a225d799f..e45856846 100644 --- a/src/scripts/ScriptLoader.cpp +++ b/src/scripts/ScriptLoader.cpp @@ -219,6 +219,7 @@ void AddSC_boss_landslide(); void AddSC_boss_noxxion(); void AddSC_boss_ptheradras(); void AddSC_maraudon(); +void AddSC_instance_maraudon(); void AddSC_boss_onyxia(); //onyxias_lair void AddSC_boss_amnennar_the_coldbringer(); //razorfen_downs void AddSC_razorfen_downs(); @@ -492,6 +493,7 @@ void AddScripts() AddSC_boss_noxxion(); AddSC_boss_ptheradras(); AddSC_maraudon(); + AddSC_instance_maraudon(); AddSC_boss_onyxia(); //onyxias_lair AddSC_boss_amnennar_the_coldbringer(); //razorfen_downs AddSC_razorfen_downs(); diff --git a/src/scripts/kalimdor/desolace/maraudon/boss_celebras_the_cursed.cpp b/src/scripts/kalimdor/desolace/maraudon/boss_celebras_the_cursed.cpp index a8b624440..9c82ee1e8 100644 --- a/src/scripts/kalimdor/desolace/maraudon/boss_celebras_the_cursed.cpp +++ b/src/scripts/kalimdor/desolace/maraudon/boss_celebras_the_cursed.cpp @@ -22,20 +22,42 @@ SDCategory: Maraudon EndScriptData */ #include "scriptPCH.h" +#include "maraudon.h" #define SPELL_WRATH 21807 #define SPELL_ENTANGLINGROOTS 12747 #define SPELL_CORRUPT_FORCES 21968 -#define GO_CELEBRAS_BLUE_AURA 178964 +enum +{ + GO_CREATOR = 178560, + GO_CELEBRAS_BLUE_AURA = 178964, + GO_TOME = 178965, + + SAY_WP_1 = 8953, + SAY_WP_3 = 8954, + SAY_WP_5 = 8949, + SAY_WP_6 = 8955, + SAY_ACCEPT = 8952, + SAY_PRE_READ = 8950, + SAY_POST_READ = 8948, + + SPELL_CHANNEL = 21916, + EMOTE_CHANNEL = 8951, + + QUEST_SCEPTER = 7046 +}; struct celebras_the_cursedAI : public ScriptedAI { celebras_the_cursedAI(Creature* pCreature) : ScriptedAI(pCreature) { + m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); Reset(); } + ScriptedInstance* m_pInstance; + uint32 Wrath_Timer; uint32 EntanglingRoots_Timer; uint32 CorruptForces_Timer; @@ -49,7 +71,8 @@ struct celebras_the_cursedAI : public ScriptedAI void JustDied(Unit* Killer) { - m_creature->SummonCreature(13716, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ() + 1, 0, TEMPSUMMON_TIMED_DESPAWN, 600000); + if (m_pInstance) + m_pInstance->SetData(TYPE_CELEBRAS, DONE); } void UpdateAI(const uint32 diff) @@ -100,35 +123,23 @@ struct celebrasSpiritAI : public npc_escortAI { m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); Event_Timer = 0; - Point = 0; - underEvent = false; SetEscortPaused(true); - isFirstWaypoint = false; - isWaitingTomeRead = false; - isLinked = false; auraGUID = 0; - isQuestCompleted = false; Reset(); } ScriptedInstance* m_pInstance; + uint8 m_uiPhase; uint32 Event_Timer; - uint32 Point; - uint64 playerGUID; uint64 auraGUID; - bool underEvent; - bool isFirstWaypoint; - bool isWaitingTomeRead; - bool isLinked; - bool isQuestCompleted; + bool m_bBookRead; void Reset() { - } - - void Aggro(Unit* pWho) - { - SetEscortPaused(true); + m_uiPhase = 0; + Event_Timer = 0; + auraGUID = 0; + m_bBookRead = false; } void WaypointReached(uint32 i) @@ -136,19 +147,20 @@ struct celebrasSpiritAI : public npc_escortAI std::list scepterList; switch (i) { - case 1: + case 0: m_creature->SetOrientation(5.342044f); - m_creature->MonsterSay("For so long I have drifted in my cursed from. You have freed me... Your hard work shall be repaid.", 0, 0); + m_creature->SetHomePosition(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetOrientation()); + break; + + case 1: + DoScriptText(SAY_WP_1, m_creature); SetRun(false); - Event_Timer = 8000; - SetEscortPaused(true); - Point = i; break; case 3: - m_creature->MonsterSay("Please do as I instruct you.", 0, 0); + if (Player* pPlayer = GetPlayerForEscort()) + DoScriptText(SAY_WP_3, m_creature, pPlayer); Event_Timer = 4000; - Point = i; break; case 4: @@ -163,139 +175,112 @@ struct celebrasSpiritAI : public npc_escortAI pGo->SetRespawnTime(6*MINUTE); pGo->Refresh(); } - m_creature->MonsterSay("Shal myrinan ishnu daldorah...", 0, 0); - if (GameObject* obj = m_creature->SummonGameObject(178964, 652.463013f, 74.085098f, -85.335297f, 3.054616f, 0, 0, 0, 0, -1, false)) + DoScriptText(SAY_WP_5, m_creature); + if (GameObject* obj = m_creature->SummonGameObject(GO_CELEBRAS_BLUE_AURA, 652.463013f, 74.085098f, -85.335297f, 3.054616f, 0, 0, 0, 0, -1, false)) auraGUID = obj->GetGUID(); - Event_Timer = 4000; - SetEscortPaused(true); - Point = i; break; case 6: - m_creature->MonsterSay("My scepter will once again become whole!", 0, 0); + DoScriptText(SAY_WP_6, m_creature); - GetGameObjectListWithEntryInGrid(scepterList, m_creature, 178560, 40.0f); + GetGameObjectListWithEntryInGrid(scepterList, m_creature, GO_CREATOR, 40.0f); for (std::list::iterator it = scepterList.begin(); it != scepterList.end(); ++it) (*it)->UseDoorOrButton(0, false); scepterList.clear(); - Point = i; break; case 9: - SetEscortPaused(true); if (GameObject* pAura = m_creature->GetMap()->GetGameObject(auraGUID)) pAura->Delete(); - Event_Timer = 3000; - Point = i; break; case 13: - SetEscortPaused(true); + Stop(); Event_Timer = 3000; - Point = i; - break; - default: break; } } - void QuestCompleted(Player* pPlayer, Quest const* pQuest) + void QuestAccepted(Player* pPlayer, Quest const* pQuest) { - if (!underEvent) - { - isQuestCompleted = false; - playerGUID = pPlayer->GetGUID(); - m_creature->MonsterSay("You wish to learn of the stone? Follow me.", 0, 0); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - Event_Timer = 5000; - SetRun(); - underEvent = true; - isFirstWaypoint = true; - } + Reset(); + DoScriptText(SAY_ACCEPT, m_creature); + Start(true, pPlayer->GetGUID(), pQuest); + } + + void JustStartedEscort() override + { + SetEscortPaused(true); + Event_Timer = 5000; + m_uiPhase = 1; } void BookRead() { - SetEscortPaused(false); + m_bBookRead = true; + if (Event_Timer > 1000) + Event_Timer = 1000; } void UpdateEscortAI(const uint32 uiDiff) { - if (Event_Timer <= uiDiff) + if (Event_Timer && !m_creature->getVictim()) { - if (isFirstWaypoint) + if (Event_Timer <= uiDiff) { - Start(true, NULL, NULL, false); - isFirstWaypoint = false; - } + Event_Timer = 0; - switch (Point) - { - case 1: - SetEscortPaused(false); - SetRun(false); - break; - case 3: - if (!isWaitingTomeRead) - { - m_creature->SetOrientation(3.009412f); - isWaitingTomeRead = true; - m_creature->MonsterSay("Read this tome I have placed before you, and speak the words aloud.", 0, 0); - //CastSpell Renew druid - m_creature->SummonGameObject(178965, 652.175f, 74.069f, -85.334327f, 5.6635f, 0, 0, 0, 0, -1, false); - isLinked = true; - Event_Timer = 4000; + switch (m_uiPhase) + { + case 1: + SetEscortPaused(false); + break; + case 2: + DoScriptText(SAY_PRE_READ, m_creature); + Event_Timer = 1000; + break; + case 3: + m_creature->SummonGameObject(GO_TOME, 652.175f, 74.069f, -85.334327f, 5.6635f, 0, 0, 0, 0, -1, false); + Event_Timer = 1000; + break; + case 4: + // m_creature->CastSpell(m_creature, SPELL_CHANNEL, true); + DoScriptText(EMOTE_CHANNEL, m_creature, 0, CHAT_TYPE_TEXT_EMOTE); SetEscortPaused(true); - m_creature->SetOrientation(3.009412f); - } - else if (isLinked) - { - m_creature->MonsterSay("Together, the two parts shall become one, one again.", 0, 0); - isLinked = false; - } - break; - case 5: - SetEscortPaused(false); - break; - case 9: - SetEscortPaused(false); - break; - case 13: - if (!isQuestCompleted) - { - isQuestCompleted = true; - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - - if (Player* player = m_creature->GetMap()->GetPlayer(playerGUID)) + Event_Timer = m_bBookRead ? 1000 : 30000; + break; + case 5: + if (!m_bBookRead) { - if (player->GetQuestStatus(7046) == QUEST_STATUS_INCOMPLETE) - player->AreaExploredOrEventHappens(7046); - - - if (m_creature->isQuestGiver()) - { - player->PrepareQuestMenu(m_creature->GetGUID()); - player->SEND_GOSSIP_MENU(player->GetGossipTextId(m_creature), m_creature->GetGUID()); - } + // timed out waiting for book to be read + ResetEscort(); + return; } - Event_Timer = 0; - Point = 0; - underEvent = false; - SetEscortPaused(true); - isFirstWaypoint = false; - isWaitingTomeRead = false; - isLinked = false; - auraGUID = 0; - playerGUID = 0; - Stop(); - } - break; - default: - break; + DoScriptText(SAY_POST_READ, m_creature); + Event_Timer = 1000; + break; + case 6: + SetEscortPaused(false); + break; + case 7: + m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP); + + if (Player* player = GetPlayerForEscort()) + { + if (player->GetQuestStatus(QUEST_SCEPTER) == QUEST_STATUS_INCOMPLETE) + { + player->AreaExploredOrEventHappens(QUEST_SCEPTER); + player->PrepareGossipMenu(m_creature, m_creature->GetCreatureInfo()->GossipMenuId); + player->SendPreparedGossip(m_creature); + } + } + break; + } + m_uiPhase++; } + else + Event_Timer -= uiDiff; } - else - Event_Timer -= uiDiff; if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; @@ -304,27 +289,15 @@ struct celebrasSpiritAI : public npc_escortAI } }; -bool GossipHello_spirit_celebras(Player* pPlayer, Creature* pCreature) -{ - ScriptedInstance* m_pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); - - if (pCreature->isQuestGiver()) - { - pPlayer->PrepareQuestMenu(pCreature->GetGUID()); - pPlayer->SEND_GOSSIP_MENU(pPlayer->GetGossipTextId(pCreature), pCreature->GetGUID()); - } - return true; -} - bool GOHello_go_book_celebras(Player* pPlayer, GameObject* pGo) { - if (pPlayer->GetQuestStatus(7046) == QUEST_STATUS_INCOMPLETE) + if (pPlayer->GetQuestStatus(QUEST_SCEPTER) == QUEST_STATUS_INCOMPLETE) { pPlayer->Say("Shal myrinan ishnu daldorah...", 0); pGo->Delete(); std::list celebrasList; - GetCreatureListWithEntryInGrid(celebrasList, pPlayer, 13716, 40.0f); + GetCreatureListWithEntryInGrid(celebrasList, pPlayer, NPC_CELEBRAS_REDEEMED, 40.0f); for (std::list::iterator it = celebrasList.begin(); it != celebrasList.end(); ++it) { if (celebrasSpiritAI* pcelebrasSpirit = dynamic_cast((*it)->AI())) @@ -337,10 +310,10 @@ bool GOHello_go_book_celebras(Player* pPlayer, GameObject* pGo) bool QuestAccept_celebras_spirit(Player* pPlayer, Creature* pQuestGiver, Quest const* pQuest) { - if (pQuest->GetQuestId() != 7046) + if (pQuest->GetQuestId() != QUEST_SCEPTER) return false; if (celebrasSpiritAI* pcelebrasSpirit = dynamic_cast(pQuestGiver->AI())) - pcelebrasSpirit->QuestCompleted(pPlayer, pQuest); + pcelebrasSpirit->QuestAccepted(pPlayer, pQuest); return true; } @@ -361,7 +334,6 @@ void AddSC_boss_celebras_the_cursed() newscript = new Script; newscript->Name = "celebras_spirit"; newscript->GetAI = &GetAI_celebras_spirit; - newscript->pGossipHello = &GossipHello_spirit_celebras; newscript->pQuestAcceptNPC = &QuestAccept_celebras_spirit; newscript->RegisterSelf(); diff --git a/src/scripts/kalimdor/desolace/maraudon/instance_maraudon.cpp b/src/scripts/kalimdor/desolace/maraudon/instance_maraudon.cpp index b52b78593..02f0eddc4 100644 --- a/src/scripts/kalimdor/desolace/maraudon/instance_maraudon.cpp +++ b/src/scripts/kalimdor/desolace/maraudon/instance_maraudon.cpp @@ -5,284 +5,108 @@ #include "scriptPCH.h" #include "maraudon.h" -#define QUEST_CELEBRAS_CEPTER 7046 -#define CREATURE_CELEBRAS 13716 -#define GO_PEDESTAL 178560 -#define GO_BLUE_AURA 178964 -#define GO_BOOK 178965 - -#define SPELL_FRENEZIED_REGEN 22896 -#define SPELL_HEARTSTONE 8690 -#define SPELL_END_EVENT 21914 - -instance_maraudon::instance_maraudon(Map *pMap) : ScriptedInstance(pMap), cGuid(static_cast(0)), pGuid(static_cast(0)), bGuid(static_cast(0)), aGuid(static_cast(0)) +struct instance_maraudon : public ScriptedInstance { -} + instance_maraudon(Map *pMap) : ScriptedInstance(pMap) + { + cGuid = 0; + } -void instance_maraudon::OnCreatureCreate(Creature *pCreature) -{ - if (pCreature->GetEntry() == CREATURE_CELEBRAS) - cGuid = pCreature->GetObjectGuid(); -} + uint32 m_auiEncounter[MARAUDON_MAX_ENCOUNTER]; + std::string strInstData; -void instance_maraudon::OnGameObjectCreate(GameObject *pGo) -{ - if (pGo->GetEntry() == GO_PEDESTAL) - pGuid = pGo->GetObjectGuid(); - if (pGo->GetEntry() == GO_BOOK) - bGuid = pGo->GetObjectGuid(); - if (pGo->GetEntry() == GO_BLUE_AURA) - aGuid = pGo->GetObjectGuid(); -} + uint64 cGuid; + + void Initialize() + { + memset(&m_auiEncounter, 0, sizeof(m_auiEncounter)); + + cGuid = 0; + } + + void OnCreatureCreate(Creature *pCreature) + { + if (pCreature->GetEntry() == NPC_CELEBRAS_REDEEMED) + { + cGuid = pCreature->GetObjectGuid(); + + if (m_auiEncounter[0] != DONE) + pCreature->SetVisibility(VISIBILITY_OFF); + } + } + + const char* Save() + { + return strInstData.c_str(); + } + + void Load(const char* chrIn) + { + if (!chrIn) + return; + std::istringstream loadStream(chrIn); + for (uint8 i = 0; i < MARAUDON_MAX_ENCOUNTER; ++i) + { + loadStream >> m_auiEncounter[i]; + if (m_auiEncounter[i] == IN_PROGRESS) + m_auiEncounter[i] = NOT_STARTED; + } + } + + uint32 GetData(uint32 uiType) + { + if (uiType == TYPE_CELEBRAS) + return m_auiEncounter[0]; + return 0; + } + + void SetData(uint32 uiType, uint32 uiData) + { + if (uiType == TYPE_CELEBRAS) + { + if (uiData == DONE) + { + if (Creature* pCreature = instance->GetCreature(GetData64(NPC_CELEBRAS_REDEEMED))) + { + pCreature->SetVisibility(VISIBILITY_ON); + } + } + + m_auiEncounter[0] = uiData; + } + + if (uiData == DONE) + { + OUT_SAVE_INST_DATA; + + std::ostringstream saveStream; + for (int i = 0; i < MARAUDON_MAX_ENCOUNTER; ++i) + saveStream << m_auiEncounter[i] << " "; + + strInstData = saveStream.str(); + + SaveToDB(); + OUT_SAVE_INST_DATA_COMPLETE; + } + } + + uint64 GetData64(uint32 uiData) + { + switch (uiData) + { + case NPC_CELEBRAS_REDEEMED: + return cGuid; + } + + return 0; + } +}; InstanceData* GetInstanceData_instance_maraudon(Map* pMap) { return new instance_maraudon(pMap); } -struct npc_celebrasAI : public ScriptedAI -{ - enum Phase - { - EVENT_PHASE_INIT, - EVENT_PHASE_SAY_1, - EVENT_PHASE_GO_1, - EVENT_PHASE_AT_1, - EVENT_PHASE_SAY_2, - EVENT_PHASE_GO_2, - EVENT_PHASE_GO_3, - EVENT_PHASE_AT_2, - EVENT_PHASE_CAST_1, - EVENT_PHASE_BOOK_1, - EVENT_PHASE_BOOK_2, - EVENT_PHASE_SAY_3, - EVENT_PHASE_GO_4, - EVENT_PHASE_AT_3, - EVENT_PHASE_GO_5, - EVENT_PHASE_GO_6, - EVENT_PHASE_GO_7, - EVENT_PHASE_GO_8, - EVENT_PHASE_GO_9, - EVENT_PHASE_AT_4, - EVENT_PHASE_GO_10, - EVENT_PHASE_END - }; - - npc_celebrasAI(Creature* pCreature) : ScriptedAI(pCreature) - { - Reset(); - } - - void Reset() override - { - InEvent = false; - EventTimer = 0; - EventPhase = EVENT_PHASE_INIT; - } - - void StartEvent(Player *plr) - { - if (InEvent) - return; - sayFlag = true; - IsCasting = false; - InEvent = true; - CastingTime = 0; - EventTimer = 0; - pGuid = plr->GetObjectGuid(); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } - - void MovementInform(uint32 /*uiMotionType*/, uint32 uiPointId) override - { - switch (uiPointId) - { - case EVENT_PHASE_GO_1: - EventTimer = 0; - EventPhase = EVENT_PHASE_AT_1; - break; - case EVENT_PHASE_GO_2: - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_3, 656.4841f, 73.4726f, -86.8292f, MOVE_PATHFINDING, 0, 3.0223f); - break; - case EVENT_PHASE_GO_3: - EventTimer = 0; - EventPhase = EVENT_PHASE_AT_2; - break; - case EVENT_PHASE_GO_4: - EventTimer = 0; - EventPhase = EVENT_PHASE_AT_3; - break; - case EVENT_PHASE_GO_5: - m_creature->MonsterSay("My scepter will once again become whole!", LANG_UNIVERSAL); - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_6, 656.4841f, 73.4726f, -86.8292f, MOVE_PATHFINDING, 0, 3.0223f); - break; - case EVENT_PHASE_GO_6: - if (instance_maraudon* pInstance = dynamic_cast((ScriptedInstance*)m_creature->GetInstanceData())) - if (GameObject *pGo = m_creature->GetMap()->GetGameObject(pInstance->GetPedestalGuid())) - pInstance->DoUseDoorOrButton(pGo->GetObjectGuid()); - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_7, 655.7295f, 67.0476f, -86.8281f); - break; - case EVENT_PHASE_GO_7: - EventTimer = 0; - EventPhase = EVENT_PHASE_AT_4; - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_8, 647.8120f, 63.5547f, -86.7693f, MOVE_PATHFINDING, 0, 1.0015f); - break; - case EVENT_PHASE_GO_9: - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_10, 657.1558f, 79.18f, -86.8292f, MOVE_PATHFINDING, 0, 4.5891f); - break; - case EVENT_PHASE_GO_10: - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_END, 654.3468f, 84.9036f, -86.8436f, MOVE_PATHFINDING, 0, 4.4439f); - break; - case EVENT_PHASE_END: - { - if (Player *pPlayer = m_creature->GetMap()->GetPlayer(pGuid)) - pPlayer->GroupEventHappens(QUEST_CELEBRAS_CEPTER, m_creature); - InEvent = false; - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); - m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); - } - break; - } - } - - void ReadBook() - { - if (EventPhase == EVENT_PHASE_BOOK_1) - { - EventPhase = EVENT_PHASE_BOOK_2; - if (instance_maraudon* pInstance = dynamic_cast((ScriptedInstance*)m_creature->GetInstanceData())) - if (GameObject *pGo = m_creature->GetMap()->GetGameObject(pInstance->GetAuraGuid())) - { - pGo->SetRespawnTime(HOUR); - pGo->Refresh(); - } - } - } - - void UpdateAI(const uint32 uiDiff) override - { - if (!InEvent || EventPhase == EVENT_PHASE_END) - return; - if (EventPhase == EVENT_PHASE_INIT) - { - m_creature->MonsterSay("You wish to learn of the stone? Follow me.", LANG_UNIVERSAL); - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_1, 654.3468f, 84.9036f, -86.8436f, MOVE_PATHFINDING, 0, 4.4439f); - EventPhase = EVENT_PHASE_GO_1; - } - if (EventPhase == EVENT_PHASE_AT_1 && EventTimer > 2000) - { - m_creature->MonsterSay("For so long I have drifted in my cursed form. You have freed me... Your hard work shall be repaid.", LANG_UNIVERSAL); - m_creature->UpdateSpeed(MOVE_WALK, true, m_creature->GetSpeed(MOVE_WALK) / 10); - EventPhase = EVENT_PHASE_SAY_2; - } - if (EventPhase == EVENT_PHASE_SAY_2 && EventTimer > 6000) - { - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_2, 657.1558f, 79.18f, -86.8292f, MOVE_PATHFINDING, 0, 4.5891f); - EventPhase = EVENT_PHASE_GO_2; - } - if (EventPhase == EVENT_PHASE_AT_2 && EventTimer > 2000) - { - if (Player *pPlayer = m_creature->GetMap()->GetPlayer(pGuid)) - m_creature->MonsterSay("Please do as I instruct you, $N.", LANG_UNIVERSAL, pPlayer); - EventPhase = EVENT_PHASE_CAST_1; - } - if (EventPhase == EVENT_PHASE_CAST_1 && EventTimer > 4000) - { - if (instance_maraudon* pInstance = dynamic_cast((ScriptedInstance*)m_creature->GetInstanceData())) - if (GameObject *pGo = m_creature->GetMap()->GetGameObject(pInstance->GetBookGuid())) - { - pGo->SetRespawnTime(HOUR); - pGo->Refresh(); - } - EventPhase = EVENT_PHASE_BOOK_1; - } - if ((EventPhase == EVENT_PHASE_BOOK_1 || EventPhase == EVENT_PHASE_BOOK_2) && EventTimer > 6000 && sayFlag) - { - sayFlag = false; - m_creature->MonsterSay("Read this tome I have placed before you, and speak the words aloud.", LANG_UNIVERSAL); - IsCasting = true; - CastingTime = 0; - } - if (EventPhase == EVENT_PHASE_BOOK_2 && EventTimer > 6000) - { - IsCasting = false; - m_creature->RemoveAurasDueToSpell(SPELL_FRENEZIED_REGEN); - DoCastSpellIfCan(m_creature, SPELL_END_EVENT, CAST_INTERRUPT_PREVIOUS); - EventTimer = 0; - } - if (EventPhase == EVENT_PHASE_BOOK_2 && EventTimer > 2000) - { - m_creature->MonsterSay("Together, the two parts shall become one, once again.", LANG_UNIVERSAL); - EventPhase = EVENT_PHASE_SAY_3; - } - if (EventPhase == EVENT_PHASE_SAY_3 && EventTimer > 6000) - { - m_creature->MonsterSay("Shal myrinan ishnu daldorah...", LANG_UNIVERSAL); - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_4, 654.0375f, 73.8043f, -86.0753f, MOVE_PATHFINDING, 0, 3.0537f); - EventPhase = EVENT_PHASE_GO_4; - } - if (EventPhase == EVENT_PHASE_AT_3 && EventTimer > 2000) - { - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_5, 656.4841f, 73.4726f, -86.8292f, MOVE_PATHFINDING, 0, 3.0223f); - EventPhase = EVENT_PHASE_GO_5; - } - if (EventPhase == EVENT_PHASE_AT_4 && EventTimer > 8000) - { - m_creature->GetMotionMaster()->MovePoint(EVENT_PHASE_GO_9, 655.7294f, 67.0476f, -86.8281f, MOVE_PATHFINDING, 0, 4.4439f); - if (instance_maraudon* pInstance = dynamic_cast((ScriptedInstance*)m_creature->GetInstanceData())) - if (GameObject *pGo = m_creature->GetMap()->GetGameObject(pInstance->GetAuraGuid())) - pGo->SetLootState(GO_JUST_DEACTIVATED); - EventPhase = EVENT_PHASE_END; - } - if (IsCasting) - { - if (CastingTime < uiDiff) - { - DoCastSpellIfCan(m_creature, SPELL_FRENEZIED_REGEN, CAST_TRIGGERED); // Apply aura - DoCastSpellIfCan(m_creature, SPELL_HEARTSTONE, CAST_INTERRUPT_PREVIOUS); - CastingTime = 9000; - } - else - CastingTime -= uiDiff; - } - EventTimer += uiDiff; - } - -private: - bool InEvent; - bool IsCasting; - uint32 EventTimer; - uint32 CastingTime; - Phase EventPhase; - ObjectGuid pGuid; - bool sayFlag; -}; - -CreatureAI* GetAI_npc_celebras(Creature* pCreature) -{ - return new npc_celebrasAI(pCreature); -} - -bool QuestAccept_npc_celebras(Player *pPlayer, Creature *pCreature, const Quest *pQuest) -{ - if (pQuest->GetQuestId() == QUEST_CELEBRAS_CEPTER) - { - if (npc_celebrasAI *pCelebras = dynamic_cast(pCreature->AI())) - pCelebras->StartEvent(pPlayer); - } - return true; -} - -bool GOUse_go_celebras_book(Player* /*pPlayer*/, GameObject* pGo) -{ - if (instance_maraudon* pInstance = dynamic_cast((ScriptedInstance*)pGo->GetInstanceData())) - if (Creature *pCreature = pGo->GetMap()->GetCreature(pInstance->GetCelebrasGuid())) - if (npc_celebrasAI* pCelebrasAI = dynamic_cast(pCreature->AI())) - pCelebrasAI->ReadBook(); - return false; -} - void AddSC_instance_maraudon() { Script* pNewScript; @@ -291,15 +115,4 @@ void AddSC_instance_maraudon() pNewScript->Name = "instance_maraudon"; pNewScript->GetInstanceData = &GetInstanceData_instance_maraudon; pNewScript->RegisterSelf(); - - pNewScript = new Script; - pNewScript->Name = "npc_celebras"; - pNewScript->GetAI = &GetAI_npc_celebras; - pNewScript->pQuestAcceptNPC = &QuestAccept_npc_celebras; - pNewScript->RegisterSelf(); - - pNewScript = new Script; - pNewScript->Name = "go_celebras_book"; - pNewScript->pGOHello = &GOUse_go_celebras_book; - pNewScript->RegisterSelf(); } diff --git a/src/scripts/kalimdor/desolace/maraudon/maraudon.h b/src/scripts/kalimdor/desolace/maraudon/maraudon.h index abce79ac2..6bfe4029d 100644 --- a/src/scripts/kalimdor/desolace/maraudon/maraudon.h +++ b/src/scripts/kalimdor/desolace/maraudon/maraudon.h @@ -6,21 +6,13 @@ #define MARAUDON_H #include "scriptPCH.h" -class instance_maraudon : public ScriptedInstance +enum { - public: - instance_maraudon(Map* pMap); - void OnCreatureCreate(Creature* pGo) override; - void OnGameObjectCreate(GameObject* pGo) override; - const ObjectGuid GetCelebrasGuid() const { return (cGuid); } - const ObjectGuid GetPedestalGuid() const { return (pGuid); } - const ObjectGuid GetBookGuid() const { return (bGuid); } - const ObjectGuid GetAuraGuid() const { return (aGuid); } - private: - ObjectGuid cGuid; - ObjectGuid pGuid; - ObjectGuid bGuid; - ObjectGuid aGuid; + MARAUDON_MAX_ENCOUNTER = 1, + + TYPE_CELEBRAS = 1, + + NPC_CELEBRAS_REDEEMED = 13716 }; #endif