diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 8b19fe40df..47c911cb4f 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -230,6 +230,15 @@ namespace OpenRA.Mods.Common.Traits repulsionForce += GetRepulsionForce(actor); } + // Actors outside the map bounds receive an extra nudge towards the center of the map + if (!self.World.Map.Contains(self.Location)) + { + // The map bounds are in projected coordinates, which is technically wrong for this, + // but we avoid the issues in practice by guessing the middle of the map instead of the edge + var center = WPos.Lerp(self.World.Map.ProjectedTopLeft, self.World.Map.ProjectedBottomRight, 1, 2); + repulsionForce += new WVec(1024, 0, 0).Rotate(WRot.FromYaw((self.CenterPosition - center).Yaw)); + } + if (Info.CanHover) return repulsionForce; diff --git a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderFog.cs b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderFog.cs index c668a2ffbe..063b71fc5a 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderFog.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderFog.cs @@ -31,7 +31,11 @@ namespace OpenRA.Mods.Common.Traits if (Info.Type == VisibilityType.Footprint) return byPlayer.Shroud.AnyVisible(self.OccupiesSpace.OccupiedCells()); - return byPlayer.Shroud.IsVisible(self.CenterPosition); + var pos = self.CenterPosition; + if (Info.Type == VisibilityType.GroundPosition) + pos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(pos)); + + return byPlayer.Shroud.IsVisible(pos); } } } diff --git a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs index a49182845f..739066e5a3 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs @@ -42,7 +42,11 @@ namespace OpenRA.Mods.Common.Traits if (Info.Type == VisibilityType.Footprint) return byPlayer.Shroud.AnyExplored(self.OccupiesSpace.OccupiedCells()); - return byPlayer.Shroud.IsExplored(self.CenterPosition); + var pos = self.CenterPosition; + if (Info.Type == VisibilityType.GroundPosition) + pos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(pos)); + + return byPlayer.Shroud.IsExplored(pos); } public bool IsVisible(Actor self, Player byPlayer) diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index b4dd0a4f0b..bd13ca3576 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -206,7 +206,7 @@ CruisingCondition: cruising CanHover: True HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition ActorLostNotification: Explodes: Weapon: HeliExplode @@ -502,7 +502,7 @@ AppearsOnRadar: UseLocation: yes HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AlwaysVisibleStances: None ActorLostNotification: AttackMove: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index ca0edf36ba..82510b2530 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -299,7 +299,7 @@ AppearsOnRadar: UseLocation: true HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AlwaysVisibleStances: None ActorLostNotification: AttackMove: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 8e17e5ac05..157ae8fe77 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -436,7 +436,7 @@ TargetTypes: Air RequiresCondition: airborne HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AttackMove: Guard: Guardable: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 435e15b237..70809b20e0 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -579,7 +579,7 @@ Voiced: VoiceSet: Heli HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AttackMove: Voice: Move ActorLostNotification: @@ -622,7 +622,7 @@ Armor: Type: Heavy HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AutoTargetIgnore: ScriptTriggers: Tooltip: