Skip to content

Commit c1222da

Browse files
authored
Disable bot XP gain when master has XP turned off (mod-playerbots#1910)
Addresses mod-playerbots#1846 This PR disables XP gain for bots whose non-bot master has disabled XP gain via an "Experience Eliminator" NPC. If the current master has disabled XP gain, randombots in the group and addclass-bots belonging to the player won't gain XP. Randombots not grouped with a player will continue to gain XP as normal. Discussed points: - `Should this feature only be enabled via a new configuration value?`: Comments currently tend towards no config value. Open points: - Should bots be allowed to gain XP until they reach the player's level, even if the player has disabled XP gain?
1 parent 00cb177 commit c1222da

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/Playerbots.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,22 @@ class PlayerbotsPlayerScript : public PlayerScript
238238

239239
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
240240
{
241-
// early return
242-
if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player)
241+
// no XP multiplier, when player is no bot.
242+
if (!player || !player->GetSession()->IsBot())
243243
return;
244244

245-
// no XP multiplier, when player is no bot.
246-
if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player))
245+
// no XP gain, if master is not a bot and has xp gain disabled.
246+
if (const Player* master = GET_PLAYERBOT_AI(player)->GetMaster())
247+
{
248+
if (!master->GetSession()->IsBot() && master->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN))
249+
{
250+
amount = 0;
251+
return;
252+
}
253+
}
254+
255+
// early return
256+
if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !sRandomPlayerbotMgr->IsRandomBot(player))
247257
return;
248258

249259
// no XP multiplier, when bot is in a group with a real player.

0 commit comments

Comments
 (0)