mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
fix(Scripts/World): Fix XP disable NPC script (#16828)
* Fix XP disable NPC script * Re-add money logic * Remove unintended whitespace
This commit is contained in:
@@ -2016,13 +2016,15 @@ public:
|
|||||||
|
|
||||||
bool OnGossipHello(Player* player, Creature* creature) override
|
bool OnGossipHello(Player* player, Creature* creature) override
|
||||||
{
|
{
|
||||||
|
auto toggleXpCost = sWorld->getIntConfig(CONFIG_TOGGLE_XP_COST);
|
||||||
|
|
||||||
if (!player->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN))
|
if (!player->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN))
|
||||||
{
|
{
|
||||||
AddGossipItemFor(player, GOSSIP_MENU_EXP_NPC, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); // "I no longer wish to gain experience."
|
AddGossipItemFor(player, GOSSIP_MENU_EXP_NPC, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1, toggleXpCost); // "I no longer wish to gain experience."
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddGossipItemFor(player, GOSSIP_MENU_EXP_NPC, 1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); // "I wish to start gaining experience again."
|
AddGossipItemFor(player, GOSSIP_MENU_EXP_NPC, 1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2, toggleXpCost); // "I wish to start gaining experience again."
|
||||||
}
|
}
|
||||||
|
|
||||||
SendGossipMenuFor(player, player->GetGossipTextId(creature), creature);
|
SendGossipMenuFor(player, player->GetGossipTextId(creature), creature);
|
||||||
@@ -2031,43 +2033,29 @@ public:
|
|||||||
|
|
||||||
bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 action) override
|
bool OnGossipSelect(Player* player, Creature* /*creature*/, uint32 /*sender*/, uint32 action) override
|
||||||
{
|
{
|
||||||
ClearGossipMenuFor(player);
|
|
||||||
bool noXPGain = player->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
|
|
||||||
bool doSwitch = false;
|
|
||||||
auto toggleXpCost = sWorld->getIntConfig(CONFIG_TOGGLE_XP_COST);
|
auto toggleXpCost = sWorld->getIntConfig(CONFIG_TOGGLE_XP_COST);
|
||||||
|
|
||||||
|
ClearGossipMenuFor(player);
|
||||||
|
|
||||||
|
if (!player->HasEnoughMoney(toggleXpCost))
|
||||||
|
{
|
||||||
|
player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
|
||||||
|
player->PlayerTalkClass->SendCloseGossip();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player->ModifyMoney(-toggleXpCost);
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case GOSSIP_ACTION_INFO_DEF + 1://xp off
|
case GOSSIP_ACTION_INFO_DEF + 1://xp off
|
||||||
{
|
player->SetPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
|
||||||
if (!noXPGain)//does gain xp
|
|
||||||
doSwitch = true;//switch to don't gain xp
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case GOSSIP_ACTION_INFO_DEF + 2://xp on
|
case GOSSIP_ACTION_INFO_DEF + 2://xp on
|
||||||
{
|
player->RemovePlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
|
||||||
if (noXPGain)//doesn't gain xp
|
|
||||||
doSwitch = true;//switch to gain xp
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (doSwitch)
|
|
||||||
{
|
|
||||||
if (!player->HasEnoughMoney(toggleXpCost))
|
|
||||||
{
|
|
||||||
player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
|
|
||||||
}
|
|
||||||
else if (noXPGain)
|
|
||||||
{
|
|
||||||
player->ModifyMoney(-toggleXpCost);
|
|
||||||
player->RemovePlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
|
|
||||||
}
|
|
||||||
else if (!noXPGain)
|
|
||||||
{
|
|
||||||
player->ModifyMoney(-toggleXpCost);
|
|
||||||
player->SetPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player->PlayerTalkClass->SendCloseGossip();
|
player->PlayerTalkClass->SendCloseGossip();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user