mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-08 13:11:10 +00:00
Improper singletons migration to clean Meyer's singletons (cherry-pick) (#2082)
# Pull Request
- Applies the clean and corrected singletons, Meyer pattern. (cherry
picked from @SmashingQuasar )
Testing by just playing the game in various ways. Been tested by myself
@Celandriel and @SmashingQuasar
---
## Complexity & Impact
- Does this change add new decision branches?
- [x] No
- [ ] Yes (**explain below**)
- Does this change increase per-bot or per-tick processing?
- [x] No
- [ ] Yes (**describe and justify impact**)
- Could this logic scale poorly under load?
- [x] No
- [ ] Yes (**explain why**)
---
## Defaults & Configuration
- Does this change modify default bot behavior?
- [x] No
- [ ] Yes (**explain why**)
---
## AI Assistance
- Was AI assistance (e.g. ChatGPT or similar tools) used while working
on this change?
- [x] No
- [ ] Yes (**explain below**)
---
## Final Checklist
- [x] Stability is not compromised
- [x] Performance impact is understood, tested, and acceptable
- [x] Added logic complexity is justified and explained
- [x] Documentation updated if needed
---
## Notes for Reviewers
Anything that significantly improves realism at the cost of stability or
performance should be carefully discussed
before merging.
---------
Co-authored-by: Nicolas Lebacq <nicolas.cordier@outlook.com>
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
This commit is contained in:
@@ -91,9 +91,9 @@ bool SummonAction::Execute(Event event)
|
||||
bool SummonAction::SummonUsingGos(Player* summoner, Player* player, bool preserveAuras)
|
||||
{
|
||||
std::list<GameObject*> targets;
|
||||
AnyGameObjectInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig->sightDistance);
|
||||
AnyGameObjectInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig.sightDistance);
|
||||
Acore::GameObjectListSearcher<AnyGameObjectInObjectRangeCheck> searcher(summoner, targets, u_check);
|
||||
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig->sightDistance);
|
||||
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig.sightDistance);
|
||||
|
||||
for (GameObject* go : targets)
|
||||
{
|
||||
@@ -107,13 +107,13 @@ bool SummonAction::SummonUsingGos(Player* summoner, Player* player, bool preserv
|
||||
|
||||
bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player, bool preserveAuras)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->summonAtInnkeepersEnabled)
|
||||
if (!sPlayerbotAIConfig.summonAtInnkeepersEnabled)
|
||||
return false;
|
||||
|
||||
std::list<Unit*> targets;
|
||||
Acore::AnyUnitInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig->sightDistance);
|
||||
Acore::AnyUnitInObjectRangeCheck u_check(summoner, sPlayerbotAIConfig.sightDistance);
|
||||
Acore::UnitListSearcher<Acore::AnyUnitInObjectRangeCheck> searcher(summoner, targets, u_check);
|
||||
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig->sightDistance);
|
||||
Cell::VisitObjects(summoner, searcher, sPlayerbotAIConfig.sightDistance);
|
||||
|
||||
for (Unit* unit : targets)
|
||||
{
|
||||
@@ -165,38 +165,37 @@ bool SummonAction::Teleport(Player* summoner, Player* player, bool preserveAuras
|
||||
for (float angle = followAngle - M_PI; angle <= followAngle + M_PI; angle += M_PI / 4)
|
||||
{
|
||||
uint32 mapId = summoner->GetMapId();
|
||||
float x = summoner->GetPositionX() + cos(angle) * sPlayerbotAIConfig->followDistance;
|
||||
float y = summoner->GetPositionY() + sin(angle) * sPlayerbotAIConfig->followDistance;
|
||||
float x = summoner->GetPositionX() + cos(angle) * sPlayerbotAIConfig.followDistance;
|
||||
float y = summoner->GetPositionY() + sin(angle) * sPlayerbotAIConfig.followDistance;
|
||||
float z = summoner->GetPositionZ();
|
||||
|
||||
if (summoner->IsWithinLOS(x, y, z))
|
||||
{
|
||||
if (sPlayerbotAIConfig
|
||||
->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
|
||||
if (sPlayerbotAIConfig.botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
|
||||
bot->DurabilityRepairAll(false, 1.0f, false);
|
||||
|
||||
if (summoner->IsInCombat() && !sPlayerbotAIConfig->allowSummonInCombat)
|
||||
if (summoner->IsInCombat() && !sPlayerbotAIConfig.allowSummonInCombat)
|
||||
{
|
||||
botAI->TellError("You cannot summon me while you're in combat");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!summoner->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead)
|
||||
if (!summoner->IsAlive() && !sPlayerbotAIConfig.allowSummonWhenMasterIsDead)
|
||||
{
|
||||
botAI->TellError("You cannot summon me while you're dead");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bot->isDead() && !bot->HasPlayerFlag(PLAYER_FLAGS_GHOST) &&
|
||||
!sPlayerbotAIConfig->allowSummonWhenBotIsDead)
|
||||
!sPlayerbotAIConfig.allowSummonWhenBotIsDead)
|
||||
{
|
||||
botAI->TellError("You cannot summon me while I'm dead, you need to release my spirit first");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool revive =
|
||||
sPlayerbotAIConfig->reviveBotWhenSummoned == 2 ||
|
||||
(sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive());
|
||||
sPlayerbotAIConfig.reviveBotWhenSummoned == 2 ||
|
||||
(sPlayerbotAIConfig.reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive());
|
||||
|
||||
if (bot->isDead() && revive)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user