Misdirection and tricks of the trade

This commit is contained in:
Yunfan Li
2024-09-04 20:08:44 +08:00
parent 484a2ae458
commit 406949f6dd
8 changed files with 34 additions and 6 deletions

View File

@@ -14,6 +14,7 @@
#include "Playerbots.h"
#include "SharedDefines.h"
#include "TemporarySummon.h"
#include "ThreatMgr.h"
#include "Timer.h"
bool LowManaTrigger::IsActive()
@@ -185,6 +186,22 @@ bool MyAttackerCountTrigger::IsActive()
return AI_VALUE2(bool, "combat", "self target") && AI_VALUE(uint8, "my attacker count") >= amount;
}
bool LowTankThreatTrigger::IsActive()
{
Unit* mt = AI_VALUE(Unit*, "main tank");
if (!mt)
return false;
Unit* current_target = AI_VALUE(Unit*, "current target");
if (!current_target)
return false;
ThreatMgr& mgr = current_target->GetThreatMgr();
float threat = mgr.GetThreat(bot);
float tankThreat = mgr.GetThreat(mt);
return tankThreat == 0.0f || threat > tankThreat * 0.5f;
}
bool AoeTrigger::IsActive()
{
Unit* current_target = AI_VALUE(Unit*, "current target");

View File

@@ -10,6 +10,7 @@
#include "HealthTriggers.h"
#include "RangeTriggers.h"
#include "Trigger.h"
class PlayerbotAI;
class Unit;
@@ -248,6 +249,13 @@ public:
MediumThreatTrigger(PlayerbotAI* botAI) : MyAttackerCountTrigger(botAI, 2) {}
};
class LowTankThreatTrigger : public Trigger
{
public:
LowTankThreatTrigger(PlayerbotAI* botAI) : Trigger(botAI, "low tank threat") {}
bool IsActive() override;
};
class AoeTrigger : public AttackerCountTrigger
{
public:

View File

@@ -102,6 +102,7 @@ public:
creators["combo points not full and high energy"] = &TriggerContext::ComboPointsNotFullAndHighEnergy;
creators["medium threat"] = &TriggerContext::MediumThreat;
creators["low tank threat"] = &TriggerContext::low_tank_threat;
creators["dead"] = &TriggerContext::Dead;
creators["corpse near"] = &TriggerContext::corpse_near;
@@ -321,6 +322,8 @@ private:
static Trigger* ComboPointsNotFull(PlayerbotAI* botAI) { return new ComboPointsNotFullTrigger(botAI); }
static Trigger* ComboPointsNotFullAndHighEnergy(PlayerbotAI* botAI) { return new TwoTriggers(botAI, "combo points not full", "high energy available"); }
static Trigger* MediumThreat(PlayerbotAI* botAI) { return new MediumThreatTrigger(botAI); }
static Trigger* low_tank_threat(PlayerbotAI* botAI) { return new LowTankThreatTrigger(botAI); }
// static Trigger* MediumThreat(PlayerbotAI* botAI) { return new MediumThreatTrigger(botAI); }
static Trigger* Dead(PlayerbotAI* botAI) { return new DeadTrigger(botAI); }
static Trigger* corpse_near(PlayerbotAI* botAI) { return new CorpseNearTrigger(botAI); }
static Trigger* PartyMemberDead(PlayerbotAI* botAI) { return new PartyMemberDeadTrigger(botAI); }