From 59a5eb493746abc3f4792085a9601d3b18f672fb Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 27 May 2015 16:51:07 +0200 Subject: [PATCH 1/3] Add default facings to lua --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../Scripting/Global/FacingGlobal.cs | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 OpenRA.Mods.Common/Scripting/Global/FacingGlobal.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 2c6ecd2864..e9f82be475 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -177,6 +177,7 @@ + diff --git a/OpenRA.Mods.Common/Scripting/Global/FacingGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/FacingGlobal.cs new file mode 100644 index 0000000000..dc069f035a --- /dev/null +++ b/OpenRA.Mods.Common/Scripting/Global/FacingGlobal.cs @@ -0,0 +1,30 @@ +#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 OpenRA.Scripting; + +namespace OpenRA.Mods.Common.Scripting.Global +{ + [ScriptGlobal("Facing")] + public class FacingGlobal : ScriptGlobal + { + public FacingGlobal(ScriptContext context) + : base(context) { } + + public int North { get { return 0; } } + public int NorthWest { get { return 32; } } + public int West { get { return 64; } } + public int SouthWest { get { return 96; } } + public int South { get { return 128; } } + public int SouthEast { get { return 160; } } + public int East { get { return 192; } } + public int NorthEast { get { return 224; } } + } +} From 05229e79cee4ea1424f5c78666296ca1d11030f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 27 May 2015 21:50:51 +0200 Subject: [PATCH 2/3] use the new facing global --- mods/cnc/maps/nod05/nod05.lua | 2 +- mods/cnc/maps/nod06a/nod06a.lua | 2 +- mods/ra/maps/survival02/survival02.lua | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mods/cnc/maps/nod05/nod05.lua b/mods/cnc/maps/nod05/nod05.lua index b40e42ea3b..b488468ce6 100644 --- a/mods/cnc/maps/nod05/nod05.lua +++ b/mods/cnc/maps/nod05/nod05.lua @@ -46,7 +46,7 @@ SendGDIAirstrike = function() local target = getAirstrikeTarget() if target then - Radar.SendAirstrike(target, false, 256 - 28) + Radar.SendAirstrike(target, false, Facing.NorthEast + 4) Trigger.AfterDelay(AirstrikeDelay, SendGDIAirstrike) else Trigger.AfterDelay(AirstrikeDelay/4, SendGDIAirstrike) diff --git a/mods/cnc/maps/nod06a/nod06a.lua b/mods/cnc/maps/nod06a/nod06a.lua index d16df4226e..bc2c817d0a 100644 --- a/mods/cnc/maps/nod06a/nod06a.lua +++ b/mods/cnc/maps/nod06a/nod06a.lua @@ -76,7 +76,7 @@ Atk3TriggerFunction = function() local target = targets[DateTime.GameTime % #targets + 1].CenterPosition if target then - Radar.SendAirstrike(target, false, 256 - 28) + Radar.SendAirstrike(target, false, Facing.NorthEast + 4) end end end diff --git a/mods/ra/maps/survival02/survival02.lua b/mods/ra/maps/survival02/survival02.lua index 239b771ecc..afde06dadc 100644 --- a/mods/ra/maps/survival02/survival02.lua +++ b/mods/ra/maps/survival02/survival02.lua @@ -161,9 +161,9 @@ FrenchReinforcements = function() end powerproxy = Actor.Create("powerproxy.parabombs", false, { Owner = allies }) - powerproxy.SendAirstrike(drum1.CenterPosition, false, 256 - 28) - powerproxy.SendAirstrike(drum2.CenterPosition, false, 256 - 32) - powerproxy.SendAirstrike(drum3.CenterPosition, false, 256 - 36) + powerproxy.SendAirstrike(drum1.CenterPosition, false, Facing.NorthEast + 4) + powerproxy.SendAirstrike(drum2.CenterPosition, false, Facing.NorthEast) + powerproxy.SendAirstrike(drum3.CenterPosition, false, Facing.NorthEast - 4) powerproxy.Destroy() Trigger.AfterDelay(DateTime.Seconds(3), function() From 34f3d2d5f14b894f4e4c31bd12d459caf65e2393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 27 May 2015 21:51:15 +0200 Subject: [PATCH 3/3] avoid code duplication --- mods/ra/maps/survival02/survival02.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mods/ra/maps/survival02/survival02.lua b/mods/ra/maps/survival02/survival02.lua index afde06dadc..da74ccb272 100644 --- a/mods/ra/maps/survival02/survival02.lua +++ b/mods/ra/maps/survival02/survival02.lua @@ -149,14 +149,18 @@ SpawnAndAttack = function(types, entry) return units end +SendFrenchReinforcements = function() + local camera = Actor.Create("camera", true, { Owner = allies, Location = SovietRally1.Location }) + Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived") + Reinforcements.Reinforce(allies, FrenchSquad, { FranceEntry.Location, FranceRally.Location }) + Trigger.AfterDelay(DateTime.Seconds(3), function() camera.Destroy() end) +end + FrenchReinforcements = function() Camera.Position = SovietRally1.CenterPosition - local camera = Actor.Create("camera", true, { Owner = allies, Location = SovietRally1.Location }) if drum1.IsDead or drum2.IsDead or drum3.IsDead then - Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived") - Reinforcements.Reinforce(allies, FrenchSquad, { FranceEntry.Location, FranceRally.Location }) - Trigger.AfterDelay(DateTime.Seconds(3), function() camera.Destroy() end) + SendFrenchReinforcements() return end @@ -167,9 +171,7 @@ FrenchReinforcements = function() powerproxy.Destroy() Trigger.AfterDelay(DateTime.Seconds(3), function() - Media.PlaySpeechNotification(allies, "AlliedReinforcementsArrived") - Reinforcements.Reinforce(allies, FrenchSquad, { FranceEntry.Location, FranceRally.Location }) - Trigger.AfterDelay(DateTime.Seconds(3), function() camera.Destroy() end) + SendFrenchReinforcements() end) end