Optimize code

This commit is contained in:
bash
2025-08-02 17:06:28 +02:00
committed by GitHub
parent fa005ac1a9
commit d4a8c4abab

View File

@@ -209,13 +209,19 @@ public:
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
{
// when default no XP scaling.
if (sPlayerbotAIConfig->randomBotXPRate == 1.0)
return;
// when player is no bot.
if (!player->GetSession()->IsBot())
return;
// when player is no bot, double check.
if (!sRandomPlayerbotMgr->IsRandomBot(player))
return;
// if player in group check leader is real player.
// when bot has group where leader is a real player.
if (Group* group = player->GetGroup())
{
Player* leader = group->GetLeader();
@@ -229,10 +235,8 @@ public:
}
}
if (sPlayerbotAIConfig->randomBotXPRate != 1.0)
{
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
}
// otherwise apply bot XP scaling.
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
}
};