From 172e1eb2954e3e93a177ccca17f4e818aa42d44a Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 5 Dec 2010 17:44:34 +1300 Subject: [PATCH] Paratroopers, Spyplane. --- .../SupportPowers/ParatroopersPower.cs | 48 +++++--------- OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs | 63 +++++++------------ mods/ra/rules/structures.yaml | 18 +++++- mods/ra/rules/system.yaml | 14 ----- 4 files changed, 56 insertions(+), 87 deletions(-) diff --git a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs index 37f36d5c7f..4bb6fa7a4c 100755 --- a/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ParatroopersPower.cs @@ -13,10 +13,10 @@ using OpenRA.Orders; using OpenRA.Traits; using OpenRA.FileFormats; using OpenRA.Mods.RA.Air; -/* + namespace OpenRA.Mods.RA { - class ParatroopersPowerInfo : SupportPowerInfo + public class ParatroopersPowerInfo : SupportPowerInfo { [ActorReference] public string[] DropItems = { }; @@ -28,58 +28,40 @@ namespace OpenRA.Mods.RA public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); } } - class ParatroopersPower : SupportPower, IResolveOrder + public class ParatroopersPower : SupportPower { public ParatroopersPower(Actor self, ParatroopersPowerInfo info) : base(self, info) { } - protected override void OnActivate() + public override void Activate(Actor self, Order order) { - Self.World.OrderGenerator = - new GenericSelectTarget( Owner.PlayerActor, "ParatroopersActivate", "ability" ); - } - - public void ResolveOrder(Actor self, Order order) - { - if (!IsReady) return; - - if (order.OrderString == "ParatroopersActivate") - { - DoParadrop(Owner, order.TargetLocation, - self.Info.Traits.Get().DropItems); - - FinishActivate(); - } - } - - void DoParadrop(Player owner, int2 p, string[] items) - { - var startPos = owner.World.ChooseRandomEdgeCell(); - owner.World.AddFrameEndTask(w => + var items = (Info as ParatroopersPowerInfo).DropItems; + var startPos = self.World.ChooseRandomEdgeCell(); + + self.World.AddFrameEndTask(w => { var info = (Info as ParatroopersPowerInfo); var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary { - new LocationInit( p ), - new OwnerInit( owner ), + new LocationInit( order.TargetLocation ), + new OwnerInit( self.Owner ), }) : null; var a = w.CreateActor(info.UnitType, new TypeDictionary { new LocationInit( startPos ), - new OwnerInit( owner ), - new FacingInit( Util.GetFacing(p - startPos, 0) ), + new OwnerInit( self.Owner ), + new FacingInit( Util.GetFacing(order.TargetLocation - startPos, 0) ), new AltitudeInit( Rules.Info[info.UnitType].Traits.Get().CruiseAltitude ), }); a.CancelActivity(); - a.QueueActivity(new FlyCircle(p)); - a.Trait().SetLZ(p, flare); + a.QueueActivity(new FlyCircle(order.TargetLocation)); + a.Trait().SetLZ(order.TargetLocation, flare); var cargo = a.Trait(); foreach (var i in items) - cargo.Load(a, owner.World.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary { new OwnerInit( a.Owner ) })); + cargo.Load(a, self.World.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary { new OwnerInit( a.Owner ) })); }); } } } -*/ \ No newline at end of file diff --git a/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs b/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs index 055acf0179..272f291b25 100755 --- a/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs @@ -14,61 +14,46 @@ using OpenRA.Traits; using OpenRA.Traits.Activities; using OpenRA.FileFormats; using OpenRA.Mods.RA.Air; -/* + namespace OpenRA.Mods.RA { class SpyPlanePowerInfo : SupportPowerInfo { - public readonly float RevealTime = .1f; // minutes + public readonly int RevealTime = 6; // seconds public override object Create(ActorInitializer init) { return new SpyPlanePower(init.self,this); } } - class SpyPlanePower : SupportPower, IResolveOrder + class SpyPlanePower : SupportPower { public SpyPlanePower(Actor self, SpyPlanePowerInfo info) : base(self, info) { } - protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "spypln1.aud"); } - protected override void OnActivate() + public override void Activate(Actor self, Order order) { - Self.World.OrderGenerator = new GenericSelectTarget(Owner.PlayerActor, "SpyPlane", "ability"); - Sound.Play("slcttgt1.aud"); - } + var enterCell = self.World.ChooseRandomEdgeCell(); - public void ResolveOrder(Actor self, Order order) - { - if (!IsReady) return; - - if (order.OrderString == "SpyPlane") + var plane = self.World.CreateActor("u2", new TypeDictionary { - FinishActivate(); + new LocationInit( enterCell ), + new OwnerInit( self.Owner ), + new FacingInit( Util.GetFacing(order.TargetLocation - enterCell, 0) ), + new AltitudeInit( Rules.Info["u2"].Traits.Get().CruiseAltitude ), + }); - var enterCell = self.World.ChooseRandomEdgeCell(); - - var plane = self.World.CreateActor("u2", new TypeDictionary + plane.CancelActivity(); + plane.QueueActivity(Fly.ToCell(order.TargetLocation)); + plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w => { - new LocationInit( enterCell ), - new OwnerInit( self.Owner ), - new FacingInit( Util.GetFacing(order.TargetLocation - enterCell, 0) ), - new AltitudeInit( Rules.Info["u2"].Traits.Get().CruiseAltitude ), - }); + var camera = w.CreateActor("camera", new TypeDictionary + { + new LocationInit( order.TargetLocation ), + new OwnerInit( self.Owner ), + }); - plane.CancelActivity(); - plane.QueueActivity(Fly.ToCell(order.TargetLocation)); - plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w => - { - var camera = w.CreateActor("camera", new TypeDictionary - { - new LocationInit( order.TargetLocation ), - new OwnerInit( Owner ), - }); - - camera.QueueActivity(new Wait((int)(25 * 60 * (Info as SpyPlanePowerInfo).RevealTime))); - camera.QueueActivity(new RemoveSelf()); - }))); - plane.QueueActivity(new FlyOffMap { Interruptible = false }); - plane.QueueActivity(new RemoveSelf()); - } + camera.QueueActivity(new Wait(25 * (Info as SpyPlanePowerInfo).RevealTime)); + camera.QueueActivity(new RemoveSelf()); + }))); + plane.QueueActivity(new FlyOffMap { Interruptible = false }); + plane.QueueActivity(new RemoveSelf()); } } } -*/ \ No newline at end of file diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 8f76ada73d..bd642d13f2 100755 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -723,7 +723,23 @@ AFLD: BelowUnits: Reservable: IronCurtainable: - + SpyPlanePower: + Image: smigicon +# ChargeTime: 180 + ChargeTime: 10 + Description: Spy Plane + LongDesc: Reveals an area of the map. + SelectTargetSound: slcttgt1.aud + EndChargeSound: spypln1.aud + ParatroopersPower: + Image: pinficon +# ChargeTime: 360 + ChargeTime: 10 + Description: Paratroopers + LongDesc: A Badger drops a squad of Riflemen \nanywhere on the map + Prerequisites: AFLD + DropItems: E1,E1,E1,E3,E3 + SelectTargetSound: slcttgt1.aud POWR: Inherits: ^Building Buildable: diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 53f8aee29f..20df6f596c 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -41,20 +41,6 @@ Player: # LongDesc: Makes a group of units invulnerable\nfor 10 seconds. # Prerequisites: IRON # Duration: 10 -# SpyPlanePower: -# Image: smigicon -# ChargeTime: 3 -# Description: Spy Plane -# LongDesc: Reveals an area of the map. -# Prerequisites: AFLD -# ParatroopersPower: -# Image: pinficon -# ChargeTime: 6 -# Description: Paratroopers -# LongDesc: A Badger drops a squad of Riflemen \nanywhere on the map -# Prerequisites: AFLD -# DropItems: E1,E1,E1,E3,E3 -# SelectTargetSound: slcttgt1.aud # SonarPulsePower: # Image: sonricon # ChargeTime: 10