Improper singletons migration to clean Meyer's singletons (cherry-pick) (#2082)

# Pull Request

- Applies the clean and corrected singletons, Meyer pattern. (cherry
picked from @SmashingQuasar )

Testing by just playing the game in various ways. Been tested by myself
@Celandriel and @SmashingQuasar
---

## Complexity & Impact

- Does this change add new decision branches?
    - [x] No
    - [ ] Yes (**explain below**)

- Does this change increase per-bot or per-tick processing?
    - [x] No
    - [ ] Yes (**describe and justify impact**)

- Could this logic scale poorly under load?
    - [x] No
    - [ ] Yes (**explain why**)

---

## Defaults & Configuration

- Does this change modify default bot behavior?
    - [x] No
    - [ ] Yes (**explain why**)

---

## AI Assistance

- Was AI assistance (e.g. ChatGPT or similar tools) used while working
on this change?
    - [x] No
    - [ ] Yes (**explain below**)
---

## Final Checklist

- [x] Stability is not compromised
- [x] Performance impact is understood, tested, and acceptable
- [x] Added logic complexity is justified and explained
- [x] Documentation updated if needed

---

## Notes for Reviewers

Anything that significantly improves realism at the cost of stability or
performance should be carefully discussed
before merging.

---------

Co-authored-by: Nicolas Lebacq <nicolas.cordier@outlook.com>
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
This commit is contained in:
bashermens
2026-01-30 21:49:37 +01:00
committed by GitHub
parent a92886032c
commit 13fff46fa0
233 changed files with 2460 additions and 2354 deletions

View File

@@ -46,10 +46,10 @@ bool AcceptInvitationAction::Execute(Event event)
if (!bot->GetGroup() || !bot->GetGroup()->IsMember(inviter->GetGUID()))
return false;
if (sRandomPlayerbotMgr->IsRandomBot(bot))
if (sRandomPlayerbotMgr.IsRandomBot(bot))
botAI->SetMaster(inviter);
// else
// sPlayerbotRepository->Save(botAI);
// PlayerbotRepository::instance().Save(botAI);
botAI->ResetStrategies();
botAI->ChangeStrategy("+follow,-lfg,-bg", BOT_STATE_NON_COMBAT);
@@ -57,7 +57,7 @@ bool AcceptInvitationAction::Execute(Event event)
botAI->TellMaster("Hello");
if (sPlayerbotAIConfig->summonWhenGroup && bot->GetDistance(inviter) > sPlayerbotAIConfig->sightDistance)
if (sPlayerbotAIConfig.summonWhenGroup && bot->GetDistance(inviter) > sPlayerbotAIConfig.sightDistance)
{
Teleport(inviter, bot, true);
}

View File

@@ -50,7 +50,7 @@ bool ReachAreaTriggerAction::Execute(Event event)
/*forceDestination*/ false);
float distance = bot->GetDistance(at->x, at->y, at->z);
float delay = 1000.0f * distance / bot->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay;
float delay = 1000.0f * distance / bot->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig.reactDelay;
botAI->TellError("Wait for me");
botAI->SetNextCheckDelay(delay);
context->GetValue<LastMovement&>("last area trigger")->Get().lastAreaTrigger = triggerId;

View File

@@ -87,8 +87,8 @@ bool AttackAction::Attack(Unit* target, bool /*with_pet*/ /*true*/)
// Check if bot OR target is in prohibited zone/area (skip for duels)
if ((target->IsPlayer() || target->IsPet()) &&
(!bot->duel || bot->duel->Opponent != target) &&
(sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()) ||
sPlayerbotAIConfig->IsPvpProhibited(target->GetZoneId(), target->GetAreaId())))
(sPlayerbotAIConfig.IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()) ||
sPlayerbotAIConfig.IsPvpProhibited(target->GetZoneId(), target->GetAreaId())))
{
if (verbose)
botAI->TellError("I cannot attack other players in PvP prohibited areas.");
@@ -160,7 +160,7 @@ bool AttackAction::Attack(Unit* target, bool /*with_pet*/ /*true*/)
}
if (botAI->CanMove() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target))
sServerFacade->SetFacingTo(bot, target);
ServerFacade::instance().SetFacingTo(bot, target);
botAI->ChangeEngine(BOT_STATE_COMBAT);

View File

