From e4e1f4152f88a4d542cbcb38bed9a10f9c8f3f7b Mon Sep 17 00:00:00 2001 From: tkrokli Date: Sat, 17 Sep 2016 05:20:40 +0200 Subject: Core/Scripts: simplified npc_pet_trainer gossip script This is what the script changes should have been in PR #17746 (also updates issue #14719 with a correct solution). - remove OnGossipHello() to use DB conditions - replace OnGossipSelect() with sGossipSelect() - focus script on the confirming gossip option - let the other gossip menus be handled in DB (cherry picked from commit a475033c76c3a4dd58562fa7b4ccf14f2212977d) --- src/server/scripts/World/npcs_special.cpp | 56 +++++++------------------------ 1 file changed, 12 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 3aa3d4a453f..037f45728c9 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1776,14 +1776,8 @@ class npc_wormhole : public CreatureScript enum PetTrainer { - MENU_ID_PET_TRAINING = 4783, MENU_ID_PET_UNLEARN = 6520, - NPC_TEXT_PET_FAMILIES = 13474, - NPC_TEXT_PET_TRAINING = 5838, - NPC_TEXT_UNLEARN = 7722, - OPTION_ID_HOW_DO_I_TRAIN = 0, - OPTION_ID_UNTRAIN_MY_PET = 1, - OPTION_ID_PLEASE_DO = 0, + OPTION_ID_PLEASE_DO = 0 }; class npc_pet_trainer : public CreatureScript @@ -1791,49 +1785,23 @@ class npc_pet_trainer : public CreatureScript public: npc_pet_trainer() : CreatureScript("npc_pet_trainer") { } - bool OnGossipHello(Player* player, Creature* creature) /*override*/ + struct npc_pet_trainerAI : public ScriptedAI { - ClearGossipMenuFor(player); - - if (creature->IsQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); + npc_pet_trainerAI(Creature* creature) : ScriptedAI(creature) { } - if (player->GetPet() && player->GetPet()->getPetType() == HUNTER_PET) + void sGossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override { - AddGossipItemFor(player, MENU_ID_PET_TRAINING, OPTION_ID_HOW_DO_I_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - AddGossipItemFor(player, MENU_ID_PET_TRAINING, OPTION_ID_UNTRAIN_MY_PET, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - SendGossipMenuFor(player, NPC_TEXT_PET_TRAINING, creature->GetGUID()); - } - else - { - AddGossipItemFor(player, MENU_ID_PET_TRAINING, OPTION_ID_HOW_DO_I_TRAIN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - SendGossipMenuFor(player, NPC_TEXT_PET_TRAINING, creature->GetGUID()); + if (menuId == MENU_ID_PET_UNLEARN && gossipListId == OPTION_ID_PLEASE_DO) + { + player->ResetPetTalents(); + CloseGossipMenuFor(player); + } } - return true; - } + }; - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) /*override*/ + CreatureAI* GetAI(Creature* creature) const override { - ClearGossipMenuFor(player); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - SendGossipMenuFor(player, NPC_TEXT_PET_FAMILIES, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - { - AddGossipItemFor(player, MENU_ID_PET_UNLEARN, OPTION_ID_PLEASE_DO, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - SendGossipMenuFor(player, NPC_TEXT_UNLEARN, creature->GetGUID()); - } - break; - case GOSSIP_ACTION_INFO_DEF + 3: - { - player->ResetPetTalents(); - CloseGossipMenuFor(player); - } - break; - } - return true; + return new npc_pet_trainerAI(creature); } }; -- cgit v1.2.3