mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-08 05:01:09 +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>
119 lines
3.2 KiB
C++
119 lines
3.2 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 "NonCombatActions.h"
|
|
|
|
#include "Event.h"
|
|
#include "Playerbots.h"
|
|
|
|
bool DrinkAction::Execute(Event event)
|
|
{
|
|
if (botAI->HasCheat(BotCheatMask::food))
|
|
{
|
|
// if (bot->IsNonMeleeSpellCast(true))
|
|
// return false;
|
|
|
|
bot->ClearUnitState(UNIT_STATE_CHASE);
|
|
bot->ClearUnitState(UNIT_STATE_FOLLOW);
|
|
|
|
if (bot->isMoving())
|
|
{
|
|
bot->StopMoving();
|
|
// botAI->SetNextCheckDelay(sPlayerbotAIConfig->globalCoolDown);
|
|
// return false;
|
|
}
|
|
bot->SetStandState(UNIT_STAND_STATE_SIT);
|
|
botAI->InterruptSpell();
|
|
|
|
// float hp = bot->GetHealthPercent();
|
|
float mp = bot->GetPowerPct(POWER_MANA);
|
|
float p = mp;
|
|
float delay;
|
|
|
|
if (!bot->InBattleground())
|
|
delay = 18000.0f * (100 - p) / 100.0f;
|
|
else
|
|
delay = 12000.0f * (100 - p) / 100.0f;
|
|
|
|
botAI->SetNextCheckDelay(delay);
|
|
|
|
bot->AddAura(25990, bot);
|
|
return true;
|
|
// return botAI->CastSpell(24707, bot);
|
|
}
|
|
|
|
return UseItemAction::Execute(event);
|
|
}
|
|
|
|
bool DrinkAction::isUseful()
|
|
{
|
|
return UseItemAction::isUseful() &&
|
|
AI_VALUE2(bool, "has mana", "self target") &&
|
|
AI_VALUE2(uint8, "mana", "self target") < 100;
|
|
}
|
|
|
|
bool DrinkAction::isPossible()
|
|
{
|
|
return !bot->IsInCombat() &&
|
|
!bot->IsMounted() &&
|
|
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
|
|
"aquatic form","flight form", "swift flight form", nullptr) &&
|
|
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
|
|
}
|
|
|
|
bool EatAction::Execute(Event event)
|
|
{
|
|
if (botAI->HasCheat(BotCheatMask::food))
|
|
{
|
|
// if (bot->IsNonMeleeSpellCast(true))
|
|
// return false;
|
|
|
|
bot->ClearUnitState(UNIT_STATE_CHASE);
|
|
bot->ClearUnitState(UNIT_STATE_FOLLOW);
|
|
|
|
if (bot->isMoving())
|
|
{
|
|
bot->StopMoving();
|
|
// botAI->SetNextCheckDelay(sPlayerbotAIConfig.globalCoolDown);
|
|
// return false;
|
|
}
|
|
|
|
bot->SetStandState(UNIT_STAND_STATE_SIT);
|
|
botAI->InterruptSpell();
|
|
|
|
float hp = bot->GetHealthPct();
|
|
// float mp = bot->HasMana() ? bot->GetPowerPercent() : 0.f;
|
|
float p = hp;
|
|
float delay;
|
|
|
|
if (!bot->InBattleground())
|
|
delay = 18000.0f * (100 - p) / 100.0f;
|
|
else
|
|
delay = 12000.0f * (100 - p) / 100.0f;
|
|
|
|
botAI->SetNextCheckDelay(delay);
|
|
|
|
bot->AddAura(25990, bot);
|
|
return true;
|
|
}
|
|
|
|
return UseItemAction::Execute(event);
|
|
}
|
|
|
|
bool EatAction::isUseful()
|
|
{
|
|
return UseItemAction::isUseful() &&
|
|
AI_VALUE2(uint8, "health", "self target") < 100;
|
|
}
|
|
|
|
bool EatAction::isPossible()
|
|
{
|
|
return !bot->IsInCombat() &&
|
|
!bot->IsMounted() &&
|
|
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
|
|
"aquatic form","flight form", "swift flight form", nullptr) &&
|
|
(botAI->HasCheat(BotCheatMask::food) || UseItemAction::isPossible());
|
|
}
|