mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-13 09:07:19 +00: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)) {
|
||||
|
||||
Reference in New Issue
Block a user