Convert Lua array-like structures to use named entries

This commit is contained in:
atlimit8
2015-10-18 15:14:11 -05:00
parent c87c2270ca
commit f79ac636f2
18 changed files with 265 additions and 267 deletions

View File

@@ -11,19 +11,19 @@ GDIReinforcements = { "e2", "e2", "e2", "e2", "e2" }
GDIReinforcementsWaypoints = { GDIReinforcementsEntry.Location, GDIReinforcementsWP1.Location }
NodHelis = {
{ DateTime.Seconds(HeliDelay[1]), { NodHeliEntry.Location, NodHeliLZ1.Location }, { "e1", "e1", "e3" } },
{ DateTime.Seconds(HeliDelay[2]), { NodHeliEntry.Location, NodHeliLZ2.Location }, { "e1", "e1", "e1", "e1" } },
{ DateTime.Seconds(HeliDelay[3]), { NodHeliEntry.Location, NodHeliLZ3.Location }, { "e1", "e1", "e3" } }
{ delay = DateTime.Seconds(HeliDelay[1]), entry = { NodHeliEntry.Location, NodHeliLZ1.Location }, types = { "e1", "e1", "e3" } },
{ delay = DateTime.Seconds(HeliDelay[2]), entry = { NodHeliEntry.Location, NodHeliLZ2.Location }, types = { "e1", "e1", "e1", "e1" } },
{ delay = DateTime.Seconds(HeliDelay[3]), entry = { NodHeliEntry.Location, NodHeliLZ3.Location }, types = { "e1", "e1", "e3" } }
}
SendHeli = function(heli)
units = Reinforcements.ReinforceWithTransport(enemy, "tran", heli[3], heli[2], { heli[2][1] })
units = Reinforcements.ReinforceWithTransport(enemy, "tran", heli.types, heli.entry, { heli.entry[1] })
Utils.Do(units[2], function(actor)
actor.Hunt()
Trigger.OnIdle(actor, actor.Hunt)
Trigger.OnKilled(actor, KillCounter)
end)
Trigger.AfterDelay(heli[1], function() SendHeli(heli) end)
Trigger.AfterDelay(heli.delay, function() SendHeli(heli) end)
end
SendGDIReinforcements = function()
@@ -134,7 +134,7 @@ WorldLoaded = function()
BuildNod1()
Utils.Do(NodHelis, function(heli)
Trigger.AfterDelay(heli[1], function() SendHeli(heli) end)
Trigger.AfterDelay(heli.delay, function() SendHeli(heli) end)
end)
autoTrigger = false

View File

@@ -28,25 +28,25 @@ AttackUnitTypes =
{
Easy =
{
{ HandOfNod, { "e1", "e1" } },
{ HandOfNod, { "e1", "e3" } },
{ HandOfNod, { "e1", "e1", "e3" } },
{ HandOfNod, { "e1", "e3", "e3" } },
{ factory = HandOfNod, types = { "e1", "e1" } },
{ factory = HandOfNod, types = { "e1", "e3" } },
{ factory = HandOfNod, types = { "e1", "e1", "e3" } },
{ factory = HandOfNod, types = { "e1", "e3", "e3" } },
},
Normal =
{
{ HandOfNod, { "e1", "e1", "e3" } },
{ HandOfNod, { "e1", "e3", "e3" } },
{ HandOfNod, { "e1", "e1", "e3", "e3" } },
{ Airfield, { "bggy" } },
{ factory = HandOfNod, types = { "e1", "e1", "e3" } },
{ factory = HandOfNod, types = { "e1", "e3", "e3" } },
{ factory = HandOfNod, types = { "e1", "e1", "e3", "e3" } },
{ factory = Airfield, types = { "bggy" } },
},
Hard =
{
{ HandOfNod, { "e1", "e1", "e3", "e3" } },
{ HandOfNod, { "e1", "e1", "e1", "e3", "e3" } },
{ HandOfNod, { "e1", "e1", "e3", "e3", "e3" } },
{ Airfield, { "bggy" } },
{ Airfield, { "ltnk" } },
{ factory = HandOfNod, types = { "e1", "e1", "e3", "e3" } },
{ factory = HandOfNod, types = { "e1", "e1", "e1", "e3", "e3" } },
{ factory = HandOfNod, types = { "e1", "e1", "e3", "e3", "e3" } },
{ factory = Airfield, types = { "bggy" } },
{ factory = Airfield, types = { "ltnk" } },
}
}
AttackPaths =
@@ -68,9 +68,9 @@ Build = function(factory, units, action)
end
Attack = function()
local types = Utils.Random(AttackUnitTypes[Map.Difficulty])
local production = Utils.Random(AttackUnitTypes[Map.Difficulty])
local path = Utils.Random(AttackPaths)
Build(types[1], types[2], function(units)
Build(production.factory, production.types, function(units)
Utils.Do(units, function(unit)
if unit.Owner ~= enemy then return end
unit.Patrol(path, false)
@@ -224,4 +224,4 @@ Tick = function()
if baseDiscovered and enemy.HasNoRequiredUnits() then
player.MarkCompletedObjective(gdiObjective3)
end
end
end

View File

@@ -8,14 +8,14 @@ AtkRoute2 = { waypoint0.Location, waypoint1.Location, waypoint2.Location, waypoi
AutoCreateTeams =
{
{ { ['e1'] = 1, ['e3'] = 3 }, AtkRoute2 },
{ { ['e1'] = 3, ['e3'] = 1 }, AtkRoute2 },
{ { ['e3'] = 4 } , AtkRoute1 },
{ { ['e1'] = 4 } , AtkRoute1 },
{ { ['bggy'] = 1 } , AtkRoute1 },
{ { ['bggy'] = 1 } , AtkRoute2 },
{ { ['ltnk'] = 1 } , AtkRoute1 },
{ { ['ltnk'] = 1 } , AtkRoute2 }
{ types = { e1 = 1, e3 = 3 }, route = AtkRoute2 },
{ types = { e1 = 3, e3 = 1 }, route = AtkRoute2 },
{ types = { e3 = 4 } , route = AtkRoute1 },
{ types = { e1 = 4 } , route = AtkRoute1 },
{ types = { bggy = 1 } , route = AtkRoute1 },
{ types = { bggy = 1 } , route = AtkRoute2 },
{ types = { ltnk = 1 } , route = AtkRoute1 },
{ types = { ltnk = 1 } , route = AtkRoute2 }
}
RepairThreshold = 0.6
@@ -55,8 +55,8 @@ end
AutoCreateTeam = function()
local team = Utils.Random(AutoCreateTeams)
for type, count in pairs(team[1]) do
MoveThenHunt(Utils.Take(count, enemy.GetActorsByType(type)), team[2])
for type, count in pairs(team.types) do
MoveThenHunt(Utils.Take(count, enemy.GetActorsByType(type)), team.route)
end
Trigger.AfterDelay(Utils.RandomInteger(AutoAtkMinDelay, AutoAtkMaxDelay), AutoCreateTeam)