Port gdi04a to the new Lua API
This commit is contained in:
@@ -1,137 +1,166 @@
|
||||
Nod1Template = { {HandOfNod, {"e1", "e1", "e3", "e3"}} }
|
||||
Auto1Template = { {HandOfNod, {"e1", "e1", "e3"}} }
|
||||
AutoTrigger = { CPos.New(51, 47), CPos.New(52, 47), CPos.New(53, 47), CPos.New(54, 47) }
|
||||
GDIHeliTrigger = { CPos.New(27, 55), CPos.New(27, 56), CPos.New(28, 56), CPos.New(28, 57), CPos.New(28, 58), CPos.New(28, 59)}
|
||||
|
||||
Nod1Units = { "e1", "e1", "e3", "e3" }
|
||||
Auto1Units = { "e1", "e1", "e3" }
|
||||
|
||||
KillsUntilReinforcements = 12
|
||||
HeliDelay = {83, 137, 211}
|
||||
HeliDelay = { 83, 137, 211 }
|
||||
|
||||
GDIReinforcements = {"e2", "e2", "e2", "e2"}
|
||||
GDIReinforcementsWaypoints = {GDIReinforcementsEntry, GDIReinforcementsWP1}
|
||||
GDIReinforcements = { "e2", "e2", "e2", "e2", "e2" }
|
||||
GDIReinforcementsWaypoints = { GDIReinforcementsEntry.Location, GDIReinforcementsWP1.Location }
|
||||
|
||||
NodHelis = {
|
||||
{Utils.Seconds(HeliDelay[1]), {NodHeliEntry, NodHeliLZ1}, {"e1", "e1", "e3"}},
|
||||
{Utils.Seconds(HeliDelay[2]), {NodHeliEntry, NodHeliLZ2}, {"e1", "e1", "e1", "e1"}},
|
||||
{Utils.Seconds(HeliDelay[3]), {NodHeliEntry, NodHeliLZ3}, {"e1", "e1", "e3"}}
|
||||
{ Utils.Seconds(HeliDelay[1]), { NodHeliEntry.Location, NodHeliLZ1.Location }, { "e1", "e1", "e3" } },
|
||||
{ Utils.Seconds(HeliDelay[2]), { NodHeliEntry.Location, NodHeliLZ2.Location }, { "e1", "e1", "e1", "e1" } },
|
||||
{ Utils.Seconds(HeliDelay[3]), { NodHeliEntry.Location, NodHeliLZ3.Location }, { "e1", "e1", "e3" } }
|
||||
}
|
||||
|
||||
SendHeli = function(heli, func)
|
||||
Reinforcements.ReinforceWithCargo(nod, "tran", heli[2], heli[3], func)
|
||||
OpenRA.RunAfterDelay(heli[1], function() SendHeli(heli, func) end)
|
||||
end
|
||||
|
||||
HeliAction = function(heliActor, team)
|
||||
Actor.AfterMove(heliActor)
|
||||
Actor.UnloadCargo(heliActor, true)
|
||||
Actor.Wait(heliActor, Utils.Seconds(2))
|
||||
Actor.ScriptedMove(heliActor, NodHeliEntry.Location)
|
||||
Actor.RemoveSelf(heliActor)
|
||||
|
||||
Team.Do(team, function(actor)
|
||||
Actor.Hunt(actor)
|
||||
Actor.OnIdle(actor, Actor.Hunt)
|
||||
Actor.OnKilled(actor, KillCounter)
|
||||
SendHeli = function(heli)
|
||||
units = Reinforcements.ReinforceWithTransport(nod, "tran", heli[3], heli[2], { heli[2][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)
|
||||
end
|
||||
|
||||
SendGDIReinforcements = function()
|
||||
Reinforcements.ReinforceWithCargo(player, "apc", GDIReinforcementsWaypoints, GDIReinforcements, function(apc, team)
|
||||
Team.Add(team, apc)
|
||||
Actor.OnKilled(apc, SendGDIReinforcements)
|
||||
Team.Do(team, function(unit) Actor.SetStance(unit, "Defend") end)
|
||||
Media.PlaySpeechNotification(gdi, "Reinforce")
|
||||
Reinforcements.ReinforceWithTransport(gdi, "apc", GDIReinforcements, GDIReinforcementsWaypoints, nil, function(apc, team)
|
||||
table.insert(team, apc)
|
||||
Trigger.OnAllKilled(team, function() Trigger.AfterDelay(Utils.Seconds(5), SendGDIReinforcements) end)
|
||||
Utils.Do(team, function(unit) unit.Stance = "Defend" end)
|
||||
end)
|
||||
end
|
||||
|
||||
BuildNod1 = function()
|
||||
Production.BuildTeamFromTemplate(nod, Nod1Template, function(team)
|
||||
Team.Do(team, function(actor)
|
||||
Actor.OnIdle(actor, Actor.Hunt)
|
||||
Actor.OnKilled(actor, KillCounter)
|
||||
if HandOfNod.IsDead then
|
||||
return
|
||||
end
|
||||
|
||||
local func = function(team)
|
||||
Utils.Do(team, function(actor)
|
||||
Trigger.OnIdle(actor, actor.Hunt)
|
||||
Trigger.OnKilled(actor, KillCounter)
|
||||
end)
|
||||
Team.AddEventHandler(team.OnAllKilled, BuildNod1)
|
||||
end)
|
||||
Trigger.OnAllKilled(team, BuildNod1)
|
||||
end
|
||||
|
||||
if not HandOfNod.Build(Nod1Units, func) then
|
||||
Trigger.AfterDelay(Utils.Seconds(5), BuildNod1)
|
||||
end
|
||||
end
|
||||
|
||||
BuildAuto1 = function()
|
||||
Production.BuildTeamFromTemplate(nod, Auto1Template, function(team)
|
||||
Team.Do(team, function(actor)
|
||||
Actor.OnIdle(actor, Actor.Hunt)
|
||||
Actor.OnKilled(actor, KillCounter)
|
||||
if HandOfNod.IsDead then
|
||||
return
|
||||
end
|
||||
|
||||
local func = function(team)
|
||||
Utils.Do(team, function(actor)
|
||||
Trigger.OnIdle(actor, actor.Hunt)
|
||||
Trigger.OnKilled(actor, KillCounter)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
if not HandOfNod.IsDead and HandOfNod.Build(Auto1Units, func) then
|
||||
Trigger.AfterDelay(Utils.Seconds(5), BuildAuto1)
|
||||
end
|
||||
end
|
||||
|
||||
kills = 0
|
||||
KillCounter = function() kills = kills + 1 end
|
||||
|
||||
Auto1Triggered = false
|
||||
GDIHeliTriggered = false
|
||||
ReinforcementsSent = false
|
||||
Tick = function()
|
||||
nod.Cash = 1000
|
||||
|
||||
if not ReinforcementsSent and kills >= KillsUntilReinforcements then
|
||||
ReinforcementsSent = true
|
||||
gdi.MarkCompletedObjective(reinforcementsObjective)
|
||||
SendGDIReinforcements()
|
||||
end
|
||||
|
||||
if Mission.RequiredUnitsAreDestroyed(player) then
|
||||
OpenRA.RunAfterDelay(Utils.Seconds(1), MissionFailed)
|
||||
end
|
||||
|
||||
if not Auto1Triggered then
|
||||
-- FIXME: replace with cell trigger when available
|
||||
local units = Map.FindUnitsInCircle(player, Auto1Trigger, 2)
|
||||
if #units > 0 then
|
||||
Auto1Triggered = true
|
||||
BuildAuto1()
|
||||
end
|
||||
elseif not GDIHeliTriggered then
|
||||
-- FIXME: replace with cell trigger when available
|
||||
local units = Map.FindUnitsInCircle(player, GDIHeliLZ, 2)
|
||||
if #units > 0 then
|
||||
GDIHeliTriggered = true
|
||||
Reinforcements.ReinforceWithCargo(player, "tran", {GDIHeliEntry, GDIHeliLZ}, nil, Actor.AfterMove)
|
||||
end
|
||||
if gdi.HasNoRequiredUnits() then
|
||||
Trigger.AfterDelay(Utils.Seconds(1), function() gdi.MarkFailedObjective(gdiObjective) end)
|
||||
end
|
||||
end
|
||||
|
||||
SetupWorld = function()
|
||||
OpenRA.GiveCash(nod, 10000)
|
||||
Production.EventHandlers.Setup(nod)
|
||||
|
||||
Utils.Do(Mission.GetGroundAttackersOf(nod), function(unit)
|
||||
Actor.OnKilled(unit, KillCounter)
|
||||
Utils.Do(nod.GetGroundAttackers(nod), function(unit)
|
||||
Trigger.OnKilled(unit, KillCounter)
|
||||
end)
|
||||
|
||||
Utils.Do(Mission.GetGroundAttackersOf(player), function(unit)
|
||||
Actor.SetStance(unit, "Defend")
|
||||
Utils.Do(gdi.GetGroundAttackers(), function(unit)
|
||||
unit.Stance = "Defend"
|
||||
end)
|
||||
|
||||
Actor.Hunt(Hunter1)
|
||||
Actor.Hunt(Hunter2)
|
||||
Hunter1.Hunt()
|
||||
Hunter2.Hunt()
|
||||
|
||||
Actor.OnRemovedFromWorld(crate, MissionAccomplished)
|
||||
Trigger.OnRemovedFromWorld(crate, function() gdi.MarkCompletedObjective(gdiObjective) end)
|
||||
end
|
||||
|
||||
WorldLoaded = function()
|
||||
Media.PlayMovieFullscreen("bkground.vqa", function() Media.PlayMovieFullscreen("nitejump.vqa") end)
|
||||
|
||||
player = OpenRA.GetPlayer("GDI")
|
||||
nod = OpenRA.GetPlayer("Nod")
|
||||
gdi = Player.GetPlayer("GDI")
|
||||
nod = Player.GetPlayer("Nod")
|
||||
|
||||
SetupWorld()
|
||||
|
||||
OpenRA.RunAfterDelay(1, BuildNod1)
|
||||
Utils.Do(NodHelis, function(heli)
|
||||
OpenRA.RunAfterDelay(heli[1], function() SendHeli(heli, HeliAction) end)
|
||||
Trigger.OnObjectiveAdded(gdi, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective")
|
||||
end)
|
||||
Trigger.OnObjectiveCompleted(gdi, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||
end)
|
||||
Trigger.OnObjectiveFailed(gdi, function(p, id)
|
||||
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||
end)
|
||||
|
||||
OpenRA.SetViewportCenterPosition(Actor56.CenterPosition)
|
||||
end
|
||||
Trigger.OnPlayerWon(gdi, function()
|
||||
Media.PlaySpeechNotification(gdi, "Win")
|
||||
Trigger.AfterDelay(Utils.Seconds(1), function()
|
||||
Media.PlayMovieFullscreen("burdet1.vqa")
|
||||
end)
|
||||
end)
|
||||
|
||||
MissionAccomplished = function()
|
||||
Mission.MissionOver({ player }, nil, true)
|
||||
Media.PlayMovieFullscreen("burdet1.vqa")
|
||||
end
|
||||
Trigger.OnPlayerLost(gdi, function()
|
||||
Media.PlaySpeechNotification(gdi, "Lose")
|
||||
Trigger.AfterDelay(Utils.Seconds(1), function()
|
||||
Media.PlayMovieFullscreen("gameover.vqa")
|
||||
end)
|
||||
end)
|
||||
|
||||
MissionFailed = function()
|
||||
Mission.MissionOver(nil, { player }, true)
|
||||
Media.PlayMovieFullscreen("gameover.vqa")
|
||||
gdiObjective = gdi.AddPrimaryObjective("Retrieve the crate with the stolen rods.")
|
||||
reinforcementsObjective = gdi.AddSecondaryObjective("Eliminate " .. KillsUntilReinforcements .. " Nod units for reinforcements.")
|
||||
nod.AddPrimaryObjective("Defend against the GDI forces.")
|
||||
|
||||
BuildNod1()
|
||||
Utils.Do(NodHelis, function(heli)
|
||||
Trigger.AfterDelay(heli[1], function() SendHeli(heli) end)
|
||||
end)
|
||||
|
||||
autoTrigger = false
|
||||
Trigger.OnEnteredFootprint(AutoTrigger, function(a, id)
|
||||
if not autoTrigger and a.Owner == gdi then
|
||||
autoTrigger = true
|
||||
Trigger.RemoveFootprintTrigger(id)
|
||||
BuildAuto1()
|
||||
end
|
||||
end)
|
||||
|
||||
gdiHeliTrigger = false
|
||||
Trigger.OnEnteredFootprint(GDIHeliTrigger, function(a, id)
|
||||
if not gdiHeliTrigger and a.Owner == gdi then
|
||||
gdiHeliTrigger = true
|
||||
Trigger.RemoveFootprintTrigger(id)
|
||||
Reinforcements.ReinforceWithTransport(gdi, "tran", nil, { GDIHeliEntry.Location, GDIHeliLZ.Location })
|
||||
end
|
||||
end)
|
||||
|
||||
Camera.Position = Actor56.CenterPosition
|
||||
|
||||
Media.PlayMovieFullscreen("bkground.vqa", function() Media.PlayMovieFullscreen("nitejump.vqa") end)
|
||||
end
|
||||
|
||||
@@ -326,6 +326,12 @@ Actors:
|
||||
Health: 1
|
||||
Facing: 0
|
||||
SubCell: 3
|
||||
Actor710: e1
|
||||
Location: 12,54
|
||||
Owner: GDI
|
||||
Health: 1
|
||||
Facing: 0
|
||||
SubCell: 5
|
||||
Actor71: e1
|
||||
Location: 12,54
|
||||
Owner: GDI
|
||||
@@ -416,6 +422,12 @@ Actors:
|
||||
Health: 1
|
||||
Facing: 64
|
||||
SubCell: 4
|
||||
Actor860: e2
|
||||
Location: 14,54
|
||||
Owner: GDI
|
||||
Health: 1
|
||||
Facing: 0
|
||||
SubCell: 5
|
||||
Actor86: e2
|
||||
Location: 14,54
|
||||
Owner: GDI
|
||||
@@ -524,9 +536,6 @@ Actors:
|
||||
GDIReinforcementsEntry: waypoint
|
||||
Location: 7,50
|
||||
Owner: Neutral
|
||||
Auto1Trigger: waypoint
|
||||
Location: 52,47
|
||||
Owner: Neutral
|
||||
NodHeliEntry: waypoint
|
||||
Location: 41,23
|
||||
Owner: Neutral
|
||||
@@ -547,8 +556,8 @@ Rules:
|
||||
-SpawnMPUnits:
|
||||
-MPStartLocations:
|
||||
-CrateSpawner:
|
||||
LuaScriptInterface:
|
||||
LuaScripts: gdi04a.lua
|
||||
LuaScript:
|
||||
Scripts: gdi04a.lua
|
||||
ObjectivesPanel:
|
||||
PanelName: MISSION_OBJECTIVES
|
||||
Player:
|
||||
@@ -595,18 +604,16 @@ Rules:
|
||||
GenericVisibility: Enemy, Ally, Neutral
|
||||
GenericStancePrefix: false
|
||||
ShowOwnerRow: false
|
||||
HARV:
|
||||
-MustBeDestroyed:
|
||||
CRATE:
|
||||
Crate:
|
||||
Lifetime: 9999
|
||||
LuaScriptEvents:
|
||||
HealUnitsCrateAction:
|
||||
-RevealMapCrateAction:
|
||||
-GiveMcvCrateAction:
|
||||
-GiveCashCrateAction:
|
||||
-ExplodeCrateAction@fire:
|
||||
-GrantUpgradeCrateAction@cloak:
|
||||
-DuplicateUnitCrateAction:
|
||||
ScriptTriggers:
|
||||
|
||||
Sequences:
|
||||
@@ -615,7 +622,7 @@ VoxelSequences:
|
||||
|
||||
Weapons:
|
||||
Tiberium:
|
||||
Warhead: SpreadDamage
|
||||
Warhead@1Dam: SpreadDamage
|
||||
Damage: 6
|
||||
|
||||
Voices:
|
||||
|
||||
Reference in New Issue
Block a user