From c1222da8b0a469f1719eb02d93feff82fd57f874 Mon Sep 17 00:00:00 2001 From: HennyWilly <5954598+HennyWilly@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:23:34 +0100 Subject: [PATCH] Disable bot XP gain when master has XP turned off (#1910) Addresses #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? --- src/Playerbots.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Playerbots.cpp b/src/Playerbots.cpp index ed4e4826..83df732a 100644 --- a/src/Playerbots.cpp +++ b/src/Playerbots.cpp @@ -238,12 +238,22 @@ public: void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override { - // early return - if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player) + // no XP multiplier, when player is no bot. + if (!player || !player->GetSession()->IsBot()) return; - // no XP multiplier, when player is no bot. - if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player)) + // no XP gain, if master is not a bot and has xp gain disabled. + if (const Player* master = GET_PLAYERBOT_AI(player)->GetMaster()) + { + if (!master->GetSession()->IsBot() && master->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN)) + { + amount = 0; + return; + } + } + + // early return + if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !sRandomPlayerbotMgr->IsRandomBot(player)) return; // no XP multiplier, when bot is in a group with a real player.