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();)
|
||||
{
|
||||
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;
|
||||
++tIter;
|
||||
@@ -113,15 +113,6 @@ void AttackersValue::RemoveNonThreating(std::unordered_set<Unit*>& targets)
|
||||
else
|
||||
++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)
|
||||
@@ -160,7 +151,7 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
||||
// bool inCannon = botAI->IsInVehicle(false, true);
|
||||
// bool enemy = botAI->GetAiObjectContext()->GetValue<Unit*>("enemy player target")->Get();
|
||||
|
||||
return attacker &&
|
||||
return attacker && attacker->IsVisible() &&
|
||||
attacker->IsInWorld() &&
|
||||
attacker->GetMapId() == bot->GetMapId() &&
|
||||
!attacker->isDead() &&
|
||||
@@ -183,10 +174,10 @@ bool AttackersValue::IsPossibleTarget(Unit* attacker, Player* bot, float range)
|
||||
|
||||
bool AttackersValue::IsValidTarget(Unit *attacker, Player *bot)
|
||||
{
|
||||
return attacker->IsVisible() &&
|
||||
IsPossibleTarget(attacker, bot) &&
|
||||
(attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
|
||||
attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
|
||||
return bot->IsWithinLOSInMap(attacker) &&
|
||||
IsPossibleTarget(attacker, bot);
|
||||
// (attacker->GetThreatMgr().getCurrentVictim() || attacker->GetGuidValue(UNIT_FIELD_TARGET) ||
|
||||
// attacker->GetGUID().IsPlayer() || attacker->GetGUID() == GET_PLAYERBOT_AI(bot)->GetAiObjectContext()->GetValue<ObjectGuid>("pull target")->Get());
|
||||
}
|
||||
|
||||
bool PossibleAddsValue::Calculate()
|
||||
|
||||
@@ -27,9 +27,7 @@ bool InvalidTargetValue::Calculate()
|
||||
target->isFeared() ||
|
||||
target->HasUnitState(UNIT_STATE_ISOLATED) ||
|
||||
target->IsFriendlyTo(bot) ||
|
||||
!AttackersValue::IsValidTarget(target, bot) ||
|
||||
// !bot->IsWithinDistInMap(target, sPlayerbotAIConfig->sightDistance) ||
|
||||
!bot->IsWithinLOSInMap(target);
|
||||
!AttackersValue::IsValidTarget(target, bot);
|
||||
}
|
||||
|
||||
return !target;
|
||||
|
||||
Reference in New Issue
Block a user