mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 18:24:12 +00:00
Fix for Area of Affect Behaviors targeting incorrect entities
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -371,7 +371,7 @@ public:
|
||||
* @param ignoreFactions whether or not check for the factions, e.g. just return true if the entity cannot be smashed
|
||||
* @return if the target ID is a valid enemy
|
||||
*/
|
||||
bool CheckValidity(LWOOBJID target, bool ignoreFactions = false) const;
|
||||
bool CheckValidity(LWOOBJID target, bool ignoreFactions = false, bool targetEnemy = true, bool targetFriend = false) const;
|
||||
|
||||
/**
|
||||
* Attempt to damage this entity, handles everything from health and armor to absorption, immunity and callbacks.
|
||||
|
Reference in New Issue
Block a user