From eab8b653fd1c60f65498399478b473a65f3179f6 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 10:09:43 +1300 Subject: [PATCH 1/8] minelayer maybe works --- OpenRa.Game/OpenRa.Game.csproj | 1 + OpenRa.Game/Traits/Minelayer.cs | 33 +++++++++++++++++++++++++++++++++ OpenRa.Game/UnitOrders.cs | 22 +++++----------------- sequences.xml | 10 ++++++++-- units.ini | 15 ++++++++++++--- 5 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 OpenRa.Game/Traits/Minelayer.cs diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 3ea793d682..af63cacf7b 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -181,6 +181,7 @@ + diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs new file mode 100644 index 0000000000..d683961ad6 --- /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("DeployMine", self, null, int2.Zero, null); + + return null; + } + + public void ResolveOrder(Actor self, Order order) + { + if (order.OrderString == "DeployMine") + { + // 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/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index 459a833627..fa9b2b858f 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -13,22 +13,6 @@ namespace OpenRa.Game { switch( order.OrderString ) { - case "Move": - case "Attack": - case "DeployMcv": - case "Enter": - case "Harvest": - case "SetRallyPoint": - case "StartProduction": - case "PauseProduction": - case "CancelProduction": - case "ActivatePortableChronoshift": - case "UsePortableChronoshift": - { - foreach( var t in order.Subject.traits.WithInterface() ) - t.ResolveOrder( order.Subject, order ); - break; - } case "PlaceBuilding": { Game.world.AddFrameEndTask( _ => @@ -114,7 +98,11 @@ namespace OpenRa.Game } default: - throw new NotImplementedException(); + { + foreach (var t in order.Subject.traits.WithInterface()) + t.ResolveOrder(order.Subject, order); + break; + } } } } diff --git a/sequences.xml b/sequences.xml index fe841d91a2..98e7d26236 100644 --- a/sequences.xml +++ b/sequences.xml @@ -498,12 +498,12 @@ - + - + @@ -981,4 +981,10 @@ + + + + + + \ No newline at end of file diff --git a/units.ini b/units.ini index 63b3ea8524..4dae19790f 100755 --- a/units.ini +++ b/units.ini @@ -88,9 +88,10 @@ Voice=VehicleVoice LongDesc=Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft [MNLY] Description=Minelayer -Traits=Unit, Mobile, RenderUnit +Traits=Unit, Mobile, RenderUnit, Minelayer Voice=VehicleVoice LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed +Primary=MINV ;; temporary hack @@ -312,7 +313,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. @@ -503,8 +507,13 @@ LongDesc=Looks like a Radar Dome ;SelectionPriority=3 +[MINV] +Traits=Unit,RenderUnit,ATMine +Selectable=no - +[MINP] +Traits=Unit,RenderUnit,APMine +Selectable=no [InfantryTypes] DOG From 06512b270d6b3da67c7a635343d6f725f2d8db7d Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 10:14:13 +1300 Subject: [PATCH 2/8] that wasnt right --- units.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/units.ini b/units.ini index 4dae19790f..c963d7cfab 100755 --- a/units.ini +++ b/units.ini @@ -508,11 +508,11 @@ LongDesc=Looks like a Radar Dome [MINV] -Traits=Unit,RenderUnit,ATMine +Traits=Unit,RenderUnit,ATMine,BelowUnits Selectable=no [MINP] -Traits=Unit,RenderUnit,APMine +Traits=Unit,RenderUnit,APMine,BelowUnits Selectable=no [InfantryTypes] From ea7638adfa598f996b0457258d248354d46f69e6 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 10:23:44 +1300 Subject: [PATCH 3/8] mines are invisible to others --- OpenRa.Game/OpenRa.Game.csproj | 1 + OpenRa.Game/Traits/InvisibleToOthers.cs | 18 ++++++++++++++++++ OpenRa.Game/Traits/Mobile.cs | 2 +- units.ini | 4 ++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 OpenRa.Game/Traits/InvisibleToOthers.cs diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index af63cacf7b..0c8a467e2c 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -181,6 +181,7 @@ + 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/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index e1fd485391..cb389f4cc6 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/units.ini b/units.ini index c963d7cfab..5024eb410e 100755 --- a/units.ini +++ b/units.ini @@ -508,11 +508,11 @@ LongDesc=Looks like a Radar Dome [MINV] -Traits=Unit,RenderUnit,ATMine,BelowUnits +Traits=Unit,RenderUnit,ATMine,BelowUnits,InvisibleToOthers Selectable=no [MINP] -Traits=Unit,RenderUnit,APMine,BelowUnits +Traits=Unit,RenderUnit,APMine,BelowUnits,InvisibleToOthers Selectable=no [InfantryTypes] From c0998b11c78c546a90dcd386972de40d0dd8393e Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 16:51:58 +1300 Subject: [PATCH 4/8] split mnly into ap/at variants --- rules.ini | 23 +++++++++++++++++++++-- units.ini | 15 +++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) 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/units.ini b/units.ini index c25e35aa91..2f40525bee 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,8 +89,15 @@ Traits=Unit, Mobile, McvDeploy, RenderUnit SelectionPriority=3 Voice=VehicleVoice LongDesc=Deploys into another Construction Yard.\n Unarmed -[MNLY] -Description=Minelayer + +[MNLY.AP] +Description=Minelayer (Anti-Personnel) +Traits=Unit, Mobile, RenderUnit, Minelayer +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 Voice=VehicleVoice LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed @@ -97,7 +105,6 @@ Primary=MINV ;; temporary hack - [ShipTypes] SS DD From 061c0ccb3f8f16909b57df26ed3fd70b1d2982d9 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 16:57:58 +1300 Subject: [PATCH 5/8] UIM for those --- OpenRa.Game/Traits/APMine.cs | 5 ++++- OpenRa.Game/Traits/ATMine.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRa.Game/Traits/APMine.cs b/OpenRa.Game/Traits/APMine.cs index 7dfbbfa7cb..deebaf87f1 100644 --- a/OpenRa.Game/Traits/APMine.cs +++ b/OpenRa.Game/Traits/APMine.cs @@ -5,12 +5,13 @@ 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) @@ -37,5 +38,7 @@ namespace OpenRa.Game.Traits 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..5dcff3c452 100644 --- a/OpenRa.Game/Traits/ATMine.cs +++ b/OpenRa.Game/Traits/ATMine.cs @@ -6,12 +6,13 @@ 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) @@ -39,5 +40,7 @@ namespace OpenRa.Game.Traits default: return false; } } + + public IEnumerable OccupiedCells() { yield return self.Location; } } } From a2db9950f374fac5959b216f807a225aaf2cde64 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 16:58:26 +1300 Subject: [PATCH 6/8] changed order name to get the right cursor --- OpenRa.Game/Traits/Minelayer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRa.Game/Traits/Minelayer.cs b/OpenRa.Game/Traits/Minelayer.cs index d683961ad6..59cfd9ffa3 100644 --- a/OpenRa.Game/Traits/Minelayer.cs +++ b/OpenRa.Game/Traits/Minelayer.cs @@ -13,14 +13,14 @@ namespace OpenRa.Game.Traits { // todo: check for ammo if (mi.Button == MouseButton.Right && underCursor == self) - return new Order("DeployMine", self, null, int2.Zero, null); + return new Order("Deploy", self, null, int2.Zero, null); return null; } public void ResolveOrder(Actor self, Order order) { - if (order.OrderString == "DeployMine") + if (order.OrderString == "Deploy") { // todo: check for and adjust ammo // todo: delay a bit? From 6a31fdef97945a45b447a656a0dfd0f429fdbd83 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 17:47:35 +1300 Subject: [PATCH 7/8] MineImmune trait --- OpenRa.Game/OpenRa.Game.csproj | 5 +++-- OpenRa.Game/Traits/MineImmune.cs | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 OpenRa.Game/Traits/MineImmune.cs diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index dfc52282ad..0d210d7912 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -1,4 +1,4 @@ - + Debug AnyCPU @@ -182,6 +182,7 @@ + @@ -265,4 +266,4 @@ --> - + \ No newline at end of file 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) { } + } +} From 3fa86b25429be4900d2a6312a02f30cc6c6c8d00 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 18:02:25 +1300 Subject: [PATCH 8/8] MNLY immune to own mines --- OpenRa.Game/Traits/APMine.cs | 9 ++++++++- OpenRa.Game/Traits/ATMine.cs | 3 +++ units.ini | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Traits/APMine.cs b/OpenRa.Game/Traits/APMine.cs index deebaf87f1..41a6b3db9c 100644 --- a/OpenRa.Game/Traits/APMine.cs +++ b/OpenRa.Game/Traits/APMine.cs @@ -16,6 +16,9 @@ namespace OpenRa.Game.Traits public void OnCrush(Actor crusher) { + if (crusher.traits.Contains() && crusher.Owner == self.Owner) + return; + Game.world.AddFrameEndTask(_ => { Game.world.Remove(self); @@ -34,7 +37,11 @@ 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; } } diff --git a/OpenRa.Game/Traits/ATMine.cs b/OpenRa.Game/Traits/ATMine.cs index 5dcff3c452..9ee444195c 100644 --- a/OpenRa.Game/Traits/ATMine.cs +++ b/OpenRa.Game/Traits/ATMine.cs @@ -17,6 +17,9 @@ namespace OpenRa.Game.Traits public void OnCrush(Actor crusher) { + if (crusher.traits.Contains() && crusher.Owner == self.Owner) + return; + Game.world.AddFrameEndTask(_ => { Game.world.Remove(self); diff --git a/units.ini b/units.ini index 2f40525bee..dd3807c0bc 100755 --- a/units.ini +++ b/units.ini @@ -92,13 +92,13 @@ LongDesc=Deploys into another Construction Yard.\n Unarmed [MNLY.AP] Description=Minelayer (Anti-Personnel) -Traits=Unit, Mobile, RenderUnit, Minelayer +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 +Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune Voice=VehicleVoice LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed Primary=MINV ;; temporary hack