mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-02 10:23:47 +00:00
# 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>
82 lines
2.3 KiB
C++
82 lines
2.3 KiB
C++
/*
|
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
|
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
|
*/
|
|
|
|
#include "AreaTriggerAction.h"
|
|
|
|
#include "Event.h"
|
|
#include "LastMovementValue.h"
|
|
#include "Playerbots.h"
|
|
#include "Transport.h"
|
|
|
|
bool ReachAreaTriggerAction::Execute(Event event)
|
|
{
|
|
if (botAI->IsRealPlayer()) // Do not trigger own area trigger.
|
|
return false;
|
|
|
|
uint32 triggerId;
|
|
WorldPacket p(event.getPacket());
|
|
p.rpos(0);
|
|
p >> triggerId;
|
|
|
|
AreaTrigger const* at = sObjectMgr->GetAreaTrigger(triggerId);
|
|
if (!at)
|
|
return false;
|
|
|
|
if (!sObjectMgr->GetAreaTriggerTeleport(triggerId))
|
|
{
|
|
WorldPacket p1(CMSG_AREATRIGGER);
|
|
p1 << triggerId;
|
|
p1.rpos(0);
|
|
bot->GetSession()->HandleAreaTriggerOpcode(p1);
|
|
|
|
return true;
|
|
}
|
|
|
|
if (bot->GetMapId() != at->map)
|
|
{
|
|
botAI->TellError("I won't follow: too far away");
|
|
return true;
|
|
}
|
|
|
|
bot->GetMotionMaster()->MovePoint(
|
|
/*id*/ at->map,
|
|
/*coords*/ at->x, at->y, at->z,
|
|
/*forcedMovement*/ FORCED_MOVEMENT_NONE,
|
|
/*speed*/ 0.0f, // default speed (not handled here)
|
|
/*orientation*/ 0.0f, // keep current orientation of bot
|
|
/*generatePath*/ true, // true => terrain path (2d mmap); false => straight spline (3d vmap)
|
|
/*forceDestination*/ false);
|
|
|
|
float distance = bot->GetDistance(at->x, at->y, at->z);
|
|
float delay = 1000.0f * distance / bot->GetSpeed(MOVE_RUN) + sPlayerbotAIConfig.reactDelay;
|
|
botAI->TellError("Wait for me");
|
|
botAI->SetNextCheckDelay(delay);
|
|
context->GetValue<LastMovement&>("last area trigger")->Get().lastAreaTrigger = triggerId;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AreaTriggerAction::Execute(Event event)
|
|
{
|
|
LastMovement& movement = context->GetValue<LastMovement&>("last area trigger")->Get();
|
|
|
|
uint32 triggerId = movement.lastAreaTrigger;
|
|
movement.lastAreaTrigger = 0;
|
|
|
|
if (!sObjectMgr->GetAreaTrigger(triggerId))
|
|
return false;
|
|
|
|
if (!sObjectMgr->GetAreaTriggerTeleport(triggerId))
|
|
return true;
|
|
|
|
WorldPacket p(CMSG_AREATRIGGER);
|
|
p << triggerId;
|
|
p.rpos(0);
|
|
bot->GetSession()->HandleAreaTriggerOpcode(p);
|
|
|
|
botAI->TellMaster("Hello");
|
|
return true;
|
|
}
|