refactor raid naxx related

This commit is contained in:
Yunfan Li
2023-07-14 23:13:46 +08:00
parent 86f7a6e9d1
commit d183d285b6
18 changed files with 389 additions and 298 deletions

View File

@@ -1,170 +0,0 @@
#include "EventMap.h"
#include "Playerbots.h"
#include "RaidNaxxTrigger.h"
#include "ScriptedCreature.h"
bool AuraRemovedTrigger::IsActive() {
bool check = botAI->HasAura(name, bot, false, false, -1, true);
bool ret = false;
if (prev_check && !check) {
ret = true;
}
prev_check = check;
return ret;
}
bool MutatingInjectionRemovedTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "grobbulus");
if (!boss) {
return false;
}
return HasNoAuraTrigger::IsActive() && botAI->GetState() == BOT_STATE_COMBAT && botAI->IsRanged(bot);
}
template<class T>
bool BossEventTrigger<T>::IsActive()
{
Unit* boss = AI_VALUE(Unit*, "boss target");
if (!boss || boss->GetEntry() != boss_entry) {
return false;
}
T* ai = dynamic_cast<T*>(boss->GetAI());
EventMap *eventMap = &ai->events;
if (!eventMap) {
return false;
}
const uint32 event_time = eventMap->GetNextEventTime(event_id);
if (event_time != last_event_time) {
last_event_time = event_time;
return true;
}
return false;
}
template<class T>
bool BossPhaseTrigger<T>::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", boss_name);
if (!boss) {
return false;
}
if (this->phase_mask == 0) {
return true;
}
T* boss_ai = dynamic_cast<T*>(boss->GetAI());
EventMap* eventMap = &boss_ai->events;
uint8 phase_mask = eventMap->GetPhaseMask();
// bot->Yell("phase mask detected: " + to_string(phase_mask) + " compare with " + to_string(this->phase_mask), LANG_UNIVERSAL);
return phase_mask == this->phase_mask;
}
bool GrobbulusCloudTrigger::IsActive()
{
Unit* boss = AI_VALUE(Unit*, "boss target");
if (!boss || boss->GetEntry() != boss_entry) {
return false;
}
if (!botAI->IsMainTank(bot)) {
return false;
}
// bot->Yell("has aggro on " + boss->GetName() + " : " + to_string(AI_VALUE2(bool, "has aggro", "boss target")), LANG_UNIVERSAL);
return AI_VALUE2(bool, "has aggro", "boss target");
}
bool HeiganMeleeTrigger::IsActive()
{
Unit* heigan = AI_VALUE2(Unit*, "find target", "heigan the unclean");
if (!heigan) {
return false;
}
return !botAI->IsRanged(bot);
}
bool HeiganRangedTrigger::IsActive()
{
Unit* heigan = AI_VALUE2(Unit*, "find target", "heigan the unclean");
if (!heigan) {
return false;
}
return botAI->IsRanged(bot);
}
// bool RazuviousTankTrigger::IsActive()
// {
// Difficulty diff = bot->GetRaidDifficulty();
// if (diff == RAID_DIFFICULTY_10MAN_NORMAL) {
// return BossPhaseTrigger::IsActive() && botAI->IsTank(bot);
// }
// return BossPhaseTrigger::IsActive() && bot->getClass() == CLASS_PRIEST;
// }
// bool RazuviousNontankTrigger::IsActive()
// {
// Difficulty diff = bot->GetRaidDifficulty();
// if (diff == RAID_DIFFICULTY_10MAN_NORMAL) {
// return BossPhaseTrigger::IsActive() && !(botAI->IsTank(bot));
// }
// return BossPhaseTrigger::IsActive() && !(bot->getClass() == CLASS_PRIEST);
// }
// bool HorsemanAttractorsTrigger::IsActive()
// {
// Difficulty diff = bot->GetRaidDifficulty();
// if (diff == RAID_DIFFICULTY_25MAN_NORMAL) {
// return BossPhaseTrigger::IsActive() && (botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0) ||
// botAI->IsHealAssistantOfIndex(bot, 1) || botAI->IsHealAssistantOfIndex(bot, 2));
// }
// return BossPhaseTrigger::IsActive() && (botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0));
// }
// bool HorsemanExceptAttractorsTrigger::IsActive()
// {
// return BossPhaseTrigger::IsActive() &&
// !(botAI->IsRangedDpsAssistantOfIndex(bot, 0) || botAI->IsHealAssistantOfIndex(bot, 0) ||
// botAI->IsHealAssistantOfIndex(bot, 1) || botAI->IsHealAssistantOfIndex(bot, 2));
// }
// bool SapphironGroundMainTankTrigger::IsActive()
// {
// return BossPhaseTrigger::IsActive() && botAI->IsMainTank(bot) && AI_VALUE2(bool, "has aggro", "boss target");
// }
// bool SapphironGroundExceptMainTankTrigger::IsActive()
// {
// return BossPhaseTrigger::IsActive() && !botAI->IsMainTank(bot);
// }
// bool SapphironFlightTrigger::IsActive()
// {
// return BossPhaseTrigger::IsActive();
// }
// bool SapphironGroundChillTrigger::IsActive()
// {
// return BossPhaseTrigger::IsActive() && !botAI->IsMainTank(bot) && botAI->HasAura("chill", bot);
// }
// bool GluthMainTankMortalWoundTrigger::IsActive()
// {
// if (!BossPhaseTrigger::IsActive()) {
// return false;
// }
// if (!botAI->IsAssistTankOfIndex(bot, 0)) {
// return false;
// }
// Unit* mt = AI_VALUE(Unit*, "main tank");
// if (!mt) {
// return false;
// }
// Aura* aura = botAI->GetAuraWithDuration("mortal wound", mt);
// if (!aura || aura->GetStackAmount() < 5) {
// return false;
// }
// // bot->Yell("Time to taunt!", LANG_UNIVERSAL);
// return true;
// }
template bool BossEventTrigger<boss_grobbulus::boss_grobbulusAI>::IsActive();
template bool BossPhaseTrigger<boss_anubrekhan::boss_anubrekhanAI>::IsActive();

View File

@@ -1,210 +0,0 @@
#ifndef _PLAYERBOT_RAIDNAXXTRIGGER_H
#define _PLAYERBOT_RAIDNAXXTRIGGER_H
#include "EventMap.h"
#include "Trigger.h"
#include "PlayerbotAIConfig.h"
#include "GenericTriggers.h"
#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_grobbulus.h"
#include "../../../../src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.h"
using namespace std;
class MutatingInjectionTrigger : public HasAuraTrigger
{
public:
MutatingInjectionTrigger(PlayerbotAI* ai): HasAuraTrigger(ai, "mutating injection", 1) {}
};
class AuraRemovedTrigger : public Trigger
{
public:
AuraRemovedTrigger(PlayerbotAI* botAI, string name): Trigger(botAI, name, 1) {
this->prev_check = false;
}
virtual bool IsActive() override;
protected:
bool prev_check;
};
class MutatingInjectionRemovedTrigger : public HasNoAuraTrigger
{
public:
MutatingInjectionRemovedTrigger(PlayerbotAI* ai): HasNoAuraTrigger(ai, "mutating injection") {}
virtual bool IsActive();
};
template<class T>
class BossEventTrigger : public Trigger
{
public:
BossEventTrigger(PlayerbotAI* ai, uint32 boss_entry, uint32 event_id, string name = "boss event"): Trigger(ai, name, 1) {
this->boss_entry = boss_entry;
this->event_id = event_id;
this->last_event_time = -1;
}
virtual bool IsActive();
protected:
uint32 boss_entry, event_id, last_event_time;
};
template<class T>
class BossPhaseTrigger : public Trigger
{
public:
BossPhaseTrigger(PlayerbotAI* ai, string boss_name, uint32 phase_mask, string name = "boss event"): Trigger(ai, name, 1) {
this->boss_name = boss_name;
this->phase_mask = phase_mask;
}
virtual bool IsActive();
protected:
string boss_name;
uint32 phase_mask;
};
class GrobbulusCloudTrigger : public BossEventTrigger<boss_grobbulus::boss_grobbulusAI>
{
public:
GrobbulusCloudTrigger(PlayerbotAI* ai): BossEventTrigger(ai, 15931, 2, "grobbulus cloud event") { }
virtual bool IsActive();
};
class HeiganMeleeTrigger : public Trigger
{
public:
HeiganMeleeTrigger(PlayerbotAI* ai): Trigger(ai, "heigan melee") {}
virtual bool IsActive();
};
class HeiganRangedTrigger : public Trigger
{
public:
HeiganRangedTrigger(PlayerbotAI* ai): Trigger(ai, "heigan ranged") {}
virtual bool IsActive();
};
// class ThaddiusPhasePetTrigger : public BossPhaseTrigger
// {
// public:
// ThaddiusPhasePetTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "thaddius", 1 << (2 - 1), "thaddius phase pet") {}
// };
// class ThaddiusPhasePetLoseAggroTrigger : public ThaddiusPhasePetTrigger
// {
// public:
// ThaddiusPhasePetLoseAggroTrigger(PlayerbotAI* ai) : ThaddiusPhasePetTrigger(ai) {}
// virtual bool IsActive() {
// Unit* target = AI_VALUE(Unit*, "current target");
// return ThaddiusPhasePetTrigger::IsActive() && ai->IsTank(bot) && target && target->GetVictim() != bot;
// }
// };
// class ThaddiusPhaseTransitionTrigger : public BossPhaseTrigger
// {
// public:
// ThaddiusPhaseTransitionTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "thaddius", 1 << (3 - 1), "thaddius phase transition") {}
// };
// class ThaddiusPhaseThaddiusTrigger : public BossPhaseTrigger
// {
// public:
// ThaddiusPhaseThaddiusTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "thaddius", 1 << (4 - 1), "thaddius phase thaddius") {}
// };
// class RazuviousTankTrigger : public BossPhaseTrigger
// {
// public:
// RazuviousTankTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "instructor razuvious", 0, "razuvious tank") {}
// virtual bool IsActive();
// };
// class RazuviousNontankTrigger : public BossPhaseTrigger
// {
// public:
// RazuviousNontankTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "instructor razuvious", 0, "razuvious nontank") {}
// virtual bool IsActive();
// };
// class HorsemanAttractorsTrigger : public BossPhaseTrigger
// {
// public:
// HorsemanAttractorsTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sir zeliek", 0, "horseman attractors") {}
// virtual bool IsActive();
// };
// class HorsemanExceptAttractorsTrigger : public BossPhaseTrigger
// {
// public:
// HorsemanExceptAttractorsTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sir zeliek", 0, "horseman except attractors") {}
// virtual bool IsActive();
// };
// class SapphironGroundMainTankTrigger : public BossPhaseTrigger
// {
// public:
// SapphironGroundMainTankTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sapphiron", (1 << (2 - 1)), "sapphiron ground main tank") {}
// virtual bool IsActive();
// };
// class SapphironGroundExceptMainTankTrigger : public BossPhaseTrigger
// {
// public:
// SapphironGroundExceptMainTankTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sapphiron", (1 << (2 - 1)), "sapphiron ground except main tank") {}
// virtual bool IsActive();
// };
// class SapphironFlightTrigger : public BossPhaseTrigger
// {
// public:
// SapphironFlightTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sapphiron", (1 << (3 - 1)), "sapphiron flight") {}
// virtual bool IsActive();
// };
// class SapphironGroundChillTrigger : public BossPhaseTrigger
// {
// public:
// SapphironGroundChillTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "sapphiron", 0, "sapphiron chill") {}
// virtual bool IsActive();
// };
// class KelthuzadTrigger : public BossPhaseTrigger
// {
// public:
// KelthuzadTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "kel'thuzad", 0, "kel'thuzad trigger") {}
// };
class AnubrekhanTrigger : public BossPhaseTrigger<boss_anubrekhan::boss_anubrekhanAI>
{
public:
AnubrekhanTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "anub'rekhan", 0, "anub'rekhan trigger") {}
};
// class KelthuzadPhaseTwoTrigger : public BossPhaseTrigger
// {
// public:
// KelthuzadPhaseTwoTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "kel'thuzad", 1 << (2 - 1), "kel'thuzad trigger") {}
// };
// class GluthTrigger : public BossPhaseTrigger
// {
// public:
// GluthTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "gluth", 0, "gluth trigger") {}
// };
// class GluthMainTankMortalWoundTrigger : public BossPhaseTrigger
// {
// public:
// GluthMainTankMortalWoundTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "gluth", 0, "gluth main tank mortal wound trigger") {}
// virtual bool IsActive();
// };
// class LoathebTrigger : public BossPhaseTrigger
// {
// public:
// LoathebTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "loatheb", 0, "loatheb trigger") {}
// };
// template BossEventTrigger<class boss_grobbulus::boss_grobbulusAI>;
#endif

