From ccd6540e13135dc4bf07adfa9fbcdd77f08340cc Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sun, 17 Aug 2014 20:56:42 +0200 Subject: [PATCH] Port nod01 to New Lua --- mods/cnc/maps/nod01/map.yaml | 4 +- mods/cnc/maps/nod01/nod01.lua | 75 ++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/mods/cnc/maps/nod01/map.yaml b/mods/cnc/maps/nod01/map.yaml index ea3be27838..ee5846e0d8 100644 --- a/mods/cnc/maps/nod01/map.yaml +++ b/mods/cnc/maps/nod01/map.yaml @@ -310,8 +310,8 @@ Rules: -CrateSpawner: -SpawnMPUnits: -MPStartLocations: - LuaScriptInterface: - LuaScripts: nod01.lua + LuaScript: + Scripts: nod01.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES C10: diff --git a/mods/cnc/maps/nod01/nod01.lua b/mods/cnc/maps/nod01/nod01.lua index 6db3abfa2d..b2e3fd1a4d 100644 --- a/mods/cnc/maps/nod01/nod01.lua +++ b/mods/cnc/maps/nod01/nod01.lua @@ -1,47 +1,66 @@ -RifleInfantryReinforcements = { "e1", "e1", } +RifleInfantryReinforcements = { "e1", "e1" } RocketInfantryReinforcements = { "e3", "e3", "e3" } -MissionAccomplished = function() - Mission.MissionOver({ player }, nil, true) -end - -MissionFailed = function() - Mission.MissionOver(nil, { player }, true) - Media.PlayMovieFullscreen("nodlose.vqa") -end - SendFirstInfantryReinforcements = function() - Media.PlaySpeechNotification("Reinforce") - Reinforcements.Reinforce(player, RifleInfantryReinforcements, StartSpawnPointRight.Location, StartRallyPoint.Location, 15) + Media.PlaySpeechNotification(nod, "Reinforce") + Reinforcements.Reinforce(nod, RifleInfantryReinforcements, { StartSpawnPointRight.Location, StartRallyPoint.Location }, 15) end SendSecondInfantryReinforcements = function() - Media.PlaySpeechNotification("Reinforce") - Reinforcements.Reinforce(player, RifleInfantryReinforcements, StartSpawnPointLeft.Location, StartRallyPoint.Location, 15) + Media.PlaySpeechNotification(nod, "Reinforce") + Reinforcements.Reinforce(nod, RifleInfantryReinforcements, { StartSpawnPointLeft.Location, StartRallyPoint.Location }, 15) end SendLastInfantryReinforcements = function() - Media.PlaySpeechNotification("Reinforce") - Reinforcements.Reinforce(player, RocketInfantryReinforcements, VillageSpawnPoint.Location, VillageRallyPoint.Location, 15) + Media.PlaySpeechNotification(nod, "Reinforce") + Reinforcements.Reinforce(nod, RocketInfantryReinforcements, { VillageSpawnPoint.Location, VillageRallyPoint.Location }, 15) end WorldLoaded = function() - player = OpenRA.GetPlayer("Nod") - enemy = OpenRA.GetPlayer("Villagers") + nod = Player.GetPlayer("Nod") + gdi = Player.GetPlayer("GDI") + villagers = Player.GetPlayer("Villagers") + + NodObjective1 = nod.AddPrimaryObjective("Kill Nikoomba") + NodObjective2 = nod.AddPrimaryObjective("Destroy the village") + NodObjective3 = nod.AddSecondaryObjective("Destroy all GDI troops in the area") + GDIObjective1 = gdi.AddPrimaryObjective("Eliminate all Nod forces") + + Trigger.OnObjectiveCompleted(nod, function() Media.DisplayMessage("Objective completed") end) + Trigger.OnObjectiveFailed(nod, function() Media.DisplayMessage("Objective failed") end) + + Trigger.OnPlayerWon(nod, function() + Media.PlaySpeechNotification(nod, "Win") + end) + + Trigger.OnPlayerLost(nod, function() + Media.PlaySpeechNotification(nod, "Lose") + Trigger.AfterDelay(Utils.Seconds(1), function() + Media.PlayMovieFullscreen("nodlose.vqa") + end) + end) + + Trigger.OnKilled(Nikoomba, function() + nod.MarkCompletedObjective(NodObjective1) + Trigger.AfterDelay(Utils.Seconds(1), function() + SendLastInfantryReinforcements() + end) + end) + + Trigger.AfterDelay(Utils.Seconds(30), SendFirstInfantryReinforcements) + Trigger.AfterDelay(Utils.Seconds(60), SendSecondInfantryReinforcements) Media.PlayMovieFullscreen("nod1pre.vqa", function() Media.PlayMovieFullscreen("nod1.vqa") end) - - Actor.OnKilled(Nikoomba, SendLastInfantryReinforcements) - - OpenRA.RunAfterDelay(25 * 30, SendFirstInfantryReinforcements) - OpenRA.RunAfterDelay(25 * 60, SendSecondInfantryReinforcements) end Tick = function() - if Mission.RequiredUnitsAreDestroyed(player) then - MissionFailed() + if nod.HasNoRequiredUnits() then + gdi.MarkCompletedObjective(GDIObjective1) end - if Mission.RequiredUnitsAreDestroyed(enemy) then - MissionAccomplished() + if villagers.HasNoRequiredUnits() then + nod.MarkCompletedObjective(NodObjective2) end -end \ No newline at end of file + if gdi.HasNoRequiredUnits() then + nod.MarkCompletedObjective(NodObjective3) + end +end