Fix for Area of Affect Behaviors targeting incorrect entities

This commit is contained in:
Jacob Hofer
2022-01-02 20:37:03 +00:00
parent 203e75ef3d
commit 1ddf7d1f94
6 changed files with 20 additions and 8 deletions

View File

@@ -498,7 +498,7 @@ Entity* DestroyableComponent::GetKiller() const
return EntityManager::Instance()->GetEntity(m_KillerID);
}
bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignoreFactions) const
bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignoreFactions, const bool targetEnemy, const bool targetFriend) const
{
auto* entity = EntityManager::Instance()->GetEntity(target);
@@ -537,15 +537,19 @@ bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignor
auto candidateList = destroyable->GetFactionIDs();
bool isEnemy = false;
for (auto value : candidateList)
{
if (std::find(enemyList.begin(), enemyList.end(), value) != enemyList.end())
{
return true;
isEnemy = true;
break;
}
}
return false;
return (isEnemy && targetEnemy) || (!isEnemy && targetFriend);
}