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>
97 lines
2.4 KiB
C++
97 lines
2.4 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 "CheatAction.h"
|
|
|
|
#include "Playerbots.h"
|
|
|
|
bool CheatAction::Execute(Event event)
|
|
{
|
|
std::string const param = event.getParam();
|
|
|
|
uint32 cheatMask = (uint32)botAI->GetCheat();
|
|
|
|
std::vector<std::string> splitted = split(param, ',');
|
|
for (std::vector<std::string>::iterator i = splitted.begin(); i != splitted.end(); i++)
|
|
{
|
|
const char* name = i->c_str();
|
|
switch (name[0])
|
|
{
|
|
case '+':
|
|
cheatMask |= (uint32)GetCheatMask(name + 1);
|
|
break;
|
|
case '-':
|
|
cheatMask ^= (uint32)GetCheatMask(name + 1);
|
|
break;
|
|
case '?':
|
|
ListCheats();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
botAI->SetCheat(BotCheatMask(cheatMask));
|
|
|
|
return true;
|
|
}
|
|
|
|
BotCheatMask CheatAction::GetCheatMask(std::string const cheat)
|
|
{
|
|
if (cheat == "taxi")
|
|
return BotCheatMask::taxi;
|
|
|
|
if (cheat == "gold")
|
|
return BotCheatMask::gold;
|
|
|
|
if (cheat == "health")
|
|
return BotCheatMask::health;
|
|
|
|
if (cheat == "mana")
|
|
return BotCheatMask::mana;
|
|
|
|
if (cheat == "power")
|
|
return BotCheatMask::power;
|
|
|
|
if (cheat == "raid")
|
|
return BotCheatMask::raid;
|
|
|
|
return BotCheatMask::none;
|
|
}
|
|
|
|
std::string const CheatAction::GetCheatName(BotCheatMask cheatMask)
|
|
{
|
|
switch (cheatMask)
|
|
{
|
|
case BotCheatMask::taxi:
|
|
return "taxi";
|
|
case BotCheatMask::gold:
|
|
return "gold";
|
|
case BotCheatMask::health:
|
|
return "health";
|
|
case BotCheatMask::mana:
|
|
return "mana";
|
|
case BotCheatMask::power:
|
|
return "power";
|
|
case BotCheatMask::raid:
|
|
return "raid";
|
|
default:
|
|
return "none";
|
|
}
|
|
}
|
|
|
|
void CheatAction::ListCheats()
|
|
{
|
|
std::ostringstream out;
|
|
for (int i = 0; i < log2((uint32)BotCheatMask::maxMask); i++)
|
|
{
|
|
BotCheatMask cheatMask = BotCheatMask(1 << i);
|
|
if ((uint32)cheatMask & (uint32)sPlayerbotAIConfig.botCheatMask)
|
|
out << "[conf:" << GetCheatName(BotCheatMask(cheatMask)) << "]";
|
|
else if (botAI->HasCheat(cheatMask))
|
|
out << "[" << GetCheatName(BotCheatMask(cheatMask)) << "]";
|
|
}
|
|
|
|
botAI->TellMasterNoFacing(out);
|
|
}
|