diff --git a/src/Ai/Class/Warrior/Trigger/WarriorTriggers.cpp b/src/Ai/Class/Warrior/Trigger/WarriorTriggers.cpp index 5aa419c92..f6e5bd234 100644 --- a/src/Ai/Class/Warrior/Trigger/WarriorTriggers.cpp +++ b/src/Ai/Class/Warrior/Trigger/WarriorTriggers.cpp @@ -4,7 +4,6 @@ */ #include "WarriorTriggers.h" - #include "Playerbots.h" bool BloodrageBuffTrigger::IsActive() @@ -16,15 +15,11 @@ bool BloodrageBuffTrigger::IsActive() bool VigilanceTrigger::IsActive() { if (!bot->HasSpell(50720)) - { return false; - } Group* group = bot->GetGroup(); if (!group) - { return false; - } Player* currentVigilanceTarget = nullptr; Player* mainTank = nullptr; @@ -33,37 +28,23 @@ bool VigilanceTrigger::IsActive() Player* highestGearScorePlayer = nullptr; uint32 highestGearScore = 0; - // Iterate once through the group to gather all necessary information for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) { Player* member = ref->GetSource(); if (!member || member == bot || !member->IsAlive()) continue; - // Check if member has Vigilance applied by the bot if (!currentVigilanceTarget && botAI->HasAura("vigilance", member, false, true)) - { currentVigilanceTarget = member; - } - // Identify Main Tank if (!mainTank && botAI->IsMainTank(member)) - { mainTank = member; - } - - // Identify Assist Tanks - if (assistTank1 == nullptr && botAI->IsAssistTankOfIndex(member, 0)) - { + else if (!assistTank1 && botAI->IsAssistTankOfIndex(member, 0)) assistTank1 = member; - } - else if (assistTank2 == nullptr && botAI->IsAssistTankOfIndex(member, 1)) - { + else if (!assistTank2 && botAI->IsAssistTankOfIndex(member, 1)) assistTank2 = member; - } - // Determine Highest Gear Score - uint32 gearScore = botAI->GetEquipGearScore(member/*, false, false*/); + uint32 gearScore = botAI->GetEquipGearScore(member); if (gearScore > highestGearScore) { highestGearScore = gearScore; @@ -71,33 +52,20 @@ bool VigilanceTrigger::IsActive() } } - // Determine the highest-priority target Player* highestPriorityTarget = mainTank ? mainTank : (assistTank1 ? assistTank1 : (assistTank2 ? assistTank2 : highestGearScorePlayer)); - // Trigger if no Vigilance is active or the current target is not the highest-priority target if (!currentVigilanceTarget || currentVigilanceTarget != highestPriorityTarget) - { return true; - } - return false; // No need to reassign Vigilance + return false; } bool ShatteringThrowTrigger::IsActive() { - // Spell cooldown check - if (!bot->HasSpell(64382)) - { + if (!bot->HasSpell(64382) || bot->HasSpellCooldown(64382)) return false; - } - - // Spell cooldown check - if (bot->HasSpellCooldown(64382)) - { - return false; - } GuidVector enemies = AI_VALUE(GuidVector, "possible targets"); @@ -107,7 +75,6 @@ bool ShatteringThrowTrigger::IsActive() if (!enemy || !enemy->IsAlive() || enemy->IsFriendlyTo(bot)) continue; - // Check if the enemy is within 25 yards and has the specific auras if (bot->IsWithinDistInMap(enemy, 25.0f) && (enemy->HasAura(642) || // Divine Shield enemy->HasAura(45438) || // Ice Block @@ -117,5 +84,74 @@ bool ShatteringThrowTrigger::IsActive() } } - return false; // No valid targets within range + return false; +} + +bool BattleShoutTrigger::IsActive() +{ + if (!BuffTrigger::IsActive()) + return false; + + uint32 battleShoutSpellId = AI_VALUE2(uint32, "spell id", "battle shout"); + if (!battleShoutSpellId) + return false; + + SpellInfo const* bsInfo = sSpellMgr->GetSpellInfo(battleShoutSpellId); + if (!bsInfo) + return false; + + int32 bsApValue = 0; + for (uint8 eff = 0; eff < MAX_SPELL_EFFECTS; ++eff) + { + if (bsInfo->Effects[eff].ApplyAuraName == SPELL_AURA_MOD_ATTACK_POWER) + { + bsApValue = bsInfo->Effects[eff].BasePoints + 1; + break; + } + } + if (!bsApValue) + return false; + + static const uint32 commandingPresenceSpells[] = { + 12318, 12857, 12858, 12860, 12861 }; + static const float commandingPresenceBonus[] = { + 0.05f, 0.10f, 0.15f, 0.20f, 0.25f }; + + float cpBonus = 0.0f; + for (int rank = 4; rank >= 0; --rank) + { + if (bot->HasAura(commandingPresenceSpells[rank])) + { + cpBonus = commandingPresenceBonus[rank]; + break; + } + } + int32 effectiveBsAp = int32(bsApValue * (1.0f + cpBonus)); + + static const char* blessingNames[] = { + "blessing of might", "greater blessing of might", nullptr + }; + for (int i = 0; blessingNames[i] != nullptr; ++i) + { + Aura* bom = botAI->GetAura(blessingNames[i], bot); + if (!bom) + continue; + + SpellInfo const* bomInfo = bom->GetSpellInfo(); + if (!bomInfo) + continue; + + for (uint8 eff = 0; eff < MAX_SPELL_EFFECTS; ++eff) + { + if (bomInfo->Effects[eff].ApplyAuraName == SPELL_AURA_MOD_ATTACK_POWER) + { + int32 bomApValue = bomInfo->Effects[eff].BasePoints + 1; + if (bomApValue >= effectiveBsAp) + return false; + break; + } + } + } + + return true; } diff --git a/src/Ai/Class/Warrior/Trigger/WarriorTriggers.h b/src/Ai/Class/Warrior/Trigger/WarriorTriggers.h index 563d70769..8a9ed9248 100644 --- a/src/Ai/Class/Warrior/Trigger/WarriorTriggers.h +++ b/src/Ai/Class/Warrior/Trigger/WarriorTriggers.h @@ -9,7 +9,13 @@ #include "GenericTriggers.h" #include "PlayerbotAI.h" -BUFF_TRIGGER(BattleShoutTrigger, "battle shout"); +class BattleShoutTrigger : public BuffTrigger +{ +public: + BattleShoutTrigger(PlayerbotAI* botAI) : BuffTrigger(botAI, "battle shout") {} + bool IsActive() override; +}; + BUFF_TRIGGER(BattleStanceTrigger, "battle stance"); BUFF_TRIGGER(DefensiveStanceTrigger, "defensive stance"); BUFF_TRIGGER(BerserkerStanceTrigger, "berserker stance"); @@ -85,4 +91,5 @@ public: // public: // SlamTrigger(PlayerbotAI* ai) : HasAuraTrigger(ai, "slam!") {} // }; + #endif