mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-03-15 21:35:09 +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>
105 lines
2.5 KiB
C++
105 lines
2.5 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 "RtiAction.h"
|
|
|
|
#include "Event.h"
|
|
#include "Playerbots.h"
|
|
#include "RtiTargetValue.h"
|
|
|
|
bool RtiAction::Execute(Event event)
|
|
{
|
|
std::string text = event.getParam();
|
|
std::string type = "rti";
|
|
if (text.find("cc ") == 0)
|
|
{
|
|
type = "rti cc";
|
|
text = text.substr(3);
|
|
}
|
|
|
|
if (text.empty() || text == "?")
|
|
{
|
|
std::ostringstream outRti;
|
|
outRti << "rti"
|
|
<< ": ";
|
|
AppendRti(outRti, "rti");
|
|
botAI->TellMaster(outRti);
|
|
|
|
std::ostringstream outRtiCc;
|
|
outRtiCc << "rti cc"
|
|
<< ": ";
|
|
AppendRti(outRtiCc, "rti cc");
|
|
botAI->TellMaster(outRtiCc);
|
|
return true;
|
|
}
|
|
|
|
context->GetValue<std::string>(type)->Set(text);
|
|
|
|
std::ostringstream out;
|
|
out << type << " set to: ";
|
|
AppendRti(out, type);
|
|
botAI->TellMaster(out);
|
|
return true;
|
|
}
|
|
|
|
void RtiAction::AppendRti(std::ostringstream& out, std::string const type)
|
|
{
|
|
out << AI_VALUE(std::string, type);
|
|
|
|
std::ostringstream n;
|
|
n << type << " target";
|
|
|
|
if (Unit* target = AI_VALUE(Unit*, n.str()))
|
|
out << " (" << target->GetName() << ")";
|
|
}
|
|
|
|
bool MarkRtiAction::Execute(Event /*event*/)
|
|
{
|
|
Group* group = bot->GetGroup();
|
|
if (!group)
|
|
return false;
|
|
|
|
if (bot->InBattleground())
|
|
return false;
|
|
|
|
Unit* target = nullptr;
|
|
GuidVector attackers = botAI->GetAiObjectContext()->GetValue<GuidVector>("attackers")->Get();
|
|
for (ObjectGuid const guid : attackers)
|
|
{
|
|
Unit* unit = botAI->GetUnit(guid);
|
|
if (!unit)
|
|
continue;
|
|
|
|
// do not mark players
|
|
if (unit->IsPlayer())
|
|
continue;
|
|
|
|
bool marked = false;
|
|
for (uint8 i = 0; i < 8; i++)
|
|
{
|
|
ObjectGuid iconGUID = group->GetTargetIcon(i);
|
|
if (iconGUID == unit->GetGUID())
|
|
{
|
|
marked = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (marked)
|
|
continue;
|
|
|
|
if (!target || target->GetHealth() > unit->GetHealth())
|
|
target = unit;
|
|
}
|
|
|
|
if (!target)
|
|
return false;
|
|
|
|
std::string const rti = AI_VALUE(std::string, "rti");
|
|
uint8 index = RtiTargetValue::GetRtiIndex(rti);
|
|
group->SetTargetIcon(index, bot->GetGUID(), target->GetGUID());
|
|
return true;
|
|
}
|