Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2023-08-01 23:21:36 +08:00
10 changed files with 556 additions and 54 deletions

View File

@@ -187,7 +187,7 @@ class spell_arcane_vacuum : public SpellScript
{
Unit* caster = GetCaster();
Unit* hitUnit = GetHitUnit();
if (caster && hitUnit && hitUnit->ToPlayer())
if (caster && hitUnit)
{
caster->GetThreatMgr().ModifyThreatByPercent(hitUnit, -100);
caster->CastSpell(hitUnit, SPELL_ARCANE_VACUUM_TP, true);

View File

@@ -2016,13 +2016,15 @@ public:
bool OnGossipHello(Player* player, Creature* creature) override
{
auto toggleXpCost = sWorld->getIntConfig(CONFIG_TOGGLE_XP_COST);
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
{
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);
@@ -2031,43 +2033,29 @@ public:
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);
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)
{
case GOSSIP_ACTION_INFO_DEF + 1://xp off
{
if (!noXPGain)//does gain xp
doSwitch = true;//switch to don't gain xp
}
player->SetPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
break;
case GOSSIP_ACTION_INFO_DEF + 2://xp on
{
if (noXPGain)//doesn't gain xp
doSwitch = true;//switch to gain xp
}
player->RemovePlayerFlag(PLAYER_FLAGS_NO_XP_GAIN);
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();
return true;
}