diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 686f62a19d..0d210d7912 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -181,6 +181,9 @@ + + + @@ -256,11 +259,11 @@ - \ No newline at end of file diff --git a/OpenRa.Game/Traits/APMine.cs b/OpenRa.Game/Traits/APMine.cs index 7dfbbfa7cb..41a6b3db9c 100644 --- a/OpenRa.Game/Traits/APMine.cs +++ b/OpenRa.Game/Traits/APMine.cs @@ -5,16 +5,20 @@ using OpenRa.Game.GameRules; using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { - class APMine : ICrushable + class APMine : ICrushable, IOccupySpace { readonly Actor self; public APMine(Actor self) { this.self = self; + Game.UnitInfluence.Add(self, this); } public void OnCrush(Actor crusher) { + if (crusher.traits.Contains() && crusher.Owner == self.Owner) + return; + Game.world.AddFrameEndTask(_ => { Game.world.Remove(self); @@ -33,9 +37,15 @@ namespace OpenRa.Game.Traits // Mines should explode indiscriminantly of player switch (umt) { - case UnitMovementType.Foot: return true; + case UnitMovementType.Foot: + case UnitMovementType.Wheel: + case UnitMovementType.Track: + return true; + default: return false; } } + + public IEnumerable OccupiedCells() { yield return self.Location; } } } diff --git a/OpenRa.Game/Traits/ATMine.cs b/OpenRa.Game/Traits/ATMine.cs index e81dc51d34..9ee444195c 100644 --- a/OpenRa.Game/Traits/ATMine.cs +++ b/OpenRa.Game/Traits/ATMine.cs @@ -6,16 +6,20 @@ using OpenRa.Game.Effects; namespace OpenRa.Game.Traits { - class ATMine : ICrushable + class ATMine : ICrushable, IOccupySpace { readonly Actor self; public ATMine(Actor self) { this.self = self; + Game.UnitInfluence.Add(self, this); } public void OnCrush(Actor crusher) { + if (crusher.traits.Contains() && crusher.Owner == self.Owner) + return; + Game.world.AddFrameEndTask(_ => { Game.world.Remove(self); @@ -39,5 +43,7 @@ namespace OpenRa.Game.Traits default: return false; } } + + public IEnumerable OccupiedCells() { yield return self.Location; } } } diff --git a/OpenRa.Game/Traits/InvisibleToOthers.cs b/OpenRa.Game/Traits/InvisibleToOthers.cs new file mode 100644 index 0000000000..f04dbe7555 --- /dev/null +++ b/OpenRa.Game/Traits/InvisibleToOthers.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game.Traits +{ + class InvisibleToOthers : IRenderModifier + { + public InvisibleToOthers(Actor self) { } + + public IEnumerable ModifyRender(Actor self, IEnumerable r) + { + return Game.LocalPlayer == self.Owner + ? r : new Renderable[] { }; + } + } +} diff --git a/OpenRa.Game/Traits/MineImmune.cs b/OpenRa.Game/Traits/MineImmune.cs new file mode 100644 index 0000000000..d711a036ba --- /dev/null +++ b/OpenRa.Game/Traits/MineImmune.cs @@ -0,0 +1,8 @@ + +namespace OpenRa.Game.Traits +{ + class MineImmune + { + public MineImmune(Actor self) { } + } +} diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs new file mode 100644 index 0000000000..59cfd9ffa3 --- /dev/null +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game.Traits +{ + class Minelayer : IOrder + { + public Minelayer(Actor self) { } + + public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor) + { + // todo: check for ammo + if (mi.Button == MouseButton.Right && underCursor == self) + return new Order("Deploy", self, null, int2.Zero, null); + + return null; + } + + public void ResolveOrder(Actor self, Order order) + { + if (order.OrderString == "Deploy") + { + // todo: check for and adjust ammo + // todo: delay a bit? + + Game.world.AddFrameEndTask( + w => w.Add(new Actor(Rules.UnitInfo[self.Info.Primary], self.Location, self.Owner))); + } + } + } +} diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 88d5a3123d..a9b7c6b5bd 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -83,7 +83,7 @@ namespace OpenRa.Game.Traits case "Plane": return UnitMovementType.Fly; default: - throw new InvalidOperationException("GetMovementType on unit that shouldn't be aable to move."); + throw new InvalidOperationException("GetMovementType on unit that shouldn't be able to move."); } } diff --git a/rules.ini b/rules.ini index 80f49d6f47..9e5b7d1afe 100644 --- a/rules.ini +++ b/rules.ini @@ -369,14 +369,33 @@ Tracked=yes Passengers=5 ; mine layer -[MNLY] +[MNLY.AP] Prerequisite=weap,fix Strength=100 Armor=heavy +Image=MNLY +Icon=MNLYICON TechLevel=3 Sight=5 Speed=9 -Owner=allies,soviet +Owner=soviet +Cost=800 +Points=50 +ROT=5 +Tracked=yes +Ammo=5 ; number of mines carried +Crewed=yes + +[MNLY.AT] +Prerequisite=weap,fix +Strength=100 +Armor=heavy +Image=MNLY +Icon=MNLYICON +TechLevel=3 +Sight=5 +Speed=9 +Owner=allies Cost=800 Points=50 ROT=5 diff --git a/sequences.xml b/sequences.xml index bd4e197c35..98e7d26236 100644 --- a/sequences.xml +++ b/sequences.xml @@ -981,4 +981,10 @@ + + + + + + \ No newline at end of file diff --git a/units.ini b/units.ini index 5869be9b95..dd3807c0bc 100755 --- a/units.ini +++ b/units.ini @@ -11,7 +11,8 @@ HARV MCV JEEP APC -MNLY +MNLY.AP +MNLY.AT [V2RL] Description=V2 Rocket @@ -88,12 +89,19 @@ Traits=Unit, Mobile, McvDeploy, RenderUnit SelectionPriority=3 Voice=VehicleVoice LongDesc=Deploys into another Construction Yard.\n Unarmed -[MNLY] -Description=Minelayer -Traits=Unit, Mobile, RenderUnit + +[MNLY.AP] +Description=Minelayer (Anti-Personnel) +Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune Voice=VehicleVoice LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed - +Primary=MINP ;; temporary hack +[MNLY.AT] +Description=Minelayer (Anti-Tank) +Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune +Voice=VehicleVoice +LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed +Primary=MINV ;; temporary hack @@ -314,7 +322,10 @@ WEAF SYRF SPEF DOMF -; TODO? : campaign-specific stuff - FCOM, civilian buildings, etc + +; pseudo-buildings +MINP +MINV ; `Dimensions` is the size of a box that will include the whole building, excluding bib. @@ -505,8 +516,13 @@ LongDesc=Looks like a Radar Dome ;SelectionPriority=3 +[MINV] +Traits=Unit,RenderUnit,ATMine,BelowUnits,InvisibleToOthers +Selectable=no - +[MINP] +Traits=Unit,RenderUnit,APMine,BelowUnits,InvisibleToOthers +Selectable=no [InfantryTypes] DOG