diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 1f231b7e5e..c51a0d79f1 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -572,6 +572,7 @@ + diff --git a/OpenRA.Mods.RA/Scripting/Global/DateGlobal.cs b/OpenRA.Mods.RA/Scripting/Global/DateGlobal.cs new file mode 100644 index 0000000000..e93919bcf6 --- /dev/null +++ b/OpenRA.Mods.RA/Scripting/Global/DateGlobal.cs @@ -0,0 +1,28 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 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; +using Eluant; +using OpenRA.Scripting; + +namespace OpenRA.Mods.RA.Scripting +{ + [ScriptGlobal("Date")] + public class DateGlobal : ScriptGlobal + { + public DateGlobal(ScriptContext context) : base(context) { } + + [Desc("True on the 31st of October.")] + public bool IsHalloween + { + get { return DateTime.Today.Month == 10 && DateTime.Today.Day == 31; } + } + } +} diff --git a/mods/ra/maps/desert-shellmap/desert-shellmap.lua b/mods/ra/maps/desert-shellmap/desert-shellmap.lua index 22d182c27a..cc8b82f733 100644 --- a/mods/ra/maps/desert-shellmap/desert-shellmap.lua +++ b/mods/ra/maps/desert-shellmap/desert-shellmap.lua @@ -1,9 +1,7 @@ -local ants = Utils.RandomInteger(0, 51) == 0 - -if ants then +if Date.IsHalloween then UnitTypes = { "ant", "ant", "ant" } BeachUnitTypes = { "ant", "ant" } - ParadropUnitTypes = { "ant", "ant", "ant", "ant", "ant" } + ParadropUnitTypes = { "zombie", "zombie", "zombie", "zombie", "zombie" } ProducedUnitTypes = { { AlliedBarracks1, { "e1", "e3" } }, @@ -30,6 +28,9 @@ else } end +ShipUnitTypes = { "1tnk", "1tnk", "jeep", "2tnk", "2tnk" } +HelicopterUnitTypes = { "e1", "e1", "e1", "e1", "e3", "e3" }; + ParadropWaypoints = { Paradrop1, Paradrop2, Paradrop3, Paradrop4, Paradrop5, Paradrop6, Paradrop7, Paradrop8 } BindActorTriggers = function(a) @@ -52,39 +53,37 @@ BindActorTriggers = function(a) end SendSovietUnits = function(entryCell, unitTypes, interval) - local i = 0 - team = {} - - Utils.Do(unitTypes, function(type) - local a = Actor.Create(type, false, { Owner = soviets, Location = entryCell }) - BindActorTriggers(a) - Trigger.AfterDelay(i * interval, function() a.IsInWorld = true end) - table.insert(team, a) - i = i + 1 + local units = Reinforcements.Reinforce(soviets, unitTypes, { entryCell }, interval) + Utils.Do(units, function(unit) + BindActorTriggers(unit) end) - - Trigger.OnAllKilled(team, function() SendSovietUnits(entryCell, unitTypes, interval) end) + Trigger.OnAllKilled(units, function() SendSovietUnits(entryCell, unitTypes, interval) end) end ShipAlliedUnits = function() - local transport = Actor.Create("lst", true, { Location = LstEntry.Location, Owner = allies }) + local units = Reinforcements.ReinforceWithTransport(allies, "lst", + ShipUnitTypes, { LstEntry.Location, LstUnload.Location }, { LstEntry.Location })[2] - Utils.Do({ "1tnk", "1tnk", "jeep", "2tnk", "2tnk" }, function(type) - local a = Actor.Create(type, false, { Owner = allies }) - BindActorTriggers(a) - transport.LoadPassenger(a) + Utils.Do(units, function(unit) + BindActorTriggers(unit) end) - transport.Move(LstUnload.Location) - transport.UnloadPassengers() - transport.Wait(50) - transport.Move(LstEntry.Location) - transport.Destroy() - Trigger.AfterDelay(60 * 25, ShipAlliedUnits) + Trigger.AfterDelay(Utils.Seconds(60), ShipAlliedUnits) +end + +InsertAlliedChinookReinforcements = function(entry, hpad) + local units = Reinforcements.ReinforceWithTransport(allies, "tran", + HelicopterUnitTypes, { entry.Location, hpad.Location + CVec.New(1, 2) }, { entry.Location })[2] + + Utils.Do(units, function(unit) + BindActorTriggers(unit) + end) + + Trigger.AfterDelay(Utils.Seconds(60), function() InsertAlliedChinookReinforcements(entry, hpad) end) end ParadropSovietUnits = function() - local lz = Utils.Random(ParadropWaypoints).Location + local lz = Utils.Random(ParadropWaypoints).Location local start = Utils.CenterOfCell(Map.RandomEdgeCell()) + WVec.New(0, 0, Actor.CruiseAltitude("badr")) local transport = Actor.Create("badr", true, { CenterPosition = start, Owner = soviets, Facing = (Utils.CenterOfCell(lz) - start).Facing }) @@ -95,7 +94,7 @@ ParadropSovietUnits = function() end) transport.Paradrop(lz) - Trigger.AfterDelay(35 * 25, ParadropSovietUnits) + Trigger.AfterDelay(Utils.Seconds(35), ParadropSovietUnits) end ProduceUnits = function(t) @@ -118,9 +117,9 @@ SetupAlliedUnits = function() end SetupFactories = function() - Utils.Do(ProducedUnitTypes, function(pair) + Utils.Do(ProducedUnitTypes, function(pair) Trigger.OnProduction(pair[1], function(_, a) BindActorTriggers(a) end) - end) + end) end ChronoshiftAlliedUnits = function() @@ -129,10 +128,10 @@ ChronoshiftAlliedUnits = function() for i = 1, #cells do local unit = Actor.Create("2tnk", true, { Owner = allies, Facing = 0 }) BindActorTriggers(unit) - units[unit] = cells[i] - end - Chronosphere.Chronoshift(units) - Trigger.AfterDelay(60 * 25, ChronoshiftAlliedUnits) + units[unit] = cells[i] + end + Chronosphere.Chronoshift(units) + Trigger.AfterDelay(Utils.Seconds(60), ChronoshiftAlliedUnits) end ticks = 0 @@ -153,9 +152,11 @@ WorldLoaded = function() SetupAlliedUnits() SetupFactories() ShipAlliedUnits() + InsertAlliedChinookReinforcements(Chinook1Entry, HeliPad1) + InsertAlliedChinookReinforcements(Chinook2Entry, HeliPad2) ParadropSovietUnits() - Trigger.AfterDelay(5 * 25, ChronoshiftAlliedUnits) - Utils.Do(ProducedUnitTypes, ProduceUnits) + Trigger.AfterDelay(Utils.Seconds(5), ChronoshiftAlliedUnits) + Utils.Do(ProducedUnitTypes, ProduceUnits) SendSovietUnits(Entry1.Location, UnitTypes, 50) SendSovietUnits(Entry2.Location, UnitTypes, 50) diff --git a/mods/ra/maps/desert-shellmap/map.yaml b/mods/ra/maps/desert-shellmap/map.yaml index 9fc0a2cdfe..9410038d01 100644 --- a/mods/ra/maps/desert-shellmap/map.yaml +++ b/mods/ra/maps/desert-shellmap/map.yaml @@ -947,8 +947,8 @@ Actors: Actor329: mine Location: 90,21 Owner: Neutral - Actor195: hpad - Location: 70,75 + HeliPad1: hpad + Location: 70,76 Owner: Allies Actor341: dome Location: 63,73 @@ -1004,7 +1004,7 @@ Actors: Actor361: pbox Location: 71,96 Owner: Allies - Actor365: hpad + HeliPad2: hpad Location: 64,78 Owner: Allies Actor221: fenc @@ -1217,6 +1217,12 @@ Actors: LstUnload: waypoint Location: 60,93 Owner: Neutral + Chinook1Entry: waypoint + Location: 44,126 + Owner: Neutral + Chinook2Entry: waypoint + Location: 47,126 + Owner: Neutral Actor184: pbox Location: 96,79 Owner: Allies