diff --git a/src/AiFactory.cpp b/src/AiFactory.cpp index 9015dc80..5c228fe4 100644 --- a/src/AiFactory.cpp +++ b/src/AiFactory.cpp @@ -283,7 +283,7 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa else if (tab == 1) engine->addStrategies("fire", "fire aoe", "threat", nullptr); else - engine->addStrategies("frost", "frost aoe", "threat", "dps aoe", nullptr); + engine->addStrategies("frost", "frost aoe", "threat", nullptr); engine->addStrategies("dps", "dps assist", "cure", "ranged", nullptr); break; diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index e114d04c..cf1eb652 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -33,6 +33,11 @@ #include "GuildMgr.h" #include "SayAction.h" +std::vector PlayerbotAI::dispel_whitelist = { + "mutating injection", + "frostbolt", +}; + std::vector& split(std::string const s, char delim, std::vector& elems); std::vector split(std::string const s, char delim); char* strstri(char const* str1, char const* str2); @@ -2748,6 +2753,16 @@ bool PlayerbotAI::canDispel(SpellInfo const* spellInfo, uint32 dispelType) { if (spellInfo->Dispel != dispelType) return false; + + if (!spellInfo->SpellName[0]) { + return true; + } + + for (std::string &wl : dispel_whitelist) { + if (strcmpi((const char*)spellInfo->SpellName[0], wl.c_str()) == 0) { + return false; + } + } return !spellInfo->SpellName[0] || (strcmpi((const char*)spellInfo->SpellName[0], "demon skin") && strcmpi((const char*)spellInfo->SpellName[0], "mage armor") && strcmpi((const char*)spellInfo->SpellName[0], "frost armor") && strcmpi((const char*)spellInfo->SpellName[0], "wavering will") && diff --git a/src/PlayerbotAI.h b/src/PlayerbotAI.h index 01d4dac7..e86fab8a 100644 --- a/src/PlayerbotAI.h +++ b/src/PlayerbotAI.h @@ -432,7 +432,7 @@ class PlayerbotAI : public PlayerbotAIBase bool CanMove(); bool IsInRealGuild(); - + static std::vector dispel_whitelist; private: void _fillGearScoreData(Player* player, Item* item, std::vector* gearScore, uint32& twoHandScore); bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); diff --git a/src/strategy/actions/RaidNaxxAction.cpp b/src/strategy/actions/RaidNaxxAction.cpp index bcdf61b9..b8a3bb69 100644 --- a/src/strategy/actions/RaidNaxxAction.cpp +++ b/src/strategy/actions/RaidNaxxAction.cpp @@ -99,8 +99,8 @@ uint32 RotateGrobbulusAction::GetCurrWaypoint() if (!boss) { return false; } - BossAI* boss_ai = dynamic_cast(boss->GetAI()); - EventMap* eventMap = boss_ai->GetEvents(); + auto* boss_ai = dynamic_cast(boss->GetAI()); + EventMap* eventMap = &boss_ai->events; const uint32 event_time = eventMap->GetNextEventTime(2); return (event_time / 15000) % intervals; } @@ -116,7 +116,7 @@ bool HeiganDanceAction::CalculateSafe() { uint32 curr_erupt = eventMap->GetNextEventTime(3); uint32 curr_dance = eventMap->GetNextEventTime(4); uint32 curr_timer = eventMap->GetTimer(); - if ((curr_phase == PHASE_SLOW_DANCE && curr_dance - curr_timer >= 80000) || (curr_phase == PHASE_FAST_DANCE && curr_dance - curr_timer >= 40000)) { + if ((curr_phase == 0 && curr_dance - curr_timer >= 80000) || (curr_phase == 1 && curr_dance - curr_timer >= 40000)) { ResetSafe(); } else if (curr_erupt != prev_erupt) { NextSafe(); @@ -128,16 +128,15 @@ bool HeiganDanceAction::CalculateSafe() { bool HeiganDanceMeleeAction::Execute(Event event) { CalculateSafe(); - if (prev_phase == PHASE_SLOW_DANCE && botAI->IsMainTank(bot) && !AI_VALUE2(bool, "has aggro", "boss target")) { + if (prev_phase == 0 && botAI->IsMainTank(bot) && !AI_VALUE2(bool, "has aggro", "boss target")) { return false; } - // botAI->TellMaster("Let\'s go " + std::to_string(curr_safe)); return MoveInside(bot->GetMapId(), waypoints[curr_safe].first, waypoints[curr_safe].second, bot->GetPositionZ(), botAI->IsMainTank(bot) ? 0 : 0); } bool HeiganDanceRangedAction::Execute(Event event) { CalculateSafe(); - if (prev_phase != PHASE_FAST_DANCE) { + if (prev_phase != 1) { return MoveTo(bot->GetMapId(), platform.first, platform.second, 276.54f); } botAI->InterruptSpell(); diff --git a/src/strategy/actions/RaidNaxxAction.h b/src/strategy/actions/RaidNaxxAction.h index 41052619..6f41a564 100644 --- a/src/strategy/actions/RaidNaxxAction.h +++ b/src/strategy/actions/RaidNaxxAction.h @@ -5,6 +5,8 @@ #include "MovementActions.h" #include "AttackAction.h" #include "GenericActions.h" +#include "PlayerbotAI.h" +#include "Playerbots.h" // just for test // class TryToGetBossAIAction : public Action diff --git a/src/strategy/generic/RaidStrategy.cpp b/src/strategy/generic/RaidStrategy.cpp index 1fa82184..ff53b964 100644 --- a/src/strategy/generic/RaidStrategy.cpp +++ b/src/strategy/generic/RaidStrategy.cpp @@ -35,7 +35,7 @@ float HeiganDanceMultiplier::GetValue(Action* action) if (dynamic_cast(action)) { return 0.0f; } - if (curr_phase != PHASE_FAST_DANCE && (int32)curr_dance - curr_timer >= 3000) { + if (curr_phase != 1 && (int32)curr_dance - curr_timer >= 3000) { return 1.0f; } if (dynamic_cast(action) || dynamic_cast(action)) { diff --git a/src/strategy/triggers/RaidNaxxTrigger.cpp b/src/strategy/triggers/RaidNaxxTrigger.cpp index 8994965e..113ff528 100644 --- a/src/strategy/triggers/RaidNaxxTrigger.cpp +++ b/src/strategy/triggers/RaidNaxxTrigger.cpp @@ -1,3 +1,4 @@ +#include "EventMap.h" #include "Playerbots.h" #include "RaidNaxxTrigger.h" #include "ScriptedCreature.h" @@ -21,12 +22,15 @@ bool MutatingInjectionRemovedTrigger::IsActive() return HasNoAuraTrigger::IsActive() && botAI->GetState() == BOT_STATE_COMBAT && botAI->IsRanged(bot); } -bool BossEventTrigger::IsActive() +template +bool BossEventTrigger::IsActive() { Unit* boss = AI_VALUE(Unit*, "boss target"); if (!boss || boss->GetEntry() != boss_entry) { return false; } + T* ai = dynamic_cast(boss->GetAI()); + EventMap *eventMap = &ai->events; if (!eventMap) { return false; } @@ -54,18 +58,18 @@ bool BossEventTrigger::IsActive() // 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 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() { @@ -159,4 +163,6 @@ bool HeiganRangedTrigger::IsActive() // } // // bot->Yell("Time to taunt!", LANG_UNIVERSAL); // return true; -// } \ No newline at end of file +// } + +template bool BossEventTrigger::IsActive(); \ No newline at end of file diff --git a/src/strategy/triggers/RaidNaxxTrigger.h b/src/strategy/triggers/RaidNaxxTrigger.h index 98f7a27a..90984b3d 100644 --- a/src/strategy/triggers/RaidNaxxTrigger.h +++ b/src/strategy/triggers/RaidNaxxTrigger.h @@ -34,6 +34,7 @@ public: virtual bool IsActive(); }; +template class BossEventTrigger : public Trigger { public: @@ -45,7 +46,6 @@ public: virtual bool IsActive(); protected: uint32 boss_entry, event_id, last_event_time; - EventMap *eventMap; }; class BossPhaseTrigger : public Trigger @@ -61,12 +61,10 @@ protected: uint32 phase_mask; }; -class GrobbulusCloudTrigger : public BossEventTrigger +class GrobbulusCloudTrigger : public BossEventTrigger { public: - GrobbulusCloudTrigger(PlayerbotAI* ai): BossEventTrigger(ai, 15931, 2, "grobbulus cloud event") { - this->eventMap = boss_grobbulus::boss_grobbulusAI - } + GrobbulusCloudTrigger(PlayerbotAI* ai): BossEventTrigger(ai, 15931, 2, "grobbulus cloud event") { } virtual bool IsActive(); }; @@ -205,4 +203,6 @@ public: // LoathebTrigger(PlayerbotAI* ai) : BossPhaseTrigger(ai, "loatheb", 0, "loatheb trigger") {} // }; + +// template BossEventTrigger; #endif \ No newline at end of file diff --git a/src/strategy/triggers/TriggerContext.h b/src/strategy/triggers/TriggerContext.h index 95281021..b6f6afc8 100644 --- a/src/strategy/triggers/TriggerContext.h +++ b/src/strategy/triggers/TriggerContext.h @@ -195,8 +195,8 @@ class TriggerContext : public NamedObjectContext 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["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; @@ -367,8 +367,8 @@ class TriggerContext : public NamedObjectContext 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* 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); }