From 8b66162e994f6d8be7ddc155621e80f1e7f26ece Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 25 Oct 2014 16:48:02 +1300 Subject: [PATCH] Fix landing craft reinforcements in GDI01 and GDI02. --- OpenRA.Mods.Cnc/Render/WithCargo.cs | 3 +- OpenRA.Mods.RA/Cargo.cs | 1 + .../Scripting/Properties/MobileProperties.cs | 14 ++++++++- .../Properties/TransportProperties.cs | 3 ++ mods/cnc/maps/gdi01/gdi01.lua | 29 ++++++++++++++++- mods/cnc/maps/gdi02/gdi02.lua | 31 +++++++++++++++++-- mods/cnc/rules/ships.yaml | 2 +- 7 files changed, 77 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Cnc/Render/WithCargo.cs b/OpenRA.Mods.Cnc/Render/WithCargo.cs index cdc489ca56..1604b517f3 100644 --- a/OpenRA.Mods.Cnc/Render/WithCargo.cs +++ b/OpenRA.Mods.Cnc/Render/WithCargo.cs @@ -64,7 +64,8 @@ namespace OpenRA.Mods.Cnc var cargoPassenger = c.Trait(); if (cargoInfo.DisplayTypes.Contains(cargoPassenger.Info.CargoType)) { - var offset = pos - c.CenterPosition + body.LocalToWorld(cargoInfo.LocalOffset[i++ % cargoInfo.LocalOffset.Length].Rotate(bodyOrientation)); + var localOffset = cargo.PassengerCount > 1 ? cargoInfo.LocalOffset[i++ % cargoInfo.LocalOffset.Length] : WVec.Zero; + var offset = pos - c.CenterPosition + body.LocalToWorld(localOffset.Rotate(bodyOrientation)); foreach (var cr in c.Render(wr)) yield return cr.OffsetBy(offset).WithZOffset(1); } diff --git a/OpenRA.Mods.RA/Cargo.cs b/OpenRA.Mods.RA/Cargo.cs index eadf368a71..be8a49002b 100644 --- a/OpenRA.Mods.RA/Cargo.cs +++ b/OpenRA.Mods.RA/Cargo.cs @@ -45,6 +45,7 @@ namespace OpenRA.Mods.RA public IEnumerable CurrentAdjacentCells { get; private set; } public bool Unloading { get; internal set; } public IEnumerable Passengers { get { return cargo; } } + public int PassengerCount { get { return cargo.Count; } } public Cargo(ActorInitializer init, CargoInfo info) { diff --git a/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs index 0af7444f78..e04f39c820 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs @@ -17,8 +17,13 @@ namespace OpenRA.Mods.RA.Scripting [ScriptPropertyGroup("Movement")] public class MobileProperties : ScriptActorProperties, Requires { + readonly Mobile mobile; + public MobileProperties(ScriptContext context, Actor self) - : base(context, self) { } + : base(context, self) + { + mobile = self.Trait(); + } [ScriptActorPropertyActivity] [Desc("Moves within the cell grid. closeEnough defines an optional range " + @@ -35,6 +40,13 @@ namespace OpenRA.Mods.RA.Scripting self.QueueActivity(new Move.Move(self, cell)); } + [ScriptActorPropertyActivity] + [Desc("Moves from outside the world into the cell grid")] + public void MoveIntoWorld(CPos cell) + { + self.QueueActivity(mobile.MoveIntoWorld(self, cell, mobile.toSubCell)); + } + [ScriptActorPropertyActivity] [Desc("Leave the current position in a random direction.")] public void Scatter() diff --git a/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs index ff826ed717..670ffbb266 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/TransportProperties.cs @@ -33,6 +33,9 @@ namespace OpenRA.Mods.RA.Scripting [Desc("Teleport an existing actor inside this transport.")] public void LoadPassenger(Actor a) { cargo.Load(self, a); } + [Desc("Remove the first actor from the transport. This actor is not added to the world.")] + public Actor UnloadPassenger() { return cargo.Unload(self); } + [ScriptActorPropertyActivity] [Desc("Command transport to unload passengers.")] public void UnloadPassengers() diff --git a/mods/cnc/maps/gdi01/gdi01.lua b/mods/cnc/maps/gdi01/gdi01.lua index 63203f3e74..547478b818 100644 --- a/mods/cnc/maps/gdi01/gdi01.lua +++ b/mods/cnc/maps/gdi01/gdi01.lua @@ -15,9 +15,36 @@ SetGunboatPath = function(gunboat) gunboat.AttackMove(gunboatRight.Location) end +ReinforceWithLandingCraft = function(units, transportStart, transportUnload, rallypoint) + local transport = Actor.Create("oldlst", true, { Owner = player, Facing = 0, Location = transportStart }) + local subcell = 0 + Utils.Do(units, function(a) + transport.LoadPassenger(Actor.Create(a, false, { Owner = transport.Owner, Facing = transport.Facing, Location = transportUnload, SubCell = subcell })) + subcell = subcell + 1 + end) + + transport.ScriptedMove(transportUnload) + + transport.CallFunc(function() + Utils.Do(units, function() + local a = transport.UnloadPassenger() + a.IsInWorld = true + a.MoveIntoWorld(transport.Location - CVec.New(0, 1)) + + if rallypoint ~= nil then + a.Move(rallypoint) + end + end) + end) + + transport.Wait(5) + transport.ScriptedMove(transportStart) + transport.Destroy() +end + Reinforce = function(units) Media.PlaySpeechNotification(player, "Reinforce") - Reinforcements.ReinforceWithTransport(player, "oldlst", units, { lstStart.Location, lstEnd.Location }, { lstStart.Location }) + ReinforceWithLandingCraft(units, lstStart.Location, lstEnd.Location) end triggerAdded = false diff --git a/mods/cnc/maps/gdi02/gdi02.lua b/mods/cnc/maps/gdi02/gdi02.lua index 3229f25725..2936f041a7 100644 --- a/mods/cnc/maps/gdi02/gdi02.lua +++ b/mods/cnc/maps/gdi02/gdi02.lua @@ -5,9 +5,36 @@ VehicleReinforcements = { "jeep" } AttackerSquadSize = 3 -Reinforce = function(passengers) - Reinforcements.ReinforceWithTransport(player, "oldlst", passengers, { lstStart.Location, lstEnd.Location }, { lstStart.Location }) +ReinforceWithLandingCraft = function(units, transportStart, transportUnload, rallypoint) + local transport = Actor.Create("oldlst", true, { Owner = player, Facing = 0, Location = transportStart }) + local subcell = 0 + Utils.Do(units, function(a) + transport.LoadPassenger(Actor.Create(a, false, { Owner = transport.Owner, Facing = transport.Facing, Location = transportUnload, SubCell = subcell })) + subcell = subcell + 1 + end) + + transport.ScriptedMove(transportUnload) + + transport.CallFunc(function() + Utils.Do(units, function() + local a = transport.UnloadPassenger() + a.IsInWorld = true + a.MoveIntoWorld(transport.Location - CVec.New(0, 1)) + + if rallypoint ~= nil then + a.Move(rallypoint) + end + end) + end) + + transport.Wait(5) + transport.ScriptedMove(transportStart) + transport.Destroy() +end + +Reinforce = function(units) Media.PlaySpeechNotification(player, "Reinforce") + ReinforceWithLandingCraft(units, lstStart.Location, lstEnd.Location) end BridgeheadSecured = function() diff --git a/mods/cnc/rules/ships.yaml b/mods/cnc/rules/ships.yaml index 727d24cbc1..6e919293cb 100644 --- a/mods/cnc/rules/ships.yaml +++ b/mods/cnc/rules/ships.yaml @@ -64,7 +64,7 @@ LST: WithRoof: WithCargo: DisplayTypes: Infantry, Vehicle - LocalOffset: 0,0,0, -390,-256,0, 390,-256,0, -390,256,0, 390,256,0 + LocalOffset: 390,-256,0, 390,256,0, 0,0,0, -390,-256,0, -390,256,0 Cargo: Types: Infantry, Vehicle MaxWeight: 5