Compare commits

...

13 Commits

Author SHA1 Message Date
bashermens
86904ed068 Create check_pr_source.yml 2026-02-01 22:21:01 +01:00
bashermens
8529654f8f Correction after singleton PR (#2095)
# Pull Request

Some logic was changed but differs from the original code, certain edge
cases so not result in same behavior. This returns the original code
with only the singleton chances.

@Wishmaster117 Reviewed the hotfix and noticed the different code paths.

ps: reverted an removed placeholder since its ongoing issue/research.
2026-02-01 10:18:59 +01:00
Crow
6ee1684e9b Fix WSG graveyard camping by flag carrier (#2086)
Quick fix for a very annoying error identified by SmashingQuasar. In
WSG, bots will camp the opposing graveyard if up 2-0. This is supposed
to exclude the flag carrier, but a logical error has resulted in the
flag carrier being excluded for Alliance camping only, meaning the Horde
flag carrier will camp the GY with the rest of the team if up 2-0 and
thus refuse to end the game.
2026-01-31 23:11:40 +01:00
Crow
9546363d41 Hotfix for OnBotLoginOperation() Crash (#2089)
Hotfix for an issue arising from
https://github.com/mod-playerbots/mod-playerbots/pull/2082

OnBotLoginOperation() is calling OnBotLogin() twice for altbots. I don't
know the full implication, but RandomPlayerbotMgr::OnBotLoginInternal()
is being called on altbots, and the server will crash if you attempt to
then log out the altbot.

This fix works for me right now. Discussed with @Celandriel , going to
push this hotfix for now until the rest of the maintainers can take a
look.
2026-01-31 10:54:19 +01:00
Crow
00d19dbf9c Fix Destro Warlock Glyphs (#2084)
Updates are only to the config. This PR should be simple. Tl;dr is
destro pve spec is using the wrong glyphs.

Longer explanation--right now, PreMadeSpecGlyph in the config provides
for destro pve spec to use the following Major Glyphs at levels 15, 30,
and 80, respectively: Life Tap, Quick Decay, Conflagrate. Quick Decay is
useless for destro because destro does not cast Corruption except as a
filler instant cast when on the move. Meanwhile, the spec is almost
unplayable without Glyph of Conflagrate, so that should not be withheld
until level 80. After Conflagrate, there are several viable glyphs,
including Life Tap, Incinerate, Immolate, and Imp. I understand Glyph of
Life Tap gets worse over time to the point that you don't want to use
that glyph in ICC, but that's quite late, and it is useful for the vast
majority of the game as a glyph that would actually be available at
level 15. I also understand that Glyph of Immolate does not excel until
high gear levels. Therefore, I decided to use Incinerate as the default
level 80 glyph.

The new order for default glyphs for destro pve for levels 15, 30, and
80 is Life Tap, Conflagrate, and Incinerate, respectively. I also made a
couple of other very minor fixes in the config. No impact on performance
or AI, obviously.

Sidenote: Glyph of Conflagrate is not available at level 30--it requires
level 40, so from 30 to 40, InitGlyphs() will plug in a random glyph for
the second Major slot. This issue applies to many specs, and it's not
avoidable unless InitGlyphs() is broken up into level brackets, which I
think is not worthwhile. I think the better approach for glyphs is to
ensure the right ones are applied at high levels, but with an attempt to
make them usable at lower levels too where possible.
2026-01-30 21:52:35 +01:00
Keleborn
caae524a0a Minor flightMasterCache fix. (#2085)
# Pull Request

Incorrect comparison fix. 

---

## How to Test the Changes

- Alliance Bots should now be able to find the correct flightmaster and
use it

## 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**)

If this introduces more advanced or AI-heavy logic:

- [X] Lightweight mode remains the default
- [ ] More complex behavior is optional and thereby configurable

---

## 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
2026-01-30 21:50:09 +01:00
bashermens
13fff46fa0 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>
2026-01-30 21:49:37 +01:00
dillyns
a92886032c Summon Logic Tweaks (#2049)
Issues:
- When you have selfbot enabled and use summon command, you will summon
yourself. This causes odd movement if you summon while moving, and can
sometimes lead to falling through the floor.
- When using the summon command on bots with pets/guardians from a
medium distance (like jumping down a ledge then commanding summon), the
pets will pathfind run to catch up. This causes them to aggro everything
on the way.

Solution: 
Fix summon logic to prevent selfbot summon and ensure pets are
teleported with bots.

---------

Co-authored-by: bashermens <31279994+hermensbas@users.noreply.github.com>
2026-01-29 12:25:50 -08:00
gtkk
f5711dc6f7 FIX Onyxia Crash (#2062)
Solve these two problems #2043 #1981
@Regrad is the main contributor of the code, while I was just helping to
submit the pull request. Express my gratitude to him.
After testing, the code is proven to be effective.
2026-01-25 14:03:53 +01:00
bashermens
43e8e31980 Update PULL_REQUEST_TEMPLATE.md (#2066) 2026-01-25 13:46:23 +01:00
bashermens
c59a02ed89 Update PULL_REQUEST_TEMPLATE.md (#2065) 2026-01-25 12:26:15 +01:00
bashermens
7abd836971 Update PULL_REQUEST_TEMPLATE.md (#2064) 2026-01-25 12:22:53 +01:00
bashermens
5365ba86b5 Added PR template (#2063) 2026-01-25 12:13:36 +01:00
239 changed files with 2616 additions and 2315 deletions

127
PULL_REQUEST_TEMPLATE.md Normal file
View File

@@ -0,0 +1,127 @@
# Pull Request
Describe what this change does and why it is needed...
---
## Design Philosophy
We prioritize **stability, performance, and predictability** over behavioral realism.
Complex player-mimicking logic is intentionally limited due to its negative impact on scalability, maintainability, and
long-term robustness.
Excessive processing overhead can lead to server hiccups, increased CPU usage, and degraded performance for all
participants. Because every action and
decision tree is executed **per bot and per trigger**, even small increases in logic complexity can scale poorly and
negatively affect both players and
world (random) bots. Bots are not expected to behave perfectly, and perfect simulation of human decision-making is not a
project goal. Increased behavioral
realism often introduces disproportionate cost, reduced predictability, and significantly higher maintenance overhead.
Every additional branch of logic increases long-term responsibility. All decision paths must be tested, validated, and
maintained continuously as the system evolves.
If advanced or AI-intensive behavior is introduced, the **default configuration must remain the lightweight decision
model**. More complex behavior should only be
available as an **explicit opt-in option**, clearly documented as having a measurable performance cost.
Principles:
- **Stability before intelligence**
A stable system is always preferred over a smarter one.
- **Performance is a shared resource**
Any increase in bot cost affects all players and all bots.
- **Simple logic scales better than smart logic**
Predictable behavior under load is more valuable than perfect decisions.
- **Complexity must justify itself**
If a feature cannot clearly explain its cost, it should not exist.
- **Defaults must be cheap**
Expensive behavior must always be optional and clearly communicated.
- **Bots should look reasonable, not perfect**
The goal is believable behavior, not human simulation.
Before submitting, confirm that this change aligns with those principles.
---
## Feature Evaluation
Please answer the following:
- Describe the **minimum logic** required to achieve the intended behavior?
- Describe the **cheapest implementation** that produces an acceptable result?
- Describe the **runtime cost** when this logic executes across many bots?
---
## How to Test the Changes
- Step-by-step instructions to test the change
- Any required setup (e.g. multiple players, bots, specific configuration)
- Expected behavior and how to verify it
## Complexity & Impact
- Does this change add new decision branches?
- [ ] No
- [ ] Yes (**explain below**)
- Does this change increase per-bot or per-tick processing?
- [ ] No
- [ ] Yes (**describe and justify impact**)
- Could this logic scale poorly under load?
- [ ] No
- [ ] Yes (**explain why**)
---
## Defaults & Configuration
- Does this change modify default bot behavior?
- [ ] No
- [ ] Yes (**explain why**)
If this introduces more advanced or AI-heavy logic:
- [ ] Lightweight mode remains the default
- [ ] More complex behavior is optional and thereby configurable
---
## AI Assistance
- Was AI assistance (e.g. ChatGPT or similar tools) used while working on this change?
- [ ] No
- [ ] Yes (**explain below**)
If yes, please specify:
- AI tool or model used (e.g. ChatGPT, GPT-4, Claude, etc.)
- Purpose of usage (e.g. brainstorming, refactoring, documentation, code generation)
- Which parts of the change were influenced or generated
- Whether the result was manually reviewed and adapted
AI assistance is allowed, but all submitted code must be fully understood, reviewed, and owned by the contributor.
Any AI-influenced changes must be verified against existing CORE and PB logic. We expect contributors to be honest
about what they do and do not understand.
---
## Final Checklist
- [ ] Stability is not compromised
- [ ] Performance impact is understood, tested, and acceptable
- [ ] Added logic complexity is justified and explained
- [ ] 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.

19
check_pr_source.yml Normal file
View File

@@ -0,0 +1,19 @@
name: Enforce test-staging → main
on:
pull_request:
branches:
- main
jobs:
require-test-staging:
runs-on: ubuntu-22.04
steps:
- name: Ensure PR source is test-staging
run: |
echo "Base: ${{ github.event.pull_request.base.ref }}"
echo "Head: ${{ github.event.pull_request.head.ref }}"
if [ "${{ github.event.pull_request.head.ref }}" != "test-staging" ]; then
echo "✖ Pull request must come from test-staging"
exit 1
fi

View File

@@ -544,8 +544,8 @@ AiPlayerbot.AutoGearQualityLimit = 3
# Max iLVL Phase 1(MC, Ony, ZG) = 78 | Phase 2(BWL) = 83 | Phase 2.5(AQ40) = 88 | Phase 3(Naxx40) = 92 # Max iLVL Phase 1(MC, Ony, ZG) = 78 | Phase 2(BWL) = 83 | Phase 2.5(AQ40) = 88 | Phase 3(Naxx40) = 92
# TBC # TBC
# Max iLVL Tier 4 = 120 | Tier 5 = 133 | Tier 6 = 164 # Max iLVL Tier 4 = 120 | Tier 5 = 133 | Tier 6 = 164
# Max iLVL Phase 1(Kara, Gruul, Mag) = 125 | Phase 1.5(ZA) = 138 | Phase 2(SC, TK) = 141 | Phase 3(Hyjal, BT) = 156 | Phase 4(Sunwell) = 164 # Max iLVL Phase 1(Kara, Gruul, Mag) = 125 | Phase 2(SSC, TK, ZA) = 141 | Phase 3(Hyjal, BT) = 156 | Phase 4(Sunwell) = 164
# Wotlk # WotLK
# Max iLVL Tier 7(10/25) = 200/213 | Tier 8(10/25) = 225/232 | Tier 9(10/25) = 232/245 | Tier 10(10/25/HC) = 251/264/290 # Max iLVL Tier 7(10/25) = 200/213 | Tier 8(10/25) = 225/232 | Tier 9(10/25) = 232/245 | Tier 10(10/25/HC) = 251/264/290
# Max iLVL Phase 1(Naxx) = 224 | Phase 2(Ulduar) = 245 | Phase 3(ToC) = 258 | Phase 4(ICC) = 290 # Max iLVL Phase 1(Naxx) = 224 | Phase 2(Ulduar) = 245 | Phase 3(ToC) = 258 | Phase 4(ICC) = 290
# Default: 0 (no limit) # Default: 0 (no limit)
@@ -736,7 +736,7 @@ AiPlayerbot.RandomGearQualityLimit = 3
# TBC # TBC
# Max iLVL Tier 4 = 120 | Tier 5 = 133 | Tier 6 = 164 # Max iLVL Tier 4 = 120 | Tier 5 = 133 | Tier 6 = 164
# Max iLVL Phase 1(Kara, Gruul, Mag) = 125 | Phase 2(SSC, TK, ZA) = 141 | Phase 3(Hyjal, BT) = 156 | Phase 4(Sunwell) = 164 # Max iLVL Phase 1(Kara, Gruul, Mag) = 125 | Phase 2(SSC, TK, ZA) = 141 | Phase 3(Hyjal, BT) = 156 | Phase 4(Sunwell) = 164
# Wotlk # WotLK
# Max iLVL Tier 7(10/25) = 200/213 | Tier 8(10/25) = 225/232 | Tier 9(10/25) = 232/245 | Tier 10(10/25/HC) = 251/264/290 # Max iLVL Tier 7(10/25) = 200/213 | Tier 8(10/25) = 225/232 | Tier 9(10/25) = 232/245 | Tier 10(10/25/HC) = 251/264/290
# Max iLVL Phase 1(Naxx) = 224 | Phase 2(Ulduar) = 245 | Phase 3(ToC) = 258 | Phase 4(ICC) = 290 # Max iLVL Phase 1(Naxx) = 224 | Phase 2(Ulduar) = 245 | Phase 3(ToC) = 258 | Phase 4(ICC) = 290
# Default: 0 (no limit) # Default: 0 (no limit)
@@ -1624,7 +1624,7 @@ AiPlayerbot.PremadeSpecLink.9.1.60 = -003203301135112530135201051
AiPlayerbot.PremadeSpecLink.9.1.70 = -003203301135112530135201051-55 AiPlayerbot.PremadeSpecLink.9.1.70 = -003203301135112530135201051-55
AiPlayerbot.PremadeSpecLink.9.1.80 = -003203301135112530135221351-55000005 AiPlayerbot.PremadeSpecLink.9.1.80 = -003203301135112530135221351-55000005
AiPlayerbot.PremadeSpecName.9.2 = destro pve AiPlayerbot.PremadeSpecName.9.2 = destro pve
AiPlayerbot.PremadeSpecGlyph.9.2 = 45785,43390,50077,43394,43393,42454 AiPlayerbot.PremadeSpecGlyph.9.2 = 45785,43390,42454,43394,43393,45785
AiPlayerbot.PremadeSpecLink.9.2.60 = --05203215200231051305031151 AiPlayerbot.PremadeSpecLink.9.2.60 = --05203215200231051305031151
AiPlayerbot.PremadeSpecLink.9.2.80 = 23-0302-05203215220331051335231351 AiPlayerbot.PremadeSpecLink.9.2.80 = 23-0302-05203215220331051335231351
AiPlayerbot.PremadeSpecName.9.3 = affli pvp AiPlayerbot.PremadeSpecName.9.3 = affli pvp

View File

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

View File

@@ -50,7 +50,7 @@ bool ReachAreaTriggerAction::Execute(Event event)
/*forceDestination*/ false); /*forceDestination*/ false);
float distance = bot->GetDistance(at->x, at->y, at->z); 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->TellError("Wait for me");
botAI->SetNextCheckDelay(delay); botAI->SetNextCheckDelay(delay);
context->GetValue<LastMovement&>("last area trigger")->Get().lastAreaTrigger = triggerId; 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) // Check if bot OR target is in prohibited zone/area (skip for duels)
if ((target->IsPlayer() || target->IsPet()) && if ((target->IsPlayer() || target->IsPet()) &&
(!bot->duel || bot->duel->Opponent != target) && (!bot->duel || bot->duel->Opponent != target) &&
(sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()) || (sPlayerbotAIConfig.IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()) ||
sPlayerbotAIConfig->IsPvpProhibited(target->GetZoneId(), target->GetAreaId()))) sPlayerbotAIConfig.IsPvpProhibited(target->GetZoneId(), target->GetAreaId())))
{ {
if (verbose) if (verbose)
botAI->TellError("I cannot attack other players in PvP prohibited areas."); 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)) if (botAI->CanMove() && !bot->HasInArc(CAST_ANGLE_IN_FRONT, target))
sServerFacade->SetFacingTo(bot, target); ServerFacade::instance().SetFacingTo(bot, target);
botAI->ChangeEngine(BOT_STATE_COMBAT); botAI->ChangeEngine(BOT_STATE_COMBAT);

View File

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

View File

@@ -89,7 +89,7 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
// continue; // continue;
if (offline) if (offline)
sRandomPlayerbotMgr->AddPlayerBot(itr->Guid, 0); sRandomPlayerbotMgr.AddPlayerBot(itr->Guid, 0);
if (member) if (member)
{ {
@@ -100,7 +100,7 @@ bool BGJoinAction::gatherArenaTeam(ArenaType type)
if (member->GetGroup() && memberBotAI->HasRealPlayerMaster()) if (member->GetGroup() && memberBotAI->HasRealPlayerMaster())
continue; continue;
if (!sPlayerbotAIConfig->IsInRandomAccountList(member->GetSession()->GetAccountId())) if (!sPlayerbotAIConfig.IsInRandomAccountList(member->GetSession()->GetAccountId()))
continue; continue;
if (member->IsInCombat()) if (member->IsInCombat())
@@ -250,13 +250,13 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
TeamSize = (uint32)type; TeamSize = (uint32)type;
// Check if bots should join Rated Arena (Only captains can queue) // 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 = uint32 ratedArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount = uint32 ratedArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue = uint32 activeRatedArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) <
(BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount)); (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
@@ -265,7 +265,7 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
{ {
if (sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type)) if (sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type))
{ {
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize;
ratedList.push_back(queueTypeId); ratedList.push_back(queueTypeId);
return true; return true;
} }
@@ -274,13 +274,13 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
// Check if bots should join Skirmish Arena // 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. // We have extra bots queue because same faction can vs each other but can't be in the same group.
uint32 skirmishArenaBotCount = uint32 skirmishArenaBotCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount = uint32 skirmishArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount = uint32 skirmishArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue = uint32 activeSkirmishArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount); uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount);
if (maxRequiredSkirmishBots != 0) if (maxRequiredSkirmishBots != 0)
maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize; maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize;
@@ -294,12 +294,12 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
} }
// Check if bots should join Battleground // Check if bots should join Battleground
uint32 bgAllianceBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount; uint32 bgAllianceBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount;
uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount; uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount;
uint32 bgHordeBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount; uint32 bgHordeBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount;
uint32 bgHordePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount; uint32 bgHordePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount;
uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue; uint32 activeBgQueue = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount; uint32 bgInstanceCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
if (teamId == TEAM_ALLIANCE) if (teamId == TEAM_ALLIANCE)
{ {
@@ -318,7 +318,7 @@ bool BGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battlegroun
bool BGJoinAction::isUseful() bool BGJoinAction::isUseful()
{ {
// do not try if BG bots disabled // do not try if BG bots disabled
if (!sPlayerbotAIConfig->randomBotJoinBG) if (!sPlayerbotAIConfig.randomBotJoinBG)
return false; return false;
// can't queue while in BG/Arena // can't queue while in BG/Arena
@@ -440,7 +440,7 @@ bool BGJoinAction::JoinQueue(uint32 type)
// get battlemaster // get battlemaster
// Unit* unit = botAI->GetUnit(AI_VALUE2(CreatureData const*, "bg master", bgTypeId)); // 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) if (!unit && isArena)
{ {
botAI->GetAiObjectContext()->GetValue<uint32>("bg type")->Set(0); 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. // This breaks groups as refresh includes a remove from group function call.
// refresh food/regs // refresh food/regs
// sRandomPlayerbotMgr->Refresh(bot); // sRandomPlayerbotMgr.Refresh(bot);
bool joinAsGroup = bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() == bot->GetGUID(); bool joinAsGroup = bot->GetGroup() && bot->GetGroup()->GetLeaderGUID() == bot->GetGUID();
@@ -523,23 +523,23 @@ bool BGJoinAction::JoinQueue(uint32 type)
{ {
if (!isRated) if (!isRated)
{ {
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount++; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount++;
} }
} }
else if (!joinAsGroup) else if (!joinAsGroup)
{ {
if (teamId == TEAM_ALLIANCE) if (teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount++; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount++;
else else
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount++;
} }
else else
{ {
if (teamId == TEAM_ALLIANCE) if (teamId == TEAM_ALLIANCE)
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount += sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount +=
bot->GetGroup()->GetMembersCount(); bot->GetGroup()->GetMembersCount();
else else
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount += sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount +=
bot->GetGroup()->GetMembersCount(); bot->GetGroup()->GetMembersCount();
} }
@@ -588,13 +588,13 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
TeamSize = (uint32)type; TeamSize = (uint32)type;
// Check if bots should join Rated Arena (Only captains can queue) // 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 = uint32 ratedArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount;
uint32 ratedArenaInstanceCount = uint32 ratedArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaInstanceCount;
uint32 activeRatedArenaQueue = uint32 activeRatedArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeRatedArenaQueue;
bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) < bool isRated = (ratedArenaBotCount + ratedArenaPlayerCount) <
(BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount)); (BracketSize * (activeRatedArenaQueue + ratedArenaInstanceCount));
@@ -603,7 +603,7 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
{ {
if (sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type)) if (sArenaTeamMgr->GetArenaTeamByCaptain(bot->GetGUID(), type))
{ {
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaBotCount += TeamSize;
ratedList.push_back(queueTypeId); ratedList.push_back(queueTypeId);
return true; return true;
} }
@@ -612,13 +612,13 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
// Check if bots should join Skirmish Arena // 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. // We have extra bots queue because same faction can vs each other but can't be in the same group.
uint32 skirmishArenaBotCount = uint32 skirmishArenaBotCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaBotCount;
uint32 skirmishArenaPlayerCount = uint32 skirmishArenaPlayerCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount;
uint32 skirmishArenaInstanceCount = uint32 skirmishArenaInstanceCount =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaInstanceCount;
uint32 activeSkirmishArenaQueue = uint32 activeSkirmishArenaQueue =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeSkirmishArenaQueue;
uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount); uint32 maxRequiredSkirmishBots = BracketSize * (activeSkirmishArenaQueue + skirmishArenaInstanceCount);
if (maxRequiredSkirmishBots != 0) if (maxRequiredSkirmishBots != 0)
maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize; maxRequiredSkirmishBots = maxRequiredSkirmishBots + TeamSize;
@@ -632,12 +632,12 @@ bool FreeBGJoinAction::shouldJoinBg(BattlegroundQueueTypeId queueTypeId, Battleg
} }
// Check if bots should join Battleground // Check if bots should join Battleground
uint32 bgAllianceBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount; uint32 bgAllianceBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAllianceBotCount;
uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount; uint32 bgAlliancePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgAlliancePlayerCount;
uint32 bgHordeBotCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordeBotCount; uint32 bgHordeBotCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordeBotCount;
uint32 bgHordePlayerCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount; uint32 bgHordePlayerCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgHordePlayerCount;
uint32 activeBgQueue = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].activeBgQueue; uint32 activeBgQueue = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].activeBgQueue;
uint32 bgInstanceCount = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].bgInstanceCount; uint32 bgInstanceCount = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].bgInstanceCount;
if (teamId == TEAM_ALLIANCE) if (teamId == TEAM_ALLIANCE)
{ {
@@ -670,7 +670,7 @@ bool BGLeaveAction::Execute(Event event)
uint16 unk = 0x1F90; uint16 unk = 0x1F90;
uint8 unk2 = 0x0; uint8 unk2 = 0x0;
bool isArena = false; bool isArena = false;
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot); bool IsRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
ArenaType arenaType = ArenaType(BattlegroundMgr::BGArenaType(queueTypeId)); ArenaType arenaType = ArenaType(BattlegroundMgr::BGArenaType(queueTypeId));
if (arenaType) if (arenaType)
@@ -709,7 +709,7 @@ bool BGStatusAction::LeaveBG(PlayerbotAI* botAI)
if (!bg) if (!bg)
return false; return false;
bool isArena = bg->isArena(); bool isArena = bg->isArena();
bool isRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot); bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
if (isRandomBot) if (isRandomBot)
botAI->SetMaster(nullptr); botAI->SetMaster(nullptr);
@@ -805,7 +805,7 @@ bool BGStatusAction::Execute(Event event)
break; break;
} }
bool IsRandomBot = sRandomPlayerbotMgr->IsRandomBot(bot); bool IsRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(QueueSlot); BattlegroundQueueTypeId queueTypeId = bot->GetBattlegroundQueueTypeId(QueueSlot);
BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId); BattlegroundTypeId _bgTypeId = BattlegroundMgr::BGTemplateId(queueTypeId);
if (!queueTypeId) if (!queueTypeId)
@@ -958,10 +958,10 @@ bool BGStatusAction::Execute(Event event)
//TeamId teamId = bot->GetTeamId(); //not used, line marked for removal. //TeamId teamId = bot->GetTeamId(); //not used, line marked for removal.
bool realPlayers = false; bool realPlayers = false;
if (isRated) if (isRated)
realPlayers = sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount > 0; realPlayers = sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].ratedArenaPlayerCount > 0;
else else
realPlayers = realPlayers =
sRandomPlayerbotMgr->BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0; sRandomPlayerbotMgr.BattlegroundData[queueTypeId][bracketId].skirmishArenaPlayerCount > 0;
if (realPlayers) if (realPlayers)
return false; 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 // useful commands for fixing BG bugs and checking waypoints/paths
bool BGTactics::HandleConsoleCommand(ChatHandler* handler, char const* args) bool BGTactics::HandleConsoleCommand(ChatHandler* handler, char const* args)
{ {
if (!sPlayerbotAIConfig->enabled) if (!sPlayerbotAIConfig.enabled)
{ {
handler->PSendSysMessage("|cffff0000Playerbot system is currently disabled!"); handler->PSendSysMessage("|cffff0000Playerbot system is currently disabled!");
return true; return true;
@@ -2219,7 +2219,7 @@ bool BGTactics::selectObjective(bool reset)
if (urand(0, 99) < 20 && teamFC) if (urand(0, 99) < 20 && teamFC)
{ {
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ()); 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); Follow(teamFC);
} }
else else
@@ -2227,8 +2227,8 @@ bool BGTactics::selectObjective(bool reset)
} }
// Graveyard Camping if in lead // Graveyard Camping if in lead
else if (!hasFlag && role < 8 && else if (!hasFlag && role < 8 &&
(team == TEAM_ALLIANCE && allianceScore == 2 && hordeScore == 0) || ((team == TEAM_ALLIANCE && allianceScore == 2 && hordeScore == 0) ||
(team == TEAM_HORDE && hordeScore == 2 && allianceScore == 0)) (team == TEAM_HORDE && hordeScore == 2 && allianceScore == 0)))
{ {
if (team == TEAM_ALLIANCE) if (team == TEAM_ALLIANCE)
SetSafePos(WS_GY_CAMPING_HORDE, 10.0f); SetSafePos(WS_GY_CAMPING_HORDE, 10.0f);
@@ -2263,7 +2263,7 @@ bool BGTactics::selectObjective(bool reset)
if (urand(0, 99) < 70) if (urand(0, 99) < 70)
{ {
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ()); 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); Follow(teamFC);
} }
} }
@@ -2284,7 +2284,7 @@ bool BGTactics::selectObjective(bool reset)
{ {
// Assist own FC if not pursuing enemy FC // Assist own FC if not pursuing enemy FC
target.Relocate(teamFC->GetPositionX(), teamFC->GetPositionY(), teamFC->GetPositionZ()); 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); Follow(teamFC);
} }
else if (urand(0, 99) < 5) else if (urand(0, 99) < 5)
@@ -3197,11 +3197,11 @@ bool BGTactics::moveToObjective(bool ignoreDist)
return true; 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; // std::ostringstream out;
// out << "It is too far away! " << pos.x << ", " << pos.y << ", Distance: " << // 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; return false;
} }
@@ -3213,7 +3213,7 @@ bool BGTactics::moveToObjective(bool ignoreDist)
} }
// std::ostringstream out; out << "Moving to objective " << pos.x << ", " << pos.y << ", Distance: " << // 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 // 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); 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: "; // out << "WP: ";
// reverse ? out << currPoint << " <<< -> " << nPoint : out << currPoint << ">>> ->" << nPoint; // reverse ? out << currPoint << " <<< -> " << nPoint : out << currPoint << ">>> ->" << nPoint;
// out << ", " << nextPoint.x << ", " << nextPoint.y << " Path Size: " << currentPath->size() << ", Dist: " << // 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); 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()) if (closeObjects.empty())
return false; return false;
bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig->mediumHealth || bool needRegen = bot->GetHealthPct() < sPlayerbotAIConfig.mediumHealth ||
(AI_VALUE2(bool, "has mana", "self target") && (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) || 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)) || bot->HasAura(BG_WS_SPELL_SILVERWING_FLAG) || bot->HasAura(BG_EY_NETHERSTORM_FLAG_SPELL)) ||
!(teamFlagTaken() || flagTaken()); !(teamFlagTaken() || flagTaken());
@@ -4057,7 +4057,7 @@ bool BGTactics::useBuff()
continue; continue;
// use speed buff only if close // 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)) go->GetEntry() == Buff_Entries[0] ? 20.0f : 50.0f))
continue; continue;
@@ -4107,7 +4107,7 @@ uint32 BGTactics::getPlayersInArea(TeamId teamId, Position point, float range, b
if (!combat && player->IsInCombat()) if (!combat && player->IsInCombat())
continue; continue;
if (sServerFacade->GetDistance2d(player, point.GetPositionX(), point.GetPositionY()) < range) if (ServerFacade::instance().GetDistance2d(player, point.GetPositionX(), point.GetPositionY()) < range)
++defCount; ++defCount;
} }
} }
@@ -4191,9 +4191,9 @@ bool BGTactics::IsLockedInsideKeep()
// get closest portal // get closest portal
if (bot->GetTeamId() == TEAM_ALLIANCE && go->GetEntry() == GO_TELEPORTER_4) 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; closestDistance = tempDist;
closestPortal = go; closestPortal = go;
@@ -4204,9 +4204,9 @@ bool BGTactics::IsLockedInsideKeep()
// get closest portal // get closest portal
if (bot->GetTeamId() == TEAM_HORDE && go->GetEntry() == GO_TELEPORTER_2) 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; closestDistance = tempDist;
closestPortal = go; closestPortal = go;
@@ -4253,7 +4253,7 @@ bool ArenaTactics::Execute(Event event)
{ {
if (!bot->InBattleground()) 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_COMBAT);
botAI->ChangeStrategy("-arena", BOT_STATE_NON_COMBAT); botAI->ChangeStrategy("-arena", BOT_STATE_NON_COMBAT);
botAI->ResetStrategies(!IsRandomBot); botAI->ResetStrategies(!IsRandomBot);

View File

@@ -130,10 +130,10 @@ bool CastCustomSpellAction::Execute(Event event)
return false; 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); ServerFacade::instance().SetFacingTo(bot, target);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); botAI->SetNextCheckDelay(sPlayerbotAIConfig.reactDelay);
msg << "cast " << text; msg << "cast " << text;
botAI->HandleCommand(CHAT_MSG_WHISPER, msg.str(), master); botAI->HandleCommand(CHAT_MSG_WHISPER, msg.str(), master);
@@ -286,7 +286,7 @@ bool CastRandomSpellAction::Execute(Event event)
if (isCast) 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; std::ostringstream cmd;
cmd << "castnc " << chat->FormatWorldobject(wo) + " " << spellId << " " << 19; cmd << "castnc " << chat->FormatWorldobject(wo) + " " << spellId << " " << 19;

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ bool CheckMailAction::Execute(Event event)
continue; continue;
uint32 account = owner->GetSession()->GetAccountId(); uint32 account = owner->GetSession()->GetAccountId();
if (sPlayerbotAIConfig->IsInRandomAccountList(account)) if (sPlayerbotAIConfig.IsInRandomAccountList(account))
continue; continue;
ProcessMail(mail, owner, trans); ProcessMail(mail, owner, trans);
@@ -80,7 +80,7 @@ void CheckMailAction::ProcessMail(Mail* mail, Player* owner, CharacterDatabaseTr
if (!item) if (!item)
continue; 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; std::ostringstream body;
body << "Hello, " << owner->GetName() << ",\n"; body << "Hello, " << owner->GetName() << ",\n";

View File

@@ -89,7 +89,7 @@ bool CheckMountStateAction::isUseful()
return false; return false;
// Not useful when level lower than minimum required // Not useful when level lower than minimum required
if (bot->GetLevel() < sPlayerbotAIConfig->useGroundMountAtMinLevel) if (bot->GetLevel() < sPlayerbotAIConfig.useGroundMountAtMinLevel)
return false; return false;
// Allow mounting while transformed only if the form allows it // 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), // 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. // 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); 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; return bot->getClass() == CLASS_WARRIOR ? std::max(18.0f, dismountDistance) : dismountDistance;
} }
@@ -413,7 +413,7 @@ float CheckMountStateAction::CalculateMountDistance() const
// seconds: // seconds:
// 21 / 7 = 21 / 14 + 1.5 = 3 (7 = dismounted speed 14 = epic-mount speed 1.5 = mount-spell cast time) // 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); 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); return std::max(21.0f, baseDistance);
} }
@@ -440,7 +440,7 @@ int32 CheckMountStateAction::CalculateMasterMountSpeed(Player* master, const Mou
int32 ridingSkill = bot->GetPureSkillValue(SKILL_RIDING); int32 ridingSkill = bot->GetPureSkillValue(SKILL_RIDING);
int32 botLevel = bot->GetLevel(); int32 botLevel = bot->GetLevel();
if (ridingSkill <= 75 && botLevel < static_cast<int32>(sPlayerbotAIConfig->useFastGroundMountAtMinLevel)) if (ridingSkill <= 75 && botLevel < static_cast<int32>(sPlayerbotAIConfig.useFastGroundMountAtMinLevel))
return 59; return 59;
// If there is a master and bot not in BG, use master's aura effects. // 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)) 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"); GuidVector possible_targets = *context->GetValue<GuidVector>("possible targets");

View File

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

View File

@@ -20,13 +20,13 @@ bool AttackEnemyPlayerAction::isUseful()
if (PlayerHasFlag::IsCapturingFlag(bot)) if (PlayerHasFlag::IsCapturingFlag(bot))
return false; return false;
return !sPlayerbotAIConfig->IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId()); return !sPlayerbotAIConfig.IsPvpProhibited(bot->GetZoneId(), bot->GetAreaId());
} }
bool AttackEnemyFlagCarrierAction::isUseful() bool AttackEnemyFlagCarrierAction::isUseful()
{ {
Unit* target = context->GetValue<Unit*>("enemy flag carrier")->Get(); 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); PlayerHasFlag::IsCapturingFlag(bot);
} }