View File

@@ -16,7 +16,7 @@
#include "StuckTriggers.h"
#include "TravelTriggers.h"
#include "NamedObjectContext.h"
#include "RaidNaxxTrigger.h"
#include "RaidNaxxTriggers.h"
class PlayerbotAI;
@@ -194,38 +194,6 @@ class TriggerContext : public NamedObjectContext<Trigger>
creators["rpg craft"] = &TriggerContext::rpg_craft;
creators["rpg trade useful"] = &TriggerContext::rpg_trade_useful;
creators["rpg duel"] = &TriggerContext::rpg_duel;
creators["mutating injection"] = &TriggerContext::mutating_injection;
creators["mutating injection removed"] = &TriggerContext::mutating_injection_removed;
creators["grobbulus cloud"] = &TriggerContext::grobbulus_cloud;
creators["heigan melee"] = &TriggerContext::heigan_melee;
creators["heigan ranged"] = &TriggerContext::heigan_ranged;
// creators["thaddius phase pet"] = &TriggerContext::thaddius_phase_pet;
// creators["thaddius phase pet lose aggro"] = &TriggerContext::thaddius_phase_pet_lose_aggro;
// creators["thaddius phase transition"] = &TriggerContext::thaddius_phase_transition;
// creators["thaddius phase thaddius"] = &TriggerContext::thaddius_phase_thaddius;
// creators["razuvious tank"] = &TriggerContext::razuvious_tank;
// creators["razuvious nontank"] = &TriggerContext::razuvious_nontank;
// creators["horseman attractors"] = &TriggerContext::horseman_attractors;
// creators["horseman except attractors"] = &TriggerContext::horseman_except_attractors;
// creators["sapphiron ground main tank"] = &TriggerContext::sapphiron_ground_main_tank;
// creators["sapphiron ground except main tank"] = &TriggerContext::sapphiron_ground_except_main_tank;
// creators["sapphiron flight"] = &TriggerContext::sapphiron_flight;
// creators["sapphiron chill"] = &TriggerContext::sapphiron_ground_chill;
// creators["kel'thuzad"] = &TriggerContext::kelthuzad;
// creators["kel'thuzad phase two"] = &TriggerContext::kelthuzad_phase_two;
creators["anub'rekhan"] = &TriggerContext::anubrekhan;
// creators["gluth"] = &TriggerContext::gluth;
// creators["gluth main tank mortal wound"] = &TriggerContext::gluth_main_tank_mortal_wound;
// creators["loatheb"] = &TriggerContext::loatheb;
}
private:
@@ -367,31 +335,6 @@ class TriggerContext : public NamedObjectContext<Trigger>
static Trigger* rpg_craft(PlayerbotAI* botAI) { return new RpgCraftTrigger(botAI); }
static Trigger* rpg_trade_useful(PlayerbotAI* botAI) { return new RpgTradeUsefulTrigger(botAI); }
static Trigger* rpg_duel(PlayerbotAI* botAI) { return new RpgDuelTrigger(botAI); }
static Trigger* mutating_injection(PlayerbotAI* ai) { return new MutatingInjectionTrigger(ai); }
static Trigger* mutating_injection_removed(PlayerbotAI* ai) { return new MutatingInjectionRemovedTrigger(ai); }
static Trigger* grobbulus_cloud(PlayerbotAI* ai) { return new GrobbulusCloudTrigger(ai); }
static Trigger* heigan_melee(PlayerbotAI* ai) { return new HeiganMeleeTrigger(ai); }
static Trigger* heigan_ranged(PlayerbotAI* ai) { return new HeiganRangedTrigger(ai); }
// static Trigger* thaddius_phase_pet(PlayerbotAI* ai) { return new ThaddiusPhasePetTrigger(ai); }
// static Trigger* thaddius_phase_pet_lose_aggro(PlayerbotAI* ai) { return new ThaddiusPhasePetLoseAggroTrigger(ai); }
// static Trigger* thaddius_phase_transition(PlayerbotAI* ai) { return new ThaddiusPhaseTransitionTrigger(ai); }
// static Trigger* thaddius_phase_thaddius(PlayerbotAI* ai) { return new ThaddiusPhaseThaddiusTrigger(ai); }
// static Trigger* razuvious_tank(PlayerbotAI* ai) { return new RazuviousTankTrigger(ai); }
// static Trigger* razuvious_nontank(PlayerbotAI* ai) { return new RazuviousNontankTrigger(ai); }
// static Trigger* horseman_attractors(PlayerbotAI* ai) { return new HorsemanAttractorsTrigger(ai); }
// static Trigger* horseman_except_attractors(PlayerbotAI* ai) { return new HorsemanExceptAttractorsTrigger(ai); }
// static Trigger* sapphiron_ground_main_tank(PlayerbotAI* ai) { return new SapphironGroundMainTankTrigger(ai); }
// static Trigger* sapphiron_ground_except_main_tank(PlayerbotAI* ai) { return new SapphironGroundExceptMainTankTrigger(ai); }
// static Trigger* sapphiron_flight(PlayerbotAI* ai) { return new SapphironFlightTrigger(ai); }
// static Trigger* sapphiron_ground_chill(PlayerbotAI* ai) { return new SapphironGroundChillTrigger(ai); }
// static Trigger* kelthuzad(PlayerbotAI* ai) { return new KelthuzadTrigger(ai); }
// static Trigger* kelthuzad_phase_two(PlayerbotAI* ai) { return new KelthuzadPhaseTwoTrigger(ai); }
static Trigger* anubrekhan(PlayerbotAI* ai) { return new AnubrekhanTrigger(ai); }
// static Trigger* gluth(PlayerbotAI* ai) { return new GluthTrigger(ai); }
// static Trigger* gluth_main_tank_mortal_wound(PlayerbotAI* ai) { return new GluthMainTankMortalWoundTrigger(ai); }
// static Trigger* loatheb(PlayerbotAI* ai) { return new LoathebTrigger(ai); }
};
#endif