mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Attack target] Fix attack
This commit is contained in:
@@ -13,24 +13,17 @@ class FindLeastHpTargetStrategy : public FindTargetStrategy
|
||||
|
||||
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Get();
|
||||
for (ObjectGuid targetGuid : prioritizedTargets) {
|
||||
if (targetGuid && attacker->GetGUID() == targetGuid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!attacker->IsAlive()) {
|
||||
return;
|
||||
}
|
||||
if (foundHighPriority) {
|
||||
return;
|
||||
}
|
||||
if (IsHighPriority(attacker)) {
|
||||
result = attacker;
|
||||
foundHighPriority = true;
|
||||
return;
|
||||
}
|
||||
if (!result || result->GetHealth() > attacker->GetHealth())
|
||||
result = attacker;
|
||||
}
|
||||
@@ -46,24 +39,17 @@ class FindMaxThreatGapTargetStrategy : public FindTargetStrategy
|
||||
|
||||
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Get();
|
||||
for (ObjectGuid targetGuid : prioritizedTargets) {
|
||||
if (targetGuid && attacker->GetGUID() == targetGuid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!attacker->IsAlive()) {
|
||||
return;
|
||||
}
|
||||
if (foundHighPriority) {
|
||||
return;
|
||||
}
|
||||
if (IsHighPriority(attacker)) {
|
||||
result = attacker;
|
||||
foundHighPriority = true;
|
||||
return;
|
||||
}
|
||||
Unit* victim = attacker->GetVictim();
|
||||
if (!result || CalcThreatGap(attacker, threatMgr) > CalcThreatGap(result, &result->GetThreatMgr()))
|
||||
result = attacker;
|
||||
@@ -85,24 +71,17 @@ class CasterFindTargetSmartStrategy : public FindTargetStrategy
|
||||
|
||||
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Get();
|
||||
for (ObjectGuid targetGuid : prioritizedTargets) {
|
||||
if (targetGuid && attacker->GetGUID() == targetGuid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!attacker->IsAlive()) {
|
||||
return;
|
||||
}
|
||||
if (foundHighPriority) {
|
||||
return;
|
||||
}
|
||||
if (IsHighPriority(attacker)) {
|
||||
result = attacker;
|
||||
foundHighPriority = true;
|
||||
return;
|
||||
}
|
||||
float expectedLifeTime = attacker->GetHealth() / dps_;
|
||||
// Unit* victim = attacker->GetVictim();
|
||||
if (!result || IsBetter(attacker, result)) {
|
||||
@@ -159,24 +138,17 @@ class NonCasterFindTargetSmartStrategy : public FindTargetStrategy
|
||||
|
||||
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Get();
|
||||
for (ObjectGuid targetGuid : prioritizedTargets) {
|
||||
if (targetGuid && attacker->GetGUID() == targetGuid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!attacker->IsAlive()) {
|
||||
return;
|
||||
}
|
||||
if (foundHighPriority) {
|
||||
return;
|
||||
}
|
||||
if (IsHighPriority(attacker)) {
|
||||
result = attacker;
|
||||
foundHighPriority = true;
|
||||
return;
|
||||
}
|
||||
float expectedLifeTime = attacker->GetHealth() / dps_;
|
||||
// Unit* victim = attacker->GetVictim();
|
||||
if (!result || IsBetter(attacker, result)) {
|
||||
@@ -221,24 +193,17 @@ class ComboFindTargetSmartStrategy : public FindTargetStrategy
|
||||
|
||||
void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) override
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Get();
|
||||
for (ObjectGuid targetGuid : prioritizedTargets) {
|
||||
if (targetGuid && attacker->GetGUID() == targetGuid) {
|
||||
result = attacker;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!attacker->IsAlive()) {
|
||||
return;
|
||||
}
|
||||
if (foundHighPriority) {
|
||||
return;
|
||||
}
|
||||
if (IsHighPriority(attacker)) {
|
||||
result = attacker;
|
||||
foundHighPriority = true;
|
||||
return;
|
||||
}
|
||||
float expectedLifeTime = attacker->GetHealth() / dps_;
|
||||
// Unit* victim = attacker->GetVictim();
|
||||
if (!result || IsBetter(attacker, result)) {
|
||||
|
||||
@@ -100,6 +100,24 @@ void FindTargetStrategy::GetPlayerCount(Unit* creature, uint32* tankCount, uint3
|
||||
dpsCountCache[creature] = *dpsCount;
|
||||
}
|
||||
|
||||
bool FindTargetStrategy::IsHighPriority(Unit* attacker)
|
||||
{
|
||||
if (Group* group = botAI->GetBot()->GetGroup())
|
||||
{
|
||||
ObjectGuid guid = group->GetTargetIcon(4);
|
||||
if (guid && attacker->GetGUID() == guid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
GuidVector prioritizedTargets = botAI->GetAiObjectContext()->GetValue<GuidVector>("prioritized targets")->Get();
|
||||
for (ObjectGuid targetGuid : prioritizedTargets) {
|
||||
if (targetGuid && attacker->GetGUID() == targetGuid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldPosition LastLongMoveValue::Calculate()
|
||||
{
|
||||
LastMovement& lastMove = *context->GetValue<LastMovement&>("last movement");
|
||||
|
||||
@@ -21,12 +21,14 @@ class FindTargetStrategy
|
||||
Unit* GetResult();
|
||||
virtual void CheckAttacker(Unit* attacker, ThreatMgr* threatMgr) = 0;
|
||||
void GetPlayerCount(Unit* creature, uint32* tankCount, uint32* dpsCount);
|
||||
bool IsHighPriority(Unit* attacker);
|
||||
|
||||
protected:
|
||||
Unit* result;
|
||||
PlayerbotAI* botAI;
|
||||
std::map<Unit*, uint32> tankCountCache;
|
||||
std::map<Unit*, uint32> dpsCountCache;
|
||||
bool foundHighPriority = false;
|
||||
};
|
||||
|
||||
class FindNonCcTargetStrategy : public FindTargetStrategy
|
||||
|
||||
Reference in New Issue
Block a user