@@ -19,7 +19,7 @@ bool AutoMaintenanceOnLevelupAction::Execute(Event event)
void AutoMaintenanceOnLevelupAction::AutoTeleportForLevel()
{
if (!sPlayerbotAIConfig->autoTeleportForLevel || !sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sPlayerbotAIConfig.autoTeleportForLevel || !sRandomPlayerbotMgr.IsRandomBot(bot))
{
return;
}
@@ -27,13 +27,13 @@ void AutoMaintenanceOnLevelupAction::AutoTeleportForLevel()
{
return;
}
sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
sRandomPlayerbotMgr.RandomTeleportForLevel(bot);
return;
}
void AutoMaintenanceOnLevelupAction::AutoPickTalents()
{
if (!sPlayerbotAIConfig->autoPickTalents || !sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sPlayerbotAIConfig.autoPickTalents || !sRandomPlayerbotMgr.IsRandomBot(bot))
return;
if (bot->GetFreeTalentPoints() <= 0)
@@ -65,10 +65,10 @@ void AutoMaintenanceOnLevelupAction::AutoLearnSpell()
void AutoMaintenanceOnLevelupAction::LearnSpells(std::ostringstream* out)
{
BroadcastHelper::BroadcastLevelup(botAI, bot);
if (sPlayerbotAIConfig->autoLearnTrainerSpells && sRandomPlayerbotMgr->IsRandomBot(bot))
if (sPlayerbotAIConfig.autoLearnTrainerSpells && sRandomPlayerbotMgr.IsRandomBot(bot))
LearnTrainerSpells(out);
if (sPlayerbotAIConfig->autoLearnQuestSpells && sRandomPlayerbotMgr->IsRandomBot(bot))
if (sPlayerbotAIConfig.autoLearnQuestSpells && sRandomPlayerbotMgr.IsRandomBot(bot))
LearnQuestSpells(out);
}
@@ -166,7 +166,7 @@ std::string const AutoMaintenanceOnLevelupAction::FormatSpell(SpellInfo const* s
void AutoMaintenanceOnLevelupAction::AutoUpgradeEquip()
{
if (!sPlayerbotAIConfig->autoUpgradeEquip || !sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sPlayerbotAIConfig.autoUpgradeEquip || !sRandomPlayerbotMgr.IsRandomBot(bot))
return;
PlayerbotFactory factory(bot, bot->GetLevel());
@@ -180,9 +180,9 @@ void AutoMaintenanceOnLevelupAction::AutoUpgradeEquip()
factory.InitConsumables();
factory.InitPotions();
if (!sPlayerbotAIConfig->equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
if (!sPlayerbotAIConfig.equipmentPersistence || bot->GetLevel() < sPlayerbotAIConfig.equipmentPersistenceLevel)
{
if (sPlayerbotAIConfig->incrementalGearInit)
if (sPlayerbotAIConfig.incrementalGearInit)
factory.InitEquipment(true);
}
}

View File

@@ -89,7 +89,7 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
// continue;
if (offline)
sRandomPlayerbotMgr->AddPlayerBot(itr->Guid, 0);
sRandomPlayerbotMgr.AddPlayerBot(itr->Guid, 0);
if (member)
{
@@ -100,7 +100,7 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
if (member->GetGroup() && memberBotAI->HasRealPlayerMaster())
continue;
if (!sPlayerbotAIConfig->IsInRandomAccountList(member->GetSession()->GetAccountId()))
if (!sPlayerbotAIConfig.IsInRandomAccountList(member->GetSession()->GetAccountId()))
continue;
if (member->IsInCombat())
@@ -250,13 +250,13 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
TeamSize = (uint32)type;
// Check if bots should join Rated Arena (Only captains can queue)
uint32 ratedArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount;
uint32 ratedArenaBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount;
uint32 ratedArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) <
(BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
@@ -265,7 +265,7 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
{
if (sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type))
{
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize;
ratedList.push_back(queueTypeId);
return true;
}
@@ -274,13 +274,13 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
// Check if bots should join Skirmish Arena
// We have extra bots queue because same faction can vs each other but can't be in the same group.
uint32 skirmishArenaBotCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount);
if (maxRequiredSkirmishBots != 0)
maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize;
@@ -294,12 +294,12 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
}
// Check if bots should join Battleground
uint32 bgAllianceBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount;
uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount;
uint32 bgHordeBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount;
uint32 bgHordePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount;
uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
uint32 bgAllianceBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount;
uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount;
uint32 bgHordeBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount;
uint32 bgHordePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount;
uint32 activeBgQueue = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
if (teamId == TEAM_ALLIANCE)
{
@@ -318,7 +318,7 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
bool BGJoinAction::isUseful()
{
// do not try if BG bots disabled
if (!sPlayerbotAIConfig->randomBotJoinBG)
if (!sPlayerbotAIConfig.randomBotJoinBG)
return false;
// can't queue while in BG/Arena
@@ -440,7 +440,7 @@ bool BGJoinAction::JoinQueue(uint32 type)
// get battlemaster
// Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId));
Unit* unit = botAI->GetUnit(sRandomPlayerbotMgr->GetBattleMasterGUID(bot, bgTypeId));
Unit* unit = botAI->GetUnit(sRandomPlayerbotMgr.GetBattleMasterGUID(bot, bgTypeId));
if (!unit && isArena)
{
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0);
@@ -450,7 +450,7 @@ bool BGJoinAction::JoinQueue(uint32 type)
// This breaks groups as refresh includes a remove from group function call.
// refresh food/regs
// sRandomPlayerbotMgr->Refresh(bot);
// sRandomPlayerbotMgr.Refresh(bot);
bool joinAsGroup = bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() == bot->GetGUID();
@@ -523,23 +523,23 @@ bool BGJoinAction::JoinQueue(uint32 type)
{
if (!isRated)
{
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount++;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount++;
}
}
else if (!joinAsGroup)
{
if (teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount++;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount++;
else
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++;
}
else
{
if (teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount +=
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount +=
bot->GetGroup()->GetMembersCount();
else
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount +=
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount +=
bot->GetGroup()->GetMembersCount();
}
@@ -588,13 +588,13 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
TeamSize = (uint32)type;
// Check if bots should join Rated Arena (Only captains can queue)
uint32 ratedArenaBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount;
uint32 ratedArenaBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount;
uint32 ratedArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) <
(BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
@@ -603,7 +603,7 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
{
if (sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type))
{
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize;
ratedList.push_back(queueTypeId);
return true;
}
@@ -612,13 +612,13 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
// Check if bots should join Skirmish Arena
// We have extra bots queue because same faction can vs each other but can't be in the same group.
uint32 skirmishArenaBotCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount);
if (maxRequiredSkirmishBots != 0)
maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize;
@@ -632,12 +632,12 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
}
// Check if bots should join Battleground
uint32 bgAllianceBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount;
uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount;
uint32 bgHordeBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount;
uint32 bgHordePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount;
uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
uint32 bgAllianceBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount;
uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount;
uint32 bgHordeBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount;
uint32 bgHordePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount;
uint32 activeBgQueue = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
if (teamId == TEAM_ALLIANCE)
{
@@ -670,7 +670,7 @@ bool BGLeaveAction::Execute(Event event)
uint16 unk = 0x1F90;
uint8 unk2 = 0x0;
bool isArena = false;
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
bool IsRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
ArenaType arenaType = ArenaType(BattlegroundMgr::BGArenaType(queueTypeId));
if (arenaType)
@@ -709,7 +709,7 @@ bool BGStatusAction::LeaveBG(PlayerbotAI* botAI)
if (!bg)
return false;
bool isArena = bg->isArena();
bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
if (isRandomBot)
botAI->SetMaster(nullptr);
@@ -805,7 +805,7 @@ bool BGStatusAction::Execute(Event event)
break;
}
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
bool IsRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(QueueSlot);
BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId);
if (!queueTypeId)
@@ -958,10 +958,10 @@ bool BGStatusAction::Execute(Event event)
//TeamId teamId = bot->GetTeamId(); //not used, line marked for removal.
bool realPlayers = false;
if (isRated)
realPlayers = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount > 0;
realPlayers = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount > 0;
else
realPlayers =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0;
sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0;
if (realPlayers)
return false;

View File

@@ -1276,7 +1276,7 @@ static std::pair<uint32, uint32> IC_AttackObjectives[] = {
// useful commands for fixing BG bugs and checking waypoints/paths
bool BGTactics::HandleConsoleCommand(ChatHandler* handler, char const* args)
{
if (!sPlayerbotAIConfig->enabled)
if (!sPlayerbotAIConfig.enabled)
{
handler->PSendSysMessage("|cffff0000Playerbot system is currently disabled!");
return true;
@@ -2219,7 +2219,7 @@ bool BGTactics::selectObjective(bool reset)
if (urand(0, 99) < 20 && teamFC)
{
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ());
if (sServerFacade->GetDistance2d(bot, teamFC) < 33.0f)
if (ServerFacade::instance().GetDistance2d(bot, teamFC) < 33.0f)
Follow(teamFC);
}
else
@@ -2263,7 +2263,7 @@ bool BGTactics::selectObjective(bool reset)
if (urand(0, 99) < 70)
{
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ());
if (sServerFacade->GetDistance2d(bot, teamFC) < 33.0f)
if (ServerFacade::instance().GetDistance2d(bot, teamFC) < 33.0f)
Follow(teamFC);
}
}
@@ -2284,7 +2284,7 @@ bool BGTactics::selectObjective(bool reset)
{
// Assist own FC if not pursuing enemy FC
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ());
if (sServerFacade->GetDistance2d(bot, teamFC) < 33.0f)
if (ServerFacade::instance().GetDistance2d(bot, teamFC) < 33.0f)
Follow(teamFC);
}
else if (urand(0, 99) < 5)
@@ -3197,11 +3197,11 @@ bool BGTactics::moveToObjective(bool ignoreDist)
return true;
}
if (!ignoreDist && sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y), 100.0f))
if (!ignoreDist && ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y), 100.0f))
{
// std::ostringstream out;
// out << "It is too far away! " << pos.x << ", " << pos.y << ", Distance: " <<
// sServerFacade->GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
// ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
return false;
}
@@ -3213,7 +3213,7 @@ bool BGTactics::moveToObjective(bool ignoreDist)
}
// std::ostringstream out; out << "Moving to objective " << pos.x << ", " << pos.y << ", Distance: " <<
// sServerFacade->GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
// ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y); bot->Say(out.str(), LANG_UNIVERSAL);
// dont increase from 1.5 will cause bugs with horde capping AV towers
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z, 1.5f);
@@ -3433,7 +3433,7 @@ bool BGTactics::moveToObjectiveWp(BattleBotPath* const& currentPath, uint32 curr
// out << "WP: ";
// reverse ? out << currPoint << " <<< -> " << nPoint : out << currPoint << ">>> ->" << nPoint;
// out << ", " << nextPoint.x << ", " << nextPoint.y << " Path Size: " << currentPath->size() << ", Dist: " <<
// sServerFacade->GetDistance2d(bot, nextPoint.x, nextPoint.y); bot->Say(out.str(), LANG_UNIVERSAL);
// ServerFacade::instance().GetDistance2d(bot, nextPoint.x, nextPoint.y); bot->Say(out.str(), LANG_UNIVERSAL);
return MoveTo(bot->GetMapId(), nextPoint.x + frand(-2, 2), nextPoint.y + frand(-2, 2), nextPoint.z);
}
@@ -4039,9 +4039,9 @@ bool BGTactics::useBuff()
if (closeObjects.empty())
return false;
bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig->mediumHealth ||
bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig.mediumHealth ||
(AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana);
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.mediumMana);
bool needSpeed = (bgType != BATTLEGROUND_WS || bot->HasAura(BG_WS_SPELL_WARSONG_FLAG) ||
bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) ||
!(teamFlagTaken() || flagTaken());
@@ -4057,7 +4057,7 @@ bool BGTactics::useBuff()
continue;
// use speed buff only if close
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go),
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, go),
go->GetEntry() == Buff_Entries[0] ? 20.0f : 50.0f))
continue;
@@ -4107,7 +4107,7 @@ uint32 BGTactics::getPlayersInArea(TeamId teamId, Position point, float range, b
if (!combat && player->IsInCombat())
continue;
if (sServerFacade->GetDistance2d(player, point.GetPositionX(), point.GetPositionY()) < range)
if (ServerFacade::instance().GetDistance2d(player, point.GetPositionX(), point.GetPositionY()) < range)
++defCount;
}
}
@@ -4191,9 +4191,9 @@ bool BGTactics::IsLockedInsideKeep()
// get closest portal
if (bot->GetTeamId() == TEAM_ALLIANCE && go->GetEntry() == GO_TELEPORTER_4)
{
float tempDist = sServerFacade->GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
float tempDist = ServerFacade::instance().GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
if (sServerFacade->IsDistanceLessThan(tempDist, closestDistance))
if (ServerFacade::instance().IsDistanceLessThan(tempDist, closestDistance))
{
closestDistance = tempDist;
closestPortal = go;
@@ -4204,9 +4204,9 @@ bool BGTactics::IsLockedInsideKeep()
// get closest portal
if (bot->GetTeamId() == TEAM_HORDE && go->GetEntry() == GO_TELEPORTER_2)
{
float tempDist = sServerFacade->GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
float tempDist = ServerFacade::instance().GetDistance2d(bot, go->GetPositionX(), go->GetPositionY());
if (sServerFacade->IsDistanceLessThan(tempDist, closestDistance))
if (ServerFacade::instance().IsDistanceLessThan(tempDist, closestDistance))
{
closestDistance = tempDist;
closestPortal = go;
@@ -4253,7 +4253,7 @@ bool ArenaTactics::Execute(Event event)
{
if (!bot->InBattleground())
{
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot->GetGUID().GetCounter());
bool IsRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot->GetGUID().GetCounter());
botAI->ChangeStrategy("-arena", BOT_STATE_COMBAT);
botAI->ChangeStrategy("-arena", BOT_STATE_NON_COMBAT);
botAI->ResetStrategies(!IsRandomBot);

View File

@@ -130,10 +130,10 @@ bool CastCustomSpellAction::Execute(Event event)
return false;
}
if (target != bot && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target, sPlayerbotAIConfig->sightDistance))
if (target != bot && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target, sPlayerbotAIConfig.sightDistance))
{
sServerFacade->SetFacingTo(bot, target);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay);
ServerFacade::instance().SetFacingTo(bot, target);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.reactDelay);
msg << "cast " << text;
botAI->HandleCommand(CHAT_MSG_WHISPER, msg.str(), master);
@@ -286,7 +286,7 @@ bool CastRandomSpellAction::Execute(Event event)
if (isCast)
{
if (MultiCast && ((wo && bot->HasInArc(CAST_ANGLE_IN_FRONT, wo, sPlayerbotAIConfig->sightDistance))))
if (MultiCast && ((wo && bot->HasInArc(CAST_ANGLE_IN_FRONT, wo, sPlayerbotAIConfig.sightDistance))))
{
std::ostringstream cmd;
cmd << "castnc " << chat->FormatWorldobject(wo) + " " << spellId << " " << 19;

View File

@@ -24,7 +24,7 @@ bool ChangeCombatStrategyAction::Execute(Event event)
case '+':
case '-':
case '~':
sPlayerbotRepository->Save(botAI);
PlayerbotRepository::instance().Save(botAI);
break;
case '?':
break;
@@ -40,7 +40,7 @@ bool ChangeNonCombatStrategyAction::Execute(Event event)
std::string const text = event.getParam();
uint32 account = bot->GetSession()->GetAccountId();
if (sPlayerbotAIConfig->IsInRandomAccountList(account) && botAI->GetMaster() &&
if (sPlayerbotAIConfig.IsInRandomAccountList(account) && botAI->GetMaster() &&
botAI->GetMaster()->GetSession()->GetSecurity() < SEC_GAMEMASTER)
{
if (text.find("loot") != std::string::npos || text.find("gather") != std::string::npos)
@@ -62,7 +62,7 @@ bool ChangeNonCombatStrategyAction::Execute(Event event)
case '+':
case '-':
case '~':
sPlayerbotRepository->Save(botAI);
PlayerbotRepository::instance().Save(botAI);
break;
case '?':
break;

View File

@@ -110,20 +110,20 @@ std::string ChangeTalentsAction::SpecList()
std::ostringstream out;
for (int specNo = 0; specNo < MAX_SPECNO; ++specNo)
{
if (sPlayerbotAIConfig->premadeSpecName[cls][specNo].size() == 0)
if (sPlayerbotAIConfig.premadeSpecName[cls][specNo].size() == 0)
{
break;
}
specFound++;
std::ostringstream out;
std::vector<std::vector<uint32>> parsed = sPlayerbotAIConfig->parsedSpecLinkOrder[cls][specNo][80];
std::vector<std::vector<uint32>> parsed = sPlayerbotAIConfig.parsedSpecLinkOrder[cls][specNo][80];
std::unordered_map<int, int> tabCount;
tabCount[0] = tabCount[1] = tabCount[2] = 0;
for (auto& item : parsed)
{
tabCount[item[0]] += item[3];
}
out << specFound << ". " << sPlayerbotAIConfig->premadeSpecName[cls][specNo] << " (";
out << specFound << ". " << sPlayerbotAIConfig.premadeSpecName[cls][specNo] << " (";
out << tabCount[0] << "-" << tabCount[1] << "-" << tabCount[2] << ")";
botAI->TellMasterNoFacing(out.str());
}
@@ -137,11 +137,11 @@ std::string ChangeTalentsAction::SpecPick(std::string param)
// int specFound = 0; //not used, line marked for removal.
for (int specNo = 0; specNo < MAX_SPECNO; ++specNo)
{
if (sPlayerbotAIConfig->premadeSpecName[cls][specNo].size() == 0)
if (sPlayerbotAIConfig.premadeSpecName[cls][specNo].size() == 0)
{
break;
}
if (sPlayerbotAIConfig->premadeSpecName[cls][specNo] == param)
if (sPlayerbotAIConfig.premadeSpecName[cls][specNo] == param)
{
PlayerbotFactory::InitTalentsBySpecNo(bot, specNo, true);
@@ -149,7 +149,7 @@ std::string ChangeTalentsAction::SpecPick(std::string param)
factory.InitGlyphs(false);
std::ostringstream out;
out << "Picking " << sPlayerbotAIConfig->premadeSpecName[cls][specNo];
out << "Picking " << sPlayerbotAIConfig.premadeSpecName[cls][specNo];
return out.str();
}
}
@@ -176,7 +176,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// std::vector<TalentPath*> ChangeTalentsAction::getPremadePaths(std::string const findName)
// {
// std::vector<TalentPath*> ret;
// // for (auto& path : sPlayerbotAIConfig->classSpecs[bot->getClass()].talentPath)
// // for (auto& path : sPlayerbotAIConfig.classSpecs[bot->getClass()].talentPath)
// // {
// // if (findName.empty() || path.name.find(findName) != std::string::npos)
// // {
@@ -191,7 +191,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// {
// std::vector<TalentPath*> ret;
// // for (auto& path : sPlayerbotAIConfig->classSpecs[bot->getClass()].talentPath)
// // for (auto& path : sPlayerbotAIConfig.classSpecs[bot->getClass()].talentPath)
// // {
// // TalentSpec newSpec = *GetBestPremadeSpec(path.id);
// // newSpec.CropTalents(bot->GetLevel());
@@ -206,7 +206,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// TalentPath* ChangeTalentsAction::getPremadePath(uint32 id)
// {
// // for (auto& path : sPlayerbotAIConfig->classSpecs[bot->getClass()].talentPath)
// // for (auto& path : sPlayerbotAIConfig.classSpecs[bot->getClass()].talentPath)
// // {
// // if (id == path.id)
// // {
@@ -214,7 +214,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// // }
// // }
// // return &sPlayerbotAIConfig->classSpecs[bot->getClass()].talentPath[0];
// // return &sPlayerbotAIConfig.classSpecs[bot->getClass()].talentPath[0];
// return nullptr;
// }
@@ -270,9 +270,9 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// return false;
// }
// uint32 specNo = sRandomPlayerbotMgr->GetValue(bot->GetGUID().GetCounter(), "specNo");
// uint32 specNo = sRandomPlayerbotMgr.GetValue(bot->GetGUID().GetCounter(), "specNo");
// uint32 specId = specNo - 1;
// std::string specLink = sRandomPlayerbotMgr->GetData(bot->GetGUID().GetCounter(), "specLink");
// std::string specLink = sRandomPlayerbotMgr.GetData(bot->GetGUID().GetCounter(), "specLink");
// //Continue the current spec
// if (specNo > 0)
@@ -319,15 +319,15 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// specId = -1;
// // specLink = "";
// }
// else if (paths.size() > 1 && false/*!sPlayerbotAIConfig->autoPickTalents*/ &&
// !sRandomPlayerbotMgr->IsRandomBot(bot))
// else if (paths.size() > 1 && false/*!sPlayerbotAIConfig.autoPickTalents*/ &&
// !sRandomPlayerbotMgr.IsRandomBot(bot))
// {
// *out << "Found multiple specs: ";
// listPremadePaths(paths, out);
// }
// else
// {
// specId = PickPremadePath(paths, sRandomPlayerbotMgr->IsRandomBot(bot))->id;
// specId = PickPremadePath(paths, sRandomPlayerbotMgr.IsRandomBot(bot))->id;
// TalentSpec newSpec = *GetBestPremadeSpec(specId);
// specLink = newSpec.GetTalentLink();
// newSpec.CropTalents(bot->GetLevel());
@@ -341,12 +341,12 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// }
// }
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", specId + 1);
// sRandomPlayerbotMgr.SetValue(bot->GetGUID().GetCounter(), "specNo", specId + 1);
// if (!specLink.empty() && specId == -1)
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specLink", 1, specLink);
// sRandomPlayerbotMgr.SetValue(bot->GetGUID().GetCounter(), "specLink", 1, specLink);
// else
// sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specLink", 0);
// sRandomPlayerbotMgr.SetValue(bot->GetGUID().GetCounter(), "specLink", 0);
// return (specNo == 0) ? false : true;
// }
@@ -364,7 +364,7 @@ std::string ChangeTalentsAction::SpecApply(std::string param)
// if (path->talentSpec.size())
// return &path->talentSpec.back();
// // return &sPlayerbotAIConfig->classSpecs[bot->getClassMask()].baseSpec;
// // return &sPlayerbotAIConfig.classSpecs[bot->getClassMask()].baseSpec;
// return nullptr;
// }
@@ -372,7 +372,7 @@ bool AutoSetTalentsAction::Execute(Event event)
{
std::ostringstream out;
if (!sPlayerbotAIConfig->autoPickTalents || !sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sPlayerbotAIConfig.autoPickTalents || !sRandomPlayerbotMgr.IsRandomBot(bot))
return false;
if (bot->GetFreeTalentPoints() <= 0)

View File

@@ -96,7 +96,7 @@ bool FollowChatShortcutAction::Execute(Event event)
/* Default mechanics takes care of this now.
if (bot->GetMapId() != master->GetMapId() || (master && bot->GetDistance(master) >
sPlayerbotAIConfig->sightDistance))
sPlayerbotAIConfig.sightDistance))
{
if (bot->isDead())
{
@@ -161,7 +161,7 @@ bool FleeChatShortcutAction::Execute(Event event)
ResetReturnPosition();
ResetStayPosition();
if (bot->GetMapId() != master->GetMapId() || bot->GetDistance(master) > sPlayerbotAIConfig->sightDistance)
if (bot->GetMapId() != master->GetMapId() || bot->GetDistance(master) > sPlayerbotAIConfig.sightDistance)
{
botAI->TellError("I will not flee with you - too far away");
return true;

View File

@@ -86,7 +86,7 @@ void CheatAction::ListCheats()
for (int i = 0; i < log2((uint32)BotCheatMask::maxMask); i++)
{
BotCheatMask cheatMask = BotCheatMask(1 << i);
if ((uint32)cheatMask & (uint32)sPlayerbotAIConfig->botCheatMask)
if ((uint32)cheatMask & (uint32)sPlayerbotAIConfig.botCheatMask)
out << "[conf:" << GetCheatName(BotCheatMask(cheatMask)) << "]";
else if (botAI->HasCheat(cheatMask))
out << "[" << GetCheatName(BotCheatMask(cheatMask)) << "]";

View File

@@ -28,7 +28,7 @@ bool CheckMailAction::Execute(Event event)
continue;
uint32 account = owner->GetSession()->GetAccountId();
if (sPlayerbotAIConfig->IsInRandomAccountList(account))
if (sPlayerbotAIConfig.IsInRandomAccountList(account))
continue;
ProcessMail(mail, owner, trans);
@@ -80,7 +80,7 @@ void CheckMailAction::ProcessMail(Mail* mail, Player* owner, CharacterDatabaseTr
if (!item)
continue;
if (!sGuildTaskMgr->CheckItemTask(i->item_template, item->GetCount(), owner, bot, true))
if (!GuildTaskMgr::instance().CheckItemTask(i->item_template, item->GetCount(), owner, bot, true))
{
std::ostringstream body;
body << "Hello, " << owner->GetName() << ",\n";

View File

@@ -89,7 +89,7 @@ bool CheckMountStateAction::isUseful()
return false;
// Not useful when level lower than minimum required
if (bot->GetLevel() < sPlayerbotAIConfig->useGroundMountAtMinLevel)
if (bot->GetLevel() < sPlayerbotAIConfig.useGroundMountAtMinLevel)
return false;
// Allow mounting while transformed only if the form allows it
@@ -402,7 +402,7 @@ float CheckMountStateAction::CalculateDismountDistance() const
// Warrior bots should dismount far enough to charge (because it's important for generating some initial rage),
// a real player would be riding toward enemy mashing the charge key but the bots won't cast charge while mounted.
bool isMelee = PlayerbotAI::IsMelee(bot);
float dismountDistance = isMelee ? sPlayerbotAIConfig->meleeDistance + 2.0f : sPlayerbotAIConfig->spellDistance + 2.0f;
float dismountDistance = isMelee ? sPlayerbotAIConfig.meleeDistance + 2.0f : sPlayerbotAIConfig.spellDistance + 2.0f;
return bot->getClass() == CLASS_WARRIOR ? std::max(18.0f, dismountDistance) : dismountDistance;
}
@@ -413,7 +413,7 @@ float CheckMountStateAction::CalculateMountDistance() const
// seconds:
// 21 / 7 = 21 / 14 + 1.5 = 3 (7 = dismounted speed 14 = epic-mount speed 1.5 = mount-spell cast time)
bool isMelee = PlayerbotAI::IsMelee(bot);
float baseDistance = isMelee ? sPlayerbotAIConfig->meleeDistance + 10.0f : sPlayerbotAIConfig->spellDistance + 10.0f;
float baseDistance = isMelee ? sPlayerbotAIConfig.meleeDistance + 10.0f : sPlayerbotAIConfig.spellDistance + 10.0f;
return std::max(21.0f, baseDistance);
}
@@ -440,7 +440,7 @@ int32 CheckMountStateAction::CalculateMasterMountSpeed(Player* master, const Mou
int32 ridingSkill = bot->GetPureSkillValue(SKILL_RIDING);
int32 botLevel = bot->GetLevel();
if (ridingSkill <= 75 && botLevel < static_cast<int32>(sPlayerbotAIConfig->useFastGroundMountAtMinLevel))
if (ridingSkill <= 75 && botLevel < static_cast<int32>(sPlayerbotAIConfig.useFastGroundMountAtMinLevel))
return 59;
// If there is a master and bot not in BG, use master's aura effects.

View File

@@ -20,7 +20,7 @@ bool CheckValuesAction::Execute(Event event)
if (botAI->HasStrategy("map", BOT_STATE_NON_COMBAT) || botAI->HasStrategy("map full", BOT_STATE_NON_COMBAT))
{
sTravelNodeMap->manageNodes(bot, botAI->HasStrategy("map full", BOT_STATE_NON_COMBAT));
TravelNodeMap::instance().manageNodes(bot, botAI->HasStrategy("map full", BOT_STATE_NON_COMBAT));
}
GuidVector possible_targets = *context->GetValue<GuidVector>("possible targets");

View File

@@ -248,7 +248,7 @@ bool ChooseRpgTargetAction::Execute(Event event)
}
std::mt19937 gen(time(0));
sTravelMgr->weighted_shuffle(guidps.begin(), guidps.end(), relevances.begin(), relevances.end(), gen);
TravelMgr::instance().weighted_shuffle(guidps.begin(), guidps.end(), relevances.begin(), relevances.end(), gen);
GuidPosition guidP(guidps.front());
if (!guidP)
@@ -279,7 +279,7 @@ bool ChooseRpgTargetAction::isUseful()
GuidPosition guidP = AI_VALUE(GuidPosition, "rpg target");
if (guidP && guidP.distance(bot) < sPlayerbotAIConfig->reactDistance * 2)
if (guidP && guidP.distance(bot) < sPlayerbotAIConfig.reactDistance * 2)
return false;
// TravelTarget* travelTarget = AI_VALUE(TravelTarget*, "travel target"); //not used, line marked for removal.
@@ -330,7 +330,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
return true;
if (bot->GetDistance(groupLeader) > sPlayerbotAIConfig->rpgDistance * 2)
if (bot->GetDistance(groupLeader) > sPlayerbotAIConfig.rpgDistance * 2)
return false;
Formation* formation = AI_VALUE(Formation*, "formation");
@@ -340,7 +340,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
{
Player* player = groupLeader;
if (groupLeader && !groupLeader->isMoving() ||
PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig->reactDistance)
PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig.reactDistance)
return true;
}

View File

@@ -20,13 +20,13 @@ bool AttackEnemyPlayerAction::isUseful()
if (PlayerHasFlag::IsCapturingFlag(bot))
return false;
return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
return !sPlayerbotAIConfig.IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
}
bool AttackEnemyFlagCarrierAction::isUseful()
{
Unit* target = context->GetValue<Unit*>("enemy flag carrier")->Get();
return target && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target), 100.0f) &&
return target && ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target), 100.0f) &&
PlayerHasFlag::IsCapturingFlag(bot);
}

View File

@@ -366,7 +366,7 @@ bool ChooseTravelTargetAction::getBestDestination(std::vector<TravelDestination*
WorldPosition botLocation(bot);
std::vector<WorldPosition*> availablePoints =
sTravelMgr->getNextPoint(&botLocation, *activePoints); // Pick a good point.
TravelMgr::instance().getNextPoint(&botLocation, *activePoints); // Pick a good point.
if (availablePoints.empty()) // No points available.
return false;
@@ -488,7 +488,7 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom
if (newQuests)
{
// Prefer new quests near the player at lower levels.
activeDestinations = sTravelMgr->getQuestTravelDestinations(bot, -1, true, false, 400 + bot->GetLevel() * 10);
activeDestinations = TravelMgr::instance().getQuestTravelDestinations(bot, -1, true, false, 400 + bot->GetLevel() * 10);
}
if (activeQuests || completedQuests)
{
@@ -510,7 +510,7 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom
continue;
//Find quest takers or objectives
std::vector<TravelDestination*> questDestinations = sTravelMgr->getQuestTravelDestinations(bot, questId, true, false, 0);
std::vector<TravelDestination*> questDestinations = TravelMgr::instance().getQuestTravelDestinations(bot, questId, true, false, 0);
if (onlyClassQuest && activeDestinations.size() && questDestinations.size()) //Only do class quests if we have any.
{
@@ -525,7 +525,7 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom
}
}
if (newQuests && activeDestinations.empty())
activeDestinations = sTravelMgr->getQuestTravelDestinations(bot, -1, true, false); //If we really don't find any new quests look futher away.
activeDestinations = TravelMgr::instance().getQuestTravelDestinations(bot, -1, true, false); //If we really don't find any new quests look futher away.
if (botAI->HasStrategy("debug travel", BotState::BOT_STATE_NON_COMBAT))
botAI->TellMasterNoFacing(std::to_string(activeDestinations.size()) + " quest destinations found.");
@@ -547,7 +547,7 @@ bool ChooseTravelTargetAction::SetNewQuestTarget(TravelTarget* target)
// Find quest givers.
std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getQuestTravelDestinations(bot, -1, botAI->HasRealPlayerMaster());
TravelMgr::instance().getQuestTravelDestinations(bot, -1, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -576,7 +576,7 @@ bool ChooseTravelTargetAction::SetRpgTarget(TravelTarget* target)
// Find rpg npcs
std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getRpgTravelDestinations(bot, botAI->HasRealPlayerMaster());
TravelMgr::instance().getRpgTravelDestinations(bot, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -605,7 +605,7 @@ bool ChooseTravelTargetAction::SetGrindTarget(TravelTarget* target)
// Find grind mobs.
std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getGrindTravelDestinations(bot, botAI->HasRealPlayerMaster());
TravelMgr::instance().getGrindTravelDestinations(bot, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -634,7 +634,7 @@ bool ChooseTravelTargetAction::SetBossTarget(TravelTarget* target)
// Find boss mobs.
std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getBossTravelDestinations(bot, botAI->HasRealPlayerMaster());
TravelMgr::instance().getBossTravelDestinations(bot, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -662,7 +662,7 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target)
WorldPosition botLocation(bot);
// Find quest givers.
std::vector<TravelDestination*> TravelDestinations = sTravelMgr->getExploreTravelDestinations(bot, true, true);
std::vector<TravelDestination*> TravelDestinations = TravelMgr::instance().getExploreTravelDestinations(bot, true, true);
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
/*
@@ -681,7 +681,7 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target)
if (activePoints.empty())
{
TravelDestinations = sTravelMgr->getExploreTravelDestinations(bot, botAI->HasRealPlayerMaster());
TravelDestinations = TravelMgr::instance().getExploreTravelDestinations(bot, botAI->HasRealPlayerMaster());
for (auto& activeTarget : activeDestinations)
{
@@ -710,7 +710,7 @@ bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vecto
std::vector<TravelDestination*> dests;
for (auto& d : sTravelMgr->getRpgTravelDestinations(bot, true, true))
for (auto& d : TravelMgr::instance().getRpgTravelDestinations(bot, true, true))
{
if (!d->getEntry())
continue;
@@ -813,7 +813,7 @@ std::vector<TravelDestination*> TravelMgr::getBossTravelDestinations(Player* bot
bool ChooseTravelTargetAction::SetNullTarget(TravelTarget* target)
{
target->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true);
target->setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition, true);
return true;
}
@@ -832,7 +832,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Quests
if (quests)
{
for (auto& d : sTravelMgr->getQuestTravelDestinations(bot, 0, true, true))
for (auto& d : TravelMgr::instance().getQuestTravelDestinations(bot, 0, true, true))
{
if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d);
@@ -842,7 +842,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Zones
if (zones)
{
for (auto& d : sTravelMgr->getExploreTravelDestinations(bot, true, true))
for (auto& d : TravelMgr::instance().getExploreTravelDestinations(bot, true, true))
{
if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d);
@@ -852,7 +852,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Npcs
if (npcs)
{
for (auto& d : sTravelMgr->getRpgTravelDestinations(bot, true, true))
for (auto& d : TravelMgr::instance().getRpgTravelDestinations(bot, true, true))
{
if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d);
@@ -862,7 +862,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Mobs
if (mobs)
{
for (auto& d : sTravelMgr->getGrindTravelDestinations(bot, true, true, 5000.0f))
for (auto& d : TravelMgr::instance().getGrindTravelDestinations(bot, true, true, 5000.0f))
{
if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d);
@@ -872,7 +872,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Bosses
if (bosses)
{
for (auto& d : sTravelMgr->getBossTravelDestinations(bot, true, true))
for (auto& d : TravelMgr::instance().getBossTravelDestinations(bot, true, true))
{
if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d);

View File

@@ -25,7 +25,7 @@ bool SwitchToMeleeAction::isUseful()
return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) &&
((bot->IsInCombat() && target &&
(target->GetVictim() == bot && (!bot->GetGroup() || lastFlee) &&
sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) ||
ServerFacade::instance().IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) ||
(!bot->IsInCombat()));
}
@@ -47,7 +47,7 @@ bool SwitchToRangedAction::isUseful()
return botAI->HasStrategy("close", BOT_STATE_COMBAT) && hasAmmo &&
((bot->IsInCombat() && target &&
((target->GetVictim() != bot || target->GetTarget() != bot->GetGUID()) ||
sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) ||
ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"), 8.0f))) ||
(!bot->IsInCombat()));
}

View File

@@ -19,7 +19,7 @@ bool DebugAction::Execute(Event event)
if (text == "scan")
{
sPlayerbotAIConfig->openLog("scan.csv", "w");
sPlayerbotAIConfig.openLog("scan.csv", "w");
uint32 i = 0;
for (auto p : WorldPosition().getCreaturesNear())
@@ -36,15 +36,15 @@ bool DebugAction::Execute(Event event)
pos.printWKT(out);
sPlayerbotAIConfig->log("scan.csv", out.str().c_str());
sPlayerbotAIConfig.log("scan.csv", out.str().c_str());
if (zoneId == 0 && areaId == 0)
{
sPlayerbotAIConfig->log("x", out.str().c_str());
sPlayerbotAIConfig.log("x", out.str().c_str());
}
else
{
sPlayerbotAIConfig->log("y", out.str().c_str());
sPlayerbotAIConfig.log("y", out.str().c_str());
}
i = zoneId;
@@ -53,8 +53,8 @@ bool DebugAction::Execute(Event event)
}
else if (text.find("printmap") != std::string::npos)
{
sTravelNodeMap->printMap();
sTravelNodeMap->printNodeStore();
TravelNodeMap::instance().printMap();
TravelNodeMap::instance().printNodeStore();
return true;
}
else if (text.find("travel ") != std::string::npos)
@@ -72,7 +72,7 @@ bool DebugAction::Execute(Event event)
return false;
std::vector<WorldPosition> beginPath, endPath;
TravelNodeRoute route = sTravelNodeMap->getRoute(botPos, *points.front(), beginPath, bot);
TravelNodeRoute route = TravelNodeMap::instance().getRoute(botPos, *points.front(), beginPath, bot);
std::ostringstream out;
out << "Traveling to " << dest->getTitle() << ": ";
@@ -108,7 +108,7 @@ bool DebugAction::Execute(Event event)
out << quest->GetTitle() << ": ";
QuestContainer* cont = sTravelMgr->quests[questId];
QuestContainer* cont = TravelMgr::instance().quests[questId];
for (auto g : cont->questGivers)
{
@@ -135,11 +135,11 @@ bool DebugAction::Execute(Event event)
else if (text.find("quest") != std::string::npos)
{
std::ostringstream out;
out << sTravelMgr->quests.size() << " quests ";
out << TravelMgr::instance().quests.size() << " quests ";
uint32 noT = 0, noG = 0, noO = 0;
for (auto q : sTravelMgr->quests)
for (auto q : TravelMgr::instance().quests)
{
if (q.second->questGivers.empty())
noG++;
@@ -164,7 +164,7 @@ bool DebugAction::Execute(Event event)
// uint32 noT = 0, noG = 0, noO = 0; //not used, line marked for removal.
for (auto q : sTravelMgr->quests)
for (auto q : TravelMgr::instance().quests)
{
Quest const* quest = sObjectMgr->GetQuestTemplate(q.first);
@@ -194,16 +194,16 @@ bool DebugAction::Execute(Event event)
std::string const name = "USER:" + text.substr(9);
/* TravelNode* startNode = */ sTravelNodeMap->addNode(pos, name, false, false); // startNode not used, but addNode as side effect, fragment marked for removal.
/* TravelNode* startNode = */ TravelNodeMap::instance().addNode(pos, name, false, false); // startNode not used, but addNode as side effect, fragment marked for removal.
for (auto& endNode : sTravelNodeMap->getNodes(pos, 2000))
for (auto& endNode : TravelNodeMap::instance().getNodes(pos, 2000))
{
endNode->setLinked(false);
}
botAI->TellMasterNoFacing("Node " + name + " created.");
sTravelNodeMap->setHasToGen();
TravelNodeMap::instance().setHasToGen();
return true;
}
@@ -211,7 +211,7 @@ bool DebugAction::Execute(Event event)
{
WorldPosition pos(bot);
TravelNode* startNode = sTravelNodeMap->getNode(pos, nullptr, 50);
TravelNode* startNode = TravelNodeMap::instance().getNode(pos, nullptr, 50);
if (!startNode)
return false;
@@ -221,24 +221,24 @@ bool DebugAction::Execute(Event event)
botAI->TellMasterNoFacing("Node can not be removed.");
}
sTravelNodeMap->m_nMapMtx.lock();
sTravelNodeMap->removeNode(startNode);
TravelNodeMap::instance().m_nMapMtx.lock();
TravelNodeMap::instance().removeNode(startNode);
botAI->TellMasterNoFacing("Node removed.");
sTravelNodeMap->m_nMapMtx.unlock();
TravelNodeMap::instance().m_nMapMtx.unlock();
sTravelNodeMap->setHasToGen();
TravelNodeMap::instance().setHasToGen();
return true;
}
else if (text.find("reset node") != std::string::npos)
{
for (auto& node : sTravelNodeMap->getNodes())
for (auto& node : TravelNodeMap::instance().getNodes())
node->setLinked(false);
return true;
}
else if (text.find("reset path") != std::string::npos)
{
for (auto& node : sTravelNodeMap->getNodes())
for (auto& node : TravelNodeMap::instance().getNodes())
for (auto& path : *node->getLinks())
node->removeLinkTo(path.first, true);
return true;
@@ -246,23 +246,23 @@ bool DebugAction::Execute(Event event)
else if (text.find("gen node") != std::string::npos)
{
// Pathfinder
sTravelNodeMap->generateNodes();
TravelNodeMap::instance().generateNodes();
return true;
}
else if (text.find("gen path") != std::string::npos)
{
sTravelNodeMap->generatePaths();
TravelNodeMap::instance().generatePaths();
return true;
}
else if (text.find("crop path") != std::string::npos)
{
sTravelNodeMap->removeUselessPaths();
TravelNodeMap::instance().removeUselessPaths();
return true;
}
else if (text.find("save node") != std::string::npos)
{
sTravelNodeMap->printNodeStore();
sTravelNodeMap->saveNodeStore();
TravelNodeMap::instance().printNodeStore();
TravelNodeMap::instance().saveNodeStore();
return true;
}
else if (text.find("load node") != std::string::npos)
@@ -270,8 +270,8 @@ bool DebugAction::Execute(Event event)
std::thread t(
[]
{
sTravelNodeMap->removeNodes();
sTravelNodeMap->loadNodeStore();
TravelNodeMap::instance().removeNodes();
TravelNodeMap::instance().loadNodeStore();
});
t.detach();
@@ -282,7 +282,7 @@ bool DebugAction::Execute(Event event)
{
WorldPosition pos(bot);
std::vector<TravelNode*> nodes = sTravelNodeMap->getNodes(pos, 500);
std::vector<TravelNode*> nodes = TravelNodeMap::instance().getNodes(pos, 500);
for (auto& node : nodes)
{

View File

@@ -10,7 +10,7 @@
bool DelayAction::Execute(Event event)
{
uint32 delay = sPlayerbotAIConfig->passiveDelay + sPlayerbotAIConfig->globalCoolDown;
uint32 delay = sPlayerbotAIConfig.passiveDelay + sPlayerbotAIConfig.globalCoolDown;
botAI->SetNextCheckDelay(delay);

View File

@@ -67,7 +67,7 @@ bool CleanQuestLogAction::Execute(Event event)
return false;
}
if (!sPlayerbotAIConfig->dropObsoleteQuests)
if (!sPlayerbotAIConfig.dropObsoleteQuests)
{
return false;
}

View File

@@ -88,7 +88,7 @@ void EmoteActionBase::InitEmotes()
bool EmoteActionBase::Emote(Unit* target, uint32 type, bool textEmote)
{
if (target && !bot->HasInArc(static_cast<float>(M_PI), target, sPlayerbotAIConfig->sightDistance))
if (target && !bot->HasInArc(static_cast<float>(M_PI), target, sPlayerbotAIConfig.sightDistance))
bot->SetFacingToObject(target);
ObjectGuid oldSelection = bot->GetTarget();
@@ -100,7 +100,7 @@ bool EmoteActionBase::Emote(Unit* target, uint32 type, bool textEmote)
if (player)
{
PlayerbotAI* playerBotAI = GET_PLAYERBOT_AI(player);
if (playerBotAI && !player->HasInArc(static_cast<float>(M_PI), bot, sPlayerbotAIConfig->sightDistance))
if (playerBotAI && !player->HasInArc(static_cast<float>(M_PI), bot, sPlayerbotAIConfig.sightDistance))
{
player->SetFacingToObject(bot);
}
@@ -133,7 +133,7 @@ Unit* EmoteActionBase::GetTarget()
for (GuidVector::iterator i = nfp.begin(); i != nfp.end(); ++i)
{
Unit* unit = botAI->GetUnit(*i);
if (unit && sServerFacade->GetDistance2d(bot, unit) < sPlayerbotAIConfig->tooCloseDistance)
if (unit && ServerFacade::instance().GetDistance2d(bot, unit) < sPlayerbotAIConfig.tooCloseDistance)
targets.push_back(unit);
}
@@ -618,8 +618,8 @@ bool EmoteActionBase::ReceiveEmote(Player* source, uint32 emote, bool verbal)
break;
}
if (source && !bot->isMoving() && !bot->HasInArc(static_cast<float>(M_PI), source, sPlayerbotAIConfig->farDistance))
sServerFacade->SetFacingTo(bot, source);
if (source && !bot->isMoving() && !bot->HasInArc(static_cast<float>(M_PI), source, sPlayerbotAIConfig.farDistance))
ServerFacade::instance().SetFacingTo(bot, source);
if (verbal)
{
@@ -689,7 +689,7 @@ bool EmoteAction::Execute(Event event)
p >> emoteId >> source;
pSource = ObjectAccessor::FindPlayer(source);
if (pSource && pSource != bot && sServerFacade->GetDistance2d(bot, pSource) < sPlayerbotAIConfig->farDistance &&
if (pSource && pSource != bot && ServerFacade::instance().GetDistance2d(bot, pSource) < sPlayerbotAIConfig.farDistance &&
emoteId != EMOTE_ONESHOT_NONE)
{
if ((pSource->GetGUID() != bot->GetGUID()) &&
@@ -737,7 +737,7 @@ bool EmoteAction::Execute(Event event)
// time_t lastEmote = AI_VALUE2(time_t, "last emote", qualifier); //not used, line marked for removal.
botAI->GetAiObjectContext()
->GetValue<time_t>("last emote", qualifier)
->Set(time(nullptr) + urand(1000, sPlayerbotAIConfig->repeatDelay) / 1000);
->Set(time(nullptr) + urand(1000, sPlayerbotAIConfig.repeatDelay) / 1000);
param = qualifier;
}

View File

@@ -330,7 +330,7 @@ void EquipAction::EquipItem(Item* item)
bool EquipUpgradesAction::Execute(Event event)
{
if (!sPlayerbotAIConfig->autoEquipUpgradeLoot && !sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sPlayerbotAIConfig.autoEquipUpgradeLoot && !sRandomPlayerbotMgr.IsRandomBot(bot))
return false;
if (event.GetSource() == "trade status")

View File

@@ -272,9 +272,9 @@ bool MoveNearWaterAction::isPossible()
float fishingSearchWindow;
if (master)
fishingSearchWindow = sPlayerbotAIConfig->fishingDistanceFromMaster;
fishingSearchWindow = sPlayerbotAIConfig.fishingDistanceFromMaster;
else
fishingSearchWindow = sPlayerbotAIConfig->fishingDistance;
fishingSearchWindow = sPlayerbotAIConfig.fishingDistance;
WorldPosition fishingHole = FindFishingHole(botAI);
@@ -385,7 +385,7 @@ bool EquipFishingPoleAction::isUseful()
}
}
if (sRandomPlayerbotMgr->IsRandomBot(bot))
if (sRandomPlayerbotMgr.IsRandomBot(bot))
{
bot->StoreNewItemInBestSlots(FISHING_POLE, 1); // Try to get a fishing pole
return true;
@@ -396,7 +396,7 @@ bool EquipFishingPoleAction::isUseful()
return false;
std::string masterName = master->GetName();
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"no_fishing_pole_error", "I don't have a Fishing Pole",{});
botAI->Whisper(text, masterName);
@@ -499,7 +499,7 @@ bool EndMasterFishingAction::isUseful()
return false;
WorldPosition nearWater = FindWaterRadial(bot, bot->GetPositionX(), bot->GetPositionY(), bot->GetPositionZ(),
bot->GetMap(), bot->GetPhaseMask(), MIN_DISTANCE_TO_WATER, sPlayerbotAIConfig->endFishingWithMaster, 10.0f);
bot->GetMap(), bot->GetPhaseMask(), MIN_DISTANCE_TO_WATER, sPlayerbotAIConfig.endFishingWithMaster, 10.0f);
return !nearWater.IsValid();
}

View File

@@ -44,7 +44,7 @@ bool FollowAction::Execute(Event event)
// botAI->PetFollow();
// }
// if (moved)
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay);
// botAI->SetNextCheckDelay(sPlayerbotAIConfig.reactDelay);
return moved;
}
@@ -98,9 +98,9 @@ bool FollowAction::isUseful()
distance = bot->GetDistance(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ());
}
if (botAI->HasStrategy("master fishing", BOT_STATE_NON_COMBAT))
return sServerFacade->IsDistanceGreaterThan(distance, sPlayerbotAIConfig->fishingDistanceFromMaster);
return ServerFacade::instance().IsDistanceGreaterThan(distance, sPlayerbotAIConfig.fishingDistanceFromMaster);
return sServerFacade->IsDistanceGreaterThan(distance, formation->GetMaxDistance());
return ServerFacade::instance().IsDistanceGreaterThan(distance, formation->GetMaxDistance());
}
bool FollowAction::CanDeadFollow(Unit* target)
@@ -130,7 +130,7 @@ bool FleeToGroupLeaderAction::Execute(Event event)
WorldPosition bosPos(bot);
float distance = bosPos.fDist(targetPos);
if (distance < sPlayerbotAIConfig->reactDistance * 3)
if (distance < sPlayerbotAIConfig.reactDistance * 3)
{
if (!urand(0, 3))
botAI->TellMaster("I am close, wait for me!");

View File

@@ -113,7 +113,7 @@ bool TogglePetSpellAutoCastAction::Execute(Event event)
}
// Debug message if pet spells have been toggled and debug is enabled
if (toggled && sPlayerbotAIConfig->petChatCommandDebug == 1)
if (toggled && sPlayerbotAIConfig.petChatCommandDebug == 1)
botAI->TellMaster("Pet autocast spells have been toggled.");
return toggled;
@@ -185,7 +185,7 @@ bool SetPetStanceAction::Execute(Event /*event*/)
}
// Get the default pet stance from the configuration
int32 stance = sPlayerbotAIConfig->defaultPetStance;
int32 stance = sPlayerbotAIConfig.defaultPetStance;
ReactStates react = REACT_DEFENSIVE;
std::string stanceText = "defensive (from config, fallback)";
@@ -221,7 +221,7 @@ bool SetPetStanceAction::Execute(Event /*event*/)
}
// If debug is enabled in config, inform the master of the new stance
if (sPlayerbotAIConfig->petChatCommandDebug == 1)
if (sPlayerbotAIConfig.petChatCommandDebug == 1)
botAI->TellMaster("Pet stance set to " + stanceText + " (applied to all pets/guardians).");
return true;

View File

@@ -87,7 +87,7 @@ namespace ai::buff
{
std::string castName = baseName;
Group* g = bot->GetGroup();
if (!g || g->GetMembersCount() < static_cast<uint32>(sPlayerbotAIConfig->minBotsForGreaterBuff))
if (!g || g->GetMembersCount() < static_cast<uint32>(sPlayerbotAIConfig.minBotsForGreaterBuff))
return castName; // Group too small: stay in solo mode
if (std::string const groupName = GroupVariantFor(baseName); !groupName.empty())
@@ -114,7 +114,7 @@ namespace ai::buff
time_t now = std::time(nullptr);
uint32 botLow = static_cast<uint32>(bot->GetGUID().GetCounter());
time_t& last = s_lastWarn[ std::make_pair(botLow, groupName) ];
if (!last || now - last >= sPlayerbotAIConfig->rpWarningCooldown) // Configurable anti-spam
if (!last || now - last >= sPlayerbotAIConfig.rpWarningCooldown) // Configurable anti-spam
{
// DB Key choice in regard of the buff
std::string key;
@@ -132,7 +132,7 @@ namespace ai::buff
placeholders["%group_spell"] = groupName;
placeholders["%base_spell"] = baseName;
std::string announceText = sPlayerbotTextMgr->GetBotTextOrDefault(key,
std::string announceText = PlayerbotTextMgr::instance().GetBotTextOrDefault(key,
"Out of components for %group_spell. Using %base_spell!", placeholders);
announce(announceText);

View File

@@ -82,7 +82,7 @@ bool CastSpellAction::isPossible()
{
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true))
{
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster()))
if (!sPlayerbotAIConfig.logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster()))
{
LOG_DEBUG("playerbots", "Can cast spell failed. Vehicle. - bot name: {}", bot->GetName());
}
@@ -94,7 +94,7 @@ bool CastSpellAction::isPossible()
if (spell == "mount" && bot->IsInCombat())
{
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster()))
if (!sPlayerbotAIConfig.logInGroupOnly || (bot->GetGroup() && botAI->HasRealPlayerMaster()))
{
LOG_DEBUG("playerbots", "Can cast spell failed. Mount. - bot name: {}", bot->GetName());
}
@@ -133,7 +133,7 @@ bool CastSpellAction::isUseful()
return spellTarget &&
AI_VALUE2(bool, "spell cast useful",
spell); // && sServerFacade->GetDistance2d(bot, spellTarget) <= (range + combatReach);
spell); // && ServerFacade::instance().GetDistance2d(bot, spellTarget) <= (range + combatReach);
}
CastMeleeSpellAction::CastMeleeSpellAction(PlayerbotAI* botAI, std::string const spell) : CastSpellAction(botAI, spell)

View File

@@ -64,7 +64,7 @@ Unit* GiveItemAction::GetTarget() { return AI_VALUE2(Unit*, "party member withou
bool GiveItemAction::isUseful()
{
return GetTarget() && AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->lowMana;
return GetTarget() && AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.lowMana;
}
Unit* GiveFoodAction::GetTarget() { return AI_VALUE(Unit*, "party member without food"); }
@@ -74,7 +74,7 @@ bool GiveFoodAction::isUseful()
if (!GetTarget())
return false;
bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr->IsRandomBot((Player*)GetTarget());
bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr.IsRandomBot((Player*)GetTarget());
return !isRandomBot || (isRandomBot && !botAI->HasCheat(BotCheatMask::food));
}
@@ -86,7 +86,7 @@ bool GiveWaterAction::isUseful()
if (!GetTarget())
return false;
bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr->IsRandomBot((Player*)GetTarget());
bool isRandomBot = GetTarget()->IsPlayer() && sRandomPlayerbotMgr.IsRandomBot((Player*)GetTarget());
return !isRandomBot || (isRandomBot && !botAI->HasCheat(BotCheatMask::food));
}

View File

@@ -61,7 +61,7 @@ bool GoAction::Execute(Event event)
else
{
botAI->TellMasterNoFacing("Clearing travel target");
target->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition);
target->setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition);
target->setForced(false);
return true;
}
@@ -75,8 +75,8 @@ bool GoAction::Execute(Event event)
if (GameObject* go = botAI->GetGameObject(guid))
if (go->isSpawned())
{
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, go),
sPlayerbotAIConfig->reactDistance))
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, go),
sPlayerbotAIConfig.reactDistance))
{
botAI->TellError("It is too far away");
return false;
@@ -86,7 +86,7 @@ bool GoAction::Execute(Event event)
out << "Moving to " << ChatHelper::FormatGameobject(go);
botAI->TellMasterNoFacing(out.str());
return MoveNear(bot->GetMapId(), go->GetPositionX(), go->GetPositionY(), go->GetPositionZ() + 0.5f,
sPlayerbotAIConfig->followDistance);
sPlayerbotAIConfig.followDistance);
}
}
return false;
@@ -106,7 +106,7 @@ bool GoAction::Execute(Event event)
out << "Moving to " << unit->GetName();
botAI->TellMasterNoFacing(out.str());
return MoveNear(bot->GetMapId(), unit->GetPositionX(), unit->GetPositionY(),
unit->GetPositionZ() + 0.5f, sPlayerbotAIConfig->followDistance);
unit->GetPositionZ() + 0.5f, sPlayerbotAIConfig.followDistance);
}
}
@@ -176,8 +176,8 @@ bool GoAction::Execute(Event event)
float z = bot->GetPositionZ();
bot->UpdateAllowedPositionZ(x, y, z);
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, x, y),
sPlayerbotAIConfig->reactDistance))
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, x, y),
sPlayerbotAIConfig.reactDistance))
{
botAI->TellMaster("It is too far away");
return false;
@@ -203,14 +203,14 @@ bool GoAction::Execute(Event event)
out << "Moving to " << x1 << "," << y1;
botAI->TellMasterNoFacing(out.str());
return MoveNear(bot->GetMapId(), x, y, z + 0.5f, sPlayerbotAIConfig->followDistance);
return MoveNear(bot->GetMapId(), x, y, z + 0.5f, sPlayerbotAIConfig.followDistance);
}
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[param];
if (pos.isSet())
{
if (sServerFacade->IsDistanceGreaterThan(sServerFacade->GetDistance2d(bot, pos.x, pos.y),
sPlayerbotAIConfig->reactDistance))
if (ServerFacade::instance().IsDistanceGreaterThan(ServerFacade::instance().GetDistance2d(bot, pos.x, pos.y),
sPlayerbotAIConfig.reactDistance))
{
botAI->TellError("It is too far away");
return false;
@@ -219,7 +219,7 @@ bool GoAction::Execute(Event event)
std::ostringstream out;
out << "Moving to position " << param;
botAI->TellMasterNoFacing(out.str());
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z + 0.5f, sPlayerbotAIConfig->followDistance);
return MoveNear(bot->GetMapId(), pos.x, pos.y, pos.z + 0.5f, sPlayerbotAIConfig.followDistance);
}
botAI->TellMaster("Whisper 'go x,y', 'go [game object]', 'go unit' or 'go position' and I will go there");

View File

@@ -20,7 +20,7 @@ bool GreetAction::Execute(Event event)
if (!player)
return false;
if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, player, sPlayerbotAIConfig->sightDistance))
if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, player, sPlayerbotAIConfig.sightDistance))
bot->SetFacingToObject(player);
ObjectGuid oldSel = bot->GetTarget();

View File

@@ -184,11 +184,11 @@ bool PetitionOfferNearbyAction::Execute(Event event)
}
else
{
if (!sPlayerbotAIConfig->randomBotGroupNearby)
if (!sPlayerbotAIConfig.randomBotGroupNearby)
return false;
}
if (sServerFacade->GetDistance2d(bot, player) > sPlayerbotAIConfig->sightDistance)
if (ServerFacade::instance().GetDistance2d(bot, player) > sPlayerbotAIConfig.sightDistance)
continue;
// Parse rpg target to quest action.

View File

@@ -171,7 +171,7 @@ bool GuildManageNearbyAction::Execute(Event event)
continue;
}
if (!sPlayerbotAIConfig->randomBotGuildNearby)
if (!sPlayerbotAIConfig.randomBotGuildNearby)
return false;
if (guild->GetMemberSize() > 1000)
@@ -185,7 +185,7 @@ bool GuildManageNearbyAction::Execute(Event event)
PlayerbotAI* botAi = GET_PLAYERBOT_AI(player);
if (!sPlayerbotAIConfig->randomBotInvitePlayer && botAi && botAi->IsRealPlayer())
if (!sPlayerbotAIConfig.randomBotInvitePlayer && botAi && botAi->IsRealPlayer())
continue;
if (botAi)
@@ -193,16 +193,16 @@ bool GuildManageNearbyAction::Execute(Event event)
if (botAi->GetGuilderType() == GuilderType::SOLO && !botAi->HasRealPlayerMaster()) //Do not invite solo players.
continue;
if (botAi->HasActivePlayerMaster() && !sRandomPlayerbotMgr->IsRandomBot(player)) //Do not invite alts of active players.
if (botAi->HasActivePlayerMaster() && !sRandomPlayerbotMgr.IsRandomBot(player)) //Do not invite alts of active players.
continue;
}
bool sameGroup = bot->GetGroup() && bot->GetGroup()->IsMember(player->GetGUID());
if (!sameGroup && sServerFacade->GetDistance2d(bot, player) > sPlayerbotAIConfig->spellDistance)
if (!sameGroup && ServerFacade::instance().GetDistance2d(bot, player) > sPlayerbotAIConfig.spellDistance)
continue;
if (sPlayerbotAIConfig->inviteChat && (sRandomPlayerbotMgr->IsRandomBot(bot) || !botAI->HasActivePlayerMaster()))
if (sPlayerbotAIConfig.inviteChat && (sRandomPlayerbotMgr.IsRandomBot(bot) || !botAI->HasActivePlayerMaster()))
{
/* std::map<std::string, std::string> placeholders;
placeholders["%name"] = player->GetName();
@@ -210,8 +210,8 @@ bool GuildManageNearbyAction::Execute(Event event)
placeholders["%guildname"] = guild->GetName();
AreaTableEntry const* current_area = botAI->GetCurrentArea();
AreaTableEntry const* current_zone = botAI->GetCurrentZone();
placeholders["%area_name"] = current_area ? current_area->area_name[BroadcastHelper::GetLocale()] : BOT_TEXT1("string_unknown_area");
placeholders["%zone_name"] = current_zone ? current_zone->area_name[BroadcastHelper::GetLocale()] : BOT_TEXT1("string_unknown_area");
placeholders["%area_name"] = current_area ? current_area->area_name[BroadcastHelper::GetLocale()] : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%zone_name"] = current_zone ? current_zone->area_name[BroadcastHelper::GetLocale()] : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
std::vector<std::string> lines;
@@ -219,45 +219,45 @@ bool GuildManageNearbyAction::Execute(Event event)
switch ((urand(0, 10) * urand(0, 10)) / 10)
{
case 0:
lines.push_back(BOT_TEXT2("Hey %name do you want to join my guild?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("Hey %name do you want to join my guild?", placeholders));
break;
case 1:
lines.push_back(BOT_TEXT2("Hey man you wanna join my guild %name?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("Hey man you wanna join my guild %name?", placeholders));
break;
case 2:
lines.push_back(BOT_TEXT2("I think you would be a good contribution to %guildname. Would you like to join %name?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("I think you would be a good contribution to %guildname. Would you like to join %name?", placeholders));
break;
case 3:
lines.push_back(BOT_TEXT2("My guild %guildname has %members quality members. Would you like to make it 1 more %name?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("My guild %guildname has %members quality members. Would you like to make it 1 more %name?", placeholders));
break;
case 4:
lines.push_back(BOT_TEXT2("Hey %name do you want to join %guildname? We have %members members and looking to become number 1 of the server.", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("Hey %name do you want to join %guildname? We have %members members and looking to become number 1 of the server.", placeholders));
break;
case 5:
lines.push_back(BOT_TEXT2("I'm not really good at smalltalk. Do you wanna join my guild %name/r?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("I'm not really good at smalltalk. Do you wanna join my guild %name/r?", placeholders));
break;
case 6:
lines.push_back(BOT_TEXT2("Welcome to %zone_name.... do you want to join my guild %name?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("Welcome to %zone_name.... do you want to join my guild %name?", placeholders));
break;
case 7:
lines.push_back(BOT_TEXT2("%name, you should join my guild!", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("%name, you should join my guild!", placeholders));
break;
case 8:
lines.push_back(BOT_TEXT2("%name, I got this guild....", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("%name, I got this guild....", placeholders));
break;
case 9:
lines.push_back(BOT_TEXT2("You are actually going to join my guild %name?", placeholders));
lines.push_back(BOT_TEXT2("Haha.. you are the man! We are going to raid Molten...", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("You are actually going to join my guild %name?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("Haha.. you are the man! We are going to raid Molten...", placeholders));
break;
case 10:
lines.push_back(BOT_TEXT2("Hey Hey! do you guys wanna join my gild????", placeholders));
lines.push_back(BOT_TEXT2("We've got a bunch of high levels and we are really super friendly..", placeholders));
lines.push_back(BOT_TEXT2("..and watch your dog and do your homework...", placeholders));
lines.push_back(BOT_TEXT2("..and we raid once a week and are working on MC raids...", placeholders));
lines.push_back(BOT_TEXT2("..and we have more members than just me...", placeholders));
lines.push_back(BOT_TEXT2("..and please stop I'm lonenly and we can get a ride the whole time...", placeholders));
lines.push_back(BOT_TEXT2("..and it's really beautifull and I feel like crying...", placeholders));
lines.push_back(BOT_TEXT2("So what do you guys say are you going to join are you going to join?", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("Hey Hey! do you guys wanna join my gild????", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("We've got a bunch of high levels and we are really super friendly..", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("..and watch your dog and do your homework...", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("..and we raid once a week and are working on MC raids...", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("..and we have more members than just me...", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("..and please stop I'm lonenly and we can get a ride the whole time...", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("..and it's really beautifull and I feel like crying...", placeholders));
lines.push_back(PlayerbotTextMgr::instance().GetBotText("So what do you guys say are you going to join are you going to join?", placeholders));
break;
}
@@ -274,7 +274,7 @@ bool GuildManageNearbyAction::Execute(Event event)
if (botAI->DoSpecificAction("guild invite", Event("guild management", guid), true))
{
if (sPlayerbotAIConfig->inviteChat)
if (sPlayerbotAIConfig.inviteChat)
return true;
found++;
}

View File

@@ -14,7 +14,7 @@ bool HireAction::Execute(Event event)
if (!master)
return false;
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
return false;
uint32 account = master->GetSession()->GetAccountId();
@@ -39,7 +39,7 @@ bool HireAction::Execute(Event event)
return false;
}
uint32 discount = sRandomPlayerbotMgr->GetTradeDiscount(bot, master);
uint32 discount = sRandomPlayerbotMgr.GetTradeDiscount(bot, master);
uint32 m = 1 + (bot->GetLevel() / 10);
uint32 moneyReq = m * 5000 * bot->GetLevel();
if (discount < moneyReq)
@@ -54,7 +54,7 @@ bool HireAction::Execute(Event event)
botAI->TellMaster("I will join you at your next relogin");
bot->SetMoney(moneyReq);
sRandomPlayerbotMgr->Remove(bot);
sRandomPlayerbotMgr.Remove(bot);
CharacterDatabase.Execute("UPDATE characters SET account = {} WHERE guid = {}", account,
bot->GetGUID().GetCounter());

View File

@@ -31,7 +31,7 @@ bool InviteToGroupAction::Invite(Player* inviter, Player* player)
if (!group->isRaidGroup() && group->GetMembersCount() > 4)
{
auto convertOp = std::make_unique<GroupConvertToRaidOperation>(inviter->GetGUID());
sPlayerbotWorldProcessor->QueueOperation(std::move(convertOp));
PlayerbotWorldThreadProcessor::instance().QueueOperation(std::move(convertOp));
}
}
@@ -62,7 +62,7 @@ bool InviteNearbyToGroupAction::Execute(Event event)
if (player->GetGroup())
continue;
if (!sPlayerbotAIConfig->randomBotInvitePlayer && GET_PLAYERBOT_AI(player)->IsRealPlayer())
if (!sPlayerbotAIConfig.randomBotInvitePlayer && GET_PLAYERBOT_AI(player)->IsRealPlayer())
continue;
Group* group = bot->GetGroup();
@@ -88,7 +88,7 @@ bool InviteNearbyToGroupAction::Execute(Event event)
if (abs(int32(player->GetLevel() - bot->GetLevel())) > 2)
continue;
if (sServerFacade->GetDistance2d(bot, player) > sPlayerbotAIConfig->sightDistance)
if (ServerFacade::instance().GetDistance2d(bot, player) > sPlayerbotAIConfig.sightDistance)
continue;
// When inviting the 5th member of the group convert to raid for future invites.
@@ -96,19 +96,19 @@ bool InviteNearbyToGroupAction::Execute(Event event)
bot->GetGroup()->GetMembersCount() > 3)
{
auto convertOp = std::make_unique<GroupConvertToRaidOperation>(bot->GetGUID());
sPlayerbotWorldProcessor->QueueOperation(std::move(convertOp));
PlayerbotWorldThreadProcessor::instance().QueueOperation(std::move(convertOp));
}
if (sPlayerbotAIConfig->inviteChat && sRandomPlayerbotMgr->IsRandomBot(bot))
if (sPlayerbotAIConfig.inviteChat && sRandomPlayerbotMgr.IsRandomBot(bot))
{
std::map<std::string, std::string> placeholders;
placeholders["%player"] = player->GetName();
if (group && group->isRaidGroup())
bot->Say(BOT_TEXT2("join_raid", placeholders),
bot->Say(PlayerbotTextMgr::instance().GetBotText("join_raid", placeholders),
(bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
else
bot->Say(BOT_TEXT2("join_group", placeholders),
bot->Say(PlayerbotTextMgr::instance().GetBotText("join_group", placeholders),
(bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
}
@@ -120,7 +120,7 @@ bool InviteNearbyToGroupAction::Execute(Event event)
bool InviteNearbyToGroupAction::isUseful()
{
if (!sPlayerbotAIConfig->randomBotGroupNearby)
if (!sPlayerbotAIConfig.randomBotGroupNearby)
return false;
if (bot->InBattleground())
@@ -186,7 +186,7 @@ bool InviteGuildToGroupAction::Execute(Event event)
if (player->isDND())
continue;
if (!sPlayerbotAIConfig->randomBotInvitePlayer && GET_PLAYERBOT_AI(player)->IsRealPlayer())
if (!sPlayerbotAIConfig.randomBotInvitePlayer && GET_PLAYERBOT_AI(player)->IsRealPlayer())
continue;
if (player->IsBeingTeleported())
@@ -221,7 +221,7 @@ bool InviteGuildToGroupAction::Execute(Event event)
player->GetLevel() + 5) // Do not invite members that too low level or risk dragging them to deadly places.
continue;
if (!playerAi && sServerFacade->GetDistance2d(bot, player) > sPlayerbotAIConfig->sightDistance)
if (!playerAi && ServerFacade::instance().GetDistance2d(bot, player) > sPlayerbotAIConfig.sightDistance)
continue;
Group* group = bot->GetGroup();
@@ -230,11 +230,11 @@ bool InviteGuildToGroupAction::Execute(Event event)
bot->GetGroup()->GetMembersCount() > 3)
{
auto convertOp = std::make_unique<GroupConvertToRaidOperation>(bot->GetGUID());
sPlayerbotWorldProcessor->QueueOperation(std::move(convertOp));
PlayerbotWorldThreadProcessor::instance().QueueOperation(std::move(convertOp));
}
if (sPlayerbotAIConfig->inviteChat &&
(sRandomPlayerbotMgr->IsRandomBot(bot) || !botAI->HasActivePlayerMaster()))
if (sPlayerbotAIConfig.inviteChat &&
(sRandomPlayerbotMgr.IsRandomBot(bot) || !botAI->HasActivePlayerMaster()))
{
BroadcastHelper::BroadcastGuildGroupOrRaidInvite(botAI, bot, player, group);
}
@@ -373,7 +373,7 @@ bool LfgAction::Execute(Event event)
else
{
auto convertOp = std::make_unique<GroupConvertToRaidOperation>(requester->GetGUID());
sPlayerbotWorldProcessor->QueueOperation(std::move(convertOp));
PlayerbotWorldThreadProcessor::instance().QueueOperation(std::move(convertOp));
}
}

View File

@@ -33,7 +33,7 @@ bool PartyCommandAction::Execute(Event event)
Player* master = GetMaster();
if (master && member == master->GetName())
{
if (sRandomPlayerbotMgr->IsRandomBot(bot))
if (sRandomPlayerbotMgr.IsRandomBot(bot))
{
Player* newMaster = botAI->FindNewMaster();
if (newMaster || bot->InBattleground())
@@ -150,7 +150,7 @@ bool LeaveFarAwayAction::isUseful()
if (abs(int32(groupLeader->GetLevel() - bot->GetLevel())) > 4)
return true;
if (bot->GetMapId() != groupLeader->GetMapId() || bot->GetDistance2d(groupLeader) >= 2 * sPlayerbotAIConfig->rpgDistance)
if (bot->GetMapId() != groupLeader->GetMapId() || bot->GetDistance2d(groupLeader) >= 2 * sPlayerbotAIConfig.rpgDistance)
{
return true;
}

View File

@@ -20,7 +20,7 @@ bool LfgJoinAction::Execute(Event event) { return JoinLFG(); }
uint32 LfgJoinAction::GetRoles()
{
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
{
if (botAI->IsTank(bot))
return PLAYER_ROLE_TANK;
@@ -101,7 +101,7 @@ bool LfgJoinAction::JoinLFG()
LfgDungeonSet list;
std::vector<uint32> selected;
std::vector<uint32> dungeons = sRandomPlayerbotMgr->LfgDungeons[bot->GetTeamId()];
std::vector<uint32> dungeons = sRandomPlayerbotMgr.LfgDungeons[bot->GetTeamId()];
if (!dungeons.size())
return false;
@@ -216,9 +216,9 @@ bool LfgAcceptAction::Execute(Event event)
*packet << id << true;
bot->GetSession()->QueuePacket(packet);
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
if (sRandomPlayerbotMgr.IsRandomBot(bot) && !bot->GetGroup())
{
sRandomPlayerbotMgr->Refresh(bot);
sRandomPlayerbotMgr.Refresh(bot);
botAI->ResetStrategies();
}
@@ -251,9 +251,9 @@ bool LfgAcceptAction::Execute(Event event)
*packet << id << true;
bot->GetSession()->QueuePacket(packet);
if (sRandomPlayerbotMgr->IsRandomBot(bot) && !bot->GetGroup())
if (sRandomPlayerbotMgr.IsRandomBot(bot) && !bot->GetGroup())
{
sRandomPlayerbotMgr->Refresh(bot);
sRandomPlayerbotMgr.Refresh(bot);
botAI->ResetStrategies();
}
@@ -306,7 +306,7 @@ bool LfgTeleportAction::Execute(Event event)
bool LfgJoinAction::isUseful()
{
if (!sPlayerbotAIConfig->randomBotJoinLfg)
if (!sPlayerbotAIConfig.randomBotJoinLfg)
{
// botAI->ChangeStrategy("-lfg", BOT_STATE_NON_COMBAT);
return false;
@@ -337,7 +337,7 @@ bool LfgJoinAction::isUseful()
if (bot->isDead())
return false;
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
return false;
Map* map = bot->GetMap();

View File

@@ -107,14 +107,14 @@ uint32 ListQuestsAction::ListQuests(bool completed, bool silent, QuestTravelDeta
if (travelDetail == QUEST_TRAVEL_DETAIL_SUMMARY)
{
std::vector<TravelDestination*> allDestinations =
sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1);
TravelMgr::instance().getQuestTravelDestinations(bot, questId, true, true, -1);
std::vector<TravelDestination*> availDestinations =
sTravelMgr->getQuestTravelDestinations(bot, questId, botAI->GetMaster(), false, -1);
TravelMgr::instance().getQuestTravelDestinations(bot, questId, botAI->GetMaster(), false, -1);
uint32 desTot = allDestinations.size();
uint32 desAvail = availDestinations.size();
uint32 desFull = desAvail - sTravelMgr->getQuestTravelDestinations(bot, questId, false, false, -1).size();
uint32 desRange = desAvail - sTravelMgr->getQuestTravelDestinations(bot, questId, false, false).size();
uint32 desFull = desAvail - TravelMgr::instance().getQuestTravelDestinations(bot, questId, false, false, -1).size();
uint32 desRange = desAvail - TravelMgr::instance().getQuestTravelDestinations(bot, questId, false, false).size();
uint32 tpoints = 0;
uint32 apoints = 0;
@@ -140,7 +140,7 @@ uint32 ListQuestsAction::ListQuests(bool completed, bool silent, QuestTravelDeta
{
uint32 limit = 0;
std::vector<TravelDestination*> allDestinations =
sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1);
TravelMgr::instance().getQuestTravelDestinations(bot, questId, true, true, -1);
std::sort(allDestinations.begin(), allDestinations.end(),
[botPos](TravelDestination* i, TravelDestination* j) {

View File

@@ -136,7 +136,7 @@ std::vector<std::pair<uint32, std::string>> ListSpellsAction::GetSpellList(std::
if (spellInfo->IsPassive())
continue;
SkillLineAbilityEntry const* skillLine = sPlayerbotSpellRepository->GetSkillLine(itr->first);
SkillLineAbilityEntry const* skillLine = PlayerbotSpellRepository::Instance().GetSkillLine(itr->first);
if (skill != SKILL_NONE && (!skillLine || skillLine->SkillLine != skill))
continue;
@@ -175,7 +175,7 @@ std::vector<std::pair<uint32, std::string>> ListSpellsAction::GetSpellList(std::
FindItemByIdVisitor visitor(itemid);
uint32 reagentsInInventory = InventoryAction::GetItemCount(&visitor);
bool buyable = sPlayerbotSpellRepository->IsItemBuyable(itemid);
bool buyable = PlayerbotSpellRepository::Instance().IsItemBuyable(itemid);
if (!buyable)
{
uint32 craftable = reagentsInInventory / reagentsRequired;
@@ -303,4 +303,4 @@ bool ListSpellsAction::Execute(Event event)
botAI->TellMasterNoFacing(i->second);
return true;
}
}

View File

@@ -25,7 +25,7 @@ bool LootAction::Execute(Event /*event*/)
LootObject prevLoot = AI_VALUE(LootObject, "loot target");
LootObject const& lootObject =
AI_VALUE(LootObjectStack*, "available loot")->GetLoot(sPlayerbotAIConfig->lootDistance);
AI_VALUE(LootObjectStack*, "available loot")->GetLoot(sPlayerbotAIConfig.lootDistance);
if (!prevLoot.IsEmpty() && prevLoot.guid != lootObject.guid)
{
@@ -37,7 +37,7 @@ bool LootAction::Execute(Event /*event*/)
// Provide a system to check if the game object id is disallowed in the user configurable list or not.
// Check if the game object id is disallowed in the user configurable list or not.
if (sPlayerbotAIConfig->disallowedGameObjects.find(lootObject.guid.GetEntry()) != sPlayerbotAIConfig->disallowedGameObjects.end())
if (sPlayerbotAIConfig.disallowedGameObjects.find(lootObject.guid.GetEntry()) != sPlayerbotAIConfig.disallowedGameObjects.end())
{
return false; // Game object ID is disallowed, so do not proceed
}
@@ -50,7 +50,7 @@ bool LootAction::Execute(Event /*event*/)
bool LootAction::isUseful()
{
return sPlayerbotAIConfig->freeMethodLoot || !bot->GetGroup() || bot->GetGroup()->GetLootMethod() != FREE_FOR_ALL;
return sPlayerbotAIConfig.freeMethodLoot || !bot->GetGroup() || bot->GetGroup()->GetLootMethod() != FREE_FOR_ALL;
}
enum ProfessionSpells
@@ -95,7 +95,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
if (bot->IsMounted())
{
bot->Dismount();
botAI->SetNextCheckDelay(sPlayerbotAIConfig->lootDelay); // Small delay to avoid animation issues
botAI->SetNextCheckDelay(sPlayerbotAIConfig.lootDelay); // Small delay to avoid animation issues
}
if (creature && creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
@@ -104,7 +104,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
*packet << lootObject.guid;
bot->GetSession()->QueuePacket(packet);
// bot->GetSession()->HandleLootOpcode(packet);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->lootDelay);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.lootDelay);
return true;
}
@@ -202,7 +202,7 @@ uint32 OpenLootAction::GetOpeningSpell(LootObject& lootObject, GameObject* go)
return spellId;
}
return sPlayerbotAIConfig->openGoSpell;
return sPlayerbotAIConfig.openGoSpell;
}
bool OpenLootAction::CanOpenLock(LootObject& /*lootObject*/, SpellInfo const* spellInfo, GameObject* go)
@@ -294,7 +294,7 @@ bool StoreLootAction::AuctionItem(uint32 itemId)
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(ahEntry);
uint32 price = oldItem->GetCount() * proto->BuyPrice * sRandomPlayerbotMgr->GetBuyMultiplier(bot);
uint32 price = oldItem->GetCount() * proto->BuyPrice * sRandomPlayerbotMgr.GetBuyMultiplier(bot);
uint32 stackCount = urand(1, proto->GetMaxStackSize());
if (!price || !stackCount)
@@ -426,28 +426,28 @@ bool StoreLootAction::Execute(Event event)
}
Player* master = botAI->GetMaster();
if (sRandomPlayerbotMgr->IsRandomBot(bot) && master)
if (sRandomPlayerbotMgr.IsRandomBot(bot) && master)
{
uint32 price = itemcount * proto->BuyPrice * sRandomPlayerbotMgr->GetBuyMultiplier(bot) + gold;
uint32 price = itemcount * proto->BuyPrice * sRandomPlayerbotMgr.GetBuyMultiplier(bot) + gold;
if (price)
sRandomPlayerbotMgr->AddTradeDiscount(bot, master, price);
sRandomPlayerbotMgr.AddTradeDiscount(bot, master, price);
if (Group* group = bot->GetGroup())
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
if (ref->GetSource() != bot)
sGuildTaskMgr->CheckItemTask(itemid, itemcount, ref->GetSource(), bot);
GuildTaskMgr::instance().CheckItemTask(itemid, itemcount, ref->GetSource(), bot);
}
WorldPacket* packet = new WorldPacket(CMSG_AUTOSTORE_LOOT_ITEM, 1);
*packet << itemindex;
bot->GetSession()->QueuePacket(packet);
// bot->GetSession()->HandleAutostoreLootItemOpcode(packet);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->lootDelay);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.lootDelay);
if (proto->Quality > ITEM_QUALITY_NORMAL && !urand(0, 50) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT) && sPlayerbotAIConfig->randomBotEmote)
if (proto->Quality > ITEM_QUALITY_NORMAL && !urand(0, 50) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT) && sPlayerbotAIConfig.randomBotEmote)
botAI->PlayEmote(TEXT_EMOTE_CHEER);
if (proto->Quality >= ITEM_QUALITY_RARE && !urand(0, 1) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT) && sPlayerbotAIConfig->randomBotEmote)
if (proto->Quality >= ITEM_QUALITY_RARE && !urand(0, 1) && botAI->HasStrategy("emote", BOT_STATE_NON_COMBAT) && sPlayerbotAIConfig.randomBotEmote)
botAI->PlayEmote(TEXT_EMOTE_CHEER);
BroadcastHelper::BroadcastLootingItem(botAI, bot, proto);
@@ -498,7 +498,7 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI)
{
// if (AI_VALUE2(uint32, "item count", proto->Name1) < quest->RequiredItemCount[i])
// {
// if (botAI->GetMaster() && sPlayerbotAIConfig->syncQuestWithPlayer)
// if (botAI->GetMaster() && sPlayerbotAIConfig.syncQuestWithPlayer)
// return false; //Quest is autocomplete for the bot so no item needed.
// }
@@ -514,7 +514,7 @@ bool StoreLootAction::IsLootAllowed(uint32 itemid, PlayerbotAI* botAI)
bool canLoot = lootStrategy->CanLoot(proto, context);
// if (canLoot && proto->Bonding == BIND_WHEN_PICKED_UP && botAI->HasActivePlayerMaster())
// canLoot = sPlayerbotAIConfig->IsInRandomAccountList(botAI->GetBot()->GetSession()->GetAccountId());
// canLoot = sPlayerbotAIConfig.IsInRandomAccountList(botAI->GetBot()->GetSession()->GetAccountId());
return canLoot;
}

