mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
[Attack target] Valid target check
This commit is contained in:
@@ -104,7 +104,7 @@ void AttackersValue::RemoveNonThreating(std::unordered_set<Unit*>& targets)
|
|||||||
for(std::unordered_set<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();)
|
for(std::unordered_set<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();)
|
||||||
{
|
{
|
||||||
Unit* unit = *tIter;
|
Unit* unit = *tIter;
|
||||||
if(bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit) || !IsValidTarget(unit, bot) || !bot->IsWithinLOSInMap(unit))
|
if(bot->GetMapId() != unit->GetMapId() || !hasRealThreat(unit) || !IsValidTarget(unit, bot))
|
||||||
{
|
{
|
||||||
std::unordered_set<Unit *>::iterator tIter2 = tIter;
|
std::unordered_set<Unit *>::iterator tIter2 = tIter;
|
||||||
++tIter;
|
++tIter;
|
||||||
@@ -113,15 +113,6 @@ void AttackersValue::RemoveNonThreating(std::unordered_set<Unit*>& targets)
|
|||||||
else
|
else
|
||||||
++tIter;
|
++tIter;
|
||||||
}
|
}
|
||||||
// Unit* unit = *tIter;
|
|
||||||
// if (!IsValidTarget(unit, bot) || !bot->IsWithinLOSInMap(unit))
|
|
||||||
// {
|
|
||||||
// std::unordered_set<Unit*>::iterator tIter2 = tIter;
|
|
||||||
// ++tIter;
|
|
||||||
// targets.erase(tIter2);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// ++tIter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttackersValue::hasRealThreat(Unit *attacker)
|
bool AttackersValue::hasRealThreat(Unit *attacker)
|
||||||
@@ -160,7 +151,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
|||||||
// bool inCannon = botAI->IsInVehicle(false, true);
|
// bool inCannon = botAI->IsInVehicle(false, true);
|
||||||
// bool enemy = botAI->GetAiObjectContext()->GetValue<Unit*>("enemy player target")->Get();
|
// bool enemy = botAI->GetAiObjectContext()->GetValue<Unit*>("enemy player target")->Get();
|
||||||
|
|
||||||
return attacker &&
|
return attacker && attacker->IsVisible() &&
|
||||||
attacker->IsInWorld() &&
|
attacker->IsInWorld() &&
|
||||||
attacker->GetMapId() == bot->GetMapId() &&
|
attacker->GetMapId() == bot->GetMapId() &&
|
||||||
!attacker->isDead() &&
|
!attacker->isDead() &&
|
||||||
@@ -183,10 +174,10 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
|||||||
|
|
||||||
bool AttackersValue::IsValidTarget(Unit *attacker, Player *bot)
|
bool AttackersValue::IsValidTarget(Unit *attacker, Player *bot)
|
||||||
{
|
{
|
||||||
return attacker->IsVisible() &&
|
return bot->IsWithinLOSInMap(attacker) &&
|
||||||
IsPossibleTarget(attacker, bot) &&
|
IsPossibleTarget(attacker, bot);
|
||||||
(attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
|
// (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
|
||||||
attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
|
// attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PossibleAddsValue::Calculate()
|
bool PossibleAddsValue::Calculate()
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ bool InvalidTargetValue::Calculate()
|
|||||||
target->isFeared() ||
|
target->isFeared() ||
|
||||||
target->HasUnitState(UNIT_STATE_ISOLATED) ||
|
target->HasUnitState(UNIT_STATE_ISOLATED) ||
|
||||||
target->IsFriendlyTo(bot) ||
|
target->IsFriendlyTo(bot) ||
|
||||||
!AttackersValue::IsValidTarget(target, bot) ||
|
!AttackersValue::IsValidTarget(target, bot);
|
||||||
// !bot->IsWithinDistInMap(target, sPlayerbotAIConfig->sightDistance) ||
|
|
||||||
!bot->IsWithinLOSInMap(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return !target;
|
return !target;
|
||||||
|
|||||||
Reference in New Issue
Block a user