Skip to content

Commit

Permalink
[Playerbot] RndbotMgr deathknight changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PargeLenis committed Oct 24, 2023
1 parent 162f073 commit c496b25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/modules/Bots/playerbot/RandomPlayerbotFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool RandomPlayerbotFactory::CreateRandomBotName(string& name)

void RandomPlayerbotFactory::CreateRandomBots()
{
for (int accountNumber = 0; accountNumber < sPlayerbotAIConfig.randomBotAccountCount; ++accountNumber)
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig.randomBotAccountCount; ++accountNumber)
{
string accountName = sPlayerbotAIConfig.randomBotAccountPrefix + to_string(accountNumber);
QueryResult* results = LoginDatabase.PQuery("SELECT id FROM account where username = '%s'", accountName.c_str());
Expand Down Expand Up @@ -207,7 +207,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
LoginDatabase.PExecute("UPDATE account SET expansion = '%u' WHERE expansion < '%u' AND username LIKE '%s%%'", MAX_EXPANSION, MAX_EXPANSION, sPlayerbotAIConfig.randomBotAccountPrefix.c_str());

uint32 totalRandomBotChars = 0;
for (int accountNumber = 0; accountNumber < sPlayerbotAIConfig.randomBotAccountCount; ++accountNumber)
for (uint32 accountNumber = 0; accountNumber < sPlayerbotAIConfig.randomBotAccountCount; ++accountNumber)
{
string accountName = sPlayerbotAIConfig.randomBotAccountPrefix + to_string(accountNumber);

Expand Down Expand Up @@ -243,7 +243,7 @@ void RandomPlayerbotFactory::CreateRandomBots()
DEBUG_LOG("Created %d bots for account %s.", sAccountMgr.GetCharactersCount(accountId) - count, accountName.c_str());
}

BASIC_LOG("%d random bot accounts with %d characters available", sPlayerbotAIConfig.randomBotAccounts.size(), totalRandomBotChars);
BASIC_LOG("%zu random bot accounts with %d characters available", sPlayerbotAIConfig.randomBotAccounts.size(), totalRandomBotChars);
}


Expand All @@ -264,8 +264,8 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
{
do
{
Field* fields = results2->Fetch();
uint32 guid = fields[0].GetUInt32();
Field* fields2 = results2->Fetch();
uint32 guid = fields2[0].GetUInt32();
randomBots.push_back(guid);
} while (results2->NextRow());
delete results2;
Expand All @@ -275,7 +275,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
delete results;
}

int guildNumber = 0;
uint32 guildNumber = 0;
vector<ObjectGuid> availableLeaders;
for (uint32& i : randomBots)
{
Expand Down Expand Up @@ -315,7 +315,7 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
Player* player = sObjectMgr.GetPlayer(leader);
if (!player)
{
sLog.outError("Cannot find player for guild leader %u", leader);
sLog.outError("Cannot find player for guild leader %u", leader.GetEntry());
break;
}

Expand Down Expand Up @@ -399,8 +399,8 @@ void RandomPlayerbotFactory::DeleteRandomGuilds()
{
do
{
Field* fields = results2->Fetch();
uint32 guid = fields[0].GetUInt32();
Field* fields2 = results2->Fetch();
uint32 guid = fields2[0].GetUInt32();
randomBots.push_back(guid);
} while (results2->NextRow());
delete results2;
Expand Down
15 changes: 11 additions & 4 deletions src/modules/Bots/playerbot/RandomPlayerbotMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void RandomPlayerbotMgr::AddRandomBots(set<uint32> &bots)
continue;
}

QueryResult* result = CharacterDatabase.PQuery("SELECT guid, race FROM characters WHERE account = '%u'", accountId);
QueryResult* result = CharacterDatabase.PQuery("SELECT 'guid', 'race', 'class' FROM characters WHERE account = '%u'", accountId);
if (!result)
{
DEBUG_LOG("Unable to fetch characters for rndbot account %d", accountId);
Expand All @@ -118,10 +118,16 @@ void RandomPlayerbotMgr::AddRandomBots(set<uint32> &bots)
Field* fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
uint8 race = fields[1].GetUInt8();
uint8 cls = fields[2].GetUInt8();
bool alliance = guids.size() % 2 == 0;

if (cls == 6 && sPlayerbotAIConfig.randomBotMaxLevel < sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL))
{
continue;
}

if (bots.find(guid) == bots.end() &&
((alliance && IsAlliance(race)) || ((!alliance && !IsAlliance(race))
)))
((alliance && IsAlliance(race)) || ((!alliance && !IsAlliance(race)))))
{
guids.push_back(guid);
SetEventValue(guid, "add", 1, urand(sPlayerbotAIConfig.minRandomBotInWorldTime, sPlayerbotAIConfig.maxRandomBotInWorldTime));
Expand Down Expand Up @@ -360,7 +366,8 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)

void RandomPlayerbotMgr::Randomize(Player* bot)
{
if (bot->getLevel() == 1)
if (bot->getLevel() == 1 ||
(bot->getClass() == 6 && bot->getLevel() == sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL)))
{
RandomizeFirst(bot);
}
Expand Down

0 comments on commit c496b25

Please sign in to comment.