mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
to be squashed with standground commit
This commit is contained in:
parent
2447d8d01c
commit
cabf1b6d76
2 changed files with 13 additions and 1 deletions
|
|
@ -271,6 +271,15 @@ Attack.prototype.CanAttack = function(target, wantedTypes)
|
|||
if (!cmpTargetPlayer || !cmpEntityPlayer)
|
||||
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 entityOwner = cmpEntityPlayer.GetPlayerID();
|
||||
const targetOwner = cmpTargetPlayer.GetPlayerID();
|
||||
|
|
|
|||
|
|
@ -6386,7 +6386,10 @@ UnitAI.prototype.GetQueryRange = function(iid)
|
|||
if (!range)
|
||||
return ret;
|
||||
ret.min = range.min;
|
||||
ret.max = Math.min(range.max, visionRange);
|
||||
// Use full attack range (not capped by vision) for StandGround.
|
||||
// Enemies visible through allied vision or as mirages are valid targets;
|
||||
// completely hidden enemies are filtered out by Attack.CanAttack's visibility check.
|
||||
ret.max = range.max;
|
||||
// For StandGround, the 'parabolic' flag is set so that the caller can create a
|
||||
// parabolic query instead of a flat one. This ensures elevation bonuses are
|
||||
// properly accounted for when detecting enemies.
|
||||
|
|
|
|||
Loading…
Reference in a new issue