mod-playerbots/src/strategy/warrior/WarriorActions.cpp
avirar 5c8283d40a
Prot warriors cast vigilance when in a group (#825)
* Add Vigilance

* Vigilance

* Update WarriorTriggers.h

* Update TankWarriorStrategy.cpp

* Update WarriorAiObjectContext.cpp

* Update WarriorTriggers.cpp

* Update WarriorTriggers.h

* Update WarriorTriggers.cpp

Check for existence of Vigilance in raid already

* Update WarriorActions.cpp

Check for existence of Vigilance in raid already
Apply to tanks, then highest gearscore DPS.

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Added logout

Bots keep assigning it to me and not maintank? Added logging to clarify

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Update WarriorTriggers.cpp

* Update WarriorTriggers.cpp

* Update WarriorTriggers.cpp

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Update WarriorTriggers.cpp

* Update WarriorActions.cpp

* Update WarriorActions.cpp

* Removed Logs

* Removed logs

* Added check for spell in trigger

* Update WarriorTriggers.cpp

* !member->IsAlive()

* !member->IsAlive()
2024-12-29 21:47:22 +01:00

104 lines
3.1 KiB
C++

/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
* and/or modify it under version 2 of the License, or (at your option), any later version.
*/
#include "WarriorActions.h"
#include "Playerbots.h"
bool CastSunderArmorAction::isUseful()
{
Aura* aura = botAI->GetAura("sunder armor", GetTarget(), false, true);
return !aura || aura->GetStackAmount() < 5 || aura->GetDuration() <= 6000;
}
Value<Unit*>* CastVigilanceAction::GetTargetValue()
{
Group* group = bot->GetGroup();
if (!group)
{
return new ManualSetValue<Unit*>(botAI, nullptr);
}
Player* currentVigilanceTarget = nullptr;
Player* mainTank = nullptr;
Player* assistTank1 = nullptr;
Player* assistTank2 = nullptr;
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))
{
assistTank1 = member;
}
else if (assistTank2 == nullptr && botAI->IsAssistTankOfIndex(member, 1))
{
assistTank2 = member;
}
// Determine Highest Gear Score
uint32 gearScore = botAI->GetEquipGearScore(member, false, false);
if (gearScore > highestGearScore)
{
highestGearScore = gearScore;
highestGearScorePlayer = member;
}
}
// Determine the highest-priority target
Player* highestPriorityTarget = mainTank ? mainTank :
(assistTank1 ? assistTank1 :
(assistTank2 ? assistTank2 : highestGearScorePlayer));
// If no valid target, return nullptr
if (!highestPriorityTarget)
{
return new ManualSetValue<Unit*>(botAI, nullptr);
}
// If the current target is already the highest-priority target, do nothing
if (currentVigilanceTarget == highestPriorityTarget)
{
return new ManualSetValue<Unit*>(botAI, nullptr);
}
// Assign the new target
Unit* targetUnit = highestPriorityTarget->ToUnit();
if (targetUnit)
{
return new ManualSetValue<Unit*>(botAI, targetUnit);
}
return new ManualSetValue<Unit*>(botAI, nullptr);
}
bool CastVigilanceAction::Execute(Event event)
{
Unit* target = GetTarget();
if (!target || target == bot)
return false;
return botAI->CastSpell("vigilance", target);
}