Merge pull request #6378 from Mailaender/desert-shellmap-lua-cleaning

Desert shellmap Lua maintenance
This commit is contained in:
obrakmann
2014-09-06 23:14:09 +02:00
4 changed files with 75 additions and 39 deletions

View File

@@ -572,6 +572,7 @@
<Compile Include="Warheads\PerCellDamageWarhead.cs" /> <Compile Include="Warheads\PerCellDamageWarhead.cs" />
<Compile Include="Warheads\SpreadDamageWarhead.cs" /> <Compile Include="Warheads\SpreadDamageWarhead.cs" />
<Compile Include="Scripting\Global\ReinforcementsGlobal.cs" /> <Compile Include="Scripting\Global\ReinforcementsGlobal.cs" />
<Compile Include="Scripting\Global\DateGlobal.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj"> <ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">

View File

@@ -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; }
}
}
}

View File

@@ -1,9 +1,7 @@
local ants = Utils.RandomInteger(0, 51) == 0 if Date.IsHalloween then
if ants then
UnitTypes = { "ant", "ant", "ant" } UnitTypes = { "ant", "ant", "ant" }
BeachUnitTypes = { "ant", "ant" } BeachUnitTypes = { "ant", "ant" }
ParadropUnitTypes = { "ant", "ant", "ant", "ant", "ant" } ParadropUnitTypes = { "zombie", "zombie", "zombie", "zombie", "zombie" }
ProducedUnitTypes = ProducedUnitTypes =
{ {
{ AlliedBarracks1, { "e1", "e3" } }, { AlliedBarracks1, { "e1", "e3" } },
@@ -30,6 +28,9 @@ else
} }
end end
ShipUnitTypes = { "1tnk", "1tnk", "jeep", "2tnk", "2tnk" }
HelicopterUnitTypes = { "e1", "e1", "e1", "e1", "e3", "e3" };
ParadropWaypoints = { Paradrop1, Paradrop2, Paradrop3, Paradrop4, Paradrop5, Paradrop6, Paradrop7, Paradrop8 } ParadropWaypoints = { Paradrop1, Paradrop2, Paradrop3, Paradrop4, Paradrop5, Paradrop6, Paradrop7, Paradrop8 }
BindActorTriggers = function(a) BindActorTriggers = function(a)
@@ -52,39 +53,37 @@ BindActorTriggers = function(a)
end end
SendSovietUnits = function(entryCell, unitTypes, interval) SendSovietUnits = function(entryCell, unitTypes, interval)
local i = 0 local units = Reinforcements.Reinforce(soviets, unitTypes, { entryCell }, interval)
team = {} Utils.Do(units, function(unit)
BindActorTriggers(unit)
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
end) end)
Trigger.OnAllKilled(units, function() SendSovietUnits(entryCell, unitTypes, interval) end)
Trigger.OnAllKilled(team, function() SendSovietUnits(entryCell, unitTypes, interval) end)
end end
ShipAlliedUnits = function() 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) Utils.Do(units, function(unit)
local a = Actor.Create(type, false, { Owner = allies }) BindActorTriggers(unit)
BindActorTriggers(a)
transport.LoadPassenger(a)
end) end)
transport.Move(LstUnload.Location) Trigger.AfterDelay(Utils.Seconds(60), ShipAlliedUnits)
transport.UnloadPassengers() end
transport.Wait(50)
transport.Move(LstEntry.Location) InsertAlliedChinookReinforcements = function(entry, hpad)
transport.Destroy() local units = Reinforcements.ReinforceWithTransport(allies, "tran",
Trigger.AfterDelay(60 * 25, ShipAlliedUnits) 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 end
ParadropSovietUnits = function() 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 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 }) local transport = Actor.Create("badr", true, { CenterPosition = start, Owner = soviets, Facing = (Utils.CenterOfCell(lz) - start).Facing })
@@ -95,7 +94,7 @@ ParadropSovietUnits = function()
end) end)
transport.Paradrop(lz) transport.Paradrop(lz)
Trigger.AfterDelay(35 * 25, ParadropSovietUnits) Trigger.AfterDelay(Utils.Seconds(35), ParadropSovietUnits)
end end
ProduceUnits = function(t) ProduceUnits = function(t)
@@ -118,9 +117,9 @@ SetupAlliedUnits = function()
end end
SetupFactories = function() SetupFactories = function()
Utils.Do(ProducedUnitTypes, function(pair) Utils.Do(ProducedUnitTypes, function(pair)
Trigger.OnProduction(pair[1], function(_, a) BindActorTriggers(a) end) Trigger.OnProduction(pair[1], function(_, a) BindActorTriggers(a) end)
end) end)
end end
ChronoshiftAlliedUnits = function() ChronoshiftAlliedUnits = function()
@@ -129,10 +128,10 @@ ChronoshiftAlliedUnits = function()
for i = 1, #cells do for i = 1, #cells do
local unit = Actor.Create("2tnk", true, { Owner = allies, Facing = 0 }) local unit = Actor.Create("2tnk", true, { Owner = allies, Facing = 0 })
BindActorTriggers(unit) BindActorTriggers(unit)
units[unit] = cells[i] units[unit] = cells[i]
end end
Chronosphere.Chronoshift(units) Chronosphere.Chronoshift(units)
Trigger.AfterDelay(60 * 25, ChronoshiftAlliedUnits) Trigger.AfterDelay(Utils.Seconds(60), ChronoshiftAlliedUnits)
end end
ticks = 0 ticks = 0
@@ -153,9 +152,11 @@ WorldLoaded = function()
SetupAlliedUnits() SetupAlliedUnits()
SetupFactories() SetupFactories()
ShipAlliedUnits() ShipAlliedUnits()
InsertAlliedChinookReinforcements(Chinook1Entry, HeliPad1)
InsertAlliedChinookReinforcements(Chinook2Entry, HeliPad2)
ParadropSovietUnits() ParadropSovietUnits()
Trigger.AfterDelay(5 * 25, ChronoshiftAlliedUnits) Trigger.AfterDelay(Utils.Seconds(5), ChronoshiftAlliedUnits)
Utils.Do(ProducedUnitTypes, ProduceUnits) Utils.Do(ProducedUnitTypes, ProduceUnits)
SendSovietUnits(Entry1.Location, UnitTypes, 50) SendSovietUnits(Entry1.Location, UnitTypes, 50)
SendSovietUnits(Entry2.Location, UnitTypes, 50) SendSovietUnits(Entry2.Location, UnitTypes, 50)

View File

@@ -947,8 +947,8 @@ Actors:
Actor329: mine Actor329: mine
Location: 90,21 Location: 90,21
Owner: Neutral Owner: Neutral
Actor195: hpad HeliPad1: hpad
Location: 70,75 Location: 70,76
Owner: Allies Owner: Allies
Actor341: dome Actor341: dome
Location: 63,73 Location: 63,73
@@ -1004,7 +1004,7 @@ Actors:
Actor361: pbox Actor361: pbox
Location: 71,96 Location: 71,96
Owner: Allies Owner: Allies
Actor365: hpad HeliPad2: hpad
Location: 64,78 Location: 64,78
Owner: Allies Owner: Allies
Actor221: fenc Actor221: fenc
@@ -1217,6 +1217,12 @@ Actors:
LstUnload: waypoint LstUnload: waypoint
Location: 60,93 Location: 60,93
Owner: Neutral Owner: Neutral
Chinook1Entry: waypoint
Location: 44,126
Owner: Neutral
Chinook2Entry: waypoint
Location: 47,126
Owner: Neutral
Actor184: pbox Actor184: pbox
Location: 96,79 Location: 96,79
Owner: Allies Owner: Allies