miscs(raid strategy, distance triggers, etc)

This commit is contained in:
Yunfan Li
2023-06-06 00:11:35 +08:00
parent 516366a74d
commit 98e46a3d02
32 changed files with 2711 additions and 76 deletions

View File

@@ -6,6 +6,8 @@
#include "LastMovementValue.h"
#include "RtiTargetValue.h"
#include "Playerbots.h"
#include "ScriptedCreature.h"
#include "ThreatMgr.h"
Unit* FindTargetStrategy::GetResult()
{
@@ -111,3 +113,50 @@ WorldPosition HomeBindValue::Calculate()
{
return WorldPosition(bot->m_homebindMapId, bot->m_homebindX, bot->m_homebindY, bot->m_homebindZ, 0.f);
}
Unit* FindTargetValue::Calculate()
{
if (qualifier == "") {
return NULL;
}
Group* group = bot->GetGroup();
if (!group) {
return NULL;
}
for (GroupReference *gref = group->GetFirstMember(); gref; gref = gref->next()) {
Player* member = gref->GetSource();
if (!member) {
continue;
}
HostileReference *ref = member->getHostileRefMgr().getFirst();
while (ref)
{
ThreatMgr *threatManager = ref->GetSource();
Unit *unit = threatManager->GetOwner();
std::wstring wnamepart;
Utf8toWStr(unit->GetName(), wnamepart);
wstrToLower(wnamepart);
if (!qualifier.empty() && qualifier.length() == wnamepart.length() && Utf8FitTo(qualifier, wnamepart)) {
return unit;
}
assert(ref);
ref = ref->next();
}
}
return nullptr;
}
void FindBossTargetStrategy::CheckAttacker(Unit* attacker, ThreatMgr* threatManager)
{
UnitAI* unitAI = attacker->GetAI();
BossAI* bossAI = dynamic_cast<BossAI*>(unitAI);
if (bossAI) {
result = attacker;
}
}
Unit* BossTargetValue::Calculate()
{
FindBossTargetStrategy strategy(botAI);
return FindTarget(&strategy);
}