mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
## Pull Request Description
These changes I originally made for myself because as a person who
really likes to raid with bots, I felt like the current group buff
system is fundamentally broken, and I needed something more consistent
and optimal. I debated a lot whether to PR this because it's such an
extensive overhaul that was almost entirely reliant on AI, and I know
that wishmaster still has a PR open regarding the greater blessings. I
decided to after a couple of conversations so at least people can look
at it and see if it's something that they want.
The tl;dr version is that this PR overhauls buff handling in two related
areas:
1. It adds a dedicated greater blessing assignment system.
2. It generalizes party/raid reagent-buff handling for Paladins, Druids,
Mages, and Priests.
Under this PR, greater blessings are determined by assignments for the
current group, and those assignments are determined based on:
1. a hardcoded priority list of blessings for each spec;
2. the number of Paladins in the group; and
3. whether any Paladins have talents for Blessing of Sanctuary, Improved
Blessing of Might, or Improved Blessing of Wisdom.
Assignment determinations are cached in a value to avoid constant
reevaluation.
The exact priority list is:
- All casters: Kings, Wisdom, Sanctuary, Might
- Physical-only DPS (Rogues, Warriors, DKs): Might, Kings, Sanctuary,
N/A
- Hybrid DPS (Enh, Ret, Hunters, Cats): Might, Kings, Wisdom, Sanctuary
- Druid tanks: Kings, Might, Sanctuary, Wisdom
- Warrior and DK tanks: Kings, Might, Sanctuary, N/A
- Paladin tank: Sanctuary, Might, Wisdom, Kings
Note that Sanctuary is preferred over Kings for Paladin tanks because of
the mana regen component but deprioritized for other tanks because Kings
provides Agility. The extra 3% damage reduction from Sanctuary does not
stack with Disc Priests’ Renewed Hope, which will have 100% uptime.
For group buffs, logic is centralized so that class triggers use the
same gating and upgrade rules for Gift of the Wild, Arcane Brilliance,
Prayer of Fortitude, Prayer of Spirit, and Prayer of Shadow Protection.
Also, Shadow Protection is now a default strategy for Priests (rshadow,
which existed before but wasn’t added by default).
I’ve added a config setting for the greater blessing system and adjusted
the current config setting for group buffs. In each case, you can pick
whether to disable the feature entirely, use it in all groups, or use it
only in raid groups. The default is raid only for greater blessings and
all groups for group buffs. Note that for group buffs, even if the
config is enabled, they will be used only if at least 3 group/raid
members on the same map are missing the buff family. This is mainly to
stop group buff spamming during wipe recovery as bots are revived
one-by-one.
I renamed the Paladin buff strategies to align them with the actual
blessing names:
- `bhealth` -> `bsanc`
- `bmana` -> `bwisdom`
- `bdps` -> `bmight`
- `bstats` -> `bkings`
This is an intentional breaking change for saved strategy strings. Bots
will need a one-time strategy reset after update.
I removed bots telling you when they are out of reagents for greater
blessings. If people like that though, I can add it back.
A small cleanup is also included in TankPaladinStrategy: Holy Shield was
subject to three overlapping health triggers with the same priority; I
removed the two lower health thresholds which have no purpose.
## Feature Evaluation
- Describe the **minimum logic** required to achieve the intended
behavior.
I’m going to let the AI answer this one.
> The minimum logic is:
> - a shared config-gated check for whether group/raid buff variants are
allowed
> - a shared way to treat single and group variants as equivalent aura
families
> - a shared upgrade path from single-target buff to group buff when the
group variant is appropriate
> - a Paladin-only cached assignment model that decides which blessing
family each Paladin should cover for the current group
> - trigger/action wiring that only attempts casts when a group member
is actually missing the assigned buff
>
> This avoids scattering separate per-class heuristics across many
triggers and actions.
- Describe the **processing cost** when this logic executes across many
bots.
Processing cost should be minimal but non-zero. The general party buff
changes are limited to existing buff trigger paths and mostly replace
duplicated checks with shared helpers. They do not add expensive default
per-tick behavior outside those existing trigger evaluations.
The Paladin greater blessing logic does add extra decision-making, but
it is limited to Paladins, gated by config and group eligibility,
subject to a delayed trigger evaluation of only once per 4s, and cached
per group assignment set instead of recomputing the full assignment
model on every action attempt.
This PR also increases the throttle duration for group buff triggers to
limit performance impact; I’m open to adjustments to these durations:
- Mark of the Wild triggers were increased from 4s to 8s
- Arcane Intellect triggers were increased from 4s to 8s
- Priest buff triggers were increased to 8s (previously, Fortitude was
6s, Spirit was 4s, and Shadow Protection had no throttle)
- There is now a 5s delay on buffing (greater blessings and group buffs)
after bots log in—I was getting bots spamming buffs as soon as they
logged in even when it was not necessary
I’ve tested with pmon, and the impact is minimal—these are very cheap
triggers even compared to standard bot rotational ability triggers.
## How to Test the Changes
1. Try different config settings to confirm that they work to
enable/disable greater blessings/group buffs in the configured scenarios
2. For greater blessing changes:
- test with one Paladin in a party/raid
- test with multiple Paladins in a party/raid
- confirm the Paladins divide blessing coverage instead of repeatedly
overwriting each other
- include at least one Paladin with Improved Blessing of Might and make
sure it casts Might over Paladins without the talent; check the same
with a Paladin with Improved Blessing of Wisdom
- do not include a Paladin that knows Sanctuary, confirm any Paladin
tank receives Kings instead (you’ll need a low-level Paladin for this
since Sanctuary is a prot talent)
- confirm bots cast blessings only when a member is actually missing the
relevant blessing family
- confirm there is a 5s delay on buffing when bots log in
3. For group buff changes:
- confirm there is a 5s delay on buffing when bots log in
- confirm that single buffs are used when there aren’t at least three
unbuffed members in the same map, even if group buffs are enabled in the
config
4. For all buffs, test with reagents missing to confirm fallback to
single-target buffs and single blessings
5. Confirm the Paladin buff strategy names are changed after resetting
AI
## Impact Assessment
- Does this change increase per-bot/per-tick processing or risk scaling
poorly with thousands of bots?
- - [ ] No, not at all
- - [x] Minimal impact (**explain below**)
- - [ ] Moderate impact (**explain below**)
Discussed above in processing costs.
- Does this change modify default bot behavior?
- - [ ] No
- - [x] Yes (**explain why**)
Yes—that is the purpose of this PR, to change default buffing behavior.
- Does this change add new decision branches or increase maintenance
complexity?
- - [ ] No
- - [x] Yes (**explain below**)
Yes, but I think it’s inevitable to add complexity to get greater
blessings to function consistently, given the challenges brought by
their mechanic of applying across each class.
## AI Assistance
Was AI assistance used while working on this change?
- - [ ] No
- - [x] Yes (**explain below**)
I used GPT-5.4 extensively for this overhaul. It’s much more complicated
than I could handle on my own. I’ve done a lot of testing and have
reviewed the code and provided plenty of revisions, but I cannot say I
can perfectly explain each addition and how it works, not even close.
## Final Checklist
- - [x] Stability is not compromised.
- - [x] Performance impact is understood, tested, and acceptable.
- - [x] Added logic complexity is justified and explained.
- - [x] Any new bot dialogue lines are translated.
- - [x] Documentation updated if needed (Conf comments, WiKi commands).
## Notes for Reviewers
---------
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
Co-authored-by: bash <hermensb@gmail.com>
Co-authored-by: Revision <tkn963@gmail.com>
Co-authored-by: kadeshar <kadeshar@gmail.com>
741 lines
20 KiB
C++
741 lines
20 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 "GenericTriggers.h"
|
|
|
|
#include <string>
|
|
|
|
#include "GenericBuffUtils.h"
|
|
#include "CreatureAI.h"
|
|
#include "ItemVisitors.h"
|
|
#include "LastSpellCastValue.h"
|
|
#include "ObjectGuid.h"
|
|
#include "PlayerbotAIConfig.h"
|
|
#include "Playerbots.h"
|
|
#include "PositionValue.h"
|
|
#include "SharedDefines.h"
|
|
#include "TemporarySummon.h"
|
|
#include "ThreatManager.h"
|
|
#include "Timer.h"
|
|
#include "PlayerbotAI.h"
|
|
#include "Player.h"
|
|
#include "Corpse.h"
|
|
|
|
bool LowManaTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(bool, "has mana", "self target") &&
|
|
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.lowMana;
|
|
}
|
|
|
|
bool MediumManaTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(bool, "has mana", "self target") &&
|
|
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.mediumMana;
|
|
}
|
|
|
|
bool LowEnergyTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(uint8, "energy", "self target") < threshold;
|
|
}
|
|
|
|
bool NoPetTrigger::IsActive()
|
|
{
|
|
return bot->GetMinionGUID().IsEmpty() && !AI_VALUE(Unit*, "pet target") && !bot->GetGuardianPet() &&
|
|
!bot->GetFirstControlled() && !AI_VALUE2(bool, "mounted", "self target");
|
|
}
|
|
|
|
bool HasPetTrigger::IsActive()
|
|
{
|
|
return AI_VALUE(Unit*, "pet target") && !AI_VALUE2(bool, "mounted", "self target");
|
|
}
|
|
|
|
bool PetAttackTrigger::IsActive()
|
|
{
|
|
Guardian* pet = bot->GetGuardianPet();
|
|
if (!pet)
|
|
return false;
|
|
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
if (!target)
|
|
return false;
|
|
|
|
if (pet->GetVictim() == target && pet->GetCharmInfo()->IsCommandAttack())
|
|
return false;
|
|
|
|
if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat())
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool HighManaTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(bool, "has mana", "self target") &&
|
|
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.highMana;
|
|
}
|
|
|
|
bool AlmostFullManaTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(bool, "has mana", "self target") &&
|
|
AI_VALUE2(uint8, "mana", "self target") > 85;
|
|
}
|
|
|
|
bool EnoughManaTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(bool, "has mana", "self target") &&
|
|
AI_VALUE2(uint8, "mana", "self target") > sPlayerbotAIConfig.highMana;
|
|
}
|
|
|
|
bool RageAvailable::IsActive() { return AI_VALUE2(uint8, "rage", "self target") >= amount; }
|
|
|
|
bool EnergyAvailable::IsActive() { return AI_VALUE2(uint8, "energy", "self target") >= amount; }
|
|
|
|
bool ComboPointsAvailableTrigger::IsActive() { return AI_VALUE2(uint8, "combo", "current target") >= amount; }
|
|
|
|
bool ComboPointsNotFullTrigger::IsActive() { return AI_VALUE2(uint8, "combo", "current target") < amount; }
|
|
|
|
bool TargetWithComboPointsLowerHealTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
if (!target || !target->IsAlive() || !target->IsInWorld())
|
|
return false;
|
|
|
|
return ComboPointsAvailableTrigger::IsActive() &&
|
|
(target->GetHealth() / AI_VALUE(float, "estimated group dps")) <= lifeTime;
|
|
}
|
|
|
|
bool LoseAggroTrigger::IsActive() { return !AI_VALUE2(bool, "has aggro", "current target"); }
|
|
|
|
bool HasAggroTrigger::IsActive() { return AI_VALUE2(bool, "has aggro", "current target"); }
|
|
|
|
bool PanicTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(uint8, "health", "self target") < sPlayerbotAIConfig.criticalHealth &&
|
|
(!AI_VALUE2(bool, "has mana", "self target") ||
|
|
AI_VALUE2(uint8, "mana", "self target") < sPlayerbotAIConfig.lowMana);
|
|
}
|
|
|
|
bool OutNumberedTrigger::IsActive()
|
|
{
|
|
if (bot->GetMap() && (bot->GetMap()->IsDungeon() || bot->GetMap()->IsRaid()))
|
|
return false;
|
|
|
|
if (bot->GetGroup() && bot->GetGroup()->isRaidGroup())
|
|
return false;
|
|
|
|
int32 botLevel = bot->GetLevel();
|
|
uint32 friendPower = 200;
|
|
uint32 foePower = 0;
|
|
for (auto& attacker : botAI->GetAiObjectContext()->GetValue<GuidVector>("attackers")->Get())
|
|
{
|
|
Creature* creature = botAI->GetCreature(attacker);
|
|
if (!creature)
|
|
continue;
|
|
|
|
int32 dLevel = creature->GetLevel() - botLevel;
|
|
if (dLevel > -10)
|
|
foePower = std::max(100 + 10 * dLevel, dLevel * 200);
|
|
}
|
|
|
|
if (!foePower)
|
|
return false;
|
|
|
|
for (auto& helper : botAI->GetAiObjectContext()->GetValue<GuidVector>("nearest friendly players")->Get())
|
|
{
|
|
Unit* player = botAI->GetUnit(helper);
|
|
if (!player || player == bot)
|
|
continue;
|
|
|
|
int32 dLevel = player->GetLevel() - botLevel;
|
|
|
|
if (dLevel > -10 && bot->GetDistance(player) < 10.0f)
|
|
friendPower += std::max(200 + 20 * dLevel, dLevel * 200);
|
|
}
|
|
|
|
return friendPower < foePower;
|
|
}
|
|
|
|
bool BuffTrigger::IsActive()
|
|
{
|
|
Unit* target = GetTarget();
|
|
if (!target)
|
|
return false;
|
|
|
|
Aura* aura = botAI->GetAura(spell, target, checkIsOwner, checkDuration);
|
|
if (!aura || (beforeDuration && aura->GetDuration() < beforeDuration))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
Value<Unit*>* BuffOnPartyTrigger::GetTargetValue()
|
|
{
|
|
return context->GetValue<Unit*>(
|
|
"party member without aura", ai::buff::MakeAuraQualifierForBuff(spell));
|
|
}
|
|
|
|
bool BuffOnPartyTrigger::IsActive()
|
|
{
|
|
Unit* target = GetTarget();
|
|
if (ai::buff::ShouldDeferPartyBuffEvaluationForRecentLogin(bot, target, spell))
|
|
return false;
|
|
|
|
return BuffTrigger::IsActive();
|
|
}
|
|
|
|
bool ProtectPartyMemberTrigger::IsActive() { return AI_VALUE(Unit*, "party member to protect"); }
|
|
|
|
Value<Unit*>* DebuffOnAttackerTrigger::GetTargetValue()
|
|
{
|
|
return context->GetValue<Unit*>("attacker without aura", spell);
|
|
}
|
|
|
|
Value<Unit*>* DebuffOnMeleeAttackerTrigger::GetTargetValue()
|
|
{
|
|
return context->GetValue<Unit*>("melee attacker without aura", spell);
|
|
}
|
|
|
|
bool NoAttackersTrigger::IsActive()
|
|
{
|
|
return !AI_VALUE(Unit*, "current target") && AI_VALUE(uint8, "my attacker count") > 0;
|
|
}
|
|
|
|
bool InvalidTargetTrigger::IsActive() { return AI_VALUE2(bool, "invalid target", "current target"); }
|
|
|
|
bool NoTargetTrigger::IsActive() { return !AI_VALUE(Unit*, "current target"); }
|
|
|
|
bool MyAttackerCountTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(bool, "combat", "self target") && AI_VALUE(uint8, "my attacker count") >= amount;
|
|
}
|
|
|
|
bool MediumThreatTrigger::IsActive()
|
|
{
|
|
if (!AI_VALUE(Unit*, "main tank"))
|
|
return false;
|
|
|
|
return MyAttackerCountTrigger::IsActive();
|
|
}
|
|
|
|
bool LowTankThreatTrigger::IsActive()
|
|
{
|
|
Unit* mainTank = AI_VALUE(Unit*, "main tank");
|
|
if (!mainTank)
|
|
return false;
|
|
|
|
Unit* current_target = AI_VALUE(Unit*, "current target");
|
|
if (!current_target)
|
|
return false;
|
|
|
|
ThreatManager& mgr = current_target->GetThreatMgr();
|
|
float threat = mgr.GetThreat(bot);
|
|
float tankThreat = mgr.GetThreat(mainTank);
|
|
return tankThreat == 0.0f || threat > tankThreat * 0.5f;
|
|
}
|
|
|
|
bool AoeTrigger::IsActive()
|
|
{
|
|
Unit* current_target = AI_VALUE(Unit*, "current target");
|
|
if (!current_target)
|
|
return false;
|
|
|
|
GuidVector attackers = context->GetValue<GuidVector>("attackers")->Get();
|
|
int attackers_count = 0;
|
|
for (ObjectGuid const guid : attackers)
|
|
{
|
|
Unit* unit = botAI->GetUnit(guid);
|
|
if (!unit || !unit->IsAlive())
|
|
continue;
|
|
|
|
if (unit->GetDistance(current_target->GetPosition()) <= range)
|
|
attackers_count++;
|
|
}
|
|
return attackers_count >= amount;
|
|
}
|
|
|
|
bool NoFoodTrigger::IsActive()
|
|
{
|
|
bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
|
|
if (isRandomBot && botAI->HasCheat(BotCheatMask::food))
|
|
return false;
|
|
|
|
return AI_VALUE2(std::vector<Item*>, "inventory items", "conjured food").empty();
|
|
}
|
|
|
|
bool NoDrinkTrigger::IsActive()
|
|
{
|
|
bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(bot);
|
|
if (isRandomBot && botAI->HasCheat(BotCheatMask::food))
|
|
return false;
|
|
|
|
return AI_VALUE2(std::vector<Item*>, "inventory items", "conjured water").empty();
|
|
}
|
|
|
|
bool TargetInSightTrigger::IsActive() { return AI_VALUE(Unit*, "grind target"); }
|
|
|
|
bool DebuffTrigger::IsActive()
|
|
{
|
|
Unit* target = GetTarget();
|
|
if (!target || !target->IsAlive() || !target->IsInWorld())
|
|
return false;
|
|
|
|
return BuffTrigger::IsActive() &&
|
|
(target->GetHealth() / AI_VALUE(float, "estimated group dps")) >= needLifeTime;
|
|
}
|
|
|
|
bool DebuffOnBossTrigger::IsActive()
|
|
{
|
|
if (!DebuffTrigger::IsActive())
|
|
return false;
|
|
|
|
Creature* creature = GetTarget()->ToCreature();
|
|
return creature && (creature->IsDungeonBoss() || creature->isWorldBoss());
|
|
}
|
|
|
|
bool SpellTrigger::IsActive() { return GetTarget(); }
|
|
|
|
bool SpellCanBeCastTrigger::IsActive()
|
|
{
|
|
Unit* target = GetTarget();
|
|
return target && botAI->CanCastSpell(spell, target);
|
|
}
|
|
|
|
bool SpellNoCooldownTrigger::IsActive()
|
|
{
|
|
uint32 spellId = AI_VALUE2(uint32, "spell id", name);
|
|
if (!spellId)
|
|
return false;
|
|
|
|
return !bot->HasSpellCooldown(spellId);
|
|
}
|
|
|
|
bool SpellCooldownTrigger::IsActive()
|
|
{
|
|
uint32 spellId = AI_VALUE2(uint32, "spell id", name);
|
|
if (!spellId)
|
|
return false;
|
|
|
|
return bot->HasSpellCooldown(spellId);
|
|
}
|
|
|
|
RandomTrigger::RandomTrigger(PlayerbotAI* botAI, std::string const name, int32 probability)
|
|
: Trigger(botAI, name), probability(probability), lastCheck(getMSTime()) {}
|
|
|
|
bool RandomTrigger::IsActive()
|
|
{
|
|
if (getMSTime() - lastCheck < sPlayerbotAIConfig.repeatDelay)
|
|
return false;
|
|
|
|
lastCheck = getMSTime();
|
|
int32 k = (int32)(probability / sPlayerbotAIConfig.randomChangeMultiplier);
|
|
if (k < 1)
|
|
k = 1;
|
|
|
|
return (rand() % k) == 0;
|
|
}
|
|
|
|
bool AndTrigger::IsActive() { return ls && rs && ls->IsActive() && rs->IsActive(); }
|
|
|
|
std::string const AndTrigger::getName()
|
|
{
|
|
std::string name(ls->getName());
|
|
name = name + " and ";
|
|
name = name + rs->getName();
|
|
return name;
|
|
}
|
|
|
|
bool TwoTriggers::IsActive()
|
|
{
|
|
if (name1.empty() || name2.empty())
|
|
return false;
|
|
|
|
Trigger* trigger1 = botAI->GetAiObjectContext()->GetTrigger(name1);
|
|
Trigger* trigger2 = botAI->GetAiObjectContext()->GetTrigger(name2);
|
|
|
|
if (!trigger1 || !trigger2)
|
|
return false;
|
|
|
|
return trigger1->IsActive() && trigger2->IsActive();
|
|
}
|
|
|
|
std::string const TwoTriggers::getName()
|
|
{
|
|
std::string name;
|
|
name = name1 + " and " + name2;
|
|
return name;
|
|
}
|
|
|
|
bool BoostTrigger::IsActive()
|
|
{
|
|
if (!BuffTrigger::IsActive())
|
|
return false;
|
|
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
if (target && target->ToPlayer())
|
|
return true;
|
|
|
|
return AI_VALUE(uint8, "balance") <= balance;
|
|
}
|
|
|
|
bool GenericBoostTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
if (target && target->ToPlayer())
|
|
return true;
|
|
|
|
return AI_VALUE(uint8, "balance") <= balance;
|
|
}
|
|
|
|
bool HealerShouldAttackTrigger::IsActive()
|
|
{
|
|
if (botAI->GetNearGroupMemberCount(sPlayerbotAIConfig.sightDistance) <= 1)
|
|
return true;
|
|
|
|
if (AI_VALUE2(uint8, "health", "party member to heal") < sPlayerbotAIConfig.almostFullHealth)
|
|
return false;
|
|
|
|
if (bot->GetAura(33891)) // Tree of Life
|
|
{
|
|
LastSpellCast& lastSpell = botAI->GetAiObjectContext()->GetValue<LastSpellCast&>("last spell cast")->Get();
|
|
if (lastSpell.timer + 5 > time(nullptr))
|
|
return false;
|
|
}
|
|
|
|
int manaThreshold;
|
|
int balance = AI_VALUE(uint8, "balance");
|
|
if (balance <= 50)
|
|
manaThreshold = 85;
|
|
else if (balance <= 100)
|
|
manaThreshold = sPlayerbotAIConfig.highMana;
|
|
else
|
|
manaThreshold = sPlayerbotAIConfig.mediumMana;
|
|
|
|
if (AI_VALUE2(bool, "has mana", "self target") && AI_VALUE2(uint8, "mana", "self target") < manaThreshold)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool ItemCountTrigger::IsActive() { return AI_VALUE2(uint32, "item count", item) < count; }
|
|
|
|
bool InterruptSpellTrigger::IsActive()
|
|
{
|
|
return SpellTrigger::IsActive() && botAI->IsInterruptableSpellCasting(GetTarget(), getName());
|
|
}
|
|
|
|
bool DeflectSpellTrigger::IsActive()
|
|
{
|
|
Unit* target = GetTarget();
|
|
if (!target || !target->IsNonMeleeSpellCast(true) || target->GetTarget() != bot->GetGUID())
|
|
return false;
|
|
|
|
uint32 spellid = context->GetValue<uint32>("spell id", spell)->Get();
|
|
if (!spellid)
|
|
return false;
|
|
|
|
SpellInfo const* deflectSpell = sSpellMgr->GetSpellInfo(spellid);
|
|
if (!deflectSpell)
|
|
return false;
|
|
|
|
// warrior deflects all
|
|
if (spell == "spell reflection")
|
|
return true;
|
|
|
|
// human priest feedback
|
|
if (spell == "feedback")
|
|
return true;
|
|
|
|
SpellSchoolMask deflectSchool = SpellSchoolMask(deflectSpell->Effects[EFFECT_0].MiscValue);
|
|
SpellSchoolMask attackSchool = SPELL_SCHOOL_MASK_NONE;
|
|
|
|
if (Spell* spell = target->GetCurrentSpell(CURRENT_GENERIC_SPELL))
|
|
{
|
|
if (SpellInfo const* tarSpellInfo = spell->GetSpellInfo())
|
|
{
|
|
attackSchool = tarSpellInfo->GetSchoolMask();
|
|
if (deflectSchool == attackSchool)
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AttackerCountTrigger::IsActive() { return AI_VALUE(uint8, "attacker count") >= amount; }
|
|
|
|
bool HasAuraTrigger::IsActive() { return botAI->HasAura(getName(), GetTarget(), false, false, -1, true); }
|
|
|
|
bool LossOfControlTrigger::IsActive()
|
|
{
|
|
return bot->HasAuraType(SPELL_AURA_MOD_STUN) ||
|
|
bot->HasAuraType(SPELL_AURA_MOD_FEAR) ||
|
|
bot->HasAuraType(SPELL_AURA_MOD_ROOT) ||
|
|
bot->HasAuraType(SPELL_AURA_MOD_CONFUSE) ||
|
|
bot->HasAuraType(SPELL_AURA_MOD_CHARM);
|
|
}
|
|
|
|
bool FearCharmSleepTrigger::IsActive()
|
|
{
|
|
return bot->HasAuraType(SPELL_AURA_MOD_FEAR) ||
|
|
bot->HasAuraType(SPELL_AURA_MOD_CHARM) ||
|
|
bot->HasAuraType(SPELL_AURA_AOE_CHARM) ||
|
|
bot->HasAuraWithMechanic(1 << MECHANIC_SLEEP);
|
|
}
|
|
|
|
bool FearSleepSapTrigger::IsActive()
|
|
{
|
|
return bot->HasAuraType(SPELL_AURA_MOD_FEAR) ||
|
|
bot->HasAuraWithMechanic(1 << MECHANIC_SLEEP) ||
|
|
bot->HasAuraWithMechanic(1 << MECHANIC_SAPPED);
|
|
}
|
|
|
|
bool HasAuraStackTrigger::IsActive()
|
|
{
|
|
return botAI->GetAura(getName(), GetTarget(), false, true, stack);
|
|
}
|
|
|
|
bool TimerTrigger::IsActive()
|
|
{
|
|
time_t now = time(nullptr);
|
|
|
|
if (now != lastCheck)
|
|
{
|
|
lastCheck = now;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool TimerBGTrigger::IsActive()
|
|
{
|
|
time_t now = time(nullptr);
|
|
|
|
if (now - lastCheck >= 60)
|
|
{
|
|
lastCheck = now;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool HasNoAuraTrigger::IsActive() { return !botAI->HasAura(getName(), GetTarget()); }
|
|
|
|
bool TankAssistTrigger::IsActive()
|
|
{
|
|
if (!AI_VALUE(uint8, "attacker count"))
|
|
return false;
|
|
|
|
Unit* currentTarget = AI_VALUE(Unit*, "current target");
|
|
if (!currentTarget)
|
|
return true;
|
|
|
|
Unit* tankTarget = AI_VALUE(Unit*, "tank target");
|
|
if (!tankTarget || currentTarget == tankTarget)
|
|
return false;
|
|
|
|
return AI_VALUE2(bool, "has aggro", "current target");
|
|
}
|
|
|
|
bool IsBehindTargetTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
return target && AI_VALUE2(bool, "behind", "current target");
|
|
}
|
|
|
|
bool IsNotBehindTargetTrigger::IsActive()
|
|
{
|
|
if (botAI->HasStrategy("stay", botAI->GetState()))
|
|
return false;
|
|
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
return target && !AI_VALUE2(bool, "behind", "current target");
|
|
}
|
|
|
|
bool IsNotFacingTargetTrigger::IsActive()
|
|
{
|
|
if (botAI->HasStrategy("stay", botAI->GetState()))
|
|
return false;
|
|
|
|
return !AI_VALUE2(bool, "facing", "current target");
|
|
}
|
|
|
|
bool HasCcTargetTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(Unit*, "cc target", getName()) && !AI_VALUE2(Unit*, "current cc target", getName());
|
|
}
|
|
|
|
bool NoMovementTrigger::IsActive() { return !AI_VALUE2(bool, "moving", "self target"); }
|
|
|
|
bool NoPossibleTargetsTrigger::IsActive()
|
|
{
|
|
GuidVector targets = AI_VALUE(GuidVector, "possible targets");
|
|
return !targets.size();
|
|
}
|
|
|
|
bool PossibleAddsTrigger::IsActive()
|
|
{
|
|
return AI_VALUE(bool, "possible adds") && !AI_VALUE(ObjectGuid, "pull target");
|
|
}
|
|
|
|
bool NotDpsTargetActiveTrigger::IsActive()
|
|
{
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
if (target && target->IsAlive())
|
|
{
|
|
Unit* enemy = AI_VALUE(Unit*, "enemy player target");
|
|
if (target == enemy)
|
|
return false;
|
|
}
|
|
|
|
Unit* dps = AI_VALUE(Unit*, "dps target");
|
|
return dps && target != dps;
|
|
}
|
|
|
|
bool NotDpsAoeTargetActiveTrigger::IsActive()
|
|
{
|
|
Unit* dps = AI_VALUE(Unit*, "dps aoe target");
|
|
Unit* target = AI_VALUE(Unit*, "current target");
|
|
Unit* enemy = AI_VALUE(Unit*, "enemy player target");
|
|
|
|
if (target && target == enemy && target->IsAlive())
|
|
return false;
|
|
|
|
return dps && target != dps;
|
|
}
|
|
|
|
bool IsSwimmingTrigger::IsActive() { return AI_VALUE2(bool, "swimming", "self target"); }
|
|
|
|
bool HasNearestAddsTrigger::IsActive()
|
|
{
|
|
GuidVector targets = AI_VALUE(GuidVector, "nearest adds");
|
|
return targets.size();
|
|
}
|
|
|
|
bool HasItemForSpellTrigger::IsActive()
|
|
{
|
|
std::string const spell = getName();
|
|
uint32 spellId = AI_VALUE2(uint32, "spell id", spell);
|
|
return spellId && AI_VALUE2(Item*, "item for spell", spellId);
|
|
}
|
|
|
|
bool TargetChangedTrigger::IsActive()
|
|
{
|
|
Unit* oldTarget = context->GetValue<Unit*>("old target")->Get();
|
|
Unit* target = context->GetValue<Unit*>("current target")->Get();
|
|
return target && oldTarget != target;
|
|
}
|
|
|
|
Value<Unit*>* InterruptEnemyHealerTrigger::GetTargetValue()
|
|
{
|
|
return context->GetValue<Unit*>("enemy healer target", spell);
|
|
}
|
|
|
|
bool RandomBotUpdateTrigger::IsActive()
|
|
{
|
|
return RandomTrigger::IsActive() && AI_VALUE(bool, "random bot update");
|
|
}
|
|
|
|
bool NoNonBotPlayersAroundTrigger::IsActive()
|
|
{
|
|
return !botAI->HasPlayerNearby();
|
|
/*if (!bot->InBattleground())
|
|
return AI_VALUE(GuidVector, "nearest non bot players").empty();
|
|
|
|
return false;
|
|
*/
|
|
}
|
|
|
|
bool NewPlayerNearbyTrigger::IsActive() { return AI_VALUE(ObjectGuid, "new player nearby"); }
|
|
|
|
bool CollisionTrigger::IsActive() { return AI_VALUE2(bool, "collision", "self target"); }
|
|
|
|
bool ReturnToStayPositionTrigger::IsActive()
|
|
{
|
|
PositionInfo stayPosition = AI_VALUE(PositionMap&, "position")["stay"];
|
|
if (stayPosition.isSet())
|
|
{
|
|
const float distance = bot->GetDistance(stayPosition.x, stayPosition.y, stayPosition.z);
|
|
return distance > sPlayerbotAIConfig.followDistance;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool GiveItemTrigger::IsActive()
|
|
{
|
|
return AI_VALUE2(Unit*, "party member without item", item) && AI_VALUE2(uint32, "item count", item);
|
|
}
|
|
|
|
bool GiveFoodTrigger::IsActive()
|
|
{
|
|
return AI_VALUE(Unit*, "party member without food") && AI_VALUE2(uint32, "item count", item);
|
|
}
|
|
|
|
bool GiveWaterTrigger::IsActive()
|
|
{
|
|
return AI_VALUE(Unit*, "party member without water") && AI_VALUE2(uint32, "item count", item);
|
|
}
|
|
|
|
Value<Unit*>* SnareTargetTrigger::GetTargetValue() { return context->GetValue<Unit*>("snare target", spell); }
|
|
|
|
bool StayTimeTrigger::IsActive()
|
|
{
|
|
time_t stayTime = AI_VALUE(time_t, "stay time");
|
|
time_t now = time(nullptr);
|
|
return delay && stayTime && now > stayTime + 2 * delay / 1000;
|
|
}
|
|
|
|
bool IsMountedTrigger::IsActive() { return AI_VALUE2(bool, "mounted", "self target"); }
|
|
|
|
bool CorpseNearTrigger::IsActive()
|
|
{
|
|
return bot->GetCorpse() && bot->GetCorpse()->IsWithinDistInMap(bot, CORPSE_RECLAIM_RADIUS, true);
|
|
}
|
|
|
|
bool IsFallingTrigger::IsActive() { return bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING); }
|
|
|
|
bool IsFallingFarTrigger::IsActive() { return bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR); }
|
|
|
|
bool HasAreaDebuffTrigger::IsActive() { return AI_VALUE2(bool, "has area debuff", "self target"); }
|
|
|
|
Value<Unit*>* BuffOnMainTankTrigger::GetTargetValue() { return context->GetValue<Unit*>("main tank", spell); }
|
|
|
|
bool AmmoCountTrigger::IsActive()
|
|
{
|
|
if (bot->GetUInt32Value(PLAYER_AMMO_ID) != 0)
|
|
return ItemCountTrigger::IsActive(); // Ammo already equipped
|
|
|
|
if (botAI->FindAmmo())
|
|
return true; // Found ammo in inventory but not equipped
|
|
|
|
return ItemCountTrigger::IsActive();
|
|
}
|
|
|
|
bool NewPetTrigger::IsActive()
|
|
{
|
|
ObjectGuid currentPetGuid = ObjectGuid::Empty;
|
|
|
|
if (Pet* pet = bot->GetPet())
|
|
currentPetGuid = pet->GetGUID();
|
|
else if (Guardian* guardian = bot->GetGuardianPet())
|
|
currentPetGuid = guardian->GetGUID();
|
|
|
|
if (currentPetGuid != lastPetGuid)
|
|
{
|
|
triggered = false;
|
|
lastPetGuid = currentPetGuid;
|
|
}
|
|
|
|
if (currentPetGuid != ObjectGuid::Empty && !triggered)
|
|
{
|
|
triggered = true;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|