Core/Scripts: move npc_experience hardcoded text to DB

(cherry picked from commit 8df4706992)

Rename 2016_08_28_17750_world.sql to 2016_08_25_05_world.sql
(cherry picked from commit 9c41af16ca)
This commit is contained in:
tkrokli
2016-08-25 09:07:45 +02:00
committed by joschiwald
parent d01dbdc528
commit ac88c6ec17
2 changed files with 29 additions and 34 deletions

View File

@@ -0,0 +1,8 @@
-- NPC 35364 Slahtz <Experience Eliminator> / 35365 Behsten <Experience Eliminator>
UPDATE `creature_template` SET `gossip_menu_id`= 10638 WHERE `entry`= 35365; -- 35364 already OK
UPDATE `gossip_menu_option` SET `box_money`= 100000, `box_text`= 'Are you certain you wish to stop gaining experience?', `BoxBroadcastTextID`= 35535 WHERE `menu_id`= 10638 AND `id`= 0;
DELETE FROM `gossip_menu_option` WHERE `menu_id`= 10638 AND `id`= 1;
INSERT INTO `gossip_menu_option` (`menu_id`,`id`,`option_icon`,`option_text`,`OptionBroadcastTextID`,`option_id`,`npc_option_npcflag`,`action_menu_id`,`action_poi_id`,`box_coded`,`box_money`,`box_text`,`BoxBroadcastTextID`,`VerifiedBuild`) VALUES
(10638,1,0,'I wish to start gaining experience again.',35532,1,1,0,0,0,100000,'Are you certain you wish to start gaining experience again?',35533,0);

View File

@@ -1841,10 +1841,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
{
@@ -1853,48 +1856,32 @@ 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(uint64(EXP_COST)))
player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
else if (noXPGain)
{
player->ModifyMoney(-int64(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();
return true;
}