mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-16 08:36:10 +00:00
# Pull Request
This is the first in a series of PRs intended to eliminate warnings in
the module. The design intent is to eliminate the calling event when not
needed in the body of the function. Based off of SmashingQuasars work.
---
## 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?
- [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:
- [ ] 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
---
## Notes for Reviewers
Anything that significantly improves realism at the cost of stability or
performance should be carefully discussed
before merging.
---------
Co-authored-by: bashermens <31279994+hermensbas@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;
|
|
}
|