From fa78d2d83e10936f390fcd81a807adabfc52e0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB?= Date: Sun, 20 Aug 2017 18:31:59 +0300 Subject: [PATCH] Core/Scripts: start fight with hardcode in scripts by sending pet trainers to DB from Core (#571) * Core/Scripts: start fight with hardcode in scripts by sending pet trainers to DB from Core * fix build(forget about it lol azetorh don't have this commit) --- .../rev_1503204010790637500.sql | 15 +++++ src/scripts/World/npcs_special.cpp | 57 +++++-------------- 2 files changed, 30 insertions(+), 42 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1503204010790637500.sql diff --git a/data/sql/updates/pending_db_world/rev_1503204010790637500.sql b/data/sql/updates/pending_db_world/rev_1503204010790637500.sql new file mode 100644 index 000000000..16d1f9abe --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1503204010790637500.sql @@ -0,0 +1,15 @@ +INSERT INTO version_db_world (`sql_rev`) VALUES ('1503204010790637500'); + +-- Pet Trainer +UPDATE `creature_template` SET `gossip_menu_id`= 4783 WHERE `entry` IN (543, 3306, 3545, 3698, 4320, 16675, 40405); +UPDATE `creature_template` SET `exp`= 0, `npcflag`= 17, `trainer_type`= 3, `flags_extra`= 2, `ScriptName`= 'npc_pet_trainer' WHERE `entry`= 40405; +UPDATE `gossip_menu_option` SET `option_icon`= 0 WHERE `menu_id`= 6520 AND `id`= 0; + +-- gossip menu conditions +DELETE FROM `conditions` WHERE `SourceGroup`= 4783; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`SourceId`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionTarget`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`NegativeCondition`,`ErrorType`,`ErrorTextId`,`ScriptName`,`Comment`) VALUES +(14,4783,5838,0,0,15,0,4,0,0,0,0,0,'','Show gossip menu 4783 text id 5838 if player is a Hunter.'), +(14,4783,5839,0,0,15,0,4,0,0,1,0,0,'','Show gossip menu 4783 text id 5839 if player is not a Hunter.'), +(15,4783, 0,0,0,15,0,4,0,0,0,0,0,'','Show gossip menu 4783 option id 0 if player is a Hunter.'), +(15,4783, 1,0,0,15,0,4,0,0,0,0,0,'','Show gossip menu 4783 option id 1 if player is a Hunter.'); + diff --git a/src/scripts/World/npcs_special.cpp b/src/scripts/World/npcs_special.cpp index 028662454..11330b7ac 100644 --- a/src/scripts/World/npcs_special.cpp +++ b/src/scripts/World/npcs_special.cpp @@ -1824,61 +1824,34 @@ class npc_wormhole : public CreatureScript enum PetTrainer { - TEXT_ISHUNTER = 5838, - TEXT_NOTHUNTER = 5839, - TEXT_PETINFO = 13474, - TEXT_CONFIRM = 7722 + PET_UNLEARN = 6520, + YES_PLEASE_DO = 0 }; -#define GOSSIP_PET1 "How do I train my pet?" -#define GOSSIP_PET2 "I wish to untrain my pet." -#define GOSSIP_PET_CONFIRM "Yes, please do." - class npc_pet_trainer : public CreatureScript { public: npc_pet_trainer() : CreatureScript("npc_pet_trainer") { } - bool OnGossipHello(Player* player, Creature* creature) + struct npc_pet_trainerAI : public ScriptedAI { - if (creature->IsQuestGiver()) - player->PrepareQuestMenu(creature->GetGUID()); + npc_pet_trainerAI(Creature* creature) : ScriptedAI(creature) { } - if (player->getClass() == CLASS_HUNTER) + + void sGossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_PET1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - if (player->GetPet() && player->GetPet()->getPetType() == HUNTER_PET) - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_PET2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - - player->PlayerTalkClass->SendGossipMenu(TEXT_ISHUNTER, creature->GetGUID()); - return true; + if (menuId == PET_UNLEARN && gossipListId == YES_PLEASE_DO) + { + player->ResetPetTalents(); + player->PlayerTalkClass->SendCloseGossip(); + } } - player->PlayerTalkClass->SendGossipMenu(TEXT_NOTHUNTER, creature->GetGUID()); - return true; - } + }; - bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) + + CreatureAI* GetAI(Creature* creature) const override { - player->PlayerTalkClass->ClearMenus(); - switch (action) - { - case GOSSIP_ACTION_INFO_DEF + 1: - player->PlayerTalkClass->SendGossipMenu(TEXT_PETINFO, creature->GetGUID()); - break; - case GOSSIP_ACTION_INFO_DEF + 2: - { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_PET_CONFIRM, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3); - player->PlayerTalkClass->SendGossipMenu(TEXT_CONFIRM, creature->GetGUID()); - } - break; - case GOSSIP_ACTION_INFO_DEF + 3: - { - player->ResetPetTalents(); - player->CLOSE_GOSSIP_MENU(); - } - break; - } - return true; + return new npc_pet_trainerAI(creature); } };