diff --git a/src/Playerbots.cpp b/src/Playerbots.cpp index 27c4c685..76b32efa 100644 --- a/src/Playerbots.cpp +++ b/src/Playerbots.cpp @@ -209,16 +209,30 @@ public: void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override { - if (!player->GetSession()->IsBot()) - return; - - if (!sRandomPlayerbotMgr->IsRandomBot(player)) + // early return + if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player) return; - if (sPlayerbotAIConfig->randomBotXPRate != 1.0) + // no XP multiplier, when player is no bot. + if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player)) + return; + + // no XP multiplier, when bot has group where leader is a real player. + if (Group* group = player->GetGroup()) { - amount = static_cast(std::round(static_cast(amount) * sPlayerbotAIConfig->randomBotXPRate)); + Player* leader = group->GetLeader(); + if (leader && leader != player) + { + if (PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader)) + { + if (leaderBotAI->HasRealPlayerMaster()) + return; + } + } } + + // otherwise apply bot XP multiplier. + amount = static_cast(std::round(static_cast(amount) * sPlayerbotAIConfig->randomBotXPRate)); } };