View File

@@ -366,7 +366,7 @@ bool ChooseTravelTargetAction::getBestDestination(std::vector<TravelDestination*
WorldPosition botLocation(bot); WorldPosition botLocation(bot);
std::vector<WorldPosition*> availablePoints = 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. if (availablePoints.empty()) // No points available.
return false; return false;
@@ -488,7 +488,7 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom
if (newQuests) if (newQuests)
{ {
// Prefer new quests near the player at lower levels. // 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) if (activeQuests || completedQuests)
{ {
@@ -510,7 +510,7 @@ bool ChooseTravelTargetAction::SetQuestTarget(TravelTarget* target, bool onlyCom
continue; continue;
//Find quest takers or objectives //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. 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()) 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)) if (botAI->HasStrategy("debug travel", BotState::BOT_STATE_NON_COMBAT))
botAI->TellMasterNoFacing(std::to_string(activeDestinations.size()) + " quest destinations found."); botAI->TellMasterNoFacing(std::to_string(activeDestinations.size()) + " quest destinations found.");
@@ -547,7 +547,7 @@ bool ChooseTravelTargetAction::SetNewQuestTarget(TravelTarget* target)
// Find quest givers. // Find quest givers.
std::vector<TravelDestination*> TravelDestinations = 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()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -576,7 +576,7 @@ bool ChooseTravelTargetAction::SetRpgTarget(TravelTarget* target)
// Find rpg npcs // Find rpg npcs
std::vector<TravelDestination*> TravelDestinations = std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getRpgTravelDestinations(bot, botAI->HasRealPlayerMaster()); TravelMgr::instance().getRpgTravelDestinations(bot, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -605,7 +605,7 @@ bool ChooseTravelTargetAction::SetGrindTarget(TravelTarget* target)
// Find grind mobs. // Find grind mobs.
std::vector<TravelDestination*> TravelDestinations = std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getGrindTravelDestinations(bot, botAI->HasRealPlayerMaster()); TravelMgr::instance().getGrindTravelDestinations(bot, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -634,7 +634,7 @@ bool ChooseTravelTargetAction::SetBossTarget(TravelTarget* target)
// Find boss mobs. // Find boss mobs.
std::vector<TravelDestination*> TravelDestinations = std::vector<TravelDestination*> TravelDestinations =
sTravelMgr->getBossTravelDestinations(bot, botAI->HasRealPlayerMaster()); TravelMgr::instance().getBossTravelDestinations(bot, botAI->HasRealPlayerMaster());
activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
@@ -662,7 +662,7 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target)
WorldPosition botLocation(bot); WorldPosition botLocation(bot);
// Find quest givers. // 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()); activeDestinations.insert(activeDestinations.end(), TravelDestinations.begin(), TravelDestinations.end());
/* /*
@@ -681,7 +681,7 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target)
if (activePoints.empty()) if (activePoints.empty())
{ {
TravelDestinations = sTravelMgr->getExploreTravelDestinations(bot, botAI->HasRealPlayerMaster()); TravelDestinations = TravelMgr::instance().getExploreTravelDestinations(bot, botAI->HasRealPlayerMaster());
for (auto& activeTarget : activeDestinations) for (auto& activeTarget : activeDestinations)
{ {
@@ -710,7 +710,7 @@ bool ChooseTravelTargetAction::SetNpcFlagTarget(TravelTarget* target, std::vecto
std::vector<TravelDestination*> dests; std::vector<TravelDestination*> dests;
for (auto& d : sTravelMgr->getRpgTravelDestinations(bot, true, true)) for (auto& d : TravelMgr::instance().getRpgTravelDestinations(bot, true, true))
{ {
if (!d->getEntry()) if (!d->getEntry())
continue; continue;
@@ -813,7 +813,7 @@ std::vector<TravelDestination*> TravelMgr::getBossTravelDestinations(Player* bot
bool ChooseTravelTargetAction::SetNullTarget(TravelTarget* target) bool ChooseTravelTargetAction::SetNullTarget(TravelTarget* target)
{ {
target->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true); target->setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition, true);
return true; return true;
} }
@@ -832,7 +832,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Quests //Quests
if (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())) if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d); dests.push_back(d);
@@ -842,7 +842,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Zones //Zones
if (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())) if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d); dests.push_back(d);
@@ -852,7 +852,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Npcs //Npcs
if (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())) if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d); dests.push_back(d);
@@ -862,7 +862,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Mobs //Mobs
if (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())) if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d); dests.push_back(d);
@@ -872,7 +872,7 @@ TravelDestination* ChooseTravelTargetAction::FindDestination(Player* bot, std::s
//Bosses //Bosses
if (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())) if (strstri(d->getTitle().c_str(), name.c_str()))
dests.push_back(d); dests.push_back(d);

View File

@@ -25,7 +25,7 @@ bool SwitchToMeleeAction::isUseful()
return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) && return botAI->HasStrategy("ranged", BOT_STATE_COMBAT) &&
((bot->IsInCombat() && target && ((bot->IsInCombat() && target &&
(target->GetVictim() == bot && (!bot->GetGroup() || lastFlee) && (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())); (!bot->IsInCombat()));
} }
@@ -47,7 +47,7 @@ bool SwitchToRangedAction::isUseful()
return botAI->HasStrategy("close", BOT_STATE_COMBAT) && hasAmmo && return botAI->HasStrategy("close", BOT_STATE_COMBAT) && hasAmmo &&
((bot->IsInCombat() && target && ((bot->IsInCombat() && target &&
((target->GetVictim() != bot || target->GetTarget() != bot->GetGUID()) || ((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())); (!bot->IsInCombat()));
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -44,7 +44,7 @@ bool FollowAction::Execute(Event event)
// botAI->PetFollow(); // botAI->PetFollow();
// } // }
// if (moved) // if (moved)
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->reactDelay); // botAI->SetNextCheckDelay(sPlayerbotAIConfig.reactDelay);
return moved; return moved;
} }
@@ -98,9 +98,9 @@ bool FollowAction::isUseful()
distance = bot->GetDistance(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ()); distance = bot->GetDistance(loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ());
} }
if (botAI->HasStrategy("master fishing", BOT_STATE_NON_COMBAT)) 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) bool FollowAction::CanDeadFollow(Unit* target)
@@ -130,7 +130,7 @@ bool FleeToGroupLeaderAction::Execute(Event event)
WorldPosition bosPos(bot); WorldPosition bosPos(bot);
float distance = bosPos.fDist(targetPos); float distance = bosPos.fDist(targetPos);
if (distance < sPlayerbotAIConfig->reactDistance * 3) if (distance < sPlayerbotAIConfig.reactDistance * 3)
{ {
if (!urand(0, 3)) if (!urand(0, 3))
botAI->TellMaster("I am close, wait for me!"); 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 // 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."); botAI->TellMaster("Pet autocast spells have been toggled.");
return toggled; return toggled;
@@ -185,7 +185,7 @@ bool SetPetStanceAction::Execute(Event /*event*/)
} }
// Get the default pet stance from the configuration // Get the default pet stance from the configuration
int32 stance = sPlayerbotAIConfig->defaultPetStance; int32 stance = sPlayerbotAIConfig.defaultPetStance;
ReactStates react = REACT_DEFENSIVE; ReactStates react = REACT_DEFENSIVE;
std::string stanceText = "defensive (from config, fallback)"; 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 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)."); botAI->TellMaster("Pet stance set to " + stanceText + " (applied to all pets/guardians).");
return true; return true;

View File

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

View File

@@ -82,7 +82,7 @@ bool CastSpellAction::isPossible()
{ {
if (botAI->IsInVehicle() && !botAI->IsInVehicle(false, false, true)) 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()); 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 (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()); LOG_DEBUG("playerbots", "Can cast spell failed. Mount. - bot name: {}", bot->GetName());
} }
@@ -133,7 +133,7 @@ bool CastSpellAction::isUseful()
return spellTarget && return spellTarget &&
AI_VALUE2(bool, "spell cast useful", 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) 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() 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"); } Unit* GiveFoodAction::GetTarget() { return AI_VALUE(Unit*, "party member without food"); }
@@ -74,7 +74,7 @@ bool GiveFoodAction::isUseful()
if (!GetTarget()) if (!GetTarget())
return false; 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)); return !isRandomBot || (isRandomBot && !botAI->HasCheat(BotCheatMask::food));
} }
@@ -86,7 +86,7 @@ bool GiveWaterAction::isUseful()
if (!GetTarget()) if (!GetTarget())
return false; 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)); return !isRandomBot || (isRandomBot && !botAI->HasCheat(BotCheatMask::food));
} }