View File

@@ -84,11 +84,11 @@ bool LootRollAction::Execute(Event event)
break;
}
}
if (sPlayerbotAIConfig->lootRollLevel == 0)
if (sPlayerbotAIConfig.lootRollLevel == 0)
{
vote = PASS;
}
else if (sPlayerbotAIConfig->lootRollLevel == 1)
else if (sPlayerbotAIConfig.lootRollLevel == 1)
{
if (vote == NEED)
{

View File

@@ -61,7 +61,7 @@ bool MoveToRpgTargetAction::Execute(Event event)
}
if ((unit && unit->isMoving() && !urand(0, 20)) || !ChooseRpgTargetAction::isFollowValid(bot, wo) ||
guidP.distance(bot) > sPlayerbotAIConfig->reactDistance * 2 || !urand(0, 50))
guidP.distance(bot) > sPlayerbotAIConfig.reactDistance * 2 || !urand(0, 50))
{
AI_VALUE(GuidSet&, "ignore rpg target").insert(AI_VALUE(GuidPosition, "rpg target"));
RESET_AI_VALUE(GuidPosition, "rpg target");
@@ -73,7 +73,7 @@ bool MoveToRpgTargetAction::Execute(Event event)
float z = wo->GetPositionZ();
float mapId = wo->GetMapId();
if (sPlayerbotAIConfig->randombotsWalkingRPG)
if (sPlayerbotAIConfig.randombotsWalkingRPG)
if (!bot->IsOutdoors())
bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_WALKING);

View File

@@ -43,7 +43,7 @@ bool MoveToTravelTargetAction::Execute(Event event)
if (memberDistance < 50.0f)
continue;
if (memberDistance > sPlayerbotAIConfig->reactDistance * 20)
if (memberDistance > sPlayerbotAIConfig.reactDistance * 20)
continue;
// float memberAngle = botLocation.getAngleBetween(targetPos, memberPos);
@@ -65,9 +65,9 @@ bool MoveToTravelTargetAction::Execute(Event event)
botAI->TellMasterNoFacing(out);
}
target->setExpireIn(target->getTimeLeft() + sPlayerbotAIConfig->maxWaitForMove);
target->setExpireIn(target->getTimeLeft() + sPlayerbotAIConfig.maxWaitForMove);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->maxWaitForMove);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.maxWaitForMove);
return true;
}
@@ -80,7 +80,7 @@ bool MoveToTravelTargetAction::Execute(Event event)
if (target->getMaxTravelTime() > target->getTimeLeft()) // The bot is late. Speed it up.
{
// distance = sPlayerbotAIConfig->fleeDistance;
// distance = sPlayerbotAIConfig.fleeDistance;
// angle = bot->GetAngle(location.GetPositionX(), location.GetPositionY());
// location = botLocation.getLocation();
}

View File

@@ -51,7 +51,7 @@ MovementAction::MovementAction(PlayerbotAI* botAI, std::string const name) : Act
void MovementAction::CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important)
{
float dist = wpOwner->GetDistance(x, y, z);
float delay = 1000.0f * dist / wpOwner->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay;
float delay = 1000.0f * dist / wpOwner->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig.reactDelay;
// if (!important)
// delay *= 0.25;
@@ -195,8 +195,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
bool generatePath = !bot->IsFlying() && !bot->isSwimming();
bool disableMoveSplinePath =
sPlayerbotAIConfig->disableMoveSplinePath >= 2 ||
(sPlayerbotAIConfig->disableMoveSplinePath == 1 && bot->InBattleground());
sPlayerbotAIConfig.disableMoveSplinePath >= 2 ||
(sPlayerbotAIConfig.disableMoveSplinePath == 1 && bot->InBattleground());
if (Vehicle* vehicle = bot->GetVehicle())
{
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(bot);
@@ -216,7 +216,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
delay -= botAI->GetReactDelay();
}
delay = std::max(.0f, delay);
delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, delay);
delay = std::min((float)sPlayerbotAIConfig.maxWaitForMove, delay);
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay, priority);
return true;
}
@@ -241,7 +241,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
delay -= botAI->GetReactDelay();
}
delay = std::max(.0f, delay);
delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, delay);
delay = std::min((float)sPlayerbotAIConfig.maxWaitForMove, delay);
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay, priority);
return true;
}
@@ -250,7 +250,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
{
float modifiedZ;
Movement::PointsArray path =
SearchForBestPath(x, y, z, modifiedZ, sPlayerbotAIConfig->maxMovementSearchTime, normal_only);
SearchForBestPath(x, y, z, modifiedZ, sPlayerbotAIConfig.maxMovementSearchTime, normal_only);
if (modifiedZ == INVALID_HEIGHT)
return false;
float distance = bot->GetExactDist(x, y, modifiedZ);
@@ -272,7 +272,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
delay -= botAI->GetReactDelay();
}
delay = std::max(.0f, delay);
delay = std::min((float)sPlayerbotAIConfig->maxWaitForMove, delay);
delay = std::min((float)sPlayerbotAIConfig.maxWaitForMove, delay);
AI_VALUE(LastMovement&, "last movement").Set(mapId, x, y, z, bot->GetOrientation(), delay, priority);
return true;
}
@@ -308,8 +308,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// }
// }
// float minDist = sPlayerbotAIConfig->targetPosRecalcDistance; //Minium distance a bot should move.
// float maxDist = sPlayerbotAIConfig->reactDistance; //Maxium distance a bot can move in one single
// float minDist = sPlayerbotAIConfig.targetPosRecalcDistance; //Minium distance a bot should move.
// float maxDist = sPlayerbotAIConfig.reactDistance; //Maxium distance a bot can move in one single
// action. float originalZ = z; // save original destination height to check
// if bot needs to fly up
@@ -372,9 +372,9 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// if (startPosition.getMapId() != endPosition.getMapId() || totalDistance > maxDist)
// {
// if (!sTravelNodeMap->getNodes().empty() && !bot->InBattleground())
// if (!TravelNodeMap::instance().getNodes().empty() && !bot->InBattleground())
// {
// if (sPlayerbotAIConfig->tweakValue)
// if (sPlayerbotAIConfig.tweakValue)
// {
// if (lastMove.future.valid())
// {
@@ -388,12 +388,12 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// }
// }
// else
// movePath = sTravelNodeMap->getFullPath(startPosition, endPosition, bot);
// movePath = TravelNodeMap::instance().getFullPath(startPosition, endPosition, bot);
// if (movePath.empty())
// {
// //We have no path. Beyond 450yd the standard PathGenerator will probably move the wrong way.
// if (sServerFacade->IsDistanceGreaterThan(totalDistance, maxDist * 3))
// if (ServerFacade::instance().IsDistanceGreaterThan(totalDistance, maxDist * 3))
// {
// movePath.clear();
// movePath.addPoint(endPosition);
@@ -402,7 +402,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// bot->StopMoving();
// if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
// botAI->TellMasterNoFacing("I have no path");
// LOG_DEBUG("playerbots", "sServerFacade->IsDistanceGreaterThan(totalDistance, maxDist * 3)");
// LOG_DEBUG("playerbots", "ServerFacade::instance().IsDistanceGreaterThan(totalDistance, maxDist * 3)");
// return false;
// }
@@ -450,7 +450,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// if (pathType == TravelNodePathType::portal) // && !botAI->isRealPlayer())
// {
// //Log bot movement
// if (sPlayerbotAIConfig->hasLog("bot_movement.csv"))
// if (sPlayerbotAIConfig.hasLog("bot_movement.csv"))
// {
// WorldPosition telePos;
// if (entry)
@@ -463,7 +463,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// telePos = movePosition;
// std::ostringstream out;
// out << sPlayerbotAIConfig->GetTimestampStr() << "+00,";
// out << sPlayerbotAIConfig.GetTimestampStr() << "+00,";
// out << bot->GetName() << ",";
// if (telePos && telePos.GetExactDist(movePosition) > 0.001)
// startPosition.printWKT({ startPosition, movePosition, telePos }, out, 1);
@@ -475,7 +475,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// out << bot->GetLevel() << ",";
// out << (entry ? -1 : entry);
// sPlayerbotAIConfig->log("bot_movement.csv", out.str().c_str());
// sPlayerbotAIConfig.log("bot_movement.csv", out.str().c_str());
// }
// if (entry)
@@ -621,10 +621,10 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// }
// //Log bot movement
// if (sPlayerbotAIConfig->hasLog("bot_movement.csv") && lastMove.lastMoveShort.GetExactDist(movePosition) > 0.001)
// if (sPlayerbotAIConfig.hasLog("bot_movement.csv") && lastMove.lastMoveShort.GetExactDist(movePosition) > 0.001)
// {
// std::ostringstream out;
// out << sPlayerbotAIConfig->GetTimestampStr() << "+00,";
// out << sPlayerbotAIConfig.GetTimestampStr() << "+00,";
// out << bot->GetName() << ",";
// startPosition.printWKT({ startPosition, movePosition }, out, 1);
// out << std::to_string(bot->getRace()) << ",";
@@ -632,7 +632,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// out << bot->GetLevel();
// out << 0;
// sPlayerbotAIConfig->log("bot_movement.csv", out.str().c_str());
// sPlayerbotAIConfig.log("bot_movement.csv", out.str().c_str());
// }
// // LOG_DEBUG("playerbots", "({}, {}) -> ({}, {})", startPosition.getX(), startPosition.getY(),
// movePosition.getX(), movePosition.getY()); if (!react)
@@ -694,7 +694,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// if (botAI->GetMaster())
// {
// if (botAI->GetMaster()->m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING) &&
// sServerFacade->GetDistance2d(bot, botAI->GetMaster()) < 20.0f)
// ServerFacade::instance().GetDistance2d(bot, botAI->GetMaster()) < 20.0f)
// masterWalking = true;
// }
@@ -787,7 +787,7 @@ bool MovementAction::MoveTo(WorldObject* target, float distance, MovementPriorit
float angle = bot->GetAngle(target);
float needToGo = distanceToTarget - distance;
float maxDistance = sPlayerbotAIConfig->spellDistance;
float maxDistance = sPlayerbotAIConfig.spellDistance;
if (needToGo > 0 && needToGo > maxDistance)
needToGo = maxDistance;
else if (needToGo < 0 && needToGo < -maxDistance)
@@ -898,8 +898,8 @@ bool MovementAction::IsMovingAllowed(WorldObject* target)
if (bot->GetMapId() != target->GetMapId())
return false;
// float distance = sServerFacade->GetDistance2d(bot, target);
// if (!bot->InBattleground() && distance > sPlayerbotAIConfig->reactDistance)
// float distance = ServerFacade::instance().GetDistance2d(bot, target);
// if (!bot->InBattleground() && distance > sPlayerbotAIConfig.reactDistance)
// return false;
return IsMovingAllowed();
@@ -923,7 +923,7 @@ bool MovementAction::IsDuplicateMove(uint32 mapId, float x, float y, float z)
LastMovement& lastMove = *context->GetValue<LastMovement&>("last movement");
// heuristic 5s
if (lastMove.msTime + sPlayerbotAIConfig->maxWaitForMove < getMSTime() ||
if (lastMove.msTime + sPlayerbotAIConfig.maxWaitForMove < getMSTime() ||
lastMove.lastMoveShort.GetExactDist(x, y, z) > 0.01f)
return false;
@@ -1046,7 +1046,7 @@ void MovementAction::UpdateMovementState()
// if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE && bot->CanNotReachTarget() &&
// !bot->InBattleground())
// {
// if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
// if (Unit* pTarget = ServerFacade::instance().GetChaseTarget(bot))
// {
// if (!bot->IsWithinMeleeRange(pTarget) && pTarget->IsCreature())
// {
@@ -1080,7 +1080,7 @@ void MovementAction::UpdateMovementState()
// bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) && bot->CanNotReachTarget()
// && !bot->InBattleground())
// {
// if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
// if (Unit* pTarget = ServerFacade::instance().GetChaseTarget(bot))
// {
// if (pTarget != botAI->GetGroupLeader())
// return;
@@ -1117,8 +1117,8 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
if (!target)
return false;
if (!bot->InBattleground() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target),
sPlayerbotAIConfig->followDistance))
if (!bot->InBattleground() && ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target),
sPlayerbotAIConfig.followDistance))
{
// botAI->TellError("No need to follow");
return false;
@@ -1126,9 +1126,9 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
/*
if (!bot->InBattleground()
&& sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target->GetPositionX(),
target->GetPositionY()), sPlayerbotAIConfig->sightDistance)
&& abs(bot->GetPositionZ() - target->GetPositionZ()) >= sPlayerbotAIConfig->spellDistance &&
&& ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target->GetPositionX(),
target->GetPositionY()), sPlayerbotAIConfig.sightDistance)
&& abs(bot->GetPositionZ() - target->GetPositionZ()) >= sPlayerbotAIConfig.spellDistance &&
botAI->HasRealPlayerMaster()
&& (target->GetMapId() && bot->GetMapId() != target->GetMapId()))
{
@@ -1189,13 +1189,13 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
WorldPosition botPos(bot);
WorldPosition cPos(corpse);
if (botPos.fDist(cPos) > sPlayerbotAIConfig->spellDistance)
if (botPos.fDist(cPos) > sPlayerbotAIConfig.spellDistance)
return MoveTo(cPos.getMapId(), cPos.getX(), cPos.getY(), cPos.getZ());
}
}
if (sServerFacade->IsDistanceGreaterOrEqualThan(sServerFacade->GetDistance2d(bot, target),
sPlayerbotAIConfig->sightDistance))
if (ServerFacade::instance().IsDistanceGreaterOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target),
sPlayerbotAIConfig.sightDistance))
{
if (target->GetGUID().IsPlayer())
{
@@ -1238,11 +1238,11 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
}
if (!target->HasUnitState(UNIT_STATE_IN_FLIGHT))
return MoveTo(target, sPlayerbotAIConfig->followDistance);
return MoveTo(target, sPlayerbotAIConfig.followDistance);
}
if (sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target),
sPlayerbotAIConfig->followDistance))
if (ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target),
sPlayerbotAIConfig.followDistance))
{
// botAI->TellError("No need to follow");
return false;
@@ -1251,8 +1251,8 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
if (target->IsFriendlyTo(bot) && bot->IsMounted() && AI_VALUE(GuidVector, "all targets").empty())
distance += angle;
if (!bot->InBattleground() && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, target),
sPlayerbotAIConfig->followDistance))
if (!bot->InBattleground() && ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, target),
sPlayerbotAIConfig.followDistance))
{
// botAI->TellError("No need to follow");
return false;
@@ -1274,7 +1274,7 @@ bool MovementAction::Follow(Unit* target, float distance, float angle)
if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE)
{
Unit* currentTarget = sServerFacade->GetChaseTarget(bot);
Unit* currentTarget = ServerFacade::instance().GetChaseTarget(bot);
if (currentTarget && currentTarget->GetGUID() == target->GetGUID())
return false;
}
@@ -1347,13 +1347,13 @@ void MovementAction::WaitForReach(float distance)
{
float delay = 1000.0f * MoveDelay(distance);
if (delay > sPlayerbotAIConfig->maxWaitForMove)
delay = sPlayerbotAIConfig->maxWaitForMove;
if (delay > sPlayerbotAIConfig.maxWaitForMove)
delay = sPlayerbotAIConfig.maxWaitForMove;
Unit* target = *botAI->GetAiObjectContext()->GetValue<Unit*>("current target");
Unit* player = *botAI->GetAiObjectContext()->GetValue<Unit*>("enemy player target");
if ((player || target) && delay > sPlayerbotAIConfig->globalCoolDown)
delay = sPlayerbotAIConfig->globalCoolDown;
if ((player || target) && delay > sPlayerbotAIConfig.globalCoolDown)
delay = sPlayerbotAIConfig.globalCoolDown;
if (delay < 0)
delay = 0;
@@ -1378,7 +1378,7 @@ bool MovementAction::Flee(Unit* target)
if (!target)
return false;
if (!sPlayerbotAIConfig->fleeingEnabled)
if (!sPlayerbotAIConfig.fleeingEnabled)
return false;
if (!IsMovingAllowed())
@@ -1390,7 +1390,7 @@ bool MovementAction::Flee(Unit* target)
bool foundFlee = false;
time_t lastFlee = AI_VALUE(LastMovement&, "last movement").lastFlee;
time_t now = time(0);
uint32 fleeDelay = urand(2, sPlayerbotAIConfig->returnDelay / 1000);
uint32 fleeDelay = urand(2, sPlayerbotAIConfig.returnDelay / 1000);
if (lastFlee)
{
@@ -1406,7 +1406,7 @@ bool MovementAction::Flee(Unit* target)
if (Group* group = bot->GetGroup())
{
Unit* fleeTarget = nullptr;
float fleeDistance = sPlayerbotAIConfig->sightDistance;
float fleeDistance = sPlayerbotAIConfig.sightDistance;
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{
@@ -1416,8 +1416,8 @@ bool MovementAction::Flee(Unit* target)
if (botAI->IsTank(player))
{
float distanceToTank = sServerFacade->GetDistance2d(bot, player);
float distanceToTarget = sServerFacade->GetDistance2d(bot, target);
float distanceToTank = ServerFacade::instance().GetDistance2d(bot, player);
float distanceToTarget = ServerFacade::instance().GetDistance2d(bot, target);
if (distanceToTank < fleeDistance)
{
fleeTarget = player;
@@ -1460,10 +1460,10 @@ bool MovementAction::Flee(Unit* target)
if ((isHealer && botAI->IsHeal(player)) || needHealer)
{
float distanceToHealer = sServerFacade->GetDistance2d(bot, player);
float distanceToTarget = sServerFacade->GetDistance2d(player, target);
float distanceToHealer = ServerFacade::instance().GetDistance2d(bot, player);
float distanceToTarget = ServerFacade::instance().GetDistance2d(player, target);
if (distanceToHealer < fleeDistance &&
distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) &&
distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig.followDistance) &&
(needHealer || player->IsWithinLOSInMap(target)))
{
fleeTarget = player;
@@ -1473,10 +1473,10 @@ bool MovementAction::Flee(Unit* target)
}
else if (isRanged && botAI->IsRanged(player))
{
float distanceToRanged = sServerFacade->GetDistance2d(bot, player);
float distanceToTarget = sServerFacade->GetDistance2d(player, target);
float distanceToRanged = ServerFacade::instance().GetDistance2d(bot, player);
float distanceToTarget = ServerFacade::instance().GetDistance2d(player, target);
if (distanceToRanged < fleeDistance &&
distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) &&
distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig.followDistance) &&
player->IsWithinLOSInMap(target))
{
fleeTarget = player;
@@ -1485,10 +1485,10 @@ bool MovementAction::Flee(Unit* target)
}
}
// remember any group member in case no one else found
float distanceToFlee = sServerFacade->GetDistance2d(bot, player);
float distanceToTarget = sServerFacade->GetDistance2d(player, target);
float distanceToFlee = ServerFacade::instance().GetDistance2d(bot, player);
float distanceToTarget = ServerFacade::instance().GetDistance2d(player, target);
if (distanceToFlee < spareDistance &&
distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance) &&
distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig.followDistance) &&
player->IsWithinLOSInMap(target))
{
spareTarget = player;
@@ -1508,8 +1508,8 @@ bool MovementAction::Flee(Unit* target)
if ((!fleeTarget || !foundFlee) && master && master->IsAlive() && master->IsWithinLOSInMap(target))
{
float distanceToTarget = sServerFacade->GetDistance2d(master, target);
if (distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig->followDistance))
float distanceToTarget = ServerFacade::instance().GetDistance2d(master, target);
if (distanceToTarget > (botAI->GetRange("shoot") / 2 + sPlayerbotAIConfig.followDistance))
foundFlee = MoveNear(master);
}
}
@@ -1846,7 +1846,7 @@ void MovementAction::DoMovePoint(Unit* unit, float x, float y, float z, bool gen
bool FleeAction::Execute(Event event)
{
return MoveAway(AI_VALUE(Unit*, "current target"), sPlayerbotAIConfig->fleeDistance, true);
return MoveAway(AI_VALUE(Unit*, "current target"), sPlayerbotAIConfig.fleeDistance, true);
}
bool FleeAction::isUseful()
@@ -1924,8 +1924,8 @@ bool AvoidAoeAction::AvoidAuraWithDynamicObj()
{
return false;
}
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(spellInfo->Id) !=
sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
if (sPlayerbotAIConfig.aoeAvoidSpellWhitelist.find(spellInfo->Id) !=
sPlayerbotAIConfig.aoeAvoidSpellWhitelist.end())
return false;
DynamicObject* dynOwner = aura->GetDynobjOwner();
@@ -1934,7 +1934,7 @@ bool AvoidAoeAction::AvoidAuraWithDynamicObj()
return false;
}
float radius = dynOwner->GetRadius();
if (!radius || radius > sPlayerbotAIConfig->maxAoeAvoidRadius)
if (!radius || radius > sPlayerbotAIConfig.maxAoeAvoidRadius)
return false;
if (bot->GetDistance(dynOwner) > radius)
{
@@ -1944,7 +1944,7 @@ bool AvoidAoeAction::AvoidAuraWithDynamicObj()
name << spellInfo->SpellName[LOCALE_enUS]; // << "] (aura)";
if (FleePosition(dynOwner->GetPosition(), radius))
{
if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10)
if (sPlayerbotAIConfig.tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10)
{
lastTellTimer = time(NULL);
lastMoveTimer = getMSTime();
@@ -1990,8 +1990,8 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage()
continue;
}
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(spellId) !=
sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
if (sPlayerbotAIConfig.aoeAvoidSpellWhitelist.find(spellId) !=
sPlayerbotAIConfig.aoeAvoidSpellWhitelist.end())
continue;
const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId);
@@ -2001,7 +2001,7 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage()
}
float radius = (float)goInfo->trap.diameter / 2 + go->GetCombatReach();
if (!radius || radius > sPlayerbotAIConfig->maxAoeAvoidRadius)
if (!radius || radius > sPlayerbotAIConfig.maxAoeAvoidRadius)
continue;
if (bot->GetDistance(go) > radius)
@@ -2012,7 +2012,7 @@ bool AvoidAoeAction::AvoidGameObjectWithDamage()
name << spellInfo->SpellName[LOCALE_enUS]; // << "] (object)";
if (FleePosition(go->GetPosition(), radius))
{
if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10)
if (sPlayerbotAIConfig.tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10)
{
lastTellTimer = time(NULL);
lastMoveTimer = getMSTime();
@@ -2061,8 +2061,8 @@ bool AvoidAoeAction::AvoidUnitWithDamageAura()
sSpellMgr->GetSpellInfo(spellInfo->Effects[aurEff->GetEffIndex()].TriggerSpell);
if (!triggerSpellInfo)
continue;
if (sPlayerbotAIConfig->aoeAvoidSpellWhitelist.find(triggerSpellInfo->Id) !=
sPlayerbotAIConfig->aoeAvoidSpellWhitelist.end())
if (sPlayerbotAIConfig.aoeAvoidSpellWhitelist.find(triggerSpellInfo->Id) !=
sPlayerbotAIConfig.aoeAvoidSpellWhitelist.end())
return false;
for (int j = 0; j < MAX_SPELL_EFFECTS; j++)
{
@@ -2073,13 +2073,13 @@ bool AvoidAoeAction::AvoidUnitWithDamageAura()
{
break;
}
if (!radius || radius > sPlayerbotAIConfig->maxAoeAvoidRadius)
if (!radius || radius > sPlayerbotAIConfig.maxAoeAvoidRadius)
continue;
std::ostringstream name;
name << triggerSpellInfo->SpellName[LOCALE_enUS]; //<< "] (unit)";
if (FleePosition(unit->GetPosition(), radius))
{
if (sPlayerbotAIConfig->tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10)
if (sPlayerbotAIConfig.tellWhenAvoidAoe && lastTellTimer < time(NULL) - 10)
{
lastTellTimer = time(NULL);
lastMoveTimer = getMSTime();
@@ -2134,7 +2134,7 @@ Position MovementAction::BestPositionForMeleeToFlee(Position pos, float radius)
continue;
}
bool strict = checkAngle.strict;
float fleeDis = std::min(radius + 1.0f, sPlayerbotAIConfig->fleeDistance);
float fleeDis = std::min(radius + 1.0f, sPlayerbotAIConfig.fleeDistance);
float dx = bot->GetPositionX() + cos(angle) * fleeDis;
float dy = bot->GetPositionY() + sin(angle) * fleeDis;
float dz = bot->GetPositionZ();
@@ -2146,7 +2146,7 @@ Position MovementAction::BestPositionForMeleeToFlee(Position pos, float radius)
Position fleePos{dx, dy, dz};
if (strict && currentTarget &&
fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() >
sPlayerbotAIConfig->tooCloseDistance &&
sPlayerbotAIConfig.tooCloseDistance &&
bot->IsWithinMeleeRange(currentTarget))
{
continue;
@@ -2197,7 +2197,7 @@ Position MovementAction::BestPositionForRangedToFlee(Position pos, float radius)
continue;
}
bool strict = checkAngle.strict;
float fleeDis = std::min(radius + 1.0f, sPlayerbotAIConfig->fleeDistance);
float fleeDis = std::min(radius + 1.0f, sPlayerbotAIConfig.fleeDistance);
float dx = bot->GetPositionX() + cos(angle) * fleeDis;
float dy = bot->GetPositionY() + sin(angle) * fleeDis;
float dz = bot->GetPositionZ();
@@ -2208,13 +2208,13 @@ Position MovementAction::BestPositionForRangedToFlee(Position pos, float radius)
}
Position fleePos{dx, dy, dz};
if (strict && currentTarget &&
fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() > sPlayerbotAIConfig->spellDistance)
fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() > sPlayerbotAIConfig.spellDistance)
{
continue;
}
if (strict && currentTarget &&
fleePos.GetExactDist(currentTarget) - currentTarget->GetCombatReach() <
(sPlayerbotAIConfig->tooCloseDistance))
(sPlayerbotAIConfig.tooCloseDistance))
{
continue;
}
@@ -2357,7 +2357,7 @@ Position CombatFormationMoveAction::AverageGroupPos(float dis, bool ranged, bool
continue;
if (!member->IsAlive() || member->GetMapId() != bot->GetMapId() || member->IsCharmed() ||
sServerFacade->GetDistance2d(bot, member) > dis)
ServerFacade::instance().GetDistance2d(bot, member) > dis)
continue;
averageX += member->GetPositionX();
@@ -2395,7 +2395,7 @@ float CombatFormationMoveAction::AverageGroupAngle(Unit* from, bool ranged, bool
continue;
if (!member->IsAlive() || member->GetMapId() != bot->GetMapId() || member->IsCharmed() ||
sServerFacade->GetDistance2d(bot, member) > sPlayerbotAIConfig->sightDistance)
ServerFacade::instance().GetDistance2d(bot, member) > sPlayerbotAIConfig.sightDistance)
continue;
cnt++;
@@ -2437,7 +2437,7 @@ Player* CombatFormationMoveAction::NearestGroupMember(float dis)
{
Player* member = ObjectAccessor::FindPlayer(itr->guid);
if (!member || !member->IsAlive() || member == bot || member->GetMapId() != bot->GetMapId() ||
member->IsCharmed() || sServerFacade->GetDistance2d(bot, member) > dis)
member->IsCharmed() || ServerFacade::instance().GetDistance2d(bot, member) > dis)
continue;
if (nearestDis > bot->GetExactDist(member))
{
@@ -2651,7 +2651,7 @@ bool MoveToLootAction::Execute(Event event)
if (!loot.IsLootPossible(bot))
return false;
return MoveNear(loot.GetWorldObject(bot), sPlayerbotAIConfig->contactDistance);
return MoveNear(loot.GetWorldObject(bot), sPlayerbotAIConfig.contactDistance);
}
bool MoveOutOfEnemyContactAction::Execute(Event event)
@@ -2660,7 +2660,7 @@ bool MoveOutOfEnemyContactAction::Execute(Event event)
if (!target)
return false;
return MoveTo(target, sPlayerbotAIConfig->contactDistance);
return MoveTo(target, sPlayerbotAIConfig.contactDistance);
}
bool MoveOutOfEnemyContactAction::isUseful() { return AI_VALUE2(bool, "inside target", "current target"); }
@@ -2674,8 +2674,8 @@ bool SetFacingTargetAction::Execute(Event event)
if (bot->HasUnitState(UNIT_STATE_IN_FLIGHT))
return true;
sServerFacade->SetFacingTo(bot, target);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay);
ServerFacade::instance().SetFacingTo(bot, target);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.reactDelay);
return true;
}
@@ -2754,7 +2754,7 @@ bool SetBehindTargetAction::Execute(Event event)
bool MoveOutOfCollisionAction::Execute(Event event)
{
float angle = M_PI * 2000 / frand(1.f, 1000.f);
float distance = sPlayerbotAIConfig->followDistance;
float distance = sPlayerbotAIConfig.followDistance;
return MoveTo(bot->GetMapId(), bot->GetPositionX() + cos(angle) * distance,
bot->GetPositionY() + sin(angle) * distance, bot->GetPositionZ());
}
@@ -2771,7 +2771,7 @@ bool MoveOutOfCollisionAction::isUseful()
bool MoveRandomAction::Execute(Event event)
{
float distance = sPlayerbotAIConfig->tooCloseDistance + urand(10, 30);
float distance = sPlayerbotAIConfig.tooCloseDistance + urand(10, 30);
Map* map = bot->GetMap();
for (int i = 0; i < 3; ++i)

View File

@@ -29,7 +29,7 @@ public:
protected:
bool JumpTo(uint32 mapId, float x, float y, float z, MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);
bool MoveNear(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->contactDistance,
bool MoveNear(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig.contactDistance,
MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);
bool MoveToLOS(WorldObject* target, bool ranged = false);
bool MoveTo(uint32 mapId, float x, float y, float z, bool idle = false, bool react = false,
@@ -38,10 +38,10 @@ protected:
bool backwards = false);
bool MoveTo(WorldObject* target, float distance = 0.0f,
MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);
bool MoveNear(WorldObject* target, float distance = sPlayerbotAIConfig->contactDistance,
bool MoveNear(WorldObject* target, float distance = sPlayerbotAIConfig.contactDistance,
MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);
float GetFollowAngle();
bool Follow(Unit* target, float distance = sPlayerbotAIConfig->followDistance);
bool Follow(Unit* target, float distance = sPlayerbotAIConfig.followDistance);
bool Follow(Unit* target, float distance, float angle);
bool ChaseTo(WorldObject* obj, float distance = 0.0f, float angle = 0.0f);
bool ReachCombatTo(Unit* target, float distance = 0.0f);
@@ -56,10 +56,10 @@ protected:
bool Flee(Unit* target);
void ClearIdleState();
void UpdateMovementState();
bool MoveAway(Unit* target, float distance = sPlayerbotAIConfig->fleeDistance, bool backwards = false);
bool MoveAway(Unit* target, float distance = sPlayerbotAIConfig.fleeDistance, bool backwards = false);
bool MoveFromGroup(float distance);
bool Move(float angle, float distance);
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig->followDistance,
bool MoveInside(uint32 mapId, float x, float y, float z, float distance = sPlayerbotAIConfig.followDistance,
MovementPriority priority = MovementPriority::MOVEMENT_NORMAL);
void CreateWp(Player* wpOwner, float x, float y, float z, float o, uint32 entry, bool important = false);
Position BestPositionForMeleeToFlee(Position pos, float radius);
@@ -86,7 +86,7 @@ private:
class FleeAction : public MovementAction
{
public:
FleeAction(PlayerbotAI* botAI, float distance = sPlayerbotAIConfig->spellDistance)
FleeAction(PlayerbotAI* botAI, float distance = sPlayerbotAIConfig.spellDistance)
: MovementAction(botAI, "flee"), distance(distance)
{
}
@@ -138,8 +138,8 @@ public:
bool Execute(Event event) override;
protected:
Position AverageGroupPos(float dis = sPlayerbotAIConfig->sightDistance, bool ranged = false, bool self = false);
Player* NearestGroupMember(float dis = sPlayerbotAIConfig->sightDistance);
Position AverageGroupPos(float dis = sPlayerbotAIConfig.sightDistance, bool ranged = false, bool self = false);
Player* NearestGroupMember(float dis = sPlayerbotAIConfig.sightDistance);
float AverageGroupAngle(Unit* from, bool ranged = false, bool self = false);
Position GetNearestPosition(const std::vector<Position>& positions);
int lastMoveTimer = 0;

View File

@@ -76,7 +76,7 @@ bool EatAction::Execute(Event event)
if (bot->isMoving())
{
bot->StopMoving();
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
// botAI->SetNextCheckDelay(sPlayerbotAIConfig.globalCoolDown);
// return false;
}

View File

@@ -16,12 +16,12 @@ bool PassLeadershipToMasterAction::Execute(Event event)
if (master && master != bot && bot->GetGroup() && bot->GetGroup()->IsMember(master->GetGUID()))
{
auto setLeaderOp = std::make_unique<GroupSetLeaderOperation>(bot->GetGUID(), master->GetGUID());
sPlayerbotWorldProcessor->QueueOperation(std::move(setLeaderOp));
PlayerbotWorldThreadProcessor::instance().QueueOperation(std::move(setLeaderOp));
if (!message.empty())
botAI->TellMasterNoFacing(message);
if (sRandomPlayerbotMgr->IsRandomBot(bot))
if (sRandomPlayerbotMgr.IsRandomBot(bot))
{
botAI->ResetStrategies();
botAI->Reset();

View File

@@ -23,7 +23,7 @@ bool PetsAction::Execute(Event event)
if (param.empty())
{
// If no parameter is provided, show usage instructions and return.
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_usage_error", "Usage: pet <aggressive|defensive|passive|stance|attack|follow|stay>", {});
botAI->TellError(text);
return false;
@@ -52,7 +52,7 @@ bool PetsAction::Execute(Event event)
// If no pets or guardians are found, notify and return.
if (targets.empty())
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_no_pet_error", "You have no pet or guardian pet.", {});
botAI->TellError(text);
return false;
@@ -65,19 +65,19 @@ bool PetsAction::Execute(Event event)
if (param == "aggressive")
{
react = REACT_AGGRESSIVE;
stanceText = sPlayerbotTextMgr->GetBotTextOrDefault(
stanceText = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_aggressive", "aggressive", {});
}
else if (param == "defensive")
{
react = REACT_DEFENSIVE;
stanceText = sPlayerbotTextMgr->GetBotTextOrDefault(
stanceText = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_defensive", "defensive", {});
}
else if (param == "passive")
{
react = REACT_PASSIVE;
stanceText = sPlayerbotTextMgr->GetBotTextOrDefault(
stanceText = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_passive", "passive", {});
}
// The "stance" command simply reports the current stance of each pet/guardian.
@@ -86,30 +86,30 @@ bool PetsAction::Execute(Event event)
for (Creature* target : targets)
{
std::string type = target->IsPet() ?
sPlayerbotTextMgr->GetBotTextOrDefault("pet_type_pet", "pet", {}) :
sPlayerbotTextMgr->GetBotTextOrDefault("pet_type_guardian", "guardian", {});
PlayerbotTextMgr::instance().GetBotTextOrDefault("pet_type_pet", "pet", {}) :
PlayerbotTextMgr::instance().GetBotTextOrDefault("pet_type_guardian", "guardian", {});
std::string name = target->GetName();
std::string stance;
switch (target->GetReactState())
{
case REACT_AGGRESSIVE:
stance = sPlayerbotTextMgr->GetBotTextOrDefault(
stance = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_aggressive", "aggressive", {});
break;
case REACT_DEFENSIVE:
stance = sPlayerbotTextMgr->GetBotTextOrDefault(
stance = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_defensive", "defensive", {});
break;
case REACT_PASSIVE:
stance = sPlayerbotTextMgr->GetBotTextOrDefault(
stance = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_passive", "passive", {});
break;
default:
stance = sPlayerbotTextMgr->GetBotTextOrDefault(
stance = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_unknown", "unknown", {});
break;
}
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_report", "Current stance of %type \"%name\": %stance.",
{{"type", type}, {"name", name}, {"stance", stance}});
botAI->TellMaster(text);
@@ -133,30 +133,30 @@ bool PetsAction::Execute(Event event)
// If no valid target is selected, show an error and return.
if (!targetUnit)
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_no_target_error", "No valid target selected by master.", {});
botAI->TellError(text);
return false;
}
if (!targetUnit->IsAlive())
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_target_dead_error", "Target is not alive.", {});
botAI->TellError(text);
return false;
}
if (!bot->IsValidAttackTarget(targetUnit))
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_invalid_target_error", "Target is not a valid attack target for the bot.", {});
botAI->TellError(text);
return false;
}
if (sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()) &&
if (sPlayerbotAIConfig.IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()) &&
(targetUnit->IsPlayer() || targetUnit->IsPet()) &&
(!bot->duel || bot->duel->Opponent != targetUnit))
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_pvp_prohibited_error", "I cannot command my pet to attack players in PvP prohibited areas.", {});
botAI->TellError(text);
return false;
@@ -208,15 +208,15 @@ bool PetsAction::Execute(Event event)
}
}
// Inform the master if the command succeeded or failed.
if (didAttack && sPlayerbotAIConfig->petChatCommandDebug == 1)
if (didAttack && sPlayerbotAIConfig.petChatCommandDebug == 1)
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_attack_success", "Pet commanded to attack your target.", {});
botAI->TellMaster(text);
}
else if (!didAttack)
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_attack_failed", "Pet did not attack. (Already attacking or unable to attack target)", {});
botAI->TellError(text);
}
@@ -226,9 +226,9 @@ bool PetsAction::Execute(Event event)
else if (param == "follow")
{
botAI->PetFollow();
if (sPlayerbotAIConfig->petChatCommandDebug == 1)
if (sPlayerbotAIConfig.petChatCommandDebug == 1)
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_follow_success", "Pet commanded to follow.", {});
botAI->TellMaster(text);
}
@@ -267,9 +267,9 @@ bool PetsAction::Execute(Event event)
charmInfo->SetForcedTargetGUID();
}
}
if (sPlayerbotAIConfig->petChatCommandDebug == 1)
if (sPlayerbotAIConfig.petChatCommandDebug == 1)
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stay_success", "Pet commanded to stay.", {});
botAI->TellMaster(text);
}
@@ -278,7 +278,7 @@ bool PetsAction::Execute(Event event)
// Unknown command: show usage instructions and return.
else
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_unknown_command_error", "Unknown pet command: %param. Use: pet <aggressive|defensive|passive|stance|attack|follow|stay>",
{{"param", param}});
botAI->TellError(text);
@@ -295,13 +295,13 @@ bool PetsAction::Execute(Event event)
}
// Inform the master of the new stance if debug is enabled.
if (sPlayerbotAIConfig->petChatCommandDebug == 1)
if (sPlayerbotAIConfig.petChatCommandDebug == 1)
{
std::string text = sPlayerbotTextMgr->GetBotTextOrDefault(
std::string text = PlayerbotTextMgr::instance().GetBotTextOrDefault(
"pet_stance_set_success", "Pet stance set to %stance.",
{{"stance", stanceText}});
botAI->TellMaster(text);
}
return true;
}
}

View File

@@ -120,7 +120,7 @@ bool MoveToPositionAction::isUseful()
{
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[qualifier];
float distance = AI_VALUE2(float, "distance", std::string("position_") + qualifier);
return pos.isSet() && distance > sPlayerbotAIConfig->followDistance && distance < sPlayerbotAIConfig->reactDistance;
return pos.isSet() && distance > sPlayerbotAIConfig.followDistance && distance < sPlayerbotAIConfig.reactDistance;
}
bool SetReturnPositionAction::Execute(Event event)
@@ -131,7 +131,7 @@ bool SetReturnPositionAction::Execute(Event event)
if (returnPos.isSet() && !randomPos.isSet())
{
float angle = 2 * M_PI * urand(0, 1000) / 100.0f;
float dist = sPlayerbotAIConfig->followDistance * urand(0, 1000) / 1000.0f;
float dist = sPlayerbotAIConfig.followDistance * urand(0, 1000) / 1000.0f;
float x = returnPos.x + cos(angle) * dist;
float y = returnPos.y + sin(angle) * dist;
float z = bot->GetPositionZ();
@@ -157,7 +157,7 @@ bool SetReturnPositionAction::isUseful()
bool ReturnAction::isUseful()
{
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[qualifier];
return pos.isSet() && AI_VALUE2(float, "distance", "position_random") > sPlayerbotAIConfig->followDistance;
return pos.isSet() && AI_VALUE2(float, "distance", "position_random") > sPlayerbotAIConfig.followDistance;
}
bool ReturnToStayPositionAction::isPossible()
@@ -167,7 +167,7 @@ bool ReturnToStayPositionAction::isPossible()
if (stayPosition.isSet())
{
const float distance = bot->GetDistance(stayPosition.x, stayPosition.y, stayPosition.z);
if (distance > sPlayerbotAIConfig->reactDistance)
if (distance > sPlayerbotAIConfig.reactDistance)
{
botAI->TellMaster("The stay position is too far to return. I am going to stay where I am now");

View File

@@ -118,7 +118,7 @@ std::string const QueryItemUsageAction::QueryItemUsage(ItemTemplate const* item)
std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item)
{
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
return "";
if (item->Bonding == BIND_WHEN_PICKED_UP)
@@ -133,7 +133,7 @@ std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item)
{
Item* sell = *i;
int32 price =
sell->GetCount() * sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot);
sell->GetCount() * sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr.GetSellMultiplier(bot);
if (!sellPrice || sellPrice > price)
sellPrice = price;
}
@@ -147,7 +147,7 @@ std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item)
if (usage == ITEM_USAGE_NONE)
return msg.str();
int32 buyPrice = item->BuyPrice * sRandomPlayerbotMgr->GetBuyMultiplier(bot);
int32 buyPrice = item->BuyPrice * sRandomPlayerbotMgr.GetBuyMultiplier(bot);
if (buyPrice)
{
if (sellPrice)

View File

@@ -73,7 +73,7 @@ bool QueryQuestAction::Execute(Event event)
{
uint32 limit = 0;
std::vector<TravelDestination*> allDestinations =
sTravelMgr->getQuestTravelDestinations(bot, questId, true, true, -1);
TravelMgr::instance().getQuestTravelDestinations(bot, questId, true, true, -1);
std::sort(allDestinations.begin(), allDestinations.end(), [ptr_botpos](TravelDestination* i, TravelDestination* j) {return i->distanceTo(ptr_botpos) < j->distanceTo(ptr_botpos); });
for (auto dest : allDestinations)

View File

@@ -182,7 +182,7 @@ bool QuestAction::ProcessQuests(WorldObject* questGiver)
{
ObjectGuid guid = questGiver->GetGUID();
if (bot->GetDistance(questGiver) > INTERACTION_DISTANCE && !sPlayerbotAIConfig->syncQuestWithPlayer)
if (bot->GetDistance(questGiver) > INTERACTION_DISTANCE && !sPlayerbotAIConfig.syncQuestWithPlayer)
{
//if (botAI->HasStrategy("debug", BotState::BOT_STATE_COMBAT) || botAI->HasStrategy("debug", BotState::BOT_STATE_NON_COMBAT))
@@ -190,7 +190,7 @@ bool QuestAction::ProcessQuests(WorldObject* questGiver)
return false;
}
if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, questGiver, sPlayerbotAIConfig->sightDistance))
if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, questGiver, sPlayerbotAIConfig.sightDistance))
bot->SetFacingToObject(questGiver);
bot->SetTarget(guid);
@@ -238,7 +238,7 @@ bool QuestAction::AcceptQuest(Quest const* quest, ObjectGuid questGiver)
p.rpos(0);
bot->GetSession()->HandleQuestgiverAcceptQuestOpcode(p);
if (bot->GetQuestStatus(questId) == QUEST_STATUS_NONE && sPlayerbotAIConfig->syncQuestWithPlayer)
if (bot->GetQuestStatus(questId) == QUEST_STATUS_NONE && sPlayerbotAIConfig.syncQuestWithPlayer)
{
Object* pObject = ObjectAccessor::GetObjectByTypeMask(*bot, questGiver,
TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM);
@@ -366,7 +366,7 @@ bool QuestUpdateAddItemAction::Execute(Event event)
placeholders["%quest_obj_required"] = std::to_string(requiredItemsCount);
if (botAI->HasStrategy("debug quest", BotState::BOT_STATE_COMBAT) || botAI->HasStrategy("debug quest", BotState::BOT_STATE_NON_COMBAT))
{
const auto text = BOT_TEXT2("%quest_link - %item_link %quest_obj_available/%quest_obj_required", placeholders);
const auto text = PlayerbotTextMgr::instance().GetBotText("%quest_link - %item_link %quest_obj_available/%quest_obj_required", placeholders);
botAI->Say(text);
LOG_INFO("playerbots", "{} => {}", bot->GetName(), text);
}
@@ -454,7 +454,7 @@ bool QuestUpdateFailedTimerAction::Execute(Event event)
{
std::map<std::string, std::string> placeholders;
placeholders["%quest_link"] = botAI->GetChatHelper()->FormatQuest(qInfo);
botAI->TellMaster(BOT_TEXT2("Failed timer for %quest_link, abandoning", placeholders));
botAI->TellMaster(PlayerbotTextMgr::instance().GetBotText("Failed timer for %quest_link, abandoning", placeholders));
BroadcastHelper::BroadcastQuestUpdateFailedTimer(botAI, bot, qInfo);
}
else

View File

@@ -20,4 +20,4 @@ bool QuestConfirmAcceptAction::Execute(Event event)
botAI->TellMaster(out);
bot->GetSession()->HandleQuestConfirmAccept(sendPacket);
return true;
}
}

View File

@@ -24,4 +24,4 @@ public:
bool Execute(Event event) override;
};
#endif
#endif

View File

@@ -10,7 +10,7 @@
bool RandomBotUpdateAction::Execute(Event event)
{
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
return false;
if (bot->GetGroup() && botAI->GetGroupLeader())
@@ -20,10 +20,10 @@ bool RandomBotUpdateAction::Execute(Event event)
return true;
}
if (botAI->HasPlayerNearby(sPlayerbotAIConfig->grindDistance))
if (botAI->HasPlayerNearby(sPlayerbotAIConfig.grindDistance))
return true;
return sRandomPlayerbotMgr->ProcessBot(bot);
return sRandomPlayerbotMgr.ProcessBot(bot);
}
bool RandomBotUpdateAction::isUseful() { return AI_VALUE(bool, "random bot update"); }

View File

@@ -28,7 +28,7 @@ bool ReachTargetAction::isUseful()
Unit* target = GetTarget();
// float dis = distance + CONTACT_DISTANCE;
return target &&
!bot->IsWithinCombatRange(target, distance); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float,
!bot->IsWithinCombatRange(target, distance); // ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float,
// "distance", GetTargetName()), distance);
}
@@ -42,8 +42,8 @@ bool CastReachTargetSpellAction::isUseful()
return false;
}
return sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"),
(distance + sPlayerbotAIConfig->contactDistance));
return ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "current target"),
(distance + sPlayerbotAIConfig.contactDistance));
}
ReachSpellAction::ReachSpellAction(PlayerbotAI* botAI)

View File

@@ -44,7 +44,7 @@ protected:
class ReachMeleeAction : public ReachTargetAction
{
public:
ReachMeleeAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach melee", sPlayerbotAIConfig->meleeDistance) {}
ReachMeleeAction(PlayerbotAI* botAI) : ReachTargetAction(botAI, "reach melee", sPlayerbotAIConfig.meleeDistance) {}
};
class ReachSpellAction : public ReachTargetAction

View File

@@ -47,7 +47,7 @@ class HealthChecker : public ReadyChecker
public:
bool Check(PlayerbotAI* botAI, AiObjectContext* context) override
{
return AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig->almostFullHealth;
return AI_VALUE2(uint8, "health", "self target") > sPlayerbotAIConfig.almostFullHealth;
}
std::string const getName() override { return "HP"; }
@@ -59,7 +59,7 @@ public:
bool Check(PlayerbotAI* botAI, AiObjectContext* context) override
{
return !AI_VALUE2(bool, "has mana", "self target") ||
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->mediumHealth;
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.mediumHealth;
}
std::string const getName() override { return "MP"; }
@@ -73,7 +73,7 @@ public:
Player* bot = botAI->GetBot();
if (Player* master = botAI->GetMaster())
{
bool distance = bot->GetDistance(master) <= sPlayerbotAIConfig->sightDistance;
bool distance = bot->GetDistance(master) <= sPlayerbotAIConfig.sightDistance;
if (!distance)
{
return false;

View File

@@ -183,9 +183,9 @@ bool AutoReleaseSpiritAction::ShouldAutoRelease() const
return false;
}
return sServerFacade->IsDistanceGreaterThan(
return ServerFacade::instance().IsDistanceGreaterThan(
AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->sightDistance);
sPlayerbotAIConfig.sightDistance);
}
bool AutoReleaseSpiritAction::ShouldDelayBattlegroundRelease() const

View File

@@ -44,7 +44,7 @@ bool ResetAiAction::Execute(Event event)
}
}
}
sPlayerbotRepository->Reset(botAI);
PlayerbotRepository::instance().Reset(botAI);
botAI->ResetStrategies(false);
botAI->TellMaster("AI was reset to defaults");
return true;

View File

@@ -20,16 +20,16 @@ bool RevealGatheringItemAction::Execute(Event event)
return false;
std::list<GameObject*> targets;
AnyGameObjectInObjectRangeCheck u_check(bot, sPlayerbotAIConfig->grindDistance);
AnyGameObjectInObjectRangeCheck u_check(bot, sPlayerbotAIConfig.grindDistance);
Acore::GameObjectListSearcher<AnyGameObjectInObjectRangeCheck> searcher(bot, targets, u_check);
Cell::VisitObjects(bot, searcher, sPlayerbotAIConfig->reactDistance);
Cell::VisitObjects(bot, searcher, sPlayerbotAIConfig.reactDistance);
std::vector<GameObject*> result;
for (GameObject* go : targets)
{
if (!go || !go->isSpawned() ||
sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, go),
sPlayerbotAIConfig->lootDistance))
ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, go),
sPlayerbotAIConfig.lootDistance))
continue;
if (LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->GetLockId()))

View File

@@ -24,8 +24,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
WorldPacket& p = event.getPacket();
if (!p.empty() && p.GetOpcode() == CMSG_RECLAIM_CORPSE && groupLeader && !corpse && bot->IsAlive())
{
if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->farDistance))
if (ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig.farDistance))
{
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
{
@@ -46,8 +46,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
if (groupLeader)
{
if (!GET_PLAYERBOT_AI(groupLeader) && groupLeader->isDead() && groupLeader->GetCorpse() &&
sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->farDistance))
ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig.farDistance))
return false;
}
@@ -87,8 +87,8 @@ bool FindCorpseAction::Execute(Event event)
// if (groupLeader)
// {
// if (!GET_PLAYERBOT_AI(groupLeader) &&
// sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
// sPlayerbotAIConfig->farDistance)) return false;
// ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
// sPlayerbotAIConfig.farDistance)) return false;
// }
uint32 dCount = AI_VALUE(uint32, "death count");
@@ -101,8 +101,8 @@ bool FindCorpseAction::Execute(Event event)
// bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
// bot->GetName().c_str());
context->GetValue<uint32>("death count")->Set(0);
// sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
sRandomPlayerbotMgr->Revive(bot);
// sRandomPlayerbotMgr.RandomTeleportForLevel(bot);
sRandomPlayerbotMgr.Revive(bot);
return true;
}
}
@@ -123,7 +123,7 @@ bool FindCorpseAction::Execute(Event event)
{
if (moveToLeader) // We are near group leader.
{
if (botPos.fDist(leaderPos) < sPlayerbotAIConfig->spellDistance)
if (botPos.fDist(leaderPos) < sPlayerbotAIConfig.spellDistance)
return false;
}
else if (deadTime > 8 * MINUTE) // We have walked too long already.
@@ -138,7 +138,7 @@ bool FindCorpseAction::Execute(Event event)
}
// If we are getting close move to a save ressurrection spot instead of just the corpse.
if (corpseDist < sPlayerbotAIConfig->reactDistance)
if (corpseDist < sPlayerbotAIConfig.reactDistance)
{
if (moveToLeader)
moveToPos = leaderPos;
@@ -162,7 +162,7 @@ bool FindCorpseAction::Execute(Event event)
if (!botAI->AllowActivity(ALL_ACTIVITY))
{
uint32 delay = sServerFacade->GetDistance2d(bot, corpse) /
uint32 delay = ServerFacade::instance().GetDistance2d(bot, corpse) /
bot->GetSpeed(MOVE_RUN); // Time a bot would take to travel to it's corpse.
delay = std::min(delay, uint32(10 * MINUTE)); // Cap time to get to corpse at 10 minutes.
@@ -308,7 +308,7 @@ bool SpiritHealerAction::Execute(Event event)
GraveyardStruct const* ClosestGrave =
GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10);
if (bot->GetDistance2d(ClosestGrave->x, ClosestGrave->y) < sPlayerbotAIConfig->sightDistance)
if (bot->GetDistance2d(ClosestGrave->x, ClosestGrave->y) < sPlayerbotAIConfig.sightDistance)
{
GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)

View File

@@ -130,7 +130,7 @@ bool RpgAction::SetNextRpgAction()
std::mt19937 gen(time(0));
sTravelMgr->weighted_shuffle(actions.begin(), actions.end(), relevances.begin(), relevances.end(), gen);
TravelMgr::instance().weighted_shuffle(actions.begin(), actions.end(), relevances.begin(), relevances.end(), gen);
Action* action = actions.front();

View File

@@ -77,9 +77,9 @@ void RpgHelper::setFacing(GuidPosition guidPosition)
void RpgHelper::setDelay(bool waitForGroup)
{
if (!botAI->HasRealPlayerMaster() || (waitForGroup && botAI->GetGroupLeader() == bot && bot->GetGroup()))
botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.rpgDelay);
else
botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay / 5);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.rpgDelay / 5);
}
bool RpgSubAction::isPossible() { return rpg->guidP() && rpg->guidP().GetWorldObject(); }
@@ -392,7 +392,7 @@ bool RpgTradeUsefulAction::Execute(Event event)
bot->Say("Start trade with" + chat->FormatWorldobject(player),
(bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.rpgDelay);
return true;
}
@@ -402,7 +402,7 @@ bool RpgTradeUsefulAction::Execute(Event event)
bool RpgDuelAction::isUseful()
{
// do not offer duel in non pvp areas
if (sPlayerbotAIConfig->IsInPvpProhibitedZone(bot->GetZoneId()))
if (sPlayerbotAIConfig.IsInPvpProhibitedZone(bot->GetZoneId()))
return false;
// Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities)
@@ -440,4 +440,4 @@ bool RpgMountAnimAction::Execute(Event event)
bot->GetSession()->HandleMountSpecialAnimOpcode(p);
return true;
}
}

View File

@@ -134,7 +134,7 @@ bool SayAction::Execute(Event event)
}
// load text based on chance
if (!sPlayerbotTextMgr->GetBotText(qualifier, text, placeholders))
if (!PlayerbotTextMgr::instance().GetBotText(qualifier, text, placeholders))
return false;
if (text.find("/y ") == 0)
@@ -206,7 +206,7 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32& type, uint32& guid1, uint
}
//toxic links
if (msg.starts_with(sPlayerbotAIConfig->toxicLinksPrefix)
if (msg.starts_with(sPlayerbotAIConfig.toxicLinksPrefix)
&& (GET_PLAYERBOT_AI(bot)->GetChatHelper()->ExtractAllItemIds(msg).size() > 0 || GET_PLAYERBOT_AI(bot)->GetChatHelper()->ExtractAllQuestIds(msg).size() > 0))
{
HandleToxicLinksReply(bot, chatChannelSource, msg, name);
@@ -230,7 +230,7 @@ bool ChatReplyAction::HandleThunderfuryReply(Player* bot, ChatChannelSource chat
const auto thunderfury = sObjectMgr->GetItemTemplate(19019);
placeholders["%thunderfury_link"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatItem(thunderfury);
std::string responseMessage = BOT_TEXT2("thunderfury_spam", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("thunderfury_spam", placeholders);
switch (chatChannelSource)
{
@@ -271,8 +271,8 @@ bool ChatReplyAction::HandleToxicLinksReply(Player* bot, ChatChannelSource chatC
std::vector<Item*> botItems = GET_PLAYERBOT_AI(bot)->GetInventoryAndEquippedItems();
std::map<std::string, std::string> placeholders;
placeholders["%random_inventory_item_link"] = botItems.size() > 0 ? GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatItem(botItems[rand() % botItems.size()]->GetTemplate()) : BOT_TEXT1("string_empty_link");
placeholders["%prefix"] = sPlayerbotAIConfig->toxicLinksPrefix;
placeholders["%random_inventory_item_link"] = botItems.size() > 0 ? GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatItem(botItems[rand() % botItems.size()]->GetTemplate()) : PlayerbotTextMgr::instance().GetBotText("string_empty_link");
placeholders["%prefix"] = sPlayerbotAIConfig.toxicLinksPrefix;
if (incompleteQuests.size() > 0)
{
@@ -287,8 +287,8 @@ bool ChatReplyAction::HandleToxicLinksReply(Player* bot, ChatChannelSource chatC
placeholders["%my_role"] = ChatHelper::FormatClass(bot, AiFactory::GetPlayerSpecTab(bot));
AreaTableEntry const* current_area = GET_PLAYERBOT_AI(bot)->GetCurrentArea();
AreaTableEntry const* current_zone = GET_PLAYERBOT_AI(bot)->GetCurrentZone();
placeholders["%area_name"] = current_area ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_area) : BOT_TEXT1("string_unknown_area");
placeholders["%zone_name"] = current_zone ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_zone) : BOT_TEXT1("string_unknown_area");
placeholders["%area_name"] = current_area ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_area) : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%zone_name"] = current_zone ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_zone) : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%my_class"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatClass(bot->getClass());
placeholders["%my_race"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatRace(bot->getRace());
placeholders["%my_level"] = std::to_string(bot->GetLevel());
@@ -297,17 +297,17 @@ bool ChatReplyAction::HandleToxicLinksReply(Player* bot, ChatChannelSource chatC
{
case ChatChannelSource::SRC_WORLD:
{
GET_PLAYERBOT_AI(bot)->SayToWorld(BOT_TEXT2("suggest_toxic_links", placeholders));
GET_PLAYERBOT_AI(bot)->SayToWorld(PlayerbotTextMgr::instance().GetBotText("suggest_toxic_links", placeholders));
break;
}
case ChatChannelSource::SRC_GENERAL:
{
GET_PLAYERBOT_AI(bot)->SayToChannel(BOT_TEXT2("suggest_toxic_links", placeholders), ChatChannelId::GENERAL);
GET_PLAYERBOT_AI(bot)->SayToChannel(PlayerbotTextMgr::instance().GetBotText("suggest_toxic_links", placeholders), ChatChannelId::GENERAL);
break;
}
case ChatChannelSource::SRC_GUILD:
{
GET_PLAYERBOT_AI(bot)->SayToGuild(BOT_TEXT2("suggest_toxic_links", placeholders));
GET_PLAYERBOT_AI(bot)->SayToGuild(PlayerbotTextMgr::instance().GetBotText("suggest_toxic_links", placeholders));
break;
}
default:
@@ -343,8 +343,8 @@ bool ChatReplyAction::HandleWTBItemsReply(Player* bot, ChatChannelSource chatCha
placeholders["%other_name"] = name;
AreaTableEntry const* current_area = GET_PLAYERBOT_AI(bot)->GetCurrentArea();
AreaTableEntry const* current_zone = GET_PLAYERBOT_AI(bot)->GetCurrentZone();
placeholders["%area_name"] = current_area ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_area) : BOT_TEXT1("string_unknown_area");
placeholders["%zone_name"] = current_zone ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_zone) : BOT_TEXT1("string_unknown_area");
placeholders["%area_name"] = current_area ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_area) : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%zone_name"] = current_zone ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_zone) : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%my_class"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatClass(bot->getClass());
placeholders["%my_race"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatRace(bot->getRace());
placeholders["%my_level"] = std::to_string(bot->GetLevel());
@@ -365,12 +365,12 @@ bool ChatReplyAction::HandleWTBItemsReply(Player* bot, ChatChannelSource chatCha
//may reply to the same channel or whisper
if (urand(0, 1))
{
std::string responseMessage = BOT_TEXT2("response_wtb_items_channel", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_wtb_items_channel", placeholders);
GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
}
else
{
std::string responseMessage = BOT_TEXT2("response_wtb_items_whisper", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_wtb_items_whisper", placeholders);
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
}
break;
@@ -380,12 +380,12 @@ bool ChatReplyAction::HandleWTBItemsReply(Player* bot, ChatChannelSource chatCha
//may reply to the same channel or whisper
if (urand(0, 1))
{
std::string responseMessage = BOT_TEXT2("response_wtb_items_channel", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_wtb_items_channel", placeholders);
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::GENERAL);
}
else
{
std::string responseMessage = BOT_TEXT2("response_wtb_items_whisper", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_wtb_items_whisper", placeholders);
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
}
break;
@@ -395,12 +395,12 @@ bool ChatReplyAction::HandleWTBItemsReply(Player* bot, ChatChannelSource chatCha
//may reply to the same channel or whisper
if (urand(0, 1))
{
std::string responseMessage = BOT_TEXT2("response_wtb_items_channel", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_wtb_items_channel", placeholders);
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::TRADE);
}
else
{
std::string responseMessage = BOT_TEXT2("response_wtb_items_whisper", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_wtb_items_whisper", placeholders);
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
}
break;
@@ -438,8 +438,8 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
placeholders["%other_name"] = name;
AreaTableEntry const* current_area = GET_PLAYERBOT_AI(bot)->GetCurrentArea();
AreaTableEntry const* current_zone = GET_PLAYERBOT_AI(bot)->GetCurrentZone();
placeholders["%area_name"] = current_area ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_area) : BOT_TEXT1("string_unknown_area");
placeholders["%zone_name"] = current_zone ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_zone) : BOT_TEXT1("string_unknown_area");
placeholders["%area_name"] = current_area ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_area) : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%zone_name"] = current_zone ? GET_PLAYERBOT_AI(bot)->GetLocalizedAreaName(current_zone) : PlayerbotTextMgr::instance().GetBotText("string_unknown_area");
placeholders["%my_class"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatClass(bot->getClass());
placeholders["%my_race"] = GET_PLAYERBOT_AI(bot)->GetChatHelper()->FormatRace(bot->getRace());
placeholders["%my_level"] = std::to_string(bot->GetLevel());
@@ -458,12 +458,12 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
//may reply to the same channel or whisper
if (urand(0, 1))
{
std::string responseMessage = BOT_TEXT2("response_lfg_quests_channel", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_lfg_quests_channel", placeholders);
GET_PLAYERBOT_AI(bot)->SayToWorld(responseMessage);
}
else
{
std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_lfg_quests_whisper", placeholders);
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
}
break;
@@ -473,12 +473,12 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
//may reply to the same channel or whisper
if (urand(0, 1))
{
std::string responseMessage = BOT_TEXT2("response_lfg_quests_channel", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_lfg_quests_channel", placeholders);
GET_PLAYERBOT_AI(bot)->SayToChannel(responseMessage, ChatChannelId::GENERAL);
}
else
{
std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_lfg_quests_whisper", placeholders);
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
}
break;
@@ -487,7 +487,7 @@ bool ChatReplyAction::HandleLFGQuestsReply(Player* bot, ChatChannelSource chatCh
{
//do not reply to the chat
//may whisper
std::string responseMessage = BOT_TEXT2("response_lfg_quests_whisper", placeholders);
std::string responseMessage = PlayerbotTextMgr::instance().GetBotText("response_lfg_quests_whisper", placeholders);
GET_PLAYERBOT_AI(bot)->Whisper(responseMessage, name);
break;
}
@@ -1042,7 +1042,7 @@ std::string ChatReplyAction::GenerateReplyMessage(Player* bot, std::string& inco
// load text if needed
if (respondsText.empty())
{
respondsText = BOT_TEXT2(replyType, name);
respondsText = PlayerbotTextMgr::instance().GetBotText(replyType, name);
}
if (respondsText.size() > 255)

View File

@@ -10,7 +10,7 @@
bool SecurityCheckAction::isUseful()
{
return sRandomPlayerbotMgr->IsRandomBot(bot) && botAI->GetMaster() &&
return sRandomPlayerbotMgr.IsRandomBot(bot) && botAI->GetMaster() &&
botAI->GetMaster()->GetSession()->GetSecurity() < SEC_GAMEMASTER && !GET_PLAYERBOT_AI(botAI->GetMaster());
}

View File

@@ -20,7 +20,7 @@ Creature* SeeSpellAction::CreateWps(Player* wpOwner, float x, float y, float z,
bool important)
{
float dist = wpOwner->GetDistance(x, y, z);
float delay = 1000.0f * dist / wpOwner->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig->reactDelay;
float delay = 1000.0f * dist / wpOwner->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig.reactDelay;
if (!important)
delay *= 0.25;
@@ -61,7 +61,7 @@ bool SeeSpellAction::Execute(Event event)
if (FISHING_SPELLS.find(spellId) != FISHING_SPELLS.end())
{
if (AI_VALUE(bool, "can fish") && sPlayerbotAIConfig->enableFishingWithMaster)
if (AI_VALUE(bool, "can fish") && sPlayerbotAIConfig.enableFishingWithMaster)
{
botAI->ChangeStrategy("+master fishing", BOT_STATE_NON_COMBAT);
return true;

View File

@@ -14,7 +14,7 @@
bool SendMailAction::Execute(Event event)
{
uint32 account = bot->GetSession()->GetAccountId();
bool randomBot = sPlayerbotAIConfig->IsInRandomAccountList(account);
bool randomBot = sPlayerbotAIConfig.IsInRandomAccountList(account);
GuidVector gos = *context->GetValue<GuidVector>("nearest game objects");
bool mailboxFound = false;

View File

@@ -109,4 +109,4 @@ bool AutoShareQuestAction::Execute(Event event)
bool AutoShareQuestAction::isUseful()
{
return bot->GetGroup() && !botAI->HasActivePlayerMaster();
}
}

View File

@@ -19,7 +19,7 @@ bool StayActionBase::Stay()
if (bot->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
return false;
uint32 sitDelay = sPlayerbotAIConfig->sitDelay / 1000;
uint32 sitDelay = sPlayerbotAIConfig.sitDelay / 1000;
time_t stayTime = AI_VALUE(time_t, "stay time");
time_t now = time(nullptr);
if (!stayTime)
@@ -48,7 +48,7 @@ bool StayAction::isUseful()
if (stayPosition.isSet())
{
const float distance = bot->GetDistance(stayPosition.x, stayPosition.y, stayPosition.z);
if (sPlayerbotAIConfig->followDistance)
if (sPlayerbotAIConfig.followDistance)
{
return false;
}

View File

@@ -54,7 +54,7 @@ SuggestWhatToDoAction::SuggestWhatToDoAction(PlayerbotAI* botAI, std::string con
bool SuggestWhatToDoAction::isUseful()
{
if (!sRandomPlayerbotMgr->IsRandomBot(bot) || bot->GetGroup() || bot->GetInstanceId() || bot->GetBattleground())
if (!sRandomPlayerbotMgr.IsRandomBot(bot) || bot->GetGroup() || bot->GetInstanceId() || bot->GetBattleground())
return false;
std::string qualifier = "suggest what to do";
@@ -140,7 +140,7 @@ void SuggestWhatToDoAction::grindMaterials()
placeholders["%role"] = chat->formatClass(bot, AiFactory::GetPlayerSpecTab(bot));
placeholders["%category"] = item;
spam(BOT_TEXT2("suggest_trade", placeholders), urand(0, 1) ? 0x3C : 0x18, !urand(0, 2), !urand(0,
spam(PlayerbotTextMgr::instance().GetBotText("suggest_trade", placeholders), urand(0, 1) ? 0x3C : 0x18, !urand(0, 2), !urand(0,
3)); return;
}
}
@@ -260,9 +260,9 @@ SuggestDungeonAction::SuggestDungeonAction(PlayerbotAI* botAI) : SuggestWhatToDo
bool SuggestDungeonAction::Execute(Event event)
{
// TODO: use sPlayerbotDungeonRepository
// TODO: use PlayerbotDungeonRepository::instance()
if (!sPlayerbotAIConfig->randomBotSuggestDungeons || bot->GetGroup())
if (!sPlayerbotAIConfig.randomBotSuggestDungeons || bot->GetGroup())
return false;
if (instances.empty())
@@ -373,7 +373,7 @@ bool SuggestTradeAction::Execute(Event event)
if (!proto)
return false;
uint32 price = proto->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot) * count;
uint32 price = proto->SellPrice * sRandomPlayerbotMgr.GetSellMultiplier(bot) * count;
if (!price)
return false;

View File

@@ -24,7 +24,7 @@ bool TalkToQuestGiverAction::ProcessQuest(Quest const* quest, Object* questGiver
QuestStatus status = bot->GetQuestStatus(quest->GetQuestId());
Player* master = GetMaster();
if (sPlayerbotAIConfig->syncQuestForPlayer && master)
if (sPlayerbotAIConfig.syncQuestForPlayer && master)
{
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
if (!masterBotAI || masterBotAI->IsRealPlayer())
@@ -35,7 +35,7 @@ bool TalkToQuestGiverAction::ProcessQuest(Quest const* quest, Object* questGiver
}
}
if (sPlayerbotAIConfig->syncQuestWithPlayer)
if (sPlayerbotAIConfig.syncQuestWithPlayer)
{
if (master && master->GetQuestStatus(quest->GetQuestId()) == QUEST_STATUS_COMPLETE &&
(status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_FAILED))
@@ -105,14 +105,14 @@ void TalkToQuestGiverAction::RewardNoItem(Quest const* quest, Object* questGiver
if (bot->CanRewardQuest(quest, false))
{
out << BOT_TEXT2("quest_status_completed", args);
out << PlayerbotTextMgr::instance().GetBotText("quest_status_completed", args);
BroadcastHelper::BroadcastQuestTurnedIn(botAI, bot, quest);
bot->RewardQuest(quest, 0, questGiver, false);
}
else
{
out << BOT_TEXT2("quest_status_unable_to_complete", args);
out << PlayerbotTextMgr::instance().GetBotText("quest_status_unable_to_complete", args);
}
}
@@ -126,13 +126,13 @@ void TalkToQuestGiverAction::RewardSingleItem(Quest const* quest, Object* questG
if (bot->CanRewardQuest(quest, index, false))
{
out << BOT_TEXT2("quest_status_complete_single_reward", args);
out << PlayerbotTextMgr::instance().GetBotText("quest_status_complete_single_reward", args);
BroadcastHelper::BroadcastQuestTurnedIn(botAI, bot, quest);
bot->RewardQuest(quest, index, questGiver, true);
}
else
{
out << BOT_TEXT2("quest_status_unable_to_complete", args);
out << PlayerbotTextMgr::instance().GetBotText("quest_status_unable_to_complete", args);
}
}
@@ -171,7 +171,7 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques
std::set<uint32> bestIds;
std::ostringstream outid;
if (!botAI->IsAlt() || sPlayerbotAIConfig->autoPickReward == "yes")
if (!botAI->IsAlt() || sPlayerbotAIConfig.autoPickReward == "yes")
{
bestIds = BestRewards(quest);
if (!bestIds.empty())
@@ -198,7 +198,7 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques
AskToSelectReward(quest, out, true);
}
}
else if (sPlayerbotAIConfig->autoPickReward == "no")
else if (sPlayerbotAIConfig.autoPickReward == "no")
{
// Old functionality, list rewards.
AskToSelectReward(quest, out, false);
@@ -260,7 +260,7 @@ bool TurnInQueryQuestAction::Execute(Event event)
QuestStatus status = bot->GetQuestStatus(quest->GetQuestId());
Player* master = GetMaster();
if (sPlayerbotAIConfig->syncQuestForPlayer && master)
if (sPlayerbotAIConfig.syncQuestForPlayer && master)
{
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
if (!masterBotAI || masterBotAI->IsRealPlayer())
@@ -271,7 +271,7 @@ bool TurnInQueryQuestAction::Execute(Event event)
}
}
if (sPlayerbotAIConfig->syncQuestWithPlayer)
if (sPlayerbotAIConfig.syncQuestWithPlayer)
{
if (status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_FAILED)
{

View File

@@ -152,4 +152,4 @@ bool TellCalculateItemAction::Execute(Event event)
out << "Calculated score of " << chat->FormatItem(proto) << " : " << score;
botAI->TellMasterNoFacing(out.str());
return true;
}
}

View File

@@ -15,7 +15,7 @@ bool TradeAction::Execute(Event event)
std::string const text = event.getParam();
// If text starts with any excluded prefix, don't process it further.
for (auto const& prefix : sPlayerbotAIConfig->tradeActionExcludedPrefixes)
for (auto const& prefix : sPlayerbotAIConfig.tradeActionExcludedPrefixes)
{
if (text.find(prefix) == 0)
return false;

View File

@@ -32,7 +32,7 @@ bool TradeStatusAction::Execute(Event event)
return false;
}
if (sPlayerbotAIConfig->enableRandomBotTrading == 0 && (sRandomPlayerbotMgr->IsRandomBot(bot)|| sRandomPlayerbotMgr->IsAddclassBot(bot)))
if (sPlayerbotAIConfig.enableRandomBotTrading == 0 && (sRandomPlayerbotMgr.IsRandomBot(bot)|| sRandomPlayerbotMgr.IsAddclassBot(bot)))
{
bot->Whisper("Trading is disabled", LANG_UNIVERSAL, trader);
return false;
@@ -61,7 +61,7 @@ bool TradeStatusAction::Execute(Event event)
uint32 status = 0;
p << status;
uint32 discount = sRandomPlayerbotMgr->GetTradeDiscount(bot, trader);
uint32 discount = sRandomPlayerbotMgr.GetTradeDiscount(bot, trader);
if (CheckTrade())
{
int32 botMoney = CalculateCost(bot, true);
@@ -81,7 +81,7 @@ bool TradeStatusAction::Execute(Event event)
bot->GetSession()->HandleAcceptTradeOpcode(p);
if (bot->GetTradeData())
{
sRandomPlayerbotMgr->SetTradeDiscount(bot, trader, discount);
sRandomPlayerbotMgr.SetTradeDiscount(bot, trader, discount);
return false;
}
@@ -96,7 +96,7 @@ bool TradeStatusAction::Execute(Event event)
craftData.AddObtained(itemId, count);
}
sGuildTaskMgr->CheckItemTask(itemId, count, trader, bot);
GuildTaskMgr::instance().CheckItemTask(itemId, count, trader, bot);
}
for (std::map<uint32, uint32>::iterator i = takenItemIds.begin(); i != takenItemIds.end(); ++i)
@@ -116,7 +116,7 @@ bool TradeStatusAction::Execute(Event event)
}
else if (status == TRADE_STATUS_BEGIN_TRADE)
{
if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, trader, sPlayerbotAIConfig->sightDistance))
if (!bot->HasInArc(CAST_ANGLE_IN_FRONT, trader, sPlayerbotAIConfig.sightDistance))
bot->SetFacingToObject(trader);
BeginTrade();
@@ -141,9 +141,9 @@ void TradeStatusAction::BeginTrade()
botAI->TellMaster("=== Inventory ===");
TellItems(visitor.items, visitor.soulbound);
if (sRandomPlayerbotMgr->IsRandomBot(bot))
if (sRandomPlayerbotMgr.IsRandomBot(bot))
{
uint32 discount = sRandomPlayerbotMgr->GetTradeDiscount(bot, botAI->GetMaster());
uint32 discount = sRandomPlayerbotMgr.GetTradeDiscount(bot, botAI->GetMaster());
if (discount)
{
std::ostringstream out;
@@ -198,7 +198,7 @@ bool TradeStatusAction::CheckTrade()
return false;
}
uint32 accountId = bot->GetSession()->GetAccountId();
if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId))
if (!sPlayerbotAIConfig.IsInRandomAccountList(accountId))
{
int32 botItemsMoney = CalculateCost(bot, true);
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;
@@ -214,12 +214,12 @@ bool TradeStatusAction::CheckTrade()
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;
int32 playerItemsMoney = CalculateCost(trader, false);
int32 playerMoney = trader->GetTradeData()->GetMoney() + playerItemsMoney;
if (botItemsMoney > 0 && sPlayerbotAIConfig->enableRandomBotTrading == 2 && (sRandomPlayerbotMgr->IsRandomBot(bot)|| sRandomPlayerbotMgr->IsAddclassBot(bot)))
if (botItemsMoney > 0 && sPlayerbotAIConfig.enableRandomBotTrading == 2 && (sRandomPlayerbotMgr.IsRandomBot(bot)|| sRandomPlayerbotMgr.IsAddclassBot(bot)))
{
bot->Whisper("Selling is disabled.", LANG_UNIVERSAL, trader);
return false;
}
if (playerItemsMoney && sPlayerbotAIConfig->enableRandomBotTrading == 3 && (sRandomPlayerbotMgr->IsRandomBot(bot)|| sRandomPlayerbotMgr->IsAddclassBot(bot)))
if (playerItemsMoney && sPlayerbotAIConfig.enableRandomBotTrading == 3 && (sRandomPlayerbotMgr.IsRandomBot(bot)|| sRandomPlayerbotMgr.IsAddclassBot(bot)))
{
bot->Whisper("Buying is disabled.", LANG_UNIVERSAL, trader);
return false;
@@ -262,7 +262,7 @@ bool TradeStatusAction::CheckTrade()
return false;
}
int32 discount = (int32)sRandomPlayerbotMgr->GetTradeDiscount(bot, trader);
int32 discount = (int32)sRandomPlayerbotMgr.GetTradeDiscount(bot, trader);
int32 delta = playerMoney - botMoney;
int32 moneyDelta = (int32)trader->GetTradeData()->GetMoney() - (int32)bot->GetTradeData()->GetMoney();
bool success = false;
@@ -287,7 +287,7 @@ bool TradeStatusAction::CheckTrade()
if (success)
{
sRandomPlayerbotMgr->AddTradeDiscount(bot, trader, delta);
sRandomPlayerbotMgr.AddTradeDiscount(bot, trader, delta);
switch (urand(0, 4))
{
case 0:
@@ -353,11 +353,11 @@ int32 TradeStatusAction::CalculateCost(Player* player, bool sell)
if (sell)
{
sum += item->GetCount() * proto->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot);
sum += item->GetCount() * proto->SellPrice * sRandomPlayerbotMgr.GetSellMultiplier(bot);
}
else
{
sum += item->GetCount() * proto->BuyPrice * sRandomPlayerbotMgr->GetBuyMultiplier(bot);
sum += item->GetCount() * proto->BuyPrice * sRandomPlayerbotMgr.GetBuyMultiplier(bot);
}
}

View File

@@ -12,7 +12,7 @@
void TrainerAction::Learn(uint32 cost, const Trainer::Spell tSpell, std::ostringstream& msg)
{
if (sPlayerbotAIConfig->autoTrainSpells != "free" && !botAI->HasCheat(BotCheatMask::gold))
if (sPlayerbotAIConfig.autoTrainSpells != "free" && !botAI->HasCheat(BotCheatMask::gold))
{
if (AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::spells) < cost)
{
@@ -126,8 +126,8 @@ bool TrainerAction::Execute(Event event)
if (spell)
spells.insert(spell);
if (text.find("learn") != std::string::npos || sRandomPlayerbotMgr->IsRandomBot(bot) ||
(sPlayerbotAIConfig->autoTrainSpells != "no" &&
if (text.find("learn") != std::string::npos || sRandomPlayerbotMgr.IsRandomBot(bot) ||
(sPlayerbotAIConfig.autoTrainSpells != "no" &&
(trainer->GetTrainerType() != Trainer::Type::Tradeskill ||
!botAI->HasActivePlayerMaster()))) // Todo rewrite to only exclude start primary profession skills and make
// config dependent.
@@ -157,7 +157,7 @@ void TrainerAction::TellFooter(uint32 totalCost)
bool MaintenanceAction::Execute(Event event)
{
if (!sPlayerbotAIConfig->maintenanceCommand)
if (!sPlayerbotAIConfig.maintenanceCommand)
{
botAI->TellError("maintenance command is not allowed, please check the configuration.");
return false;
@@ -186,66 +186,66 @@ bool MaintenanceAction::Execute(Event event)
factory.InitMounts();
factory.InitGlyphs(false);
factory.InitKeyring();
if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
if (bot->GetLevel() >= sPlayerbotAIConfig.minEnchantingBotLevel)
factory.ApplyEnchantAndGemsNew();
}
else
{
if (sPlayerbotAIConfig->altMaintenanceAttunementQs)
if (sPlayerbotAIConfig.altMaintenanceAttunementQs)
factory.InitAttunementQuests();
if (sPlayerbotAIConfig->altMaintenanceBags)
if (sPlayerbotAIConfig.altMaintenanceBags)
factory.InitBags(false);
if (sPlayerbotAIConfig->altMaintenanceAmmo)
if (sPlayerbotAIConfig.altMaintenanceAmmo)
factory.InitAmmo();
if (sPlayerbotAIConfig->altMaintenanceFood)
if (sPlayerbotAIConfig.altMaintenanceFood)
factory.InitFood();
if (sPlayerbotAIConfig->altMaintenanceReagents)
if (sPlayerbotAIConfig.altMaintenanceReagents)
factory.InitReagents();
if (sPlayerbotAIConfig->altMaintenanceConsumables)
if (sPlayerbotAIConfig.altMaintenanceConsumables)
factory.InitConsumables();
if (sPlayerbotAIConfig->altMaintenancePotions)
if (sPlayerbotAIConfig.altMaintenancePotions)
factory.InitPotions();
if (sPlayerbotAIConfig->altMaintenanceTalentTree)
if (sPlayerbotAIConfig.altMaintenanceTalentTree)
factory.InitTalentsTree(true);
if (sPlayerbotAIConfig->altMaintenancePet)
if (sPlayerbotAIConfig.altMaintenancePet)
factory.InitPet();
if (sPlayerbotAIConfig->altMaintenancePetTalents)
if (sPlayerbotAIConfig.altMaintenancePetTalents)
factory.InitPetTalents();
if (sPlayerbotAIConfig->altMaintenanceSkills)
if (sPlayerbotAIConfig.altMaintenanceSkills)
factory.InitSkills();
if (sPlayerbotAIConfig->altMaintenanceClassSpells)
if (sPlayerbotAIConfig.altMaintenanceClassSpells)
factory.InitClassSpells();
if (sPlayerbotAIConfig->altMaintenanceAvailableSpells)
if (sPlayerbotAIConfig.altMaintenanceAvailableSpells)
factory.InitAvailableSpells();
if (sPlayerbotAIConfig->altMaintenanceReputation)
if (sPlayerbotAIConfig.altMaintenanceReputation)
factory.InitReputation();
if (sPlayerbotAIConfig->altMaintenanceSpecialSpells)
if (sPlayerbotAIConfig.altMaintenanceSpecialSpells)
factory.InitSpecialSpells();
if (sPlayerbotAIConfig->altMaintenanceMounts)
if (sPlayerbotAIConfig.altMaintenanceMounts)
factory.InitMounts();
if (sPlayerbotAIConfig->altMaintenanceGlyphs)
if (sPlayerbotAIConfig.altMaintenanceGlyphs)
factory.InitGlyphs(false);
if (sPlayerbotAIConfig->altMaintenanceKeyring)
if (sPlayerbotAIConfig.altMaintenanceKeyring)
factory.InitKeyring();
if (sPlayerbotAIConfig->altMaintenanceGemsEnchants && bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
if (sPlayerbotAIConfig.altMaintenanceGemsEnchants && bot->GetLevel() >= sPlayerbotAIConfig.minEnchantingBotLevel)
factory.ApplyEnchantAndGemsNew();
}
@@ -267,28 +267,28 @@ bool RemoveGlyphAction::Execute(Event event)
bool AutoGearAction::Execute(Event event)
{
if (!sPlayerbotAIConfig->autoGearCommand)
if (!sPlayerbotAIConfig.autoGearCommand)
{
botAI->TellError("autogear command is not allowed, please check the configuration.");
return false;
}
if (!sPlayerbotAIConfig->autoGearCommandAltBots &&
!sPlayerbotAIConfig->IsInRandomAccountList(bot->GetSession()->GetAccountId()))
if (!sPlayerbotAIConfig.autoGearCommandAltBots &&
!sPlayerbotAIConfig.IsInRandomAccountList(bot->GetSession()->GetAccountId()))
{
botAI->TellError("You cannot use autogear on alt bots.");
return false;
}
botAI->TellMaster("I'm auto gearing");
uint32 gs = sPlayerbotAIConfig->autoGearScoreLimit == 0
uint32 gs = sPlayerbotAIConfig.autoGearScoreLimit == 0
? 0
: PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->autoGearScoreLimit,
sPlayerbotAIConfig->autoGearQualityLimit);
PlayerbotFactory factory(bot, bot->GetLevel(), sPlayerbotAIConfig->autoGearQualityLimit, gs);
: PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig.autoGearScoreLimit,
sPlayerbotAIConfig.autoGearQualityLimit);
PlayerbotFactory factory(bot, bot->GetLevel(), sPlayerbotAIConfig.autoGearQualityLimit, gs);
factory.InitEquipment(true);
factory.InitAmmo();
if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
if (bot->GetLevel() >= sPlayerbotAIConfig.minEnchantingBotLevel)
{
factory.ApplyEnchantAndGemsNew();
}

View File

@@ -21,9 +21,9 @@ bool TravelAction::Execute(Event event)
Unit* newTarget = nullptr;
std::list<Unit*> targets;
Acore::AnyUnitInObjectRangeCheck u_check(bot, sPlayerbotAIConfig->sightDistance * 2);
Acore::AnyUnitInObjectRangeCheck u_check(bot, sPlayerbotAIConfig.sightDistance * 2);
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(bot, targets, u_check);
Cell::VisitObjects(bot, searcher, sPlayerbotAIConfig->sightDistance);
Cell::VisitObjects(bot, searcher, sPlayerbotAIConfig.sightDistance);
for (Unit* unit : targets)
{
@@ -77,7 +77,7 @@ bool MoveToDarkPortalAction::Execute(Event event)
if (bot->GetTeamId() == TEAM_ALLIANCE)
{
Quest const* quest = sObjectMgr->GetQuestTemplate(10119);
CreatureData const* creatureData = sRandomPlayerbotMgr->GetCreatureDataByEntry(16841);
CreatureData const* creatureData = sRandomPlayerbotMgr.GetCreatureDataByEntry(16841);
if (quest && creatureData)
{
auto creatureBounds =
@@ -89,7 +89,7 @@ bool MoveToDarkPortalAction::Execute(Event event)
else
{
Quest const* quest = sObjectMgr->GetQuestTemplate(9407);
CreatureData const* creatureData = sRandomPlayerbotMgr->GetCreatureDataByEntry(19254);
CreatureData const* creatureData = sRandomPlayerbotMgr.GetCreatureDataByEntry(19254);
if (quest && creatureData)
{
auto creatureBounds =

View File

@@ -187,7 +187,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
if (bot->isMoving())
{
bot->StopMoving();
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.globalCoolDown);
return false;
}
@@ -229,7 +229,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
out << " on " << chat->FormatItem(itemForSpell->GetTemplate());
}
uint32 castTime = spellInfo->CalcCastTime();
botAI->SetNextCheckDelay(castTime + sPlayerbotAIConfig->reactDelay);
botAI->SetNextCheckDelay(castTime + sPlayerbotAIConfig.reactDelay);
}
break;
@@ -307,7 +307,7 @@ bool UseItemAction::UseItem(Item* item, ObjectGuid goGuid, Item* itemTarget, Uni
if (!spellId)
return false;
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
// botAI->SetNextCheckDelay(sPlayerbotAIConfig.globalCoolDown);
botAI->TellMasterNoFacing(out.str());
bot->GetSession()->HandleUseItemOpcode(packet);
return true;
@@ -486,7 +486,7 @@ bool UseRandomQuestItem::Execute(Event event)
bool used = UseItem(item, goTarget, nullptr, unitTarget);
if (used)
botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
botAI->SetNextCheckDelay(sPlayerbotAIConfig.globalCoolDown);
return used;
}

View File

@@ -91,9 +91,9 @@ bool SummonAction::Execute(Event event)
bool SummonAction::SummonUsingGos(Player* summoner, Player* player, bool preserveAuras)
{
std::list<GameObject*> targets;
AnyGameObjectInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig->sightDistance);
AnyGameObjectInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig.sightDistance);
Acore::GameObjectListSearcher<AnyGameObjectInObjectRangeCheck> searcher(summoner, targets, u_check);
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig->sightDistance);
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig.sightDistance);
for (GameObject* go : targets)
{
@@ -107,13 +107,13 @@ bool SummonAction::SummonUsingGos(Player* summoner, Player* player, bool preserv
bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player, bool preserveAuras)
{
if (!sPlayerbotAIConfig->summonAtInnkeepersEnabled)
if (!sPlayerbotAIConfig.summonAtInnkeepersEnabled)
return false;
std::list<Unit*> targets;
Acore::AnyUnitInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig->sightDistance);
Acore::AnyUnitInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig.sightDistance);
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(summoner, targets, u_check);
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig->sightDistance);
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig.sightDistance);
for (Unit* unit : targets)
{
@@ -165,38 +165,37 @@ bool SummonAction::Teleport(Player* summoner, Player* player, bool preserveAuras
for (float angle = followAngle - M_PI; angle <= followAngle + M_PI; angle += M_PI / 4)
{
uint32 mapId = summoner->GetMapId();
float x = summoner->GetPositionX() + cos(angle) * sPlayerbotAIConfig->followDistance;
float y = summoner->GetPositionY() + sin(angle) * sPlayerbotAIConfig->followDistance;
float x = summoner->GetPositionX() + cos(angle) * sPlayerbotAIConfig.followDistance;
float y = summoner->GetPositionY() + sin(angle) * sPlayerbotAIConfig.followDistance;
float z = summoner->GetPositionZ();
if (summoner->IsWithinLOS(x, y, z))
{
if (sPlayerbotAIConfig
->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
if (sPlayerbotAIConfig.botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
bot->DurabilityRepairAll(false, 1.0f, false);
if (summoner->IsInCombat() && !sPlayerbotAIConfig->allowSummonInCombat)
if (summoner->IsInCombat() && !sPlayerbotAIConfig.allowSummonInCombat)
{
botAI->TellError("You cannot summon me while you're in combat");
return false;
}
if (!summoner->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead)
if (!summoner->IsAlive() && !sPlayerbotAIConfig.allowSummonWhenMasterIsDead)
{
botAI->TellError("You cannot summon me while you're dead");
return false;
}
if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST) &&
!sPlayerbotAIConfig->allowSummonWhenBotIsDead)
!sPlayerbotAIConfig.allowSummonWhenBotIsDead)
{
botAI->TellError("You cannot summon me while I'm dead, you need to release my spirit first");
return false;
}
bool revive =
sPlayerbotAIConfig->reviveBotWhenSummoned == 2 ||
(sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive());
sPlayerbotAIConfig.reviveBotWhenSummoned == 2 ||
(sPlayerbotAIConfig.reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive());
if (bot->isDead() && revive)
{

View File

@@ -74,7 +74,7 @@ bool EnterVehicleAction::Execute(Event event)
bool EnterVehicleAction::EnterVehicle(Unit* vehicleBase, bool moveIfFar)
{
float dist = sServerFacade->GetDistance2d(bot, vehicleBase);
float dist = ServerFacade::instance().GetDistance2d(bot, vehicleBase);
if (dist > 40.0f)
return false;

View File

@@ -33,7 +33,7 @@ bool WhoAction::Execute(Event event)
{
out << QuerySkill(text);
if (sRandomPlayerbotMgr->IsRandomBot(bot))
if (sRandomPlayerbotMgr.IsRandomBot(bot))
out << QueryTrade(text);
}
else
@@ -74,7 +74,7 @@ std::string const WhoAction::QueryTrade(std::string const text)
for (Item* sell : items)
{
int32 sellPrice =
sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot) * sell->GetCount();
sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr.GetSellMultiplier(bot) * sell->GetCount();
if (!sellPrice)
continue;

View File

@@ -25,7 +25,7 @@ std::vector<uint32> WorldBuffAction::NeedWorldBuffs(Unit* unit)
{
std::vector<uint32> retVec;
if (sPlayerbotAIConfig->worldBuffs.empty())
if (sPlayerbotAIConfig.worldBuffs.empty())
return retVec;
FactionTemplateEntry const* humanFaction = sFactionTemplateStore.LookupEntry(1);
@@ -70,7 +70,7 @@ std::vector<uint32> WorldBuffAction::NeedWorldBuffs(Unit* unit)
// If tank, effectiveSpec remains unchanged
}
for (auto const& wb : sPlayerbotAIConfig->worldBuffs)
for (auto const& wb : sPlayerbotAIConfig.worldBuffs)
{
// Faction check
if (wb.factionId != 0 && wb.factionId != factionId)

View File

@@ -20,7 +20,7 @@ bool WtsAction::Execute(Event event)
std::ostringstream out;
std::string const text = event.getParam();
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
return false;
std::string const link = event.getParam();
@@ -42,7 +42,7 @@ bool WtsAction::Execute(Event event)
if (usage == ITEM_USAGE_NONE)
continue;
int32 buyPrice = proto->BuyPrice * sRandomPlayerbotMgr->GetBuyMultiplier(bot);
int32 buyPrice = proto->BuyPrice * sRandomPlayerbotMgr.GetBuyMultiplier(bot);
if (!buyPrice)
continue;

View File

@@ -40,14 +40,14 @@ bool XpGainAction::Execute(Event event)
}
// randomBotXPRate is now implemented in OnPlayerGiveXP script
// if (!sRandomPlayerbotMgr->IsRandomBot(bot) || sPlayerbotAIConfig->randomBotXPRate == 1)
// if (!sRandomPlayerbotMgr.IsRandomBot(bot) || sPlayerbotAIConfig.randomBotXPRate == 1)
// return true;
// Unit* victim = nullptr;
// if (guid)
// victim = botAI->GetUnit(guid);
// xpgain = xpgain * (sPlayerbotAIConfig->randomBotXPRate - 1);
// xpgain = xpgain * (sPlayerbotAIConfig.randomBotXPRate - 1);
// GiveXP(xpgain, victim);
return true;

View File

@@ -12,39 +12,14 @@
#include "PvpValues.h"
#include "QuestValues.h"
class PlayerbotAI;
class SharedValueContext : public NamedObjectContext<UntypedValue>
{
public:
SharedValueContext() : NamedObjectContext(true)
{
creators["bg masters"] = &SharedValueContext::bg_masters;
creators["drop map"] = &SharedValueContext::drop_map;
creators["item drop list"] = &SharedValueContext::item_drop_list;
creators["entry loot list"] = &SharedValueContext::entry_loot_list;
creators["entry quest relation"] = &SharedValueContext::entry_quest_relation;
creators["quest guidp map"] = &SharedValueContext::quest_guidp_map;
creators["quest givers"] = &SharedValueContext::quest_givers;
}
private:
static UntypedValue* bg_masters(PlayerbotAI* botAI) { return new BgMastersValue(botAI); }
static UntypedValue* drop_map(PlayerbotAI* botAI) { return new DropMapValue(botAI); }
static UntypedValue* item_drop_list(PlayerbotAI* botAI) { return new ItemDropListValue(botAI); }
static UntypedValue* entry_loot_list(PlayerbotAI* botAI) { return new EntryLootListValue(botAI); }
static UntypedValue* entry_quest_relation(PlayerbotAI* botAI) { return new EntryQuestRelationMapValue(botAI); }
static UntypedValue* quest_guidp_map(PlayerbotAI* botAI) { return new QuestGuidpMapValue(botAI); }
static UntypedValue* quest_givers(PlayerbotAI* botAI) { return new QuestGiversValue(botAI); }
// Global acess functions
public:
static SharedValueContext* instance()
static SharedValueContext& instance()
{
static SharedValueContext instance;
return &instance;
return instance;
}
template <class T>
@@ -74,6 +49,36 @@ public:
out << param;
return getGlobalValue<T>(name, out.str());
}
private:
SharedValueContext() : NamedObjectContext(true)
{
creators["bg masters"] = &SharedValueContext::bg_masters;
creators["drop map"] = &SharedValueContext::drop_map;
creators["item drop list"] = &SharedValueContext::item_drop_list;
creators["entry loot list"] = &SharedValueContext::entry_loot_list;
creators["entry quest relation"] = &SharedValueContext::entry_quest_relation;
creators["quest guidp map"] = &SharedValueContext::quest_guidp_map;
creators["quest givers"] = &SharedValueContext::quest_givers;
}
~SharedValueContext() = default;
SharedValueContext(const SharedValueContext&) = delete;
SharedValueContext& operator=(const SharedValueContext&) = delete;
SharedValueContext(SharedValueContext&&) = delete;
SharedValueContext& operator=(SharedValueContext&&) = delete;
static UntypedValue* bg_masters(PlayerbotAI* botAI) { return new BgMastersValue(botAI); }
static UntypedValue* drop_map(PlayerbotAI* botAI) { return new DropMapValue(botAI); }
static UntypedValue* item_drop_list(PlayerbotAI* botAI) { return new ItemDropListValue(botAI); }
static UntypedValue* entry_loot_list(PlayerbotAI* botAI) { return new EntryLootListValue(botAI); }
static UntypedValue* entry_quest_relation(PlayerbotAI* botAI) { return new EntryQuestRelationMapValue(botAI); }
static UntypedValue* quest_guidp_map(PlayerbotAI* botAI) { return new QuestGuidpMapValue(botAI); }
static UntypedValue* quest_givers(PlayerbotAI* botAI) { return new QuestGiversValue(botAI); }
};
#define sSharedValueContext SharedValueContext::instance()

View File

@@ -16,7 +16,7 @@ float CastTimeMultiplier::GetValue(Action* action)
if (!action->GetTarget() || action->GetTarget() != AI_VALUE(Unit*, "current target"))
return 1.0f;
if (/*targetHealth < sPlayerbotAIConfig->criticalHealth && */ dynamic_cast<CastSpellAction*>(action))
if (/*targetHealth < sPlayerbotAIConfig.criticalHealth && */ dynamic_cast<CastSpellAction*>(action))
{
CastSpellAction* spellAction = dynamic_cast<CastSpellAction*>(action);
uint32 spellId = AI_VALUE2(uint32, "spell id", spellAction->getSpell());

View File

@@ -19,9 +19,9 @@
// uint8 targetHealth = AI_VALUE2(uint8, "health", "current target");
// uint8 mana = AI_VALUE2(uint8, "mana", "self target");
// bool hasMana = AI_VALUE2(bool, "has mana", "self target");
// bool mediumMana = hasMana && mana < sPlayerbotAIConfig->mediumMana;
// bool mediumMana = hasMana && mana < sPlayerbotAIConfig.mediumMana;
// if (health < sPlayerbotAIConfig->lowHealth)
// if (health < sPlayerbotAIConfig.lowHealth)
// return 1.0f;
// Unit* target = AI_VALUE(Unit*, "current target");
@@ -92,7 +92,7 @@
float HealerAutoSaveManaMultiplier::GetValue(Action* action)
{
uint8 mana = bot->GetPowerPct(Powers::POWER_MANA);
if (mana > sPlayerbotAIConfig->saveManaThreshold)
if (mana > sPlayerbotAIConfig.saveManaThreshold)
return 1.0f;
CastHealingSpellAction* healingAction = dynamic_cast<CastHealingSpellAction*>(action);
@@ -110,16 +110,16 @@ float HealerAutoSaveManaMultiplier::GetValue(Action* action)
if (isTank)
{
estAmount /= 1.5; // tanks have more health
if (health >= sPlayerbotAIConfig->mediumHealth &&
if (health >= sPlayerbotAIConfig.mediumHealth &&
(lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::MEDIUM))
return 0.0f;
if (health >= sPlayerbotAIConfig->lowHealth &&
if (health >= sPlayerbotAIConfig.lowHealth &&
(lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::LOW))
return 0.0f;
}
else
{
if (health >= sPlayerbotAIConfig->mediumHealth &&
if (health >= sPlayerbotAIConfig.mediumHealth &&
(lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::MEDIUM))
return 0.0f;
if (lossAmount < estAmount || manaEfficiency <= HealingManaEfficiency::LOW)
@@ -131,4 +131,4 @@ float HealerAutoSaveManaMultiplier::GetValue(Action* action)
void HealerAutoSaveManaStrategy::InitMultipliers(std::vector<Multiplier*>& multipliers)
{
multipliers.push_back(new HealerAutoSaveManaMultiplier(botAI));
}
}

View File

@@ -9,7 +9,7 @@
void EmoteStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
{
if (sPlayerbotAIConfig->randomBotEmote)
if (sPlayerbotAIConfig.randomBotEmote)
{
triggers.push_back(new TriggerNode("often", { NextAction("talk", 1.0f) }));
triggers.push_back(new TriggerNode("seldom", { NextAction("emote", 1.0f) }));
@@ -19,7 +19,7 @@ void EmoteStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
new TriggerNode("receive emote", { NextAction("emote", 10.0f) }));
}
if (sPlayerbotAIConfig->randomBotTalk)
if (sPlayerbotAIConfig.randomBotTalk)
{
triggers.push_back(new TriggerNode(
"often",
@@ -27,7 +27,7 @@ void EmoteStrategy::InitTriggers(std::vector<TriggerNode*>& triggers)
NextAction("suggest trade", 3.0f) }));
}
if (sPlayerbotAIConfig->enableGreet)
if (sPlayerbotAIConfig.enableGreet)
triggers.push_back(
new TriggerNode("new player nearby", { NextAction("greet", 1.0f) }));

View File

@@ -22,17 +22,18 @@
#include "Timer.h"
#include "PlayerbotAI.h"
#include "Player.h"
#include "Corpse.h"
bool LowManaTrigger::IsActive()
{
return AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana;
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.lowMana;
}
bool MediumManaTrigger::IsActive()
{
return AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->mediumMana;
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.mediumMana;
}
bool NoPetTrigger::IsActive()
@@ -72,7 +73,7 @@ bool PetAttackTrigger::IsActive()
bool HighManaTrigger::IsActive()
{
return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->highMana;
return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.highMana;
}
bool AlmostFullManaTrigger::IsActive()
@@ -82,7 +83,7 @@ bool AlmostFullManaTrigger::IsActive()
bool EnoughManaTrigger::IsActive()
{
return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig->highMana;
return AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.highMana;
}
bool RageAvailable::IsActive() { return AI_VALUE2(uint8, "rage", "self target") >= amount; }
@@ -110,9 +111,9 @@ bool HasAggroTrigger::IsActive() { return AI_VALUE2(bool, "has aggro", "current
bool PanicTrigger::IsActive()
{
return AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig->criticalHealth &&
return AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig.criticalHealth &&
(!AI_VALUE2(bool, "has mana", "self target") ||
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig->lowMana);
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.lowMana);
}
bool OutNumberedTrigger::IsActive()
@@ -248,7 +249,7 @@ bool AoeTrigger::IsActive()
bool NoFoodTrigger::IsActive()
{
bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
if (isRandomBot && botAI->HasCheat(BotCheatMask::food))
return false;
@@ -257,7 +258,7 @@ bool NoFoodTrigger::IsActive()
bool NoDrinkTrigger::IsActive()
{
bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
if (isRandomBot && botAI->HasCheat(BotCheatMask::food))
return false;
@@ -319,11 +320,11 @@ RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 p
bool RandomTrigger::IsActive()
{
if (getMSTime() - lastCheck < sPlayerbotAIConfig->repeatDelay)
if (getMSTime() - lastCheck < sPlayerbotAIConfig.repeatDelay)
return false;
lastCheck = getMSTime();
int32 k = (int32)(probability / sPlayerbotAIConfig->randomChangeMultiplier);
int32 k = (int32)(probability / sPlayerbotAIConfig.randomChangeMultiplier);
if (k < 1)
k = 1;
return (rand() % k) == 0;
@@ -381,10 +382,10 @@ bool GenericBoostTrigger::IsActive()
bool HealerShouldAttackTrigger::IsActive()
{
// nobody can help me
if (botAI->GetNearGroupMemberCount(sPlayerbotAIConfig->sightDistance) <= 1)
if (botAI->GetNearGroupMemberCount(sPlayerbotAIConfig.sightDistance) <= 1)
return true;
if (AI_VALUE2(uint8, "health", "party member to heal") < sPlayerbotAIConfig->almostFullHealth)
if (AI_VALUE2(uint8, "health", "party member to heal") < sPlayerbotAIConfig.almostFullHealth)
return false;
// special check for resto druid (dont remove tree of life frequently)
@@ -401,9 +402,9 @@ bool HealerShouldAttackTrigger::IsActive()
if (balance <= 50)
manaThreshold = 85;
else if (balance <= 100)
manaThreshold = sPlayerbotAIConfig->highMana;
manaThreshold = sPlayerbotAIConfig.highMana;
else
manaThreshold = sPlayerbotAIConfig->mediumMana;
manaThreshold = sPlayerbotAIConfig.mediumMana;
if (AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < manaThreshold)
return false;
@@ -632,7 +633,7 @@ bool ReturnToStayPositionTrigger::IsActive()
if (stayPosition.isSet())
{
const float distance = bot->GetDistance(stayPosition.x, stayPosition.y, stayPosition.z);
return distance > sPlayerbotAIConfig->followDistance;
return distance > sPlayerbotAIConfig.followDistance;
}
return false;

View File

@@ -216,7 +216,7 @@ public:
class AttackerCountTrigger : public Trigger
{
public:
AttackerCountTrigger(PlayerbotAI* botAI, int32 amount, float distance = sPlayerbotAIConfig->sightDistance)
AttackerCountTrigger(PlayerbotAI* botAI, int32 amount, float distance = sPlayerbotAIConfig.sightDistance)
: Trigger(botAI), amount(amount), distance(distance)
{
}
@@ -836,7 +836,7 @@ private:
class SitTrigger : public StayTimeTrigger
{
public:
SitTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig->sitDelay, "sit") {}
SitTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig.sitDelay, "sit") {}
};
class ReturnToStayPositionTrigger : public Trigger
@@ -850,7 +850,7 @@ public:
class ReturnTrigger : public StayTimeTrigger
{
public:
ReturnTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig->returnDelay, "return") {}
ReturnTrigger(PlayerbotAI* botAI) : StayTimeTrigger(botAI, sPlayerbotAIConfig.returnDelay, "return") {}
};
class GiveItemTrigger : public Trigger

View File

@@ -38,4 +38,4 @@ bool AoeInGroupTrigger::IsActive()
threshold = std::min(threshold, 15);
return AI_VALUE2(uint8, "aoe heal", type) >= threshold;
}
}

View File

@@ -48,7 +48,7 @@ class LowHealthTrigger : public HealthInRangeTrigger
{
public:
LowHealthTrigger(PlayerbotAI* botAI, std::string const name = "low health",
float value = sPlayerbotAIConfig->lowHealth, float minValue = 0)
float value = sPlayerbotAIConfig.lowHealth, float minValue = 0)
: HealthInRangeTrigger(botAI, name, value, minValue)
{
}
@@ -60,7 +60,7 @@ class CriticalHealthTrigger : public LowHealthTrigger
{
public:
CriticalHealthTrigger(PlayerbotAI* botAI)
: LowHealthTrigger(botAI, "critical health", sPlayerbotAIConfig->criticalHealth, 0)
: LowHealthTrigger(botAI, "critical health", sPlayerbotAIConfig.criticalHealth, 0)
{
}
};
@@ -69,7 +69,7 @@ class MediumHealthTrigger : public LowHealthTrigger
{
public:
MediumHealthTrigger(PlayerbotAI* botAI)
: LowHealthTrigger(botAI, "medium health", sPlayerbotAIConfig->mediumHealth, 0)
: LowHealthTrigger(botAI, "medium health", sPlayerbotAIConfig.mediumHealth, 0)
{
}
};
@@ -78,8 +78,8 @@ class AlmostFullHealthTrigger : public LowHealthTrigger
{
public:
AlmostFullHealthTrigger(PlayerbotAI* botAI)
: LowHealthTrigger(botAI, "almost full health", sPlayerbotAIConfig->almostFullHealth,
sPlayerbotAIConfig->mediumHealth)
: LowHealthTrigger(botAI, "almost full health", sPlayerbotAIConfig.almostFullHealth,
sPlayerbotAIConfig.mediumHealth)
{
}
};
@@ -88,7 +88,7 @@ class PartyMemberLowHealthTrigger : public HealthInRangeTrigger
{
public:
PartyMemberLowHealthTrigger(PlayerbotAI* botAI, std::string const name = "party member low health",
float value = sPlayerbotAIConfig->lowHealth,
float value = sPlayerbotAIConfig.lowHealth,
float minValue = 0)
: HealthInRangeTrigger(botAI, name, value, minValue)
{
@@ -101,7 +101,7 @@ class PartyMemberCriticalHealthTrigger : public PartyMemberLowHealthTrigger
{
public:
PartyMemberCriticalHealthTrigger(PlayerbotAI* botAI)
: PartyMemberLowHealthTrigger(botAI, "party member critical health", sPlayerbotAIConfig->criticalHealth, 0)
: PartyMemberLowHealthTrigger(botAI, "party member critical health", sPlayerbotAIConfig.criticalHealth, 0)
{
}
};
@@ -110,7 +110,7 @@ class PartyMemberMediumHealthTrigger : public PartyMemberLowHealthTrigger
{
public:
PartyMemberMediumHealthTrigger(PlayerbotAI* botAI)
: PartyMemberLowHealthTrigger(botAI, "party member medium health", sPlayerbotAIConfig->mediumHealth,
: PartyMemberLowHealthTrigger(botAI, "party member medium health", sPlayerbotAIConfig.mediumHealth,
0)
{
}
@@ -120,7 +120,7 @@ class PartyMemberAlmostFullHealthTrigger : public PartyMemberLowHealthTrigger
{
public:
PartyMemberAlmostFullHealthTrigger(PlayerbotAI* botAI)
: PartyMemberLowHealthTrigger(botAI, "party member almost full health", sPlayerbotAIConfig->almostFullHealth,
: PartyMemberLowHealthTrigger(botAI, "party member almost full health", sPlayerbotAIConfig.almostFullHealth,
0)
{
}

View File

@@ -15,11 +15,11 @@ bool LootAvailableTrigger::IsActive()
if (botAI->HasStrategy("stay", BOT_STATE_NON_COMBAT))
{
distanceCheck =
sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), CONTACT_DISTANCE);
ServerFacade::instance().IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"), CONTACT_DISTANCE);
}
else
{
distanceCheck = sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"),
distanceCheck = ServerFacade::instance().IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "loot target"),
INTERACTION_DISTANCE - 2.0f);
}

View File

@@ -247,7 +247,7 @@ bool EnemyFlagCarrierNear::IsActive()
{
Unit* carrier = AI_VALUE(Unit*, "enemy flag carrier");
if (!carrier || !sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, carrier), 100.f))
if (!carrier || !ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, carrier), 100.f))
return false;
// Check if there is another enemy player target closer than the FC
@@ -255,8 +255,8 @@ bool EnemyFlagCarrierNear::IsActive()
if (nearbyEnemy)
{
float distToFC = sServerFacade->GetDistance2d(bot, carrier);
float distToEnemy = sServerFacade->GetDistance2d(bot, nearbyEnemy);
float distToFC = ServerFacade::instance().GetDistance2d(bot, carrier);
float distToEnemy = ServerFacade::instance().GetDistance2d(bot, nearbyEnemy);
// If the other enemy is significantly closer, don't pursue FC
if (distToEnemy + 15.0f < distToFC) // Add small buffer
@@ -283,7 +283,7 @@ bool TeamFlagCarrierNear::IsActive()
}
Unit* carrier = AI_VALUE(Unit*, "team flag carrier");
return carrier && sServerFacade->IsDistanceLessOrEqualThan(sServerFacade->GetDistance2d(bot, carrier), 200.f);
return carrier && ServerFacade::instance().IsDistanceLessOrEqualThan(ServerFacade::instance().GetDistance2d(bot, carrier), 200.f);
}
bool PlayerWantsInBattlegroundTrigger::IsActive()

View File

@@ -34,7 +34,7 @@ bool EnemyTooCloseForSpellTrigger::IsActive()
// bool isBoss = false;
// bool isRaid = false;
// float combatReach = bot->GetCombatReach() + target->GetCombatReach();
// float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach;
// float targetDistance = ServerFacade::instance().GetDistance2d(bot, target) + combatReach;
// if (target->IsCreature())
// {
// Creature* creature = botAI->GetCreature(target->GetGUID());
@@ -48,10 +48,10 @@ bool EnemyTooCloseForSpellTrigger::IsActive()
// isRaid = true;
// // if (isBoss || isRaid)
// // return sServerFacade->IsDistanceLessThan(targetDistance, (sPlayerbotAIConfig->tooCloseDistance +
// // return ServerFacade::instance().IsDistanceLessThan(targetDistance, (sPlayerbotAIConfig.tooCloseDistance +
// combatReach) / 2);
// return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, (sPlayerbotAIConfig->tooCloseDistance +
// return ServerFacade::instance().IsDistanceLessOrEqualThan(targetDistance, (sPlayerbotAIConfig.tooCloseDistance +
// combatReach / 2));
}
@@ -80,7 +80,7 @@ bool EnemyTooCloseForAutoShotTrigger::IsActive()
// bool isBoss = false;
// bool isRaid = false;
// float combatReach = bot->GetCombatReach() + target->GetCombatReach();
// float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach;
// float targetDistance = ServerFacade::instance().GetDistance2d(bot, target) + combatReach;
// if (target->IsCreature())
// {
// Creature* creature = botAI->GetCreature(target->GetGUID());
@@ -93,7 +93,7 @@ bool EnemyTooCloseForAutoShotTrigger::IsActive()
// if (bot->GetMap() && bot->GetMap()->IsRaid())
// isRaid = true;
// return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, 5.0f);
// return ServerFacade::instance().IsDistanceLessOrEqualThan(targetDistance, 5.0f);
}
bool EnemyTooCloseForShootTrigger::IsActive()
@@ -115,7 +115,7 @@ bool EnemyTooCloseForShootTrigger::IsActive()
// bool isBoss = false;
// bool isRaid = false;
// float combatReach = bot->GetCombatReach() + target->GetCombatReach();
// float targetDistance = sServerFacade->GetDistance2d(bot, target) + combatReach;
// float targetDistance = ServerFacade::instance().GetDistance2d(bot, target) + combatReach;
// if (target->IsCreature())
// {
// Creature* creature = botAI->GetCreature(target->GetGUID());
@@ -129,9 +129,9 @@ bool EnemyTooCloseForShootTrigger::IsActive()
// isRaid = true;
// // if (isBoss || isRaid)
// // return sServerFacade->IsDistanceLessThan(targetDistance, botAI->GetRange("shoot") + combatReach);
// // return ServerFacade::instance().IsDistanceLessThan(targetDistance, botAI->GetRange("shoot") + combatReach);
// return sServerFacade->IsDistanceLessOrEqualThan(targetDistance, (botAI->GetRange("shoot") + combatReach /
// return ServerFacade::instance().IsDistanceLessOrEqualThan(targetDistance, (botAI->GetRange("shoot") + combatReach /
// 2));
}
@@ -147,8 +147,8 @@ bool EnemyTooCloseForMeleeTrigger::IsActive()
bool EnemyIsCloseTrigger::IsActive()
{
Unit* target = AI_VALUE(Unit*, "current target");
return target && sServerFacade->IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"),
sPlayerbotAIConfig->tooCloseDistance);
return target && ServerFacade::instance().IsDistanceLessOrEqualThan(AI_VALUE2(float, "distance", "current target"),
sPlayerbotAIConfig.tooCloseDistance);
}
bool EnemyWithinMeleeTrigger::IsActive()
@@ -165,7 +165,7 @@ bool OutOfRangeTrigger::IsActive()
return target &&
!bot->IsWithinCombatRange(
target,
dis); // sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance);
dis); // ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", GetTargetName()), distance);
}
EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI)
@@ -180,8 +180,8 @@ EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI)
// return false;
// float combatReach = bot->GetCombatReach() + target->GetCombatReach();
// return target && (sServerFacade->GetDistance2d(bot, target) > (distance + combatReach +
// sPlayerbotAIConfig->contactDistance) || !bot->IsWithinLOSInMap(target));
// return target && (ServerFacade::instance().GetDistance2d(bot, target) > (distance + combatReach +
// sPlayerbotAIConfig.contactDistance) || !bot->IsWithinLOSInMap(target));
// }
// bool EnemyOutOfMeleeTrigger::IsActive()
@@ -190,7 +190,7 @@ EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI)
// if (!target)
// return false;
// float targetDistance = sServerFacade->GetDistance2d(bot, target);
// float targetDistance = ServerFacade::instance().GetDistance2d(bot, target);
// return target && (targetDistance > std::max(5.0f, bot->GetCombatReach() + target->GetCombatReach()) ||
// (!bot->IsWithinLOSInMap(target) && targetDistance > 5.0f));
// }
@@ -202,7 +202,7 @@ bool PartyMemberToHealOutOfSpellRangeTrigger::IsActive()
return false;
float combatReach = bot->GetCombatReach() + target->GetCombatReach();
return target && (sServerFacade->GetDistance2d(bot, target) > (distance + sPlayerbotAIConfig->contactDistance) ||
return target && (ServerFacade::instance().GetDistance2d(bot, target) > (distance + sPlayerbotAIConfig.contactDistance) ||
!bot->IsWithinLOSInMap(target));
}
@@ -213,7 +213,7 @@ PartyMemberToHealOutOfSpellRangeTrigger::PartyMemberToHealOutOfSpellRangeTrigger
bool FarFromMasterTrigger::IsActive()
{
return sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "group leader"), distance);
return ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "group leader"), distance);
}
bool TooCloseToCreatureTrigger::TooCloseToCreature(uint32 creatureId, float range, bool alive)

View File

@@ -78,7 +78,7 @@ class EnemyOutOfMeleeTrigger : public OutOfRangeTrigger
{
public:
EnemyOutOfMeleeTrigger(PlayerbotAI* botAI)
: OutOfRangeTrigger(botAI, "enemy out of melee range", sPlayerbotAIConfig->meleeDistance)
: OutOfRangeTrigger(botAI, "enemy out of melee range", sPlayerbotAIConfig.meleeDistance)
{
}

View File

@@ -21,7 +21,7 @@ bool AtDarkPortalAzerothTrigger::IsActive()
{
if (bot->GetAreaId() == 72)
{
if (sServerFacade->GetDistance2d(bot, -11906.9f, -3208.53f) < 20.0f)
if (ServerFacade::instance().GetDistance2d(bot, -11906.9f, -3208.53f) < 20.0f)
{
return true;
}
@@ -34,7 +34,7 @@ bool AtDarkPortalOutlandTrigger::IsActive()
{
if (bot->GetAreaId() == 3539)
{
if (sServerFacade->GetDistance2d(bot, -248.1939f, 921.919f) < 10.0f)
if (ServerFacade::instance().GetDistance2d(bot, -248.1939f, 921.919f) < 10.0f)
{
return true;
}

View File

@@ -16,13 +16,13 @@ uint8 AoeHealValue::Calculate()
float range = 0;
if (qualifier == "low")
range = sPlayerbotAIConfig->lowHealth;
range = sPlayerbotAIConfig.lowHealth;
else if (qualifier == "medium")
range = sPlayerbotAIConfig->mediumHealth;
range = sPlayerbotAIConfig.mediumHealth;
else if (qualifier == "critical")
range = sPlayerbotAIConfig->criticalHealth;
range = sPlayerbotAIConfig.criticalHealth;
else if (qualifier == "almost full")
range = sPlayerbotAIConfig->almostFullHealth;
range = sPlayerbotAIConfig.almostFullHealth;
uint8 count = 0;
Group::MemberSlotList const& groupSlot = group->GetMemberSlots();
@@ -32,7 +32,7 @@ uint8 AoeHealValue::Calculate()
if (!player || !player->IsAlive())
continue;
if (player->GetDistance(bot) >= sPlayerbotAIConfig->sightDistance)
if (player->GetDistance(bot) >= sPlayerbotAIConfig.sightDistance)
continue;
float percent = (static_cast<float>(player->GetHealth()) / player->GetMaxHealth()) * 100;

View File

@@ -29,8 +29,8 @@ GuidVector FindMaxDensity(Player* bot)
if (!other)
continue;
float d = sServerFacade->GetDistance2d(unit, other);
if (sServerFacade->IsDistanceLessOrEqualThan(d, sPlayerbotAIConfig->aoeRadius * 2))
float d = ServerFacade::instance().GetDistance2d(unit, other);
if (ServerFacade::instance().IsDistanceLessOrEqualThan(d, sPlayerbotAIConfig.aoeRadius * 2))
groups[*i].push_back(*j);
}
@@ -157,4 +157,4 @@ Aura* AreaDebuffValue::Calculate()
}
}
return nullptr;
}
}

View File

@@ -31,15 +31,15 @@ WorldLocation ArrowFormation::GetLocationInternal()
tanks.PlaceUnits(&placer);
tanks.Move(-cos(orientation) * offset, -sin(orientation) * offset);
offset += tankLines * sPlayerbotAIConfig->followDistance + sPlayerbotAIConfig->tooCloseDistance / 2;
offset += tankLines * sPlayerbotAIConfig.followDistance + sPlayerbotAIConfig.tooCloseDistance / 2;
melee.PlaceUnits(&placer);
melee.Move(-cos(orientation) * offset, -sin(orientation) * offset);
offset += meleeLines * sPlayerbotAIConfig->followDistance + sPlayerbotAIConfig->tooCloseDistance / 2;
offset += meleeLines * sPlayerbotAIConfig.followDistance + sPlayerbotAIConfig.tooCloseDistance / 2;
ranged.PlaceUnits(&placer);
ranged.Move(-cos(orientation) * offset, -sin(orientation) * offset);
offset += rangedLines * sPlayerbotAIConfig->followDistance;
offset += rangedLines * sPlayerbotAIConfig.followDistance;
healers.PlaceUnits(&placer);
healers.Move(-cos(orientation) * offset, -sin(orientation) * offset);
@@ -143,16 +143,16 @@ UnitPosition MultiLineUnitPlacer::Place(FormationUnit* unit, uint32 index, uint3
uint32 lineNo = index / 6;
uint32 indexInLine = index % 6;
uint32 lineSize = std::max(count - lineNo * 6, uint32(6));
float x = cos(orientation) * sPlayerbotAIConfig->followDistance * lineNo;
float y = sin(orientation) * sPlayerbotAIConfig->followDistance * lineNo;
float x = cos(orientation) * sPlayerbotAIConfig.followDistance * lineNo;
float y = sin(orientation) * sPlayerbotAIConfig.followDistance * lineNo;
return placer.Place(unit, indexInLine, lineSize);
}
UnitPosition SingleLineUnitPlacer::Place(FormationUnit* unit, uint32 index, uint32 count)
{
float angle = orientation - M_PI / 2.0f;
float x = cos(angle) * sPlayerbotAIConfig->followDistance * ((float)index - (float)count / 2);
float y = sin(angle) * sPlayerbotAIConfig->followDistance * ((float)index - (float)count / 2);
float x = cos(angle) * sPlayerbotAIConfig.followDistance * ((float)index - (float)count / 2);
float y = sin(angle) * sPlayerbotAIConfig.followDistance * ((float)index - (float)count / 2);
return UnitPosition(x, y);
}

Some files were not shown because too many files have changed in this diff Show More