From fd1d030cb0bb269d22cc9fcd4c92e3ed1d8fa8d3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 8 Dec 2016 18:16:30 +0000 Subject: [PATCH 1/3] Add GroundPosition support to HiddenUnder(Shroud|Fog). --- OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderFog.cs | 6 +++++- OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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 bbedbcfc7c..53b22958a7 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/HiddenUnderShroud.cs @@ -44,7 +44,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) From 7a9174e7fc37bf2d08dbf418e9e84cf09c28855d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 8 Dec 2016 18:19:00 +0000 Subject: [PATCH 2/3] Fix aircraft defaults. --- mods/cnc/rules/defaults.yaml | 4 ++-- mods/d2k/rules/defaults.yaml | 2 +- mods/ra/rules/defaults.yaml | 2 +- mods/ts/rules/defaults.yaml | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 6786586e8c..5685a7606c 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -204,7 +204,7 @@ CruisingUpgrades: cruising CanHover: True HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition ActorLostNotification: Explodes: Weapon: HeliExplode @@ -500,7 +500,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 1c4a8846dc..0241a2bb07 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 d7ad8b18c0..015f32b942 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -432,7 +432,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 679010a8d5..296d7a22eb 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -571,7 +571,7 @@ Voiced: VoiceSet: Heli HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AttackMove: Voice: Move ActorLostNotification: @@ -614,7 +614,7 @@ Armor: Type: Heavy HiddenUnderFog: - Type: CenterPosition + Type: GroundPosition AutoTargetIgnore: ScriptTriggers: Tooltip: From 83564ecc60e6a76ec342372818bc06429f6135cf Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 8 Dec 2016 18:33:55 +0000 Subject: [PATCH 3/3] Nudge aircraft back inside the map. --- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index c43946e7f8..e946af5f72 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -228,6 +228,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;