From e1c674aecad00d02a7571e7f4c2ad2176e8ce066 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 22 Jun 2015 18:32:04 +0200 Subject: [PATCH 1/4] Add EnterTransport function to lua --- .../Scripting/Properties/MobileProperties.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs index 8314022a27..2445c215ab 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs @@ -54,5 +54,12 @@ namespace OpenRA.Mods.Common.Scripting { Self.Trait().Nudge(Self, Self, true); } + + [ScriptActorPropertyActivity] + [Desc("Move to and enter the transport.")] + public void EnterTransport(Actor transport) + { + Self.QueueActivity(new EnterTransport(Self, transport, 1, true)); + } } } \ No newline at end of file From 31986469a9da4ae59a017f9c92246fcb0dfb8197 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 22 Jun 2015 18:32:24 +0200 Subject: [PATCH 2/4] Use the new EnterTransport function in soviet05 --- mods/ra/maps/soviet-05/main.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/ra/maps/soviet-05/main.lua b/mods/ra/maps/soviet-05/main.lua index 3a2b82dc58..028256abe4 100644 --- a/mods/ra/maps/soviet-05/main.lua +++ b/mods/ra/maps/soviet-05/main.lua @@ -95,8 +95,7 @@ Expand = function() return end - mcvGG.IsInWorld = false - mcvtransport.LoadPassenger(mcvGG) + mcvGG.EnterTransport(mcvtransport) mcvtransport.Move(GGUnloadPoint.Location) mcvtransport.UnloadPassengers() Trigger.AfterDelay(DateTime.Seconds(12), function() @@ -151,7 +150,7 @@ Tick = function() Greece.Cash = Greece.Cash + Greece.Resources - Greece.ResourceCapacity * 0.25 Greece.Resources = Greece.ResourceCapacity * 0.25 end - + if GoodGuy.Resources >= GoodGuy.ResourceCapacity * 0.75 then GoodGuy.Cash = GoodGuy.Cash + GoodGuy.Resources - GoodGuy.ResourceCapacity * 0.25 GoodGuy.Resources = GoodGuy.ResourceCapacity * 0.25 From a4fd34558da5bb8eb907709581c4b693f2e6f766 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 22 Jun 2015 18:49:23 +0200 Subject: [PATCH 3/4] Add a lua function for beacons --- OpenRA.Mods.Common/Effects/Beacon.cs | 3 +- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../Scripting/Global/BeaconGlobal.cs | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 OpenRA.Mods.Common/Scripting/Global/BeaconGlobal.cs diff --git a/OpenRA.Mods.Common/Effects/Beacon.cs b/OpenRA.Mods.Common/Effects/Beacon.cs index 01d6ecd474..e6adb47a1a 100644 --- a/OpenRA.Mods.Common/Effects/Beacon.cs +++ b/OpenRA.Mods.Common/Effects/Beacon.cs @@ -12,10 +12,11 @@ using System; using System.Collections.Generic; using OpenRA.Effects; using OpenRA.Graphics; +using OpenRA.Scripting; namespace OpenRA.Mods.Common.Effects { - public class Beacon : IEffect + public class Beacon : IEffect, IScriptBindable { static readonly int MaxArrowHeight = 512; diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 67807b257f..aa0a9f8c1f 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -213,6 +213,7 @@ + diff --git a/OpenRA.Mods.Common/Scripting/Global/BeaconGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/BeaconGlobal.cs new file mode 100644 index 0000000000..c1446c48a0 --- /dev/null +++ b/OpenRA.Mods.Common/Scripting/Global/BeaconGlobal.cs @@ -0,0 +1,47 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System.Linq; +using OpenRA.Mods.Common.Effects; +using OpenRA.Mods.Common.Traits; +using OpenRA.Scripting; + +namespace OpenRA.Mods.Common.Scripting +{ + [ScriptGlobal("Beacon")] + public class BeaconGlobal : ScriptGlobal + { + readonly RadarPings radarPings; + + public BeaconGlobal(ScriptContext context) : base(context) + { + radarPings = context.World.WorldActor.TraitOrDefault(); + } + + [Desc("Creates a new beacon that stays for the specified time at the specified WPos." + + "Does not remove player set beacons, nor gets removed by placing them.")] + public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true, string palettePrefix = "player") + { + var playerBeacon = new Beacon(owner, position, duration, palettePrefix); + owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon)); + + if (showRadarPings && radarPings != null) + { + radarPings.Add( + () => owner.IsAlliedWith(owner.World.RenderPlayer), + position, + owner.Color.RGB, + duration); + } + + return playerBeacon; + } + } +} From db0b20f5f818afedf71a6db65d43d069116b3ec9 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 22 Jun 2015 20:53:45 +0200 Subject: [PATCH 4/4] Use the new Beacon function in survival 01 and 02 --- mods/ra/maps/survival01/survival01.lua | 1 + mods/ra/maps/survival02/survival02.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/mods/ra/maps/survival01/survival01.lua b/mods/ra/maps/survival01/survival01.lua index 0812808745..c962fd7291 100644 --- a/mods/ra/maps/survival01/survival01.lua +++ b/mods/ra/maps/survival01/survival01.lua @@ -263,6 +263,7 @@ TimerExpired = function() SpawningInfantry = false SpawnNavalUnits = false + Beacon.New(allies, SovietEntryPoint7.CenterPosition - WVec.New(3 * 1024, 0, 0)) Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived") Reinforcements.Reinforce(allies, FrenchReinforcements, { SovietEntryPoint7.Location, Alliesbase.Location }) diff --git a/mods/ra/maps/survival02/survival02.lua b/mods/ra/maps/survival02/survival02.lua index 539e22561d..7e1af2cb19 100644 --- a/mods/ra/maps/survival02/survival02.lua +++ b/mods/ra/maps/survival02/survival02.lua @@ -151,6 +151,7 @@ end SendFrenchReinforcements = function() local camera = Actor.Create("camera", true, { Owner = allies, Location = SovietRally1.Location }) + Beacon.New(allies, FranceEntry.CenterPosition - WVec.New(0, 3 * 1024, 0)) Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived") Reinforcements.Reinforce(allies, FrenchSquad, { FranceEntry.Location, FranceRally.Location }) Trigger.AfterDelay(DateTime.Seconds(3), function() camera.Destroy() end)