From e6ded0e491dc511af36f91fab1037e21a0abfbf7 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 25 Jan 2010 00:28:43 +1300 Subject: [PATCH] Mostly implemented Sonar Pulse --- OpenRa.Game/OpenRa.Game.csproj | 1 + OpenRa.Game/Traits/SonarPulsePower.cs | 30 ++++ OpenRa.Game/Traits/SupportPower.cs | 7 +- OpenRa.Mods.RA/InfiltrateForSonarPulse.cs | 17 +++ OpenRa.Mods.RA/OpenRa.Mods.RA.csproj | 1 + mods/ra/merge-rules.yaml | 19 ++- mods/ra/rules.yaml | 158 ++++++++++++---------- mods/ra/units.ini | 23 +--- 8 files changed, 158 insertions(+), 98 deletions(-) create mode 100644 OpenRa.Game/Traits/SonarPulsePower.cs create mode 100644 OpenRa.Mods.RA/InfiltrateForSonarPulse.cs diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 025eccea47..21466b0a3d 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -224,6 +224,7 @@ + diff --git a/OpenRa.Game/Traits/SonarPulsePower.cs b/OpenRa.Game/Traits/SonarPulsePower.cs new file mode 100644 index 0000000000..7caa3fe088 --- /dev/null +++ b/OpenRa.Game/Traits/SonarPulsePower.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRa.Orders; + +namespace OpenRa.Traits +{ + public class SonarPulsePowerInfo : SupportPowerInfo + { + public override object Create(Actor self) { return new SonarPulsePower(self, this); } + } + + public class SonarPulsePower : SupportPower + { + public SonarPulsePower(Actor self, SonarPulsePowerInfo info) : base(self, info) { } + + protected override void OnBeginCharging() { } + protected override void OnFinishCharging() { Sound.Play("pulse1.aud"); } + protected override void OnActivate() + { + // Question: Is this method synced? or does it have to go via an order? + + // TODO: Reveal submarines + + // Should this play for all players? + Sound.Play("sonpulse.aud"); + FinishActivate(); + } + } +} diff --git a/OpenRa.Game/Traits/SupportPower.cs b/OpenRa.Game/Traits/SupportPower.cs index f69306598e..1ed738baed 100644 --- a/OpenRa.Game/Traits/SupportPower.cs +++ b/OpenRa.Game/Traits/SupportPower.cs @@ -5,7 +5,7 @@ using System.Text; namespace OpenRa.Traits { - abstract class SupportPowerInfo : ITraitInfo + public abstract class SupportPowerInfo : ITraitInfo { public readonly bool RequiresPower = true; public readonly bool OneShot = false; @@ -20,7 +20,7 @@ namespace OpenRa.Traits public abstract object Create(Actor self); } - class SupportPower : ITick + public class SupportPower : ITick { public readonly SupportPowerInfo Info; public int RemainingTime { get; private set; } @@ -58,7 +58,8 @@ namespace OpenRa.Traits } // Do we have enough powered prerequisites? - var isPowered = effectivePrereq.Any() && effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get().Disabled)); + // Hack in support for special powers without prereqs + var isPowered = (Info.Prerequisites.Count() == 0) ? self.Owner.GetPowerState() == PowerState.Normal : effectivePrereq.Any() && effectivePrereq.All(a => buildings[a].Any(b => !b.traits.Get().Disabled)); if (IsAvailable && (!Info.RequiresPower || isPowered)) { diff --git a/OpenRa.Mods.RA/InfiltrateForSonarPulse.cs b/OpenRa.Mods.RA/InfiltrateForSonarPulse.cs new file mode 100644 index 0000000000..098140ee57 --- /dev/null +++ b/OpenRa.Mods.RA/InfiltrateForSonarPulse.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using OpenRa.Traits; + +namespace OpenRa.Mods.RA +{ + class InfiltrateForSonarPulseInfo : StatelessTraitInfo { } + + class InfiltrateForSonarPulse : IAcceptSpy + { + public void OnInfiltrate(Actor self, Actor spy) + { + Game.world.LocalPlayer.PlayerActor.traits.Get().Give(1.0f); + } + } +} diff --git a/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj b/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj index a1ed1d7c47..a27a5f26fb 100644 --- a/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj +++ b/OpenRa.Mods.RA/OpenRa.Mods.RA.csproj @@ -52,6 +52,7 @@ + diff --git a/mods/ra/merge-rules.yaml b/mods/ra/merge-rules.yaml index 97bb46195a..5416eb31d0 100644 --- a/mods/ra/merge-rules.yaml +++ b/mods/ra/merge-rules.yaml @@ -38,9 +38,17 @@ Player: Image: atomicon ChargeTime: 13 Description: Atom Bomb - LongDesc: Launches a nuclear missile at your target. + LongDesc: Launches a nuclear missile at a target location. Prerequisites: MSLO TechLevel: 12 + SonarPulsePower: + Image: sonricon + ChargeTime: 10 + Description: Sonar Pulse + LongDesc: Reveals all submarines on the map for a \nshort time. + TechLevel: 5 + GivenAuto: no + OneShot: yes World: WaterPaletteRotation: @@ -93,6 +101,11 @@ BRIDGE2: Bridge: UseAlternateNames: yes - MSLO: - NukeSilo: \ No newline at end of file + NukeSilo: + +SPEN: + InfiltrateForSonarPulse: + +SYRD: + InfiltrateForSonarPulse: \ No newline at end of file diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index 0334300d53..357f0ca021 100644 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -34,6 +34,21 @@ Player: LongDesc: Reveals an area of the map. Prerequisites: AFLD TechLevel: 5 + NukePower: + Image: atomicon + ChargeTime: 13 + Description: Atom Bomb + LongDesc: Launches a nuclear missile at a target location. + Prerequisites: MSLO + TechLevel: 12 + SonarPulsePower: + Image: sonricon + ChargeTime: 10 + Description: Sonar Pulse + LongDesc: Reveals all submarines on the map for a \nshort time. + TechLevel: 5 + GivenAuto: no + OneShot: yes World: WaterPaletteRotation: @@ -197,6 +212,79 @@ BRIDGE2: Dimensions: 5,2 HP: 1000 +MSLO: + NukeSilo: + Inherits: ^Building + Buildable: + TechLevel: 13 + Prerequisites: @Tech Center + Owner: soviet,allies + Cost: 2500 + Description: Missile Silo + LongDesc: Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile + Building: + Power: -100 + Footprint: xx + Dimensions: 2,1 + HP: 400 + Armor: heavy + Crewed: yes + Sight: 5 + RenderBuilding: + IronCurtainable: + +SPEN: + InfiltrateForSonarPulse: + Inherits: ^Building + Buildable: + TechLevel: 3 + Prerequisites: powr + Owner: soviet + Cost: 650 + Description: Sub Pen + LongDesc: Produces and repairs submarines and \ntransports + Building: + Power: -30 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Adjacent: 8 + HP: 1000 + Armor: light + WaterBound: yes + Sight: 4 + RenderBuilding: + ProductionSurround: + Produces: Ship + IronCurtainable: + +SYRD: + InfiltrateForSonarPulse: + Inherits: ^Building + Buildable: + TechLevel: 3 + Prerequisites: powr + Owner: allies + Cost: 650 + Description: Shipyard + LongDesc: Produces and repairs ships + Building: + Power: -30 + Footprint: xxx xxx xxx + Dimensions: 3,3 + Capturable: true + BaseNormal: no + Adjacent: 8 + HP: 1000 + Armor: light + WaterBound: yes + Sight: 4 + RenderBuilding: + ProductionSurround: + Produces: Ship + IronCurtainable: + V2RL: Inherits: ^Vehicle Buildable: @@ -1019,26 +1107,6 @@ SAM: AutoTarget: IronCurtainable: -MSLO: - Inherits: ^Building - Buildable: - TechLevel: 13 - Prerequisites: @Tech Center - Owner: soviet,allies - Cost: 2500 - Description: Missile Silo - LongDesc: Launches a devastating nuclear strike.\n Strong vs Infantry, Buildings\n Weak vs Tanks\n Special Ability: Nuclear Missile - Building: - Power: -100 - Footprint: xx - Dimensions: 2,1 - HP: 400 - Armor: heavy - Crewed: yes - Sight: 5 - RenderBuilding: - IronCurtainable: - ATEK: Inherits: ^Building Buildable: @@ -1089,56 +1157,6 @@ WEAP: Produces: Vehicle IronCurtainable: -SYRD: - Inherits: ^Building - Buildable: - TechLevel: 3 - Prerequisites: powr - Owner: allies - Cost: 650 - Description: Shipyard - LongDesc: Produces and repairs ships - Building: - Power: -30 - Footprint: xxx xxx xxx - Dimensions: 3,3 - Capturable: true - BaseNormal: no - Adjacent: 8 - HP: 1000 - Armor: light - WaterBound: yes - Sight: 4 - RenderBuilding: - ProductionSurround: - Produces: Ship - IronCurtainable: - -SPEN: - Inherits: ^Building - Buildable: - TechLevel: 3 - Prerequisites: powr - Owner: soviet - Cost: 650 - Description: Sub Pen - LongDesc: Produces and repairs submarines and \ntransports - Building: - Power: -30 - Footprint: xxx xxx xxx - Dimensions: 3,3 - Capturable: true - BaseNormal: no - Adjacent: 8 - HP: 1000 - Armor: light - WaterBound: yes - Sight: 4 - RenderBuilding: - ProductionSurround: - Produces: Ship - IronCurtainable: - FACT: Inherits: ^Building Building: diff --git a/mods/ra/units.ini b/mods/ra/units.ini index 4891301efb..14a8d3f5f8 100644 --- a/mods/ra/units.ini +++ b/mods/ra/units.ini @@ -869,25 +869,4 @@ Powered=no Image=pbmbicon TechLevel=8 GivenAuto=no -Impl=NullPower - -[SonarPulsePower] ; picked up in a crate, or by spy -> spen/syrd -ChargeTime=10 -Description=Sonar Pulse -LongDesc=Reveals all submarines on the map for a \nshort time. -OneShot=yes -Powered=no -Image=sonricon -TechLevel=5 -GivenAuto=no -Impl=NullPower - -[NukePower] ; the point of MSLO -ChargeTime=13 -Description=Atom Bomb -LongDesc=Launches a nuclear missile at your target -Prerequisite=MSLO -Image=atomicon -TechLevel=12 -Impl=NullPower - +Impl=NullPower \ No newline at end of file