diff --git a/scripts/northrend/sholazar_basin.cpp b/scripts/northrend/sholazar_basin.cpp index b11ec06..5a2d3c9 100644 --- a/scripts/northrend/sholazar_basin.cpp +++ b/scripts/northrend/sholazar_basin.cpp @@ -17,7 +17,7 @@ /* ScriptData SDName: Sholazar_Basin SD%Complete: 100 -SDComment: Quest support: 12570, 12580, 12688 +SDComment: Quest support: 12570, 12580, 12644, 12688 SDCategory: Sholazar Basin EndScriptData */ @@ -25,6 +25,9 @@ EndScriptData */ npc_helice npc_injured_rainspeaker npc_mosswalker_victim +npc_tipsy_mcmanus +npc_credit_for_quest_still_at_it +go_credit_for_quest_still_at_it EndContentData */ #include "precompiled.h" @@ -408,6 +411,261 @@ bool GossipSelect_npc_mosswalker_victim(Player* pPlayer, Creature* pCreature, ui return true; } +/*###### +## npc_tipsy_mcmanus +######*/ + +enum +{ + QUEST_STILL_AT_IT = 12644, + + GOSSIP_ITEM_TIPSY_MCMANUS = -3649011, + TEXT_ID_READY = 13288, + + SAY_NPC_TIPSY_TASK_START = -1999926, + + SAY_NPC_TIPSY_ACTION_1 = -1999927, + SAY_NPC_TIPSY_ACTION_2 = -1999928, + SAY_NPC_TIPSY_ACTION_3 = -1999929, + SAY_NPC_TIPSY_ACTION_4 = -1999930, + SAY_NPC_TIPSY_ACTION_5 = -1999931, + + SAY_NPC_TIPSY_ACTION_COMPLETE_1 = -1999932, + SAY_NPC_TIPSY_ACTION_COMPLETE_2 = -1999933, + SAY_NPC_TIPSY_ACTION_COMPLETE_3 = -1999934, + + SAY_NPC_TIPSY_TASK_COMPLETE = -1999935, + + ACTION_WANTS_ORANGE_CREDIT = 28535, + ACTION_WANTS_PAPAYA_CREDIT = 28536, + ACTION_WANTS_BANANA_CREDIT = 28537, + ACTION_STEAMING_VALVE_CREDIT = 28539, + ACTION_WANTS_FIRE_CREDIT = 28540, + + GO_THUNDERBREW_JUNGLE_PUNCH = 190643, +}; + +struct MANGOS_DLL_DECL npc_tipsy_mcmanusAI : public ScriptedAI +{ + npc_tipsy_mcmanusAI(Creature* pCreature) : ScriptedAI(pCreature) { Reset(); } + + uint32 m_uiTaskTimer; + uint8 m_uiAction; + uint32 m_uiActionTimer; + uint32 m_uiActionCredit; + + void Reset() + { + m_uiTaskTimer = 0; + m_uiAction = 0; + m_uiActionTimer = 0; + m_uiActionCredit = 0; + } + + void TaskStart(uint32 uiTaskTimer, uint8 uiAction) + { + m_uiTaskTimer = uiTaskTimer; + m_uiAction = uiAction; + } + + void ActionComplete(uint32 uiActionCredit) + { + if (uiActionCredit == m_uiActionCredit) + { + switch (urand(0, 2)) + { + case 0: + DoScriptText(SAY_NPC_TIPSY_ACTION_COMPLETE_1, m_creature, m_creature->getVictim()); + break; + case 1: + DoScriptText(SAY_NPC_TIPSY_ACTION_COMPLETE_2, m_creature, m_creature->getVictim()); + break; + case 2: + DoScriptText(SAY_NPC_TIPSY_ACTION_COMPLETE_3, m_creature, m_creature->getVictim()); + break; + } + m_uiTaskTimer = 5000; + ++m_uiAction; + m_uiActionTimer = 0; + } + else + { + Reset(); + } + } + + void UpdateAI(const uint32 uiDiff) + { + if (m_uiTaskTimer <= uiDiff) + { + if (m_uiAction) + { + switch (m_uiAction) + { + case 1: + DoScriptText(SAY_NPC_TIPSY_TASK_START, m_creature, m_creature->getVictim()); + m_uiTaskTimer = 5000; + ++m_uiAction; + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + if (m_uiActionTimer == 0) + { + switch (urand(0, 4)) + { + case 0: + DoScriptText(SAY_NPC_TIPSY_ACTION_1, m_creature, m_creature->getVictim()); + m_uiActionCredit = ACTION_WANTS_BANANA_CREDIT; + break; + case 1: + DoScriptText(SAY_NPC_TIPSY_ACTION_2, m_creature, m_creature->getVictim()); + m_uiActionCredit = ACTION_WANTS_ORANGE_CREDIT; + break; + case 2: + DoScriptText(SAY_NPC_TIPSY_ACTION_3, m_creature, m_creature->getVictim()); + m_uiActionCredit = ACTION_STEAMING_VALVE_CREDIT; + break; + case 3: + DoScriptText(SAY_NPC_TIPSY_ACTION_4, m_creature, m_creature->getVictim()); + m_uiActionCredit = ACTION_WANTS_FIRE_CREDIT; + break; + case 4: + DoScriptText(SAY_NPC_TIPSY_ACTION_5, m_creature, m_creature->getVictim()); + m_uiActionCredit = ACTION_WANTS_PAPAYA_CREDIT; + break; + } + m_uiActionTimer += uiDiff; + } + else if (m_uiActionTimer > 10000) + { + Reset(); + } + else + { + m_uiActionTimer += uiDiff; + } + break; + case 11: + DoScriptText(SAY_NPC_TIPSY_TASK_COMPLETE, m_creature, m_creature->getVictim()); + std::list lGoInRange; + GetGameObjectListWithEntryInGrid(lGoInRange, m_creature, GO_THUNDERBREW_JUNGLE_PUNCH, 10.0f); + for (std::list::const_iterator itr = lGoInRange.begin(); itr != lGoInRange.end(); ++itr) + { + (*itr)->SetRespawnTime(30); + (*itr)->Refresh(); + } + ++m_uiAction; + break; + } + } + } + else + m_uiTaskTimer -= uiDiff; + } +}; + +CreatureAI* GetAI_npc_tipsy_mcmanus(Creature* pCreature) +{ + return new npc_tipsy_mcmanusAI(pCreature); +} + +bool GossipHello_npc_tipsy_mcmanus(Player* pPlayer, Creature* pCreature) +{ + if (pPlayer->GetQuestStatus(QUEST_STILL_AT_IT) == QUEST_STATUS_INCOMPLETE) + pPlayer->ADD_GOSSIP_ITEM_ID(GOSSIP_ICON_CHAT, GOSSIP_ITEM_TIPSY_MCMANUS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + + pPlayer->SEND_GOSSIP_MENU(TEXT_ID_READY, pCreature->GetObjectGuid()); + return true; +} + +bool GossipSelect_npc_tipsy_mcmanus(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction) +{ + pPlayer->CLOSE_GOSSIP_MENU(); + if (npc_tipsy_mcmanusAI* pTipsyMcmanusAI = dynamic_cast(pCreature->AI())) + pTipsyMcmanusAI->TaskStart(2000, 1); + + return true; +} + +/*###### +## npc_credit_for_quest_still_at_it +######*/ + +enum +{ + SPELL_TOSS_ORANGE = 51931, + SPELL_TOSS_BANANA = 51932, + SPELL_TOSS_PAPAYA = 51933, + + NPC_TIPSY_MCMANUS = 28566, +}; + +bool EffectDummyCreature_npc_credit_for_quest_still_at_it(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Creature* pCreatureTarget, ObjectGuid /*originalCasterGuid*/) +{ + if (uiSpellId == SPELL_TOSS_ORANGE || uiSpellId == SPELL_TOSS_BANANA || uiSpellId == SPELL_TOSS_PAPAYA) + { + if (((Player*)pCaster)->GetQuestStatus(QUEST_STILL_AT_IT) == QUEST_STATUS_INCOMPLETE) + { + if (Creature* pTipsyMcmanus = GetClosestCreatureWithEntry(pCaster, NPC_TIPSY_MCMANUS, 2*INTERACTION_DISTANCE)) + { + if (npc_tipsy_mcmanusAI* pTipsyMcmanusAI = dynamic_cast(pTipsyMcmanus->AI())) + { + pTipsyMcmanusAI->ActionComplete(pCreatureTarget->GetEntry()); + return true; + } + } + } + } + + return false; +} + +/*###### +## go_credit_for_quest_still_at_it +######*/ + +enum +{ + GO_PRESSURE_VALVE = 190635, + GO_BRAZIER = 190636, +}; + +bool GOUse_go_credit_for_quest_still_at_it(Player* pPlayer, GameObject* pGo) +{ + if (pPlayer->GetQuestStatus(QUEST_STILL_AT_IT) == QUEST_STATUS_INCOMPLETE) + { + if (Creature* pTipsyMcmanus = GetClosestCreatureWithEntry(pPlayer, NPC_TIPSY_MCMANUS, 2*INTERACTION_DISTANCE)) + { + if (npc_tipsy_mcmanusAI* pTipsyMcmanusAI = dynamic_cast(pTipsyMcmanus->AI())) + { + uint32 uiActionCredit = 0; + switch (pGo->GetEntry()) + { + case GO_PRESSURE_VALVE: + uiActionCredit = ACTION_STEAMING_VALVE_CREDIT; + break; + case GO_BRAZIER: + uiActionCredit = ACTION_WANTS_FIRE_CREDIT; + break; + } + if (uiActionCredit) + { + pTipsyMcmanusAI->ActionComplete(uiActionCredit); + return false; + } + } + } + } + return false; +} + void AddSC_sholazar_basin() { Script* pNewScript; @@ -431,4 +689,21 @@ void AddSC_sholazar_basin() pNewScript->pGossipHello = &GossipHello_npc_mosswalker_victim; pNewScript->pGossipSelect = &GossipSelect_npc_mosswalker_victim; pNewScript->RegisterSelf(); + + pNewScript = new Script; + pNewScript->Name = "npc_tipsy_mcmanus"; + pNewScript->GetAI = &GetAI_npc_tipsy_mcmanus; + pNewScript->pGossipHello = &GossipHello_npc_tipsy_mcmanus; + pNewScript->pGossipSelect = &GossipSelect_npc_tipsy_mcmanus; + pNewScript->RegisterSelf(); + + pNewScript = new Script; + pNewScript->Name = "npc_credit_for_quest_still_at_it"; + pNewScript->pEffectDummyNPC = &EffectDummyCreature_npc_credit_for_quest_still_at_it; + pNewScript->RegisterSelf(); + + pNewScript = new Script; + pNewScript->Name = "go_credit_for_quest_still_at_it"; + pNewScript->pGOUse = &GOUse_go_credit_for_quest_still_at_it; + pNewScript->RegisterSelf(); }