diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index fe0a9a30da..689aafae86 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -160,6 +160,7 @@
+
diff --git a/OpenRa.Game/Traits/Activities/CallFunc.cs b/OpenRa.Game/Traits/Activities/CallFunc.cs
index 08556e3251..562a75a0b0 100644
--- a/OpenRa.Game/Traits/Activities/CallFunc.cs
+++ b/OpenRa.Game/Traits/Activities/CallFunc.cs
@@ -7,6 +7,8 @@ namespace OpenRa.Traits.Activities
{
public class CallFunc : IActivity
{
+ public CallFunc(Action a) { this.a = a; }
+
Action a;
public IActivity NextActivity { get; set; }
diff --git a/OpenRa.Game/Traits/Activities/RemoveSelf.cs b/OpenRa.Game/Traits/Activities/RemoveSelf.cs
new file mode 100644
index 0000000000..06ea0983e5
--- /dev/null
+++ b/OpenRa.Game/Traits/Activities/RemoveSelf.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OpenRa.Traits.Activities
+{
+ class RemoveSelf : IActivity
+ {
+ bool isCanceled;
+ public IActivity NextActivity { get; set; }
+
+ public IActivity Tick(Actor self)
+ {
+ if (isCanceled) return NextActivity;
+ self.World.AddFrameEndTask(w => w.Remove(self));
+ return null;
+ }
+
+ public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
+ }
+}
diff --git a/OpenRa.Game/Traits/SpyPlanePower.cs b/OpenRa.Game/Traits/SpyPlanePower.cs
index 31cf83bb0e..9430abd2cc 100644
--- a/OpenRa.Game/Traits/SpyPlanePower.cs
+++ b/OpenRa.Game/Traits/SpyPlanePower.cs
@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using OpenRa.Traits.Activities;
namespace OpenRa.Traits
{
class SpyPlanePowerInfo : SupportPowerInfo
{
+ public readonly int Range = 10;
public override object Create(Actor self) { return new SpyPlanePower(self,this); }
}
@@ -21,6 +23,18 @@ namespace OpenRa.Traits
Sound.Play("slcttgt1.aud");
}
+ static int2 ChooseRandomEdgeCell(World w)
+ {
+ var isX = Game.SharedRandom.Next(2) == 0;
+ var edge = Game.SharedRandom.Next(2) == 0;
+
+ return new int2(
+ isX ? Game.SharedRandom.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width)
+ : (edge ? w.Map.XOffset : w.Map.XOffset + w.Map.Width),
+ !isX ? Game.SharedRandom.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height)
+ : (edge ? w.Map.YOffset : w.Map.YOffset + w.Map.Height));
+ }
+
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "SpyPlane")
@@ -30,14 +44,17 @@ namespace OpenRa.Traits
if (order.Player == Owner.World.LocalPlayer)
Game.controller.CancelInputMode();
- // todo: pick a cell p1 on the edge of the map; get the cell p2 at the other end of the line
- // through that p1 & the target location;
+ var enterCell = ChooseRandomEdgeCell(self.World);
+ var exitCell = ChooseRandomEdgeCell(self.World);
- // todo: spawn a SpyPlane at p1 with activities:
- // -- fly to target point
- // -- take picture
- // -- fly to p2
- // -- leave the world
+ var plane = self.World.CreateActor("U2", enterCell, self.Owner);
+ plane.CancelActivity();
+ plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
+ plane.QueueActivity(new CallFunc(
+ () => Owner.Shroud.Explore(Owner.World, order.TargetLocation,
+ (Info as SpyPlanePowerInfo).Range)));
+ plane.QueueActivity(new Fly(Util.CenterOfCell(exitCell)));
+ plane.QueueActivity(new RemoveSelf());
}
}
diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml
index fd8a5814d4..0334300d53 100644
--- a/mods/ra/rules.yaml
+++ b/mods/ra/rules.yaml
@@ -781,6 +781,19 @@ HIND:
Ammo: 12
IronCurtainable:
+U2:
+ Inherits: ^Plane
+ Unit:
+ HP: 2000
+ Armor: heavy
+ ROT: 7
+ Sight: 0
+ Speed: 40
+ Plane:
+ RenderUnit:
+ WithShadow:
+ IronCurtainable:
+
IRON:
Inherits: ^Building
Buildable:
diff --git a/mods/ra/sequences.xml b/mods/ra/sequences.xml
index 6b77c4b93c..babbc2f263 100644
--- a/mods/ra/sequences.xml
+++ b/mods/ra/sequences.xml
@@ -379,14 +379,14 @@
-
+
-
+
@@ -1037,4 +1037,7 @@
+
+
+
\ No newline at end of file
diff --git a/mods/ra/units.ini b/mods/ra/units.ini
index c65055783c..4891301efb 100644
--- a/mods/ra/units.ini
+++ b/mods/ra/units.ini
@@ -164,6 +164,7 @@ YAK
TRAN
HELI
HIND
+U2
; TODO:
; U2 (spyplane)
; BADR (paratrooper/paradrop plane)
@@ -206,7 +207,8 @@ PrimaryOffset=-5,0,0,2
SecondaryOffset=5,0,0,2
InitialFacing=20
LongDesc=Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks
-
+[U2]
+Traits=Unit, Plane, RenderUnit, WithShadow, IronCurtainable