Paratroopers, Spyplane.

This commit is contained in:
Paul Chote
2010-12-05 17:44:34 +13:00
parent 9e16eb513f
commit 172e1eb295
4 changed files with 56 additions and 87 deletions

View File

@@ -13,10 +13,10 @@ using OpenRA.Orders;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Mods.RA.Air; using OpenRA.Mods.RA.Air;
/*
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class ParatroopersPowerInfo : SupportPowerInfo public class ParatroopersPowerInfo : SupportPowerInfo
{ {
[ActorReference] [ActorReference]
public string[] DropItems = { }; public string[] DropItems = { };
@@ -28,58 +28,40 @@ namespace OpenRA.Mods.RA
public override object Create(ActorInitializer init) { return new ParatroopersPower(init.self, this); } 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) { } public ParatroopersPower(Actor self, ParatroopersPowerInfo info) : base(self, info) { }
protected override void OnActivate() public override void Activate(Actor self, Order order)
{ {
Self.World.OrderGenerator = var items = (Info as ParatroopersPowerInfo).DropItems;
new GenericSelectTarget( Owner.PlayerActor, "ParatroopersActivate", "ability" ); var startPos = self.World.ChooseRandomEdgeCell();
}
public void ResolveOrder(Actor self, Order order) self.World.AddFrameEndTask(w =>
{
if (!IsReady) return;
if (order.OrderString == "ParatroopersActivate")
{
DoParadrop(Owner, order.TargetLocation,
self.Info.Traits.Get<ParatroopersPowerInfo>().DropItems);
FinishActivate();
}
}
void DoParadrop(Player owner, int2 p, string[] items)
{
var startPos = owner.World.ChooseRandomEdgeCell();
owner.World.AddFrameEndTask(w =>
{ {
var info = (Info as ParatroopersPowerInfo); var info = (Info as ParatroopersPowerInfo);
var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary
{ {
new LocationInit( p ), new LocationInit( order.TargetLocation ),
new OwnerInit( owner ), new OwnerInit( self.Owner ),
}) : null; }) : null;
var a = w.CreateActor(info.UnitType, new TypeDictionary var a = w.CreateActor(info.UnitType, new TypeDictionary
{ {
new LocationInit( startPos ), new LocationInit( startPos ),
new OwnerInit( owner ), new OwnerInit( self.Owner ),
new FacingInit( Util.GetFacing(p - startPos, 0) ), new FacingInit( Util.GetFacing(order.TargetLocation - startPos, 0) ),
new AltitudeInit( Rules.Info[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude ), new AltitudeInit( Rules.Info[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude ),
}); });
a.CancelActivity(); a.CancelActivity();
a.QueueActivity(new FlyCircle(p)); a.QueueActivity(new FlyCircle(order.TargetLocation));
a.Trait<ParaDrop>().SetLZ(p, flare); a.Trait<ParaDrop>().SetLZ(order.TargetLocation, flare);
var cargo = a.Trait<Cargo>(); var cargo = a.Trait<Cargo>();
foreach (var i in items) 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 ) }));
}); });
} }
} }
} }
*/

View File

@@ -14,61 +14,46 @@ using OpenRA.Traits;
using OpenRA.Traits.Activities; using OpenRA.Traits.Activities;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Mods.RA.Air; using OpenRA.Mods.RA.Air;
/*
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
class SpyPlanePowerInfo : SupportPowerInfo 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); } 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) { } public SpyPlanePower(Actor self, SpyPlanePowerInfo info) : base(self, info) { }
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "spypln1.aud"); } public override void Activate(Actor self, Order order)
protected override void OnActivate()
{ {
Self.World.OrderGenerator = new GenericSelectTarget(Owner.PlayerActor, "SpyPlane", "ability"); var enterCell = self.World.ChooseRandomEdgeCell();
Sound.Play("slcttgt1.aud");
}
public void ResolveOrder(Actor self, Order order) var plane = self.World.CreateActor("u2", new TypeDictionary
{
if (!IsReady) return;
if (order.OrderString == "SpyPlane")
{ {
FinishActivate(); new LocationInit( enterCell ),
new OwnerInit( self.Owner ),
new FacingInit( Util.GetFacing(order.TargetLocation - enterCell, 0) ),
new AltitudeInit( Rules.Info["u2"].Traits.Get<PlaneInfo>().CruiseAltitude ),
});
var enterCell = self.World.ChooseRandomEdgeCell(); plane.CancelActivity();
plane.QueueActivity(Fly.ToCell(order.TargetLocation));
var plane = self.World.CreateActor("u2", new TypeDictionary plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
{ {
new LocationInit( enterCell ), var camera = w.CreateActor("camera", new TypeDictionary
new OwnerInit( self.Owner ), {
new FacingInit( Util.GetFacing(order.TargetLocation - enterCell, 0) ), new LocationInit( order.TargetLocation ),
new AltitudeInit( Rules.Info["u2"].Traits.Get<PlaneInfo>().CruiseAltitude ), new OwnerInit( self.Owner ),
}); });
plane.CancelActivity(); camera.QueueActivity(new Wait(25 * (Info as SpyPlanePowerInfo).RevealTime));
plane.QueueActivity(Fly.ToCell(order.TargetLocation)); camera.QueueActivity(new RemoveSelf());
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w => })));
{ plane.QueueActivity(new FlyOffMap { Interruptible = false });
var camera = w.CreateActor("camera", new TypeDictionary plane.QueueActivity(new RemoveSelf());
{
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());
}
} }
} }
} }
*/

View File

@@ -723,7 +723,23 @@ AFLD:
BelowUnits: BelowUnits:
Reservable: Reservable:
IronCurtainable: 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: POWR:
Inherits: ^Building Inherits: ^Building
Buildable: Buildable:

View File

@@ -41,20 +41,6 @@ Player:
# LongDesc: Makes a group of units invulnerable\nfor 10 seconds. # LongDesc: Makes a group of units invulnerable\nfor 10 seconds.
# Prerequisites: IRON # Prerequisites: IRON
# Duration: 10 # 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: # SonarPulsePower:
# Image: sonricon # Image: sonricon
# ChargeTime: 10 # ChargeTime: 10