Compare commits

...

6 Commits

View File

@@ -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<uint32>(std::round(static_cast<float>(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<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
}
};