mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-10 05:51:28 +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>
128 lines
3.8 KiB
C++
128 lines
3.8 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 "RogueTriggers.h"
|
|
|
|
#include "GenericTriggers.h"
|
|
#include "Playerbots.h"
|
|
#include "ServerFacade.h"
|
|
|
|
// bool AdrenalineRushTrigger::isPossible()
|
|
// {
|
|
// return !botAI->HasAura("stealth", bot);
|
|
// }
|
|
|
|
bool UnstealthTrigger::IsActive()
|
|
{
|
|
if (!botAI->HasAura("stealth", bot))
|
|
return false;
|
|
|
|
return botAI->HasAura("stealth", bot) && !AI_VALUE(uint8, "attacker count") &&
|
|
(AI_VALUE2(bool, "moving", "self target") &&
|
|
((botAI->GetMaster() &&
|
|
ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "group leader"), 10.0f) &&
|
|
AI_VALUE2(bool, "moving", "group leader")) ||
|
|
!AI_VALUE(uint8, "attacker count")));
|
|
}
|
|
|
|
bool StealthTrigger::IsActive()
|
|
{
|
|
if (botAI->HasAura("stealth", bot) || bot->IsInCombat() || bot->HasSpellCooldown(1784))
|
|
return false;
|
|
|
|
float distance = 30.f;
|
|
|
|
Unit* target = AI_VALUE(Unit*, "enemy player target");
|
|
if (target && !target->IsInWorld())
|
|
{
|
|
return false;
|
|
}
|
|
if (!target)
|
|
target = AI_VALUE(Unit*, "grind target");
|
|
|
|
if (!target)
|
|
target = AI_VALUE(Unit*, "dps target");
|
|
|
|
if (!target)
|
|
return false;
|
|
|
|
if (target && target->GetVictim())
|
|
distance -= 10;
|
|
|
|
if (target->isMoving() && target->GetVictim())
|
|
distance -= 10;
|
|
|
|
if (bot->InBattleground())
|
|
distance += 15;
|
|
|
|
if (bot->InArena())
|
|
distance += 15;
|
|
|
|
return target && ServerFacade::instance().GetDistance2d(bot, target) < distance;
|
|
}
|
|
|
|
bool SapTrigger::IsPossible() { return bot->GetLevel() > 10 && bot->HasSpell(6770) && !bot->IsInCombat(); }
|
|
|
|
bool SprintTrigger::IsPossible() { return bot->HasSpell(2983); }
|
|
|
|
bool SprintTrigger::IsActive()
|
|
{
|
|
if (bot->HasSpellCooldown(2983))
|
|
return false;
|
|
|
|
float distance = botAI->GetMaster() ? 45.0f : 35.0f;
|
|
if (botAI->HasAura("stealth", bot))
|
|
distance -= 10;
|
|
|
|
bool targeted = false;
|
|
|
|
Unit* dps = AI_VALUE(Unit*, "dps target");
|
|
Unit* enemyPlayer = AI_VALUE(Unit*, "enemy player target");
|
|
|
|
if (enemyPlayer && !enemyPlayer->IsInWorld())
|
|
{
|
|
return false;
|
|
}
|
|
if (dps)
|
|
targeted = (dps == AI_VALUE(Unit*, "current target"));
|
|
|
|
if (enemyPlayer && !targeted)
|
|
targeted = (enemyPlayer == AI_VALUE(Unit*, "current target"));
|
|
|
|
if (!targeted)
|
|
return false;
|
|
|
|
if ((dps && dps->IsInCombat()) || enemyPlayer)
|
|
distance -= 10;
|
|
|
|
return AI_VALUE2(bool, "moving", "self target") &&
|
|
(AI_VALUE2(bool, "moving", "dps target") || AI_VALUE2(bool, "moving", "enemy player target")) && targeted &&
|
|
(ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), distance) ||
|
|
ServerFacade::instance().IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), distance));
|
|
}
|
|
|
|
bool ExposeArmorTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target"); // Get the bot's current target
|
|
return DebuffTrigger::IsActive() && !botAI->HasAura("sunder armor", target, false, false, -1, true) &&
|
|
AI_VALUE2(uint8, "combo", "current target") <= 3;
|
|
}
|
|
|
|
bool MainHandWeaponNoEnchantTrigger::IsActive()
|
|
{
|
|
Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
|
|
if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
bool OffHandWeaponNoEnchantTrigger::IsActive()
|
|
{
|
|
Item* const itemForSpell = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
|
|
if (!itemForSpell || itemForSpell->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT))
|
|
return false;
|
|
return true;
|
|
}
|