From 8df4706992f0fa39af5892dce2c23a0dde5bd9c1 Mon Sep 17 00:00:00 2001 From: tkrokli Date: Thu, 25 Aug 2016 09:07:45 +0200 Subject: Core/Scripts: move npc_experience hardcoded text to DB --- src/server/scripts/World/npcs_special.cpp | 57 ++++++++++++------------------- 1 file changed, 22 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index eed92818e83..b4019321131 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1846,10 +1846,13 @@ public: ## npc_experience ######*/ -#define EXP_COST 100000 //10 00 00 copper (10golds) -#define GOSSIP_TEXT_EXP 14736 -#define GOSSIP_XP_OFF "I no longer wish to gain experience." -#define GOSSIP_XP_ON "I wish to start gaining experience again." +enum BehstenSlahtz +{ + MENU_ID_XP_ON_OFF = 10638, + NPC_TEXT_XP_ON_OFF = 14736, + OPTION_ID_XP_OFF = 0, // "I no longer wish to gain experience." + OPTION_ID_XP_ON = 1 // "I wish to start gaining experience again." +}; class npc_experience : public CreatureScript { @@ -1858,49 +1861,33 @@ public: bool OnGossipHello(Player* player, Creature* creature) override { - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_XP_OFF, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_XP_ON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); - player->PlayerTalkClass->SendGossipMenu(GOSSIP_TEXT_EXP, creature->GetGUID()); + if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN)) // not gaining XP + { + player->ADD_GOSSIP_ITEM_DB(MENU_ID_XP_ON_OFF, OPTION_ID_XP_ON, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); + player->SEND_GOSSIP_MENU(NPC_TEXT_XP_ON_OFF, creature->GetGUID()); + } + else // currently gaining XP + { + player->ADD_GOSSIP_ITEM_DB(MENU_ID_XP_ON_OFF, OPTION_ID_XP_OFF, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + player->SEND_GOSSIP_MENU(NPC_TEXT_XP_ON_OFF, creature->GetGUID()); + } return true; } bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 action) override { player->PlayerTalkClass->ClearMenus(); - bool noXPGain = player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN); - bool doSwitch = false; switch (action) { - case GOSSIP_ACTION_INFO_DEF + 1://xp off - { - if (!noXPGain)//does gain xp - doSwitch = true;//switch to don't gain xp - } + case GOSSIP_ACTION_INFO_DEF + 1: // XP ON selected + player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN); // turn on XP gain break; - case GOSSIP_ACTION_INFO_DEF + 2://xp on - { - if (noXPGain)//doesn't gain xp - doSwitch = true;//switch to gain xp - } + case GOSSIP_ACTION_INFO_DEF + 2: // XP OFF selected + player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN); // turn off XP gain break; } - if (doSwitch) - { - if (!player->HasEnoughMoney(EXP_COST)) - player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); - else if (noXPGain) - { - player->ModifyMoney(-EXP_COST); - player->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN); - } - else if (!noXPGain) - { - player->ModifyMoney(-EXP_COST); - player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN); - } - } - player->PlayerTalkClass->SendCloseGossip(); + player->CLOSE_GOSSIP_MENU(); return true; } }; -- cgit v1.2.3