From 00fcf5f969116bff061010530e30038c966fb6ea Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Mon, 4 Aug 2014 11:50:21 +0200 Subject: [PATCH] Convert gdi01 to new Lua --- mods/cnc/maps/gdi01/gdi01.lua | 88 +++++++++++++++++++++-------------- mods/cnc/maps/gdi01/map.yaml | 4 +- 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/mods/cnc/maps/gdi01/gdi01.lua b/mods/cnc/maps/gdi01/gdi01.lua index 52fbc5f8e7..b54c5f8e98 100644 --- a/mods/cnc/maps/gdi01/gdi01.lua +++ b/mods/cnc/maps/gdi01/gdi01.lua @@ -2,58 +2,76 @@ InfantryReinforcements = { "e1", "e1", "e1" } VehicleReinforcements = { "jeep" } NodPatrol = { "e1", "e1" } -MissionAccomplished = function() - Mission.MissionOver({ player }, nil, true) - Media.PlayMovieFullscreen("consyard.vqa") -end - -MissionFailed = function() - Mission.MissionOver(nil, { player }, true) - Media.PlayMovieFullscreen("gameover.vqa") -end - SendNodPatrol = function() - local patrol = Reinforcements.Reinforce(enemy, NodPatrol, nod0.Location, nod1.Location, 0) - Utils.Do(patrol, function(soldier) - Actor.Move(soldier, nod2.Location) - Actor.Move(soldier, nod3.Location) - Actor.Hunt(soldier) + Utils.Do(NodPatrol, function(type) + local soldier = Actor.Create(type, true, { Location = nod0.Location, Owner = enemy }) + soldier.Move(nod1.Location) + soldier.AttackMove(nod2.Location) + soldier.Move(nod3.Location) + soldier.Hunt() end) end -SetGunboatPath = function() - Actor.AttackMove(Gunboat, gunboatLeft.Location) - Actor.AttackMove(Gunboat, gunboatRight.Location) +SetGunboatPath = function(gunboat) + gunboat.AttackMove(gunboatLeft.Location) + gunboat.AttackMove(gunboatRight.Location) end ReinforceFromSea = function(passengers) - local hovercraft, troops = Reinforcements.Insert(player, "oldlst", passengers, { lstStart.Location, lstEnd.Location }, { lstStart.Location }) - Media.PlaySpeechNotification("Reinforce") + local transport = Actor.Create("oldlst", true, { Location = lstStart.Location, Owner = player }) + + Utils.Do(passengers, function(actorType) + local passenger = Actor.Create(actorType, false, { Owner = player }) + transport.LoadPassenger(passenger) + end) + + transport.Move(lstEnd.Location) + transport.UnloadPassengers() + transport.Wait(50) + transport.Move(lstStart.Location) + transport.Destroy() + + Media.PlaySpeechNotification(player, "Reinforce") end WorldLoaded = function() - player = OpenRA.GetPlayer("GDI") - enemy = OpenRA.GetPlayer("Nod") - Media.PlayMovieFullscreen("gdi1.vqa", function() Media.PlayMovieFullscreen("landing.vqa") end) + player = Player.GetPlayer("GDI") + enemy = Player.GetPlayer("Nod") + + gdiObjective = player.AddPrimaryObjective("Destroy all Nod forces in the area!") + + Trigger.OnPlayerWon(player, function() + Media.PlaySpeechNotification(player, "Win") + Trigger.AfterDelay(25, function() + Media.PlayMovieFullscreen("consyard.vqa") + end) + end) + + Trigger.OnPlayerLost(player, function() + Media.PlaySpeechNotification(player, "Lose") + Trigger.AfterDelay(25, function() + Media.PlayMovieFullscreen("gameover.vqa") + end) + end) + + Trigger.OnIdle(Gunboat, function() SetGunboatPath(Gunboat) end) + SendNodPatrol() - OpenRA.RunAfterDelay(25 * 5, function() ReinforceFromSea(InfantryReinforcements) end) - OpenRA.RunAfterDelay(25 * 15, function() ReinforceFromSea(InfantryReinforcements) end) - OpenRA.RunAfterDelay(25 * 30, function() ReinforceFromSea(VehicleReinforcements) end) - OpenRA.RunAfterDelay(25 * 60, function() ReinforceFromSea(VehicleReinforcements) end) + Trigger.AfterDelay(25 * 5, function() ReinforceFromSea(InfantryReinforcements) end) + Trigger.AfterDelay(25 * 15, function() ReinforceFromSea(InfantryReinforcements) end) + Trigger.AfterDelay(25 * 30, function() ReinforceFromSea(VehicleReinforcements) end) + Trigger.AfterDelay(25 * 60, function() ReinforceFromSea(VehicleReinforcements) end) end Tick = function() - if Actor.IsIdle(Gunboat) then - SetGunboatPath() + if enemy.HasNoRequiredUnits() then + player.MarkCompletedObjective(gdiObjective) end - if Mission.RequiredUnitsAreDestroyed(player) then - MissionFailed() + if player.HasNoRequiredUnits() then + player.MarkFailedObjective(gdiObjective) end - if Mission.RequiredUnitsAreDestroyed(enemy) then - MissionAccomplished() - end -end \ No newline at end of file +end diff --git a/mods/cnc/maps/gdi01/map.yaml b/mods/cnc/maps/gdi01/map.yaml index 4a82cf473e..c06e937d74 100644 --- a/mods/cnc/maps/gdi01/map.yaml +++ b/mods/cnc/maps/gdi01/map.yaml @@ -457,8 +457,8 @@ Rules: PlayMusicOnMapLoad: Music: aoi Loop: false - LuaScriptInterface: - LuaScripts: gdi01.lua + LuaScript: + Scripts: gdi01.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES Player: