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

@@ -38,7 +38,7 @@ bool HasAggroValue::Calculate()
{
if (Player* pl = victim->ToPlayer())
{
if (botAI->IsTank(pl))
if (botAI->IsMainTank(pl))
{
return true;
}

View File

@@ -45,7 +45,7 @@ Unit* PartyMemberToHeal::Calculate()
if (player && Check(player) && player->IsAlive()) {
uint8 health = player->GetHealthPct();
if (isRaid || health < sPlayerbotAIConfig->mediumHealth || !IsTargetOfSpellCast(player, predicate)) {
if (player->GetDistance2d(bot) > sPlayerbotAIConfig->spellDistance) {
if (player->GetDistance2d(bot) > sPlayerbotAIConfig->healDistance) {
calc.probe(health + 30, player);
} else {
calc.probe(health + player->GetDistance2d(bot) / 10, player);
@@ -75,7 +75,7 @@ bool PartyMemberToHeal::Check(Unit* player)
// return player && player != bot && player->GetMapId() == bot->GetMapId() && player->IsInWorld() &&
// sServerFacade->GetDistance2d(bot, player) < (player->IsPlayer() && botAI->IsTank((Player*)player) ? 50.0f : 40.0f);
return player && player->GetMapId() == bot->GetMapId() &&
bot->GetDistance2d(player) < sPlayerbotAIConfig->spellDistance * 2 &&
bot->GetDistance2d(player) < sPlayerbotAIConfig->healDistance * 2 &&
bot->IsWithinLOS(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
}

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);
}

View File

@@ -7,6 +7,7 @@
#include "TravelMgr.h"
#include "Value.h"
#include "NamedObjectContext.h"
class PlayerbotAI;
class ThreatMgr;
@@ -97,4 +98,28 @@ class PullTargetValue : public ManualSetValue<ObjectGuid>
PullTargetValue(PlayerbotAI* botAI, std::string const name = "pull target") : ManualSetValue<ObjectGuid>(botAI, ObjectGuid::Empty, name) { }
};
class FindTargetValue : public UnitCalculatedValue, public Qualified
{
public:
FindTargetValue(PlayerbotAI* ai) : UnitCalculatedValue(ai) {}
public:
Unit* Calculate();
};
class FindBossTargetStrategy : public FindTargetStrategy
{
public:
FindBossTargetStrategy(PlayerbotAI* ai) : FindTargetStrategy(ai) {}
virtual void CheckAttacker(Unit* attacker, ThreatMgr* threatManager);
};
class BossTargetValue : public TargetValue, public Qualified
{
public:
BossTargetValue(PlayerbotAI* ai) : TargetValue(ai) {}
public:
Unit* Calculate();
};
#endif

View File

@@ -287,6 +287,8 @@ class ValueContext : public NamedObjectContext<UntypedValue>
creators["has area debuff"] = &ValueContext::has_area_debuff;
creators["main tank"] = &ValueContext::main_tank;
creators["find target"] = &ValueContext::find_target;
creators["boss target"] = &ValueContext::boss_target;
}
private:
@@ -479,6 +481,8 @@ class ValueContext : public NamedObjectContext<UntypedValue>
static UntypedValue* has_area_debuff(PlayerbotAI* botAI) { return new HasAreaDebuffValue(botAI); }
static UntypedValue* main_tank(PlayerbotAI* ai) { return new PartyMemberMainTankValue(ai); }
static UntypedValue* find_target(PlayerbotAI* ai) { return new FindTargetValue(ai); }
static UntypedValue* boss_target(PlayerbotAI* ai) { return new BossTargetValue(ai); }
};
#endif