mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Filter out hidden targets in CanAttack
Units should not be able to attack entities with "hidden" visibility. Visible and fogged (mirage/retainInFog) targets remain attackable.
This commit is contained in:
parent
41076070a6
commit
accfd151ed
1 changed files with 9 additions and 0 deletions
|
|
@ -286,6 +286,15 @@ Attack.prototype.CanAttack = function(target, wantedTypes)
|
||||||
if (!cmpTargetPlayer || !cmpEntityPlayer)
|
if (!cmpTargetPlayer || !cmpEntityPlayer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Must be visible or miraged / with retainInFog flag, not completely hidden
|
||||||
|
const cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||||
|
if (cmpRangeManager)
|
||||||
|
{
|
||||||
|
const visibility = cmpRangeManager.GetLosVisibility(target, cmpEntityPlayer.GetPlayerID());
|
||||||
|
if (visibility == "hidden")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const types = this.GetAttackTypes(wantedTypes);
|
const types = this.GetAttackTypes(wantedTypes);
|
||||||
const entityOwner = cmpEntityPlayer.GetPlayerID();
|
const entityOwner = cmpEntityPlayer.GetPlayerID();
|
||||||
const targetOwner = cmpTargetPlayer.GetPlayerID();
|
const targetOwner = cmpTargetPlayer.GetPlayerID();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue