Magic focus magic on party

This commit is contained in:
Yunfan Li
2025-01-19 22:39:34 +08:00
parent 4c1469fc58
commit 89941ada48
7 changed files with 88 additions and 2 deletions

View File

@@ -5,8 +5,10 @@
#include "MageActions.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
#include "ServerFacade.h"
#include "SharedDefines.h"
Value<Unit*>* CastPolymorphAction::GetTargetValue() { return context->GetValue<Unit*>("cc target", getName()); }
@@ -42,4 +44,47 @@ bool CastBlastWaveAction::isUseful()
return false;
bool targetClose = bot->IsWithinCombatRange(target, 10.0f);
return targetClose;
}
Unit* CastFocusMagicOnPartyAction::GetTarget()
{
Group* group = bot->GetGroup();
if (!group)
return nullptr;
Unit* casterDps = nullptr;
Unit* healer = nullptr;
Unit* target = nullptr;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{
Player* member = ref->GetSource();
if (!member || member == bot || !member->IsAlive())
continue;
if (member->GetMap() != bot->GetMap() || bot->GetDistance(member) > sPlayerbotAIConfig->spellDistance)
continue;
if (member->HasAura(54646))
continue;
if (member->getClass() == CLASS_MAGE)
return member;
if (!casterDps && botAI->IsCaster(member) && botAI->IsDps(member))
casterDps = member;
if (!healer && botAI->IsHeal(member))
healer = member;
if (!target)
target = member;
}
if (casterDps)
return casterDps;
if (healer)
return healer;
return target;
}