View File

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

View File

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

View File

@@ -171,7 +171,7 @@ bool GuildManageNearbyAction::Execute(Event event)
continue; continue;
} }
if (!sPlayerbotAIConfig->randomBotGuildNearby) if (!sPlayerbotAIConfig.randomBotGuildNearby)
return false; return false;
if (guild->GetMemberSize() > 1000) if (guild->GetMemberSize() > 1000)
@@ -185,7 +185,7 @@ bool GuildManageNearbyAction::Execute(Event event)
PlayerbotAI* botAi = GET_PLAYERBOT_AI(player); PlayerbotAI* botAi = GET_PLAYERBOT_AI(player);
if (!sPlayerbotAIConfig->randomBotInvitePlayer && botAi && botAi->IsRealPlayer()) if (!sPlayerbotAIConfig.randomBotInvitePlayer && botAi && botAi->IsRealPlayer())
continue; continue;
if (botAi) if (botAi)
@@ -193,16 +193,16 @@ bool GuildManageNearbyAction::Execute(Event event)
if (botAi->GetGuilderType() == GuilderType::SOLO && !botAi->HasRealPlayerMaster()) //Do not invite solo players. if (botAi->GetGuilderType() == GuilderType::SOLO && !botAi->HasRealPlayerMaster()) //Do not invite solo players.
continue; 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; continue;
} }
bool sameGroup = bot->GetGroup() && bot->GetGroup()->IsMember(player->GetGUID()); 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; continue;
if (sPlayerbotAIConfig->inviteChat && (sRandomPlayerbotMgr->IsRandomBot(bot) || !botAI->HasActivePlayerMaster())) if (sPlayerbotAIConfig.inviteChat && (sRandomPlayerbotMgr.IsRandomBot(bot) || !botAI->HasActivePlayerMaster()))
{ {
/* std::map<std::string, std::string> placeholders; /* std::map<std::string, std::string> placeholders;
placeholders["%name"] = player->GetName(); placeholders["%name"] = player->GetName();
@@ -210,8 +210,8 @@ bool GuildManageNearbyAction::Execute(Event event)
placeholders["%guildname"] = guild->GetName(); placeholders["%guildname"] = guild->GetName();
AreaTableEntry const* current_area = botAI->GetCurrentArea(); AreaTableEntry const* current_area = botAI->GetCurrentArea();
AreaTableEntry const* current_zone = botAI->GetCurrentZone(); AreaTableEntry const* current_zone = botAI->GetCurrentZone();
placeholders["%area_name"] = current_area ? current_area->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()] : BOT_TEXT1("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; std::vector<std::string> lines;
@@ -219,45 +219,45 @@ bool GuildManageNearbyAction::Execute(Event event)
switch ((urand(0, 10) * urand(0, 10)) / 10) switch ((urand(0, 10) * urand(0, 10)) / 10)
{ {
case 0: 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; break;
case 1: 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; break;
case 2: 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; break;
case 3: 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; break;
case 4: 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; break;
case 5: 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; break;
case 6: 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; break;
case 7: 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; break;
case 8: 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; break;
case 9: case 9:
lines.push_back(BOT_TEXT2("You are actually going to join my guild %name?", placeholders)); lines.push_back(PlayerbotTextMgr::instance().GetBotText("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("Haha.. you are the man! We are going to raid Molten...", placeholders));
break; break;
case 10: case 10:
lines.push_back(BOT_TEXT2("Hey Hey! do you guys wanna join my gild????", placeholders)); lines.push_back(PlayerbotTextMgr::instance().GetBotText("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(PlayerbotTextMgr::instance().GetBotText("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(PlayerbotTextMgr::instance().GetBotText("..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(PlayerbotTextMgr::instance().GetBotText("..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(PlayerbotTextMgr::instance().GetBotText("..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(PlayerbotTextMgr::instance().GetBotText("..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(PlayerbotTextMgr::instance().GetBotText("..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("So what do you guys say are you going to join are you going to join?", placeholders));
break; break;
} }
@@ -274,7 +274,7 @@ bool GuildManageNearbyAction::Execute(Event event)
if (botAI->DoSpecificAction("guild invite", Event("guild management", guid), true)) if (botAI->DoSpecificAction("guild invite", Event("guild management", guid), true))
{ {
if (sPlayerbotAIConfig->inviteChat) if (sPlayerbotAIConfig.inviteChat)
return true; return true;
found++; found++;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -25,7 +25,7 @@ bool LootAction::Execute(Event /*event*/)
LootObject prevLoot = AI_VALUE(LootObject, "loot target"); LootObject prevLoot = AI_VALUE(LootObject, "loot target");
LootObject const& lootObject = 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) 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. // 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. // 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 return false; // Game object ID is disallowed, so do not proceed
} }
@@ -50,7 +50,7 @@ bool LootAction::Execute(Event /*event*/)
bool LootAction::isUseful() 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 enum ProfessionSpells
@@ -95,7 +95,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
if (bot->IsMounted()) if (bot->IsMounted())
{ {
bot->Dismount(); 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)) if (creature && creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
@@ -104,7 +104,7 @@ bool OpenLootAction::DoLoot(LootObject& lootObject)
*packet << lootObject.guid; *packet << lootObject.guid;
bot->GetSession()->QueuePacket(packet); bot->GetSession()->QueuePacket(packet);
// bot->GetSession()->HandleLootOpcode(packet); // bot->GetSession()->HandleLootOpcode(packet);
botAI->SetNextCheckDelay(sPlayerbotAIConfig->lootDelay); botAI->SetNextCheckDelay(sPlayerbotAIConfig.lootDelay);
return true; return true;
} }
@@ -202,7 +202,7 @@ uint32 OpenLootAction::GetOpeningSpell(LootObject& lootObject, GameObject* go)
return spellId; return spellId;
} }
return sPlayerbotAIConfig->openGoSpell; return sPlayerbotAIConfig.openGoSpell;
} }
bool OpenLootAction::CanOpenLock(LootObject& /*lootObject*/, SpellInfo const* spellInfo, GameObject* go) bool OpenLootAction::CanOpenLock(LootObject& /*lootObject*/, SpellInfo const* spellInfo, GameObject* go)
@@ -294,7 +294,7 @@ bool StoreLootAction::AuctionItem(uint32 itemId)
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(ahEntry); 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()); uint32 stackCount = urand(1, proto->GetMaxStackSize());
if (!price || !stackCount) if (!price || !stackCount)
@@ -426,28 +426,28 @@ bool StoreLootAction::Execute(Event event)
} }
Player* master = botAI->GetMaster(); 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) if (price)
sRandomPlayerbotMgr->AddTradeDiscount(bot, master, price); sRandomPlayerbotMgr.AddTradeDiscount(bot, master, price);
if (Group* group = bot->GetGroup()) if (Group* group = bot->GetGroup())
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
if (ref->GetSource() != bot) 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); WorldPacket* packet = new WorldPacket(CMSG_AUTOSTORE_LOOT_ITEM, 1);
*packet << itemindex; *packet << itemindex;
bot->GetSession()->QueuePacket(packet); bot->GetSession()->QueuePacket(packet);
// bot->GetSession()->HandleAutostoreLootItemOpcode(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); 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); botAI->PlayEmote(TEXT_EMOTE_CHEER);
BroadcastHelper::BroadcastLootingItem(botAI, bot, proto); 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 (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. // 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); bool canLoot = lootStrategy->CanLoot(proto, context);
// if (canLoot && proto->Bonding == BIND_WHEN_PICKED_UP && botAI->HasActivePlayerMaster()) // 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; return canLoot;
} }

View File

@@ -84,11 +84,11 @@ bool LootRollAction::Execute(Event event)
break; break;
} }
} }
if (sPlayerbotAIConfig->lootRollLevel == 0) if (sPlayerbotAIConfig.lootRollLevel == 0)
{ {
vote = PASS; vote = PASS;
} }
else if (sPlayerbotAIConfig->lootRollLevel == 1) else if (sPlayerbotAIConfig.lootRollLevel == 1)
{ {
if (vote == NEED) 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) || 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")); AI_VALUE(GuidSet&, "ignore rpg target").insert(AI_VALUE(GuidPosition, "rpg target"));
RESET_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 z = wo->GetPositionZ();
float mapId = wo->GetMapId(); float mapId = wo->GetMapId();
if (sPlayerbotAIConfig->randombotsWalkingRPG) if (sPlayerbotAIConfig.randombotsWalkingRPG)
if (!bot->IsOutdoors()) if (!bot->IsOutdoors())
bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_WALKING); bot->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_WALKING);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -120,7 +120,7 @@ bool MoveToPositionAction::isUseful()
{ {
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[qualifier]; PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[qualifier];
float distance = AI_VALUE2(float, "distance", std::string("position_") + 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) bool SetReturnPositionAction::Execute(Event event)
@@ -131,7 +131,7 @@ bool SetReturnPositionAction::Execute(Event event)
if (returnPos.isSet() && !randomPos.isSet()) if (returnPos.isSet() && !randomPos.isSet())
{ {
float angle = 2 * M_PI * urand(0, 1000) / 100.0f; 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 x = returnPos.x + cos(angle) * dist;
float y = returnPos.y + sin(angle) * dist; float y = returnPos.y + sin(angle) * dist;
float z = bot->GetPositionZ(); float z = bot->GetPositionZ();
@@ -157,7 +157,7 @@ bool SetReturnPositionAction::isUseful()
bool ReturnAction::isUseful() bool ReturnAction::isUseful()
{ {
PositionInfo pos = context->GetValue<PositionMap&>("position")->Get()[qualifier]; 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() bool ReturnToStayPositionAction::isPossible()
@@ -167,7 +167,7 @@ bool ReturnToStayPositionAction::isPossible()
if (stayPosition.isSet()) if (stayPosition.isSet())
{ {
const float distance = bot->GetDistance(stayPosition.x, stayPosition.y, stayPosition.z); 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"); 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) std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item)
{ {
if (!sRandomPlayerbotMgr->IsRandomBot(bot)) if (!sRandomPlayerbotMgr.IsRandomBot(bot))
return ""; return "";
if (item->Bonding == BIND_WHEN_PICKED_UP) if (item->Bonding == BIND_WHEN_PICKED_UP)
@@ -133,7 +133,7 @@ std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item)
{ {
Item* sell = *i; Item* sell = *i;
int32 price = int32 price =
sell->GetCount() * sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot); sell->GetCount() * sell->GetTemplate()->SellPrice * sRandomPlayerbotMgr.GetSellMultiplier(bot);
if (!sellPrice || sellPrice > price) if (!sellPrice || sellPrice > price)
sellPrice = price; sellPrice = price;
} }
@@ -147,7 +147,7 @@ std::string const QueryItemUsageAction::QueryItemPrice(ItemTemplate const* item)
if (usage == ITEM_USAGE_NONE) if (usage == ITEM_USAGE_NONE)
return msg.str(); return msg.str();
int32 buyPrice = item->BuyPrice * sRandomPlayerbotMgr->GetBuyMultiplier(bot); int32 buyPrice = item->BuyPrice * sRandomPlayerbotMgr.GetBuyMultiplier(bot);
if (buyPrice) if (buyPrice)
{ {
if (sellPrice) if (sellPrice)

View File

@@ -73,7 +73,7 @@ bool QueryQuestAction::Execute(Event event)
{ {
uint32 limit = 0; uint32 limit = 0;
std::vector<TravelDestination*> allDestinations = 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); }); 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) for (auto dest : allDestinations)

View File

@@ -182,7 +182,7 @@ bool QuestAction::ProcessQuests(WorldObject* questGiver)
{ {
ObjectGuid guid = questGiver->GetGUID(); 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)) //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; 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->SetFacingToObject(questGiver);
bot->SetTarget(guid); bot->SetTarget(guid);
@@ -238,7 +238,7 @@ bool QuestAction::AcceptQuest(Quest const* quest, ObjectGuid questGiver)
p.rpos(0); p.rpos(0);
bot->GetSession()->HandleQuestgiverAcceptQuestOpcode(p); 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, Object* pObject = ObjectAccessor::GetObjectByTypeMask(*bot, questGiver,
TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM); TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM);
@@ -366,7 +366,7 @@ bool QuestUpdateAddItemAction::Execute(Event event)
placeholders["%quest_obj_required"] = std::to_string(requiredItemsCount); 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)) 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); botAI->Say(text);
LOG_INFO("playerbots", "{} => {}", bot->GetName(), text); LOG_INFO("playerbots", "{} => {}", bot->GetName(), text);
} }
@@ -454,7 +454,7 @@ bool QuestUpdateFailedTimerAction::Execute(Event event)
{ {
std::map<std::string, std::string> placeholders; std::map<std::string, std::string> placeholders;
placeholders["%quest_link"] = botAI->GetChatHelper()->FormatQuest(qInfo); 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); BroadcastHelper::BroadcastQuestUpdateFailedTimer(botAI, bot, qInfo);
} }
else else

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -183,9 +183,9 @@ bool AutoReleaseSpiritAction::ShouldAutoRelease() const
return false; return false;
} }
return sServerFacade->IsDistanceGreaterThan( return ServerFacade::instance().IsDistanceGreaterThan(
AI_VALUE2(float, "distance", "group leader"), AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->sightDistance); sPlayerbotAIConfig.sightDistance);
} }
bool AutoReleaseSpiritAction::ShouldDelayBattlegroundRelease() const 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->ResetStrategies(false);
botAI->TellMaster("AI was reset to defaults"); botAI->TellMaster("AI was reset to defaults");
return true; return true;

View File

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

View File

@@ -24,8 +24,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
WorldPacket& p = event.getPacket(); WorldPacket& p = event.getPacket();
if (!p.empty() && p.GetOpcode() == CMSG_RECLAIM_CORPSE && groupLeader && !corpse && bot->IsAlive()) if (!p.empty() && p.GetOpcode() == CMSG_RECLAIM_CORPSE && groupLeader && !corpse && bot->IsAlive())
{ {
if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"), if (ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->farDistance)) sPlayerbotAIConfig.farDistance))
{ {
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT)) if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
{ {
@@ -46,8 +46,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
if (groupLeader) if (groupLeader)
{ {
if (!GET_PLAYERBOT_AI(groupLeader) && groupLeader->isDead() && groupLeader->GetCorpse() && if (!GET_PLAYERBOT_AI(groupLeader) && groupLeader->isDead() && groupLeader->GetCorpse() &&
sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"), ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
sPlayerbotAIConfig->farDistance)) sPlayerbotAIConfig.farDistance))
return false; return false;
} }
@@ -87,8 +87,8 @@ bool FindCorpseAction::Execute(Event event)
// if (groupLeader) // if (groupLeader)
// { // {
// if (!GET_PLAYERBOT_AI(groupLeader) && // if (!GET_PLAYERBOT_AI(groupLeader) &&
// sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"), // ServerFacade::instance().IsDistanceLessThan(AI_VALUE2(float, "distance", "group leader"),
// sPlayerbotAIConfig->farDistance)) return false; // sPlayerbotAIConfig.farDistance)) return false;
// } // }
uint32 dCount = AI_VALUE(uint32, "death count"); 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->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
// bot->GetName().c_str()); // bot->GetName().c_str());
context->GetValue<uint32>("death count")->Set(0); context->GetValue<uint32>("death count")->Set(0);
// sRandomPlayerbotMgr->RandomTeleportForLevel(bot); // sRandomPlayerbotMgr.RandomTeleportForLevel(bot);
sRandomPlayerbotMgr->Revive(bot); sRandomPlayerbotMgr.Revive(bot);
return true; return true;
} }
} }
@@ -123,7 +123,7 @@ bool FindCorpseAction::Execute(Event event)
{ {
if (moveToLeader) // We are near group leader. if (moveToLeader) // We are near group leader.
{ {
if (botPos.fDist(leaderPos) < sPlayerbotAIConfig->spellDistance) if (botPos.fDist(leaderPos) < sPlayerbotAIConfig.spellDistance)
return false; return false;
} }
else if (deadTime > 8 * MINUTE) // We have walked too long already. 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 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) if (moveToLeader)
moveToPos = leaderPos; moveToPos = leaderPos;
@@ -162,7 +162,7 @@ bool FindCorpseAction::Execute(Event event)
if (!botAI->AllowActivity(ALL_ACTIVITY)) 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. 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. 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 = GraveyardStruct const* ClosestGrave =
GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10); 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"); GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++) for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)

View File

@@ -130,7 +130,7 @@ bool RpgAction::SetNextRpgAction()
std::mt19937 gen(time(0)); 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(); Action* action = actions.front();

View File

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

View File

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

View File

@@ -10,7 +10,7 @@
bool SecurityCheckAction::isUseful() 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()); 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) bool important)
{ {
float dist = wpOwner->GetDistance(x, y, z); 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) if (!important)
delay *= 0.25; delay *= 0.25;
@@ -61,7 +61,7 @@ bool SeeSpellAction::Execute(Event event)
if (FISHING_SPELLS.find(spellId) != FISHING_SPELLS.end()) 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); botAI->ChangeStrategy("+master fishing", BOT_STATE_NON_COMBAT);
return true; return true;

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,7 +24,7 @@ bool TalkToQuestGiverAction::ProcessQuest(Quest const* quest, Object* questGiver
QuestStatus status = bot->GetQuestStatus(quest->GetQuestId()); QuestStatus status = bot->GetQuestStatus(quest->GetQuestId());
Player* master = GetMaster(); Player* master = GetMaster();
if (sPlayerbotAIConfig->syncQuestForPlayer && master) if (sPlayerbotAIConfig.syncQuestForPlayer && master)
{ {
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master); PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
if (!masterBotAI || masterBotAI->IsRealPlayer()) 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 && if (master && master->GetQuestStatus(quest->GetQuestId()) == QUEST_STATUS_COMPLETE &&
(status == QUEST_STATUS_INCOMPLETE || status == QUEST_STATUS_FAILED)) (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)) 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); BroadcastHelper::BroadcastQuestTurnedIn(botAI, bot, quest);
bot->RewardQuest(quest, 0, questGiver, false); bot->RewardQuest(quest, 0, questGiver, false);
} }
else 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)) 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); BroadcastHelper::BroadcastQuestTurnedIn(botAI, bot, quest);
bot->RewardQuest(quest, index, questGiver, true); bot->RewardQuest(quest, index, questGiver, true);
} }
else 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::set<uint32> bestIds;
std::ostringstream outid; std::ostringstream outid;
if (!botAI->IsAlt() || sPlayerbotAIConfig->autoPickReward == "yes") if (!botAI->IsAlt() || sPlayerbotAIConfig.autoPickReward == "yes")
{ {
bestIds = BestRewards(quest); bestIds = BestRewards(quest);
if (!bestIds.empty()) if (!bestIds.empty())
@@ -198,7 +198,7 @@ void TalkToQuestGiverAction::RewardMultipleItem(Quest const* quest, Object* ques
AskToSelectReward(quest, out, true); AskToSelectReward(quest, out, true);
} }
} }
else if (sPlayerbotAIConfig->autoPickReward == "no") else if (sPlayerbotAIConfig.autoPickReward == "no")
{ {
// Old functionality, list rewards. // Old functionality, list rewards.
AskToSelectReward(quest, out, false); AskToSelectReward(quest, out, false);
@@ -260,7 +260,7 @@ bool TurnInQueryQuestAction::Execute(Event event)
QuestStatus status = bot->GetQuestStatus(quest->GetQuestId()); QuestStatus status = bot->GetQuestStatus(quest->GetQuestId());
Player* master = GetMaster(); Player* master = GetMaster();
if (sPlayerbotAIConfig->syncQuestForPlayer && master) if (sPlayerbotAIConfig.syncQuestForPlayer && master)
{ {
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master); PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(master);
if (!masterBotAI || masterBotAI->IsRealPlayer()) 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) 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; out << "Calculated score of " << chat->FormatItem(proto) << " : " << score;
botAI->TellMasterNoFacing(out.str()); botAI->TellMasterNoFacing(out.str());
return true; return true;
} }

View File

@@ -15,7 +15,7 @@ bool TradeAction::Execute(Event event)
std::string const text = event.getParam(); std::string const text = event.getParam();
// If text starts with any excluded prefix, don't process it further. // 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) if (text.find(prefix) == 0)
return false; return false;

View File

@@ -32,7 +32,7 @@ bool TradeStatusAction::Execute(Event event)
return false; 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); bot->Whisper("Trading is disabled", LANG_UNIVERSAL, trader);
return false; return false;
@@ -61,7 +61,7 @@ bool TradeStatusAction::Execute(Event event)
uint32 status = 0; uint32 status = 0;
p << status; p << status;
uint32 discount = sRandomPlayerbotMgr->GetTradeDiscount(bot, trader); uint32 discount = sRandomPlayerbotMgr.GetTradeDiscount(bot, trader);
if (CheckTrade()) if (CheckTrade())
{ {
int32 botMoney = CalculateCost(bot, true); int32 botMoney = CalculateCost(bot, true);
@@ -81,7 +81,7 @@ bool TradeStatusAction::Execute(Event event)
bot->GetSession()->HandleAcceptTradeOpcode(p); bot->GetSession()->HandleAcceptTradeOpcode(p);
if (bot->GetTradeData()) if (bot->GetTradeData())
{ {
sRandomPlayerbotMgr->SetTradeDiscount(bot, trader, discount); sRandomPlayerbotMgr.SetTradeDiscount(bot, trader, discount);
return false; return false;
} }
@@ -96,7 +96,7 @@ bool TradeStatusAction::Execute(Event event)
craftData.AddObtained(itemId, count); 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) 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) 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); bot->SetFacingToObject(trader);
BeginTrade(); BeginTrade();
@@ -141,9 +141,9 @@ void TradeStatusAction::BeginTrade()
botAI->TellMaster("=== Inventory ==="); botAI->TellMaster("=== Inventory ===");
TellItems(visitor.items, visitor.soulbound); 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) if (discount)
{ {
std::ostringstream out; std::ostringstream out;
@@ -198,7 +198,7 @@ bool TradeStatusAction::CheckTrade()
return false; return false;
} }
uint32 accountId = bot->GetSession()->GetAccountId(); uint32 accountId = bot->GetSession()->GetAccountId();
if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId)) if (!sPlayerbotAIConfig.IsInRandomAccountList(accountId))
{ {
int32 botItemsMoney = CalculateCost(bot, true); int32 botItemsMoney = CalculateCost(bot, true);
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney; int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;
@@ -214,12 +214,12 @@ bool TradeStatusAction::CheckTrade()
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney; int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;
int32 playerItemsMoney = CalculateCost(trader, false); int32 playerItemsMoney = CalculateCost(trader, false);
int32 playerMoney = trader->GetTradeData()->GetMoney() + playerItemsMoney; 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); bot->Whisper("Selling is disabled.", LANG_UNIVERSAL, trader);
return false; 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); bot->Whisper("Buying is disabled.", LANG_UNIVERSAL, trader);
return false; return false;
@@ -262,7 +262,7 @@ bool TradeStatusAction::CheckTrade()
return false; return false;
} }
int32 discount = (int32)sRandomPlayerbotMgr->GetTradeDiscount(bot, trader); int32 discount = (int32)sRandomPlayerbotMgr.GetTradeDiscount(bot, trader);
int32 delta = playerMoney - botMoney; int32 delta = playerMoney - botMoney;
int32 moneyDelta = (int32)trader->GetTradeData()->GetMoney() - (int32)bot->GetTradeData()->GetMoney(); int32 moneyDelta = (int32)trader->GetTradeData()->GetMoney() - (int32)bot->GetTradeData()->GetMoney();
bool success = false; bool success = false;
@@ -287,7 +287,7 @@ bool TradeStatusAction::CheckTrade()
if (success) if (success)
{ {
sRandomPlayerbotMgr->AddTradeDiscount(bot, trader, delta); sRandomPlayerbotMgr.AddTradeDiscount(bot, trader, delta);
switch (urand(0, 4)) switch (urand(0, 4))
{ {
case 0: case 0:
@@ -353,11 +353,11 @@ int32 TradeStatusAction::CalculateCost(Player* player, bool sell)
if (sell) if (sell)
{ {
sum += item->GetCount() * proto->SellPrice * sRandomPlayerbotMgr->GetSellMultiplier(bot); sum += item->GetCount() * proto->SellPrice * sRandomPlayerbotMgr.GetSellMultiplier(bot);
} }
else 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) 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) if (AI_VALUE2(uint32, "free money for", (uint32)NeedMoneyFor::spells) < cost)
{ {
@@ -126,8 +126,8 @@ bool TrainerAction::Execute(Event event)
if (spell) if (spell)
spells.insert(spell); spells.insert(spell);
if (text.find("learn") != std::string::npos || sRandomPlayerbotMgr->IsRandomBot(bot) || if (text.find("learn") != std::string::npos || sRandomPlayerbotMgr.IsRandomBot(bot) ||
(sPlayerbotAIConfig->autoTrainSpells != "no" && (sPlayerbotAIConfig.autoTrainSpells != "no" &&
(trainer->GetTrainerType() != Trainer::Type::Tradeskill || (trainer->GetTrainerType() != Trainer::Type::Tradeskill ||
!botAI->HasActivePlayerMaster()))) // Todo rewrite to only exclude start primary profession skills and make !botAI->HasActivePlayerMaster()))) // Todo rewrite to only exclude start primary profession skills and make
// config dependent. // config dependent.
@@ -157,7 +157,7 @@ void TrainerAction::TellFooter(uint32 totalCost)
bool MaintenanceAction::Execute(Event event) bool MaintenanceAction::Execute(Event event)
{ {
if (!sPlayerbotAIConfig->maintenanceCommand) if (!sPlayerbotAIConfig.maintenanceCommand)
{ {
botAI->TellError("maintenance command is not allowed, please check the configuration."); botAI->TellError("maintenance command is not allowed, please check the configuration.");
return false; return false;
@@ -186,66 +186,66 @@ bool MaintenanceAction::Execute(Event event)
factory.InitMounts(); factory.InitMounts();
factory.InitGlyphs(false); factory.InitGlyphs(false);
factory.InitKeyring(); factory.InitKeyring();
if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) if (bot->GetLevel() >= sPlayerbotAIConfig.minEnchantingBotLevel)
factory.ApplyEnchantAndGemsNew(); factory.ApplyEnchantAndGemsNew();
} }
else else
{ {
if (sPlayerbotAIConfig->altMaintenanceAttunementQs) if (sPlayerbotAIConfig.altMaintenanceAttunementQs)
factory.InitAttunementQuests(); factory.InitAttunementQuests();
if (sPlayerbotAIConfig->altMaintenanceBags) if (sPlayerbotAIConfig.altMaintenanceBags)
factory.InitBags(false); factory.InitBags(false);
if (sPlayerbotAIConfig->altMaintenanceAmmo) if (sPlayerbotAIConfig.altMaintenanceAmmo)
factory.InitAmmo(); factory.InitAmmo();
if (sPlayerbotAIConfig->altMaintenanceFood) if (sPlayerbotAIConfig.altMaintenanceFood)
factory.InitFood(); factory.InitFood();
if (sPlayerbotAIConfig->altMaintenanceReagents) if (sPlayerbotAIConfig.altMaintenanceReagents)
factory.InitReagents(); factory.InitReagents();
if (sPlayerbotAIConfig->altMaintenanceConsumables) if (sPlayerbotAIConfig.altMaintenanceConsumables)
factory.InitConsumables(); factory.InitConsumables();
if (sPlayerbotAIConfig->altMaintenancePotions) if (sPlayerbotAIConfig.altMaintenancePotions)
factory.InitPotions(); factory.InitPotions();
if (sPlayerbotAIConfig->altMaintenanceTalentTree) if (sPlayerbotAIConfig.altMaintenanceTalentTree)
factory.InitTalentsTree(true); factory.InitTalentsTree(true);
if (sPlayerbotAIConfig->altMaintenancePet) if (sPlayerbotAIConfig.altMaintenancePet)
factory.InitPet(); factory.InitPet();
if (sPlayerbotAIConfig->altMaintenancePetTalents) if (sPlayerbotAIConfig.altMaintenancePetTalents)
factory.InitPetTalents(); factory.InitPetTalents();
if (sPlayerbotAIConfig->altMaintenanceSkills) if (sPlayerbotAIConfig.altMaintenanceSkills)
factory.InitSkills(); factory.InitSkills();
if (sPlayerbotAIConfig->altMaintenanceClassSpells) if (sPlayerbotAIConfig.altMaintenanceClassSpells)
factory.InitClassSpells(); factory.InitClassSpells();
if (sPlayerbotAIConfig->altMaintenanceAvailableSpells) if (sPlayerbotAIConfig.altMaintenanceAvailableSpells)
factory.InitAvailableSpells(); factory.InitAvailableSpells();
if (sPlayerbotAIConfig->altMaintenanceReputation) if (sPlayerbotAIConfig.altMaintenanceReputation)
factory.InitReputation(); factory.InitReputation();
if (sPlayerbotAIConfig->altMaintenanceSpecialSpells) if (sPlayerbotAIConfig.altMaintenanceSpecialSpells)
factory.InitSpecialSpells(); factory.InitSpecialSpells();
if (sPlayerbotAIConfig->altMaintenanceMounts) if (sPlayerbotAIConfig.altMaintenanceMounts)
factory.InitMounts(); factory.InitMounts();
if (sPlayerbotAIConfig->altMaintenanceGlyphs) if (sPlayerbotAIConfig.altMaintenanceGlyphs)
factory.InitGlyphs(false); factory.InitGlyphs(false);
if (sPlayerbotAIConfig->altMaintenanceKeyring) if (sPlayerbotAIConfig.altMaintenanceKeyring)
factory.InitKeyring(); factory.InitKeyring();
if (sPlayerbotAIConfig->altMaintenanceGemsEnchants && bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) if (sPlayerbotAIConfig.altMaintenanceGemsEnchants && bot->GetLevel() >= sPlayerbotAIConfig.minEnchantingBotLevel)
factory.ApplyEnchantAndGemsNew(); factory.ApplyEnchantAndGemsNew();
} }
@@ -267,28 +267,28 @@ bool RemoveGlyphAction::Execute(Event event)
bool AutoGearAction::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."); botAI->TellError("autogear command is not allowed, please check the configuration.");
return false; return false;
} }
if (!sPlayerbotAIConfig->autoGearCommandAltBots && if (!sPlayerbotAIConfig.autoGearCommandAltBots &&
!sPlayerbotAIConfig->IsInRandomAccountList(bot->GetSession()->GetAccountId())) !sPlayerbotAIConfig.IsInRandomAccountList(bot->GetSession()->GetAccountId()))
{ {
botAI->TellError("You cannot use autogear on alt bots."); botAI->TellError("You cannot use autogear on alt bots.");
return false; return false;
} }
botAI->TellMaster("I'm auto gearing"); botAI->TellMaster("I'm auto gearing");
uint32 gs = sPlayerbotAIConfig->autoGearScoreLimit == 0 uint32 gs = sPlayerbotAIConfig.autoGearScoreLimit == 0
? 0 ? 0
: PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig->autoGearScoreLimit, : PlayerbotFactory::CalcMixedGearScore(sPlayerbotAIConfig.autoGearScoreLimit,
sPlayerbotAIConfig->autoGearQualityLimit); sPlayerbotAIConfig.autoGearQualityLimit);
PlayerbotFactory factory(bot, bot->GetLevel(), sPlayerbotAIConfig->autoGearQualityLimit, gs); PlayerbotFactory factory(bot, bot->GetLevel(), sPlayerbotAIConfig.autoGearQualityLimit, gs);
factory.InitEquipment(true); factory.InitEquipment(true);
factory.InitAmmo(); factory.InitAmmo();
if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) if (bot->GetLevel() >= sPlayerbotAIConfig.minEnchantingBotLevel)
{ {
factory.ApplyEnchantAndGemsNew(); factory.ApplyEnchantAndGemsNew();
} }

View File

@@ -21,9 +21,9 @@ bool TravelAction::Execute(Event event)
Unit* newTarget = nullptr; Unit* newTarget = nullptr;
std::list<Unit*> targets; 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); 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) for (Unit* unit : targets)
{ {
@@ -77,7 +77,7 @@ bool MoveToDarkPortalAction::Execute(Event event)
if (bot->GetTeamId() == TEAM_ALLIANCE) if (bot->GetTeamId() == TEAM_ALLIANCE)
{ {
Quest const* quest = sObjectMgr->GetQuestTemplate(10119); Quest const* quest = sObjectMgr->GetQuestTemplate(10119);
CreatureData const* creatureData = sRandomPlayerbotMgr->GetCreatureDataByEntry(16841); CreatureData const* creatureData = sRandomPlayerbotMgr.GetCreatureDataByEntry(16841);
if (quest && creatureData) if (quest && creatureData)
{ {
auto creatureBounds = auto creatureBounds =
@@ -89,7 +89,7 @@ bool MoveToDarkPortalAction::Execute(Event event)
else else
{ {
Quest const* quest = sObjectMgr->GetQuestTemplate(9407); Quest const* quest = sObjectMgr->GetQuestTemplate(9407);
CreatureData const* creatureData = sRandomPlayerbotMgr->GetCreatureDataByEntry(19254); CreatureData const* creatureData = sRandomPlayerbotMgr.GetCreatureDataByEntry(19254);
if (quest && creatureData) if (quest && creatureData)
{ {
auto creatureBounds = auto creatureBounds =

View File

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

View File

@@ -91,9 +91,9 @@ bool SummonAction::Execute(Event event)
bool SummonAction::SummonUsingGos(Player* summoner, Player* player, bool preserveAuras) bool SummonAction::SummonUsingGos(Player* summoner, Player* player, bool preserveAuras)
{ {
std::list<GameObject*> targets; std::list<GameObject*> targets;
AnyGameObjectInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig->sightDistance); AnyGameObjectInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig.sightDistance);
Acore::GameObjectListSearcher<AnyGameObjectInObjectRangeCheck> searcher(summoner, targets, u_check); Acore::GameObjectListSearcher<AnyGameObjectInObjectRangeCheck> searcher(summoner, targets, u_check);
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig->sightDistance); Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig.sightDistance);
for (GameObject* go : targets) 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) bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player, bool preserveAuras)
{ {
if (!sPlayerbotAIConfig->summonAtInnkeepersEnabled) if (!sPlayerbotAIConfig.summonAtInnkeepersEnabled)
return false; return false;
std::list<Unit*> targets; 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); 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) for (Unit* unit : targets)
{ {
@@ -150,7 +150,7 @@ bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player, bool preser
bool SummonAction::Teleport(Player* summoner, Player* player, bool preserveAuras) bool SummonAction::Teleport(Player* summoner, Player* player, bool preserveAuras)
{ {
// Player* master = GetMaster(); // Player* master = GetMaster();
if (!summoner) if (!summoner || summoner == player)
return false; return false;
if (player->GetVehicle()) if (player->GetVehicle())
@@ -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) for (float angle = followAngle - M_PI; angle <= followAngle + M_PI; angle += M_PI / 4)
{ {
uint32 mapId = summoner->GetMapId(); uint32 mapId = summoner->GetMapId();
float x = summoner->GetPositionX() + cos(angle) * sPlayerbotAIConfig->followDistance; float x = summoner->GetPositionX() + cos(angle) * sPlayerbotAIConfig.followDistance;
float y = summoner->GetPositionY() + sin(angle) * sPlayerbotAIConfig->followDistance; float y = summoner->GetPositionY() + sin(angle) * sPlayerbotAIConfig.followDistance;
float z = summoner->GetPositionZ(); float z = summoner->GetPositionZ();
if (summoner->IsWithinLOS(x, y, z)) if (summoner->IsWithinLOS(x, y, z))
{ {
if (sPlayerbotAIConfig if (sPlayerbotAIConfig.botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
bot->DurabilityRepairAll(false, 1.0f, false); 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"); botAI->TellError("You cannot summon me while you're in combat");
return false; return false;
} }
if (!summoner->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead) if (!summoner->IsAlive() && !sPlayerbotAIConfig.allowSummonWhenMasterIsDead)
{ {
botAI->TellError("You cannot summon me while you're dead"); botAI->TellError("You cannot summon me while you're dead");
return false; return false;
} }
if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST) && 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"); botAI->TellError("You cannot summon me while I'm dead, you need to release my spirit first");
return false; return false;
} }
bool revive = bool revive =
sPlayerbotAIConfig->reviveBotWhenSummoned == 2 || sPlayerbotAIConfig.reviveBotWhenSummoned == 2 ||
(sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive()); (sPlayerbotAIConfig.reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive());
if (bot->isDead() && revive) if (bot->isDead() && revive)
{ {
@@ -212,9 +211,11 @@ bool SummonAction::Teleport(Player* summoner, Player* player, bool preserveAuras
if (!preserveAuras) if (!preserveAuras)
player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED | player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TELEPORTED |
AURA_INTERRUPT_FLAG_CHANGE_MAP); AURA_INTERRUPT_FLAG_CHANGE_MAP);
player->TeleportTo(mapId, x, y, z, 0); player->TeleportTo(mapId, x, y, z, 0);
if (player->GetPet())
player->GetPet()->NearTeleportTo(x, y, z, player->GetOrientation());
if (player->GetGuardianPet())
player->GetGuardianPet()->NearTeleportTo(x, y, z, player->GetOrientation());
if (botAI->HasStrategy("stay", botAI->GetState())) if (botAI->HasStrategy("stay", botAI->GetState()))
{ {
PositionMap& posMap = AI_VALUE(PositionMap&, "position"); PositionMap& posMap = AI_VALUE(PositionMap&, "position");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,39 +12,14 @@
#include "PvpValues.h" #include "PvpValues.h"
#include "QuestValues.h" #include "QuestValues.h"
class PlayerbotAI;
class SharedValueContext : public NamedObjectContext<UntypedValue> class SharedValueContext : public NamedObjectContext<UntypedValue>
{ {
public: public:
SharedValueContext() : NamedObjectContext(true) static SharedValueContext& instance()
{
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> template <class T>
@@ -74,6 +49,36 @@ public:
out << param; out << param;
return getGlobalValue<T>(name, out.str()); 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() #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")) if (!action->GetTarget() || action->GetTarget() != AI_VALUE(Unit*, "current target"))
return 1.0f; 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); CastSpellAction* spellAction = dynamic_cast<CastSpellAction*>(action);
uint32 spellId = AI_VALUE2(uint32, "spell id", spellAction->getSpell()); uint32 spellId = AI_VALUE2(uint32, "spell id", spellAction->getSpell());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -78,7 +78,7 @@ class EnemyOutOfMeleeTrigger : public OutOfRangeTrigger
{ {
public: public:
EnemyOutOfMeleeTrigger(PlayerbotAI* botAI) 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 (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; return true;
} }
@@ -34,7 +34,7 @@ bool AtDarkPortalOutlandTrigger::IsActive()
{ {
if (bot->GetAreaId() == 3539) 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; return true;
} }

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