Added a lua function for paratroopers

This commit is contained in:
abcdefg30
2014-12-25 23:27:19 +01:00
parent 660f43cc66
commit a4f051ad6b
10 changed files with 108 additions and 53 deletions

View File

@@ -11,6 +11,7 @@
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Traits;
using OpenRA.Scripting; using OpenRA.Scripting;
using OpenRA.Traits; using OpenRA.Traits;
@@ -65,4 +66,22 @@ namespace OpenRA.Mods.RA.Scripting
Self.QueueActivity(new RemoveSelf()); Self.QueueActivity(new RemoveSelf());
} }
} }
[ScriptGlobal("Air Support Powers")]
public class ParatroopersProperties : ScriptActorProperties, Requires<ParatroopersPowerInfo>
{
readonly ParatroopersPower pp;
public ParatroopersProperties(ScriptContext context, Actor self)
: base(context, self)
{
pp = self.TraitsImplementing<ParatroopersPower>().First();
}
[Desc("Activate the actor's Paratroopers Power. Returns the dropped units.")]
public Actor[] SendParatroopers(WPos target, bool randomize = true, int facing = 0)
{
return pp.SendParatroopers(Self, target, randomize, facing);
}
}
} }

View File

@@ -61,13 +61,22 @@ namespace OpenRA.Mods.RA.Traits
{ {
base.Activate(self, order, manager); base.Activate(self, order, manager);
SendParatroopers(self, self.World.Map.CenterOfCell(order.TargetLocation));
}
public Actor[] SendParatroopers(Actor self, WPos target, bool randomize = true, int dropFacing = 0)
{
var units = new List<Actor>();
var info = Info as ParatroopersPowerInfo; var info = Info as ParatroopersPowerInfo;
var dropFacing = Util.QuantizeFacing(self.World.SharedRandom.Next(256), info.QuantizedFacings) * (256 / info.QuantizedFacings);
var dropRotation = WRot.FromFacing(dropFacing); if (randomize)
var delta = new WVec(0, -1024, 0).Rotate(dropRotation); dropFacing = Util.QuantizeFacing(self.World.SharedRandom.Next(256), info.QuantizedFacings) * (256 / info.QuantizedFacings);
var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude.Range; var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude.Range;
var target = self.World.Map.CenterOfCell(order.TargetLocation) + new WVec(0, 0, altitude); var dropRotation = WRot.FromFacing(dropFacing);
var delta = new WVec(0, -1024, 0).Rotate(dropRotation);
target = target + new WVec(0, 0, altitude);
var startEdge = target - (self.World.Map.DistanceToEdge(target, -delta) + info.Cordon).Range * delta / 1024; var startEdge = target - (self.World.Map.DistanceToEdge(target, -delta) + info.Cordon).Range * delta / 1024;
var finishEdge = target + (self.World.Map.DistanceToEdge(target, delta) + info.Cordon).Range * delta / 1024; var finishEdge = target + (self.World.Map.DistanceToEdge(target, delta) + info.Cordon).Range * delta / 1024;
@@ -84,7 +93,7 @@ namespace OpenRA.Mods.RA.Traits
{ {
camera = w.CreateActor(info.CameraActor, new TypeDictionary camera = w.CreateActor(info.CameraActor, new TypeDictionary
{ {
new LocationInit(order.TargetLocation), new LocationInit(self.World.Map.CellContaining(target)),
new OwnerInit(self.Owner), new OwnerInit(self.Owner),
}); });
}); });
@@ -128,6 +137,14 @@ namespace OpenRA.Mods.RA.Traits
} }
}; };
foreach (var p in info.DropItems)
{
var unit = self.World.CreateActor(false, p.ToLowerInvariant(),
new TypeDictionary { new OwnerInit(self.Owner) });
units.Add(unit);
}
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
var notification = self.Owner.IsAlliedWith(self.World.RenderPlayer) ? Info.LaunchSound : Info.IncomingSound; var notification = self.Owner.IsAlliedWith(self.World.RenderPlayer) ? Info.LaunchSound : Info.IncomingSound;
@@ -162,13 +179,13 @@ namespace OpenRA.Mods.RA.Traits
drop.OnRemovedFromWorld += onExitRange; drop.OnRemovedFromWorld += onExitRange;
var cargo = a.Trait<Cargo>(); var cargo = a.Trait<Cargo>();
var passengers = info.DropItems.Skip(added).Take(passengersPerPlane); var passengers = units.Skip(added).Take(passengersPerPlane);
added += passengersPerPlane; added += passengersPerPlane;
foreach (var p in passengers) foreach (var p in passengers)
cargo.Load(a, self.World.CreateActor(false, p.ToLowerInvariant(), cargo.Load(a, p);
new TypeDictionary { new OwnerInit(a.Owner) }));
a.QueueActivity(new Fly(a, Target.FromPos(target + spawnOffset)));
a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset))); a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset)));
a.QueueActivity(new RemoveSelf()); a.QueueActivity(new RemoveSelf());
aircraftInRange.Add(a, false); aircraftInRange.Add(a, false);
@@ -180,8 +197,8 @@ namespace OpenRA.Mods.RA.Traits
var distance = (target - startEdge).HorizontalLength; var distance = (target - startEdge).HorizontalLength;
beacon = new Beacon( beacon = new Beacon(
order.Player, self.Owner,
self.World.Map.CenterOfCell(order.TargetLocation), target,
Info.BeaconPalettePrefix, Info.BeaconPalettePrefix,
Info.BeaconPoster, Info.BeaconPoster,
Info.BeaconPosterPalette, Info.BeaconPosterPalette,
@@ -190,6 +207,8 @@ namespace OpenRA.Mods.RA.Traits
w.Add(beacon); w.Add(beacon);
} }
}); });
return units.ToArray();
} }
} }
} }

View File

@@ -1,6 +1,5 @@
ProductionUnits = { "e1", "e1", "e2" } ProductionUnits = { "e1", "e1", "e2" }
ProductionBuildings = { USSRBarracks1, USSRBarracks2 } ProductionBuildings = { USSRBarracks1, USSRBarracks2 }
ParatroopersReinforcements = { "e1", "e1", "e1", "e2", "e2" }
TransportReinforcements = { "e1", "e1", "e1", "e2", "e2" } TransportReinforcements = { "e1", "e1", "e1", "e2", "e2" }
FirstUSSRBase = { USSRFlameTower1, USSRBarracks1, USSRPowerPlant1, USSRPowerPlant2, USSRConstructionYard1, USSRTechCenter, USSRBaseGuard1, USSRBaseGuard2, USSRBaseGuard3, USSRBaseGuard4, USSRBaseGuard5, USSRBaseGuard6, USSRBaseGuard7, USSRBaseGuard8 } FirstUSSRBase = { USSRFlameTower1, USSRBarracks1, USSRPowerPlant1, USSRPowerPlant2, USSRConstructionYard1, USSRTechCenter, USSRBaseGuard1, USSRBaseGuard2, USSRBaseGuard3, USSRBaseGuard4, USSRBaseGuard5, USSRBaseGuard6, USSRBaseGuard7, USSRBaseGuard8 }
SecondUSSRBase = { USSRBarracks2, USSRKennel, USSRRadarDome, USSRBaseGuard10, USSRBaseGuard11, USSRBaseGuard12, USSRBaseGuard13, USSRBaseGuard14 } SecondUSSRBase = { USSRBarracks2, USSRKennel, USSRRadarDome, USSRBaseGuard10, USSRBaseGuard11, USSRBaseGuard12, USSRBaseGuard13, USSRBaseGuard14 }
@@ -59,14 +58,19 @@ SendAlliedUnits = function()
Trigger.OnKilled(Tanya, function() player.MarkFailedObjective(TanyaSurvive) end) Trigger.OnKilled(Tanya, function() player.MarkFailedObjective(TanyaSurvive) end)
end end
SendUSSRParadrops = function(units, entry, dropzone) SendUSSRParadrops = function()
local plane = Actor.Create("badr", true, { Owner = ussr, Location = entry }) local powerproxy = Actor.Create("powerproxy.paratroopers", false, { Owner = ussr })
Utils.Do(units, function(type) local unitsA = powerproxy.SendParatroopers(ParadropLZ.CenterPosition, false, 128 + 32)
local unit = Actor.Create(type, false, { Owner = ussr }) local unitsB = powerproxy.SendParatroopers(ParadropLZ.CenterPosition, false, 128 - 32)
plane.LoadPassenger(unit)
Utils.Do(unitsA, function(unit)
IdleHunt(unit) IdleHunt(unit)
end) end)
plane.Paradrop(dropzone) Utils.Do(unitsB, function(unit)
IdleHunt(unit)
end)
powerproxy.Destroy()
end end
SendUSSRWaterTransport = function() SendUSSRWaterTransport = function()
@@ -215,8 +219,7 @@ InitTriggers = function()
if a.Owner == player and not paradropsTriggered then if a.Owner == player and not paradropsTriggered then
paradropsTriggered = true paradropsTriggered = true
Trigger.RemoveFootprintTrigger(id) Trigger.RemoveFootprintTrigger(id)
SendUSSRParadrops(ParatroopersReinforcements, ParadropTransportEntry1.Location, ParadropLZ.Location) SendUSSRParadrops()
SendUSSRParadrops(ParatroopersReinforcements, ParadropTransportEntry2.Location, ParadropLZ.Location)
end end
end) end)
Trigger.OnEnteredFootprint(ReinforcementsTriggerArea, function(a, id) Trigger.OnEnteredFootprint(ReinforcementsTriggerArea, function(a, id)

View File

@@ -1304,12 +1304,6 @@ Actors:
LargeCameraWaypoint: waypoint LargeCameraWaypoint: waypoint
Location: 71,65 Location: 71,65
Owner: Neutral Owner: Neutral
ParadropTransportEntry1: waypoint
Location: 66,38
Owner: Neutral
ParadropTransportEntry2: waypoint
Location: 85,38
Owner: Neutral
ParadropLZ: waypoint ParadropLZ: waypoint
Location: 73,57 Location: 73,57
Owner: Neutral Owner: Neutral
@@ -1378,6 +1372,9 @@ Rules:
^Crate: ^Crate:
Tooltip: Tooltip:
ShowOwnerRow: false ShowOwnerRow: false
powerproxy.paratroopers:
ParatroopersPower:
DropItems: E1,E1,E1,E2,E2
HACKE6: HACKE6:
Inherits: E6 Inherits: E6
-RepairsBridges: -RepairsBridges:

View File

@@ -1,7 +1,7 @@
if DateTime.IsHalloween then if DateTime.IsHalloween then
UnitTypes = { "ant", "ant", "ant" } UnitTypes = { "ant", "ant", "ant" }
BeachUnitTypes = { "ant", "ant" } BeachUnitTypes = { "ant", "ant" }
ParadropUnitTypes = { "zombie", "zombie", "zombie", "zombie", "zombie" } ProxyType = "powerproxy.parazombies"
ProducedUnitTypes = ProducedUnitTypes =
{ {
{ AlliedBarracks1, { "e1", "e3" } }, { AlliedBarracks1, { "e1", "e3" } },
@@ -15,7 +15,7 @@ if DateTime.IsHalloween then
else else
UnitTypes = { "3tnk", "ftrk", "ttnk", "apc" } UnitTypes = { "3tnk", "ftrk", "ttnk", "apc" }
BeachUnitTypes = { "e1", "e2", "e3", "e4", "e1", "e2", "e3", "e4", "e1", "e2", "e3", "e4", "e1", "e2", "e3", "e4" } BeachUnitTypes = { "e1", "e2", "e3", "e4", "e1", "e2", "e3", "e4", "e1", "e2", "e3", "e4", "e1", "e2", "e3", "e4" }
ParadropUnitTypes = { "e1", "e1", "e2", "e3", "e4" } ProxyType = "powerproxy.paratroopers"
ProducedUnitTypes = ProducedUnitTypes =
{ {
{ AlliedBarracks1, { "e1", "e3" } }, { AlliedBarracks1, { "e1", "e3" } },
@@ -83,17 +83,13 @@ InsertAlliedChinookReinforcements = function(entry, hpad)
end end
ParadropSovietUnits = function() ParadropSovietUnits = function()
local lz = Utils.Random(ParadropWaypoints).Location local lz = Utils.Random(ParadropWaypoints)
local start = Map.CenterOfCell(Map.RandomEdgeCell()) + WVec.New(0, 0, Actor.CruiseAltitude("badr")) local units = powerproxy.SendParatroopers(lz.CenterPosition)
local transport = Actor.Create("badr", true, { CenterPosition = start, Owner = soviets, Facing = (Map.CenterOfCell(lz) - start).Facing })
Utils.Do(ParadropUnitTypes, function(type) Utils.Do(units, function(a)
local a = Actor.Create(type, false, { Owner = soviets })
BindActorTriggers(a) BindActorTriggers(a)
transport.LoadPassenger(a)
end) end)
transport.Paradrop(lz)
Trigger.AfterDelay(DateTime.Seconds(35), ParadropSovietUnits) Trigger.AfterDelay(DateTime.Seconds(35), ParadropSovietUnits)
end end
@@ -139,7 +135,7 @@ speed = 5
Tick = function() Tick = function()
ticks = ticks + 1 ticks = ticks + 1
local t = (ticks + 45) % (360 * speed) * (math.pi / 180) / speed; local t = (ticks + 45) % (360 * speed) * (math.pi / 180) / speed;
Camera.Position = viewportOrigin + WVec.New(19200 * math.sin(t), 20480 * math.cos(t), 0) Camera.Position = viewportOrigin + WVec.New(19200 * math.sin(t), 20480 * math.cos(t), 0)
end end
@@ -154,6 +150,7 @@ WorldLoaded = function()
ShipAlliedUnits() ShipAlliedUnits()
InsertAlliedChinookReinforcements(Chinook1Entry, HeliPad1) InsertAlliedChinookReinforcements(Chinook1Entry, HeliPad1)
InsertAlliedChinookReinforcements(Chinook2Entry, HeliPad2) InsertAlliedChinookReinforcements(Chinook2Entry, HeliPad2)
powerproxy = Actor.Create(ProxyType, false, { Owner = soviets })
ParadropSovietUnits() ParadropSovietUnits()
Trigger.AfterDelay(DateTime.Seconds(5), ChronoshiftAlliedUnits) Trigger.AfterDelay(DateTime.Seconds(5), ChronoshiftAlliedUnits)
Utils.Do(ProducedUnitTypes, ProduceUnits) Utils.Do(ProducedUnitTypes, ProduceUnits)

View File

@@ -1331,6 +1331,15 @@ Rules:
HP: 200 HP: 200
E7: E7:
-Selectable: -Selectable:
powerproxy.paratroopers:
ParatroopersPower:
DisplayBeacon: false
DropItems: E1,E1,E2,E3,E4
powerproxy.parazombies:
ParatroopersPower:
DropItems: ZOMBIE,ZOMBIE,ZOMBIE,ZOMBIE,ZOMBIE
QuantizedFacings: 8
DisplayBeacon: false
Sequences: Sequences:

View File

@@ -54,19 +54,16 @@ GroundPatrolUnits =
{ "apc", "apc", "ftrk" }, { "apc", "apc", "ftrk" },
{ "3tnk", "3tnk" } { "3tnk", "3tnk" }
} }
Paratroopers = { "e1", "e1", "e1", "e3", "e3" }
ParadropSovietUnits = function() ParadropSovietUnits = function()
local start = BaseRaidEntrypoint.CenterPosition + WVec.New(0, 0, Actor.CruiseAltitude("badr")) local powerproxy = Actor.Create("powerproxy.paratroopers", false, { Owner = soviets })
local transport = Actor.Create("badr", true, { CenterPosition = start, Owner = soviets, Facing = (Map.CenterOfCell(MCVDeployLocation.Location) - start).Facing }) local units = powerproxy.SendParatroopers(MCVDeployLocation.CenterPosition, false, 256 - 53)
Utils.Do(Paratroopers, function(type) Utils.Do(units, function(a)
local a = Actor.Create(type, false, { Owner = soviets }) Trigger.OnIdle(a, a.Hunt)
transport.LoadPassenger(a)
Trigger.OnIdle(a, function(b) b.Hunt() end)
end) end)
transport.Paradrop(MCVDeployLocation.Location) powerproxy.Destroy()
end end
AirRaid = function(planeTypes, ingress, egress, target) AirRaid = function(planeTypes, ingress, egress, target)

View File

@@ -1248,6 +1248,9 @@ Rules:
GenericVisibility: Enemy, Ally, Neutral GenericVisibility: Enemy, Ally, Neutral
GenericStancePrefix: false GenericStancePrefix: false
ShowOwnerRow: false ShowOwnerRow: false
powerproxy.paratroopers:
ParatroopersPower:
DropItems: E1,E1,E1,E2,E2
CAMERA.sam: CAMERA.sam:
Inherits: CAMERA Inherits: CAMERA
RevealsShroud: RevealsShroud:

View File

@@ -44,13 +44,12 @@ SovietAttackGroupSize = 5
SovietInfantryGroupSize = 7 SovietInfantryGroupSize = 7
FactoryClearRange = 10 FactoryClearRange = 10
ParadropTicks = DateTime.Seconds(30) ParadropTicks = DateTime.Seconds(30)
BadgerPassengers = { "e1", "e1", "e1", "e2", "e2" }
ParadropWaypoints = ParadropWaypoints =
{ {
{ BadgerEntryPoint1.Location, ParaDrop1.Location }, { 192 + 4, ParaDrop1},
{ BadgerEntryPoint2.Location, ParaDrop2.Location }, { 192 - 4, ParaDrop2},
{ BadgerEntryPoint1.Location, Alliesbase2.Location }, { 192 + 4, Alliesbase2},
{ BadgerEntryPoint2.Location, Alliesbase1.Location } { 192 - 4, Alliesbase1}
} }
NavalTransportPassengers = { "e1", "e1", "e2", "e4", "e4" } NavalTransportPassengers = { "e1", "e1", "e2", "e4", "e4" }
NavalReinforcementsWaypoints = { NavalWaypoint1, NavalWaypoint2, NavalWaypoint2, NavalWaypoint3 } NavalReinforcementsWaypoints = { NavalWaypoint1, NavalWaypoint2, NavalWaypoint2, NavalWaypoint3 }
@@ -120,13 +119,11 @@ Tick = function()
end end
SendSovietParadrops = function(table) SendSovietParadrops = function(table)
local plane = Actor.Create("badr", true, { Owner = soviets, Location = table[1] }) local units = powerproxy.SendParatroopers(table[2].CenterPosition, false, table[1])
Utils.Do(BadgerPassengers, function(type)
local unit = Actor.Create(type, false, { Owner = soviets }) Utils.Do(units, function(unit)
plane.LoadPassenger(unit)
Trigger.OnIdle(unit, unit.Hunt) Trigger.OnIdle(unit, unit.Hunt)
end) end)
plane.Paradrop(table[2])
end end
SendSovietNavalReinforcements = function() SendSovietNavalReinforcements = function()
@@ -357,6 +354,7 @@ SetupSoviets = function()
Reinforcements.Reinforce(soviets, Squad1, { AlliesBaseGate1.Location, Alliesbase1.Location }) Reinforcements.Reinforce(soviets, Squad1, { AlliesBaseGate1.Location, Alliesbase1.Location })
Reinforcements.Reinforce(soviets, Squad2, { AlliesBaseGate2.Location, Alliesbase2.Location }) Reinforcements.Reinforce(soviets, Squad2, { AlliesBaseGate2.Location, Alliesbase2.Location })
powerproxy = Actor.Create("powerproxy.paratroopers", false, { Owner = soviets })
Trigger.AfterDelay(ParadropTicks, function() Trigger.AfterDelay(ParadropTicks, function()
SendSovietParadrops(ParadropWaypoints[1]) SendSovietParadrops(ParadropWaypoints[1])
SendSovietParadrops(ParadropWaypoints[2]) SendSovietParadrops(ParadropWaypoints[2])

View File

@@ -329,6 +329,19 @@ powerproxy.sonarpulse:
EffectSequence: moveflsh EffectSequence: moveflsh
EffectPalette: moveflash EffectPalette: moveflash
powerproxy.paratroopers:
ParatroopersPower:
Icon: paratroopers
Description: Paratroopers
LongDesc: A Badger drops a squad of infantry\nanywhere on the map.
DropItems: E1,E1,E1,E3,E3
SelectTargetSound: slcttgt1.aud
AllowImpassableCells: false
QuantizedFacings: 8
CameraActor: camera.paradrop
DisplayBeacon: true
BeaconPoster: pinficon
mpspawn: mpspawn:
Immobile: Immobile:
OccupiesSpace: false OccupiesSpace: false