mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-29 08:23:48 +00:00
Compare commits
2 Commits
hermensbas
...
2317652d72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2317652d72 | ||
|
|
1fcd6c5cda |
@@ -264,46 +264,33 @@ public:
|
|||||||
|
|
||||||
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
|
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
|
||||||
{
|
{
|
||||||
if (!player || !player->IsInWorld())
|
// early return
|
||||||
|
if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (WorldSession* session = player->GetSession(); !session || !session->IsBot())
|
// no XP multiplier, when player is no bot.
|
||||||
|
if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayerbotAI* botAI = GET_PLAYERBOT_AI(player);
|
// no XP multiplier, when bot is in a group with a real player.
|
||||||
if (!botAI)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// No XP gain if master is a real player with XP gain disabled
|
|
||||||
if (const Player* master = botAI->GetMaster())
|
|
||||||
{
|
|
||||||
if (WorldSession* masterSession = master->GetSession();
|
|
||||||
masterSession && !masterSession->IsBot() &&
|
|
||||||
master->HasPlayerFlag(PLAYER_FLAGS_NO_XP_GAIN))
|
|
||||||
{
|
|
||||||
amount = 0; // disable XP multiplier
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// From here on we only care about random bots
|
|
||||||
if (sPlayerbotAIConfig->randomBotXPRate == 1.0f || !sRandomPlayerbotMgr->IsRandomBot(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// No XP multiplier if bot is in a group with at least one real player
|
|
||||||
if (Group* group = player->GetGroup())
|
if (Group* group = player->GetGroup())
|
||||||
{
|
{
|
||||||
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
|
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
|
||||||
{
|
{
|
||||||
if (Player* member = gref->GetSource())
|
Player* member = gref->GetSource();
|
||||||
|
if (!member)
|
||||||
{
|
{
|
||||||
if (WorldSession* session = member->GetSession();session && !session->IsBot())
|
continue;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if (!member->GetSession()->IsBot())
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise apply XP multiplier
|
// otherwise apply bot XP multiplier.
|
||||||
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
|
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2593,14 +2593,17 @@ void RandomPlayerbotMgr::Refresh(Player* bot)
|
|||||||
|
|
||||||
bool RandomPlayerbotMgr::IsRandomBot(Player* bot)
|
bool RandomPlayerbotMgr::IsRandomBot(Player* bot)
|
||||||
{
|
{
|
||||||
if (!bot)
|
if (bot && GET_PLAYERBOT_AI(bot))
|
||||||
return false;
|
{
|
||||||
|
if (GET_PLAYERBOT_AI(bot)->IsRealPlayer())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (bot)
|
||||||
|
{
|
||||||
|
return IsRandomBot(bot->GetGUID().GetCounter());
|
||||||
|
}
|
||||||
|
|
||||||
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
|
return false;
|
||||||
if (!botAI || botAI->IsRealPlayer())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return IsRandomBot(bot->GetGUID().GetCounter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RandomPlayerbotMgr::IsRandomBot(ObjectGuid::LowType bot)
|
bool RandomPlayerbotMgr::IsRandomBot(ObjectGuid::LowType bot)
|
||||||
|
|||||||
Reference in New Issue
Block a user