mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Don't apply XPRate multiplier when bot is in group with real player (#1495)
* dont apply XPRate if bot is in group with real player https://github.com/liyunfan1223/mod-playerbots/issues/1490 * Optimize code * Oops minor correction * Defense check on the player itself * Safer way to check the leader is real player. * Added abit more defense programming, should be needed still ..why not
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user