From 7d6d484afd56cf73e8fbe1370ba88b02f6eea9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 28 Dec 2013 18:40:27 +0100 Subject: [PATCH 1/3] recreated GDI01 in Lua --- OpenRA.Mods.Cnc/Missions/Gdi01Script.cs | 221 ------------------------ OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj | 1 - mods/cnc/maps/gdi01/map.yaml | 19 +- mods/cnc/maps/gdi01/mission.lua | 61 +++++++ mods/cnc/rules/defaults.yaml | 2 +- mods/cnc/voices.yaml | 12 +- 6 files changed, 83 insertions(+), 233 deletions(-) delete mode 100644 OpenRA.Mods.Cnc/Missions/Gdi01Script.cs create mode 100644 mods/cnc/maps/gdi01/mission.lua diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs deleted file mode 100644 index d279af21f4..0000000000 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ /dev/null @@ -1,221 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2011 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 System.Collections.Generic; -using System.Linq; -using OpenRA.FileFormats; -using OpenRA.Graphics; -using OpenRA.Mods.RA; -using OpenRA.Mods.RA.Activities; -using OpenRA.Mods.RA.Move; -using OpenRA.Scripting; -using OpenRA.Traits; - -namespace OpenRA.Mods.Cnc.Missions -{ - class Gdi01ScriptInfo : TraitInfo { } - - class Gdi01Script : IWorldLoaded, ITick - { - Dictionary actors; - Dictionary players; - - public void WorldLoaded(World w, WorldRenderer wr) - { - players = w.Players.ToDictionary(p => p.InternalName); - actors = w.WorldActor.Trait().Actors; - var b = w.Map.Bounds; - wr.Viewport.Center(new CPos(b.Left + b.Width / 2, b.Top + b.Height / 2).CenterPosition); - - Action afterFMV = () => - { - Sound.PlayMusic(Rules.Music["aoi"]); - started = true; - }; - Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "gdi1.vqa", () => - Media.PlayFMVFullscreen(w, "landing.vqa", afterFMV))); - } - - public void OnVictory(World w) - { - Action afterFMV = () => - { - players["GoodGuy"].WinState = WinState.Won; - started = false; - Sound.StopMusic(); - Sound.PlayToPlayer(players["GoodGuy"], "accom1.aud"); - }; - Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "consyard.vqa", afterFMV)); - } - - public void OnLose(World w) - { - Action afterFMV = () => - { - players["GoodGuy"].WinState = WinState.Lost; - started = false; - Sound.StopMusic(); - Sound.PlayToPlayer(players["GoodGuy"], "fail1.aud"); - }; - Game.RunAfterDelay(0, () => Media.PlayFMVFullscreen(w, "gameover.vqa", afterFMV)); - } - - int ticks = 0; - bool started = false; - - int lastBadCount = -1; - public void Tick(Actor self) - { - if (!started) - return; - - if (ticks == 0) - { - SetGunboatPath(); - self.World.AddFrameEndTask(w => - { - // Initial Nod reinforcements - foreach (var i in new[] { "e1", "e1" }) - { - var a = self.World.CreateActor(i.ToLowerInvariant(), new TypeDictionary - { - new OwnerInit(players["BadGuy"]), - new FacingInit(0), - new LocationInit(actors["nod0"].Location), - }); - var mobile = a.Trait(); - a.QueueActivity(mobile.MoveTo(actors["nod1"].Location, 2)); - a.QueueActivity(mobile.MoveTo(actors["nod2"].Location, 2)); - a.QueueActivity(mobile.MoveTo(actors["nod3"].Location, 2)); - - // TODO: Queue hunt order - } - }); - } - - // GoodGuy win conditions - // BadGuy is dead - var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor && - a.Owner == players["BadGuy"] && !a.IsDead()); - if (badcount != lastBadCount) - { - Game.Debug("{0} badguys remain".F(badcount)); - lastBadCount = badcount; - - if (badcount == 0) - OnVictory(self.World); - } - - // GoodGuy lose conditions: MCV/cyard must survive - var hasAnything = self.World.ActorsWithTrait() - .Any(a => a.Actor.Owner == players["GoodGuy"]); - if (!hasAnything) - OnLose(self.World); - - // GoodGuy reinforcements - if (ticks == 25 * 5) - { - ReinforceFromSea(self.World, - actors["lstStart"].Location, - actors["lstEnd"].Location, - new CPos(53, 53), - new string[] { "e1", "e1", "e1" }, - players["GoodGuy"]); - } - - if (ticks == 25 * 15) - { - ReinforceFromSea(self.World, - actors["lstStart"].Location, - actors["lstEnd"].Location, - new CPos(53, 53), - new string[] { "e1", "e1", "e1" }, - players["GoodGuy"]); - } - - if (ticks == 25 * 30) - { - ReinforceFromSea(self.World, - actors["lstStart"].Location, - actors["lstEnd"].Location, - new CPos(53, 53), - new string[] { "jeep" }, - players["GoodGuy"]); - } - - if (ticks == 25 * 60) - { - ReinforceFromSea(self.World, - actors["lstStart"].Location, - actors["lstEnd"].Location, - new CPos(53, 53), - new string[] { "jeep" }, - players["GoodGuy"]); - } - - ticks++; - } - - void SetGunboatPath() - { - var self = actors["Gunboat"]; - var mobile = self.Trait(); - self.Trait().stance = UnitStance.AttackAnything; // TODO: this is ignored - self.QueueActivity(mobile.ScriptedMove(actors["gunboatLeft"].Location)); - self.QueueActivity(mobile.ScriptedMove(actors["gunboatRight"].Location)); - self.QueueActivity(new CallFunc(() => SetGunboatPath())); - } - - void ReinforceFromSea(World world, CPos startPos, CPos endPos, CPos unload, string[] items, Player player) - { - world.AddFrameEndTask(w => - { - Sound.PlayToPlayer(w.LocalPlayer, "reinfor1.aud"); - - var a = w.CreateActor("lst", new TypeDictionary - { - new LocationInit(startPos), - new OwnerInit(player), - new FacingInit(0), - }); - - var mobile = a.Trait(); - var cargo = a.Trait(); - foreach (var i in items) - cargo.Load(a, world.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary - { - new OwnerInit(player), - new FacingInit(0), - })); - - a.CancelActivity(); - a.QueueActivity(mobile.ScriptedMove(endPos)); - a.QueueActivity(new CallFunc(() => - { - while (!cargo.IsEmpty(a)) - { - var b = cargo.Unload(a); - world.AddFrameEndTask(w2 => - { - if (b.Destroyed) return; - w2.Add(b); - b.TraitsImplementing().FirstOrDefault().SetPosition(b, a.Location); - b.QueueActivity(mobile.MoveTo(unload, 2)); - }); - } - })); - a.QueueActivity(new Wait(25)); - a.QueueActivity(mobile.ScriptedMove(startPos)); - a.QueueActivity(new RemoveSelf()); - }); - } - } -} diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 9c27902df6..1fe13d58e6 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -77,7 +77,6 @@ - diff --git a/mods/cnc/maps/gdi01/map.yaml b/mods/cnc/maps/gdi01/map.yaml index 8059162c79..41178ecae6 100644 --- a/mods/cnc/maps/gdi01/map.yaml +++ b/mods/cnc/maps/gdi01/map.yaml @@ -26,7 +26,7 @@ Options: Shroud: True AllyBuildRadius: False FragileAlliances: False - StartingCash: 500 + StartingCash: 5000 ConfigurableStartingUnits: False Players: @@ -454,9 +454,15 @@ Rules: -SpawnMPUnits: -MPStartLocations: -CrateSpawner: - Gdi01Script: + PlayMusicOnMapLoad: + Music: aoi + Loop: false + LuaScriptInterface: + LuaScripts: mission.lua Player: -ConquestVictoryConditions: + ^Infantry: + MustBeDestroyed: PROC: -Buildable: SILO: @@ -475,6 +481,7 @@ Rules: -Buildable: GUN: -Buildable: + MustBeDestroyed: GTWR: -Buildable: ATWR: @@ -488,8 +495,12 @@ Rules: RMBO: -Buildable: BOAT: - Mobile: - OnRails: false + Health: + HP: 1000 + AutoTarget: + InitialStance: AttackAnything + RejectsOrders: + Except: Attack Sequences: diff --git a/mods/cnc/maps/gdi01/mission.lua b/mods/cnc/maps/gdi01/mission.lua new file mode 100644 index 0000000000..285617c5f6 --- /dev/null +++ b/mods/cnc/maps/gdi01/mission.lua @@ -0,0 +1,61 @@ +InfantryReinforcements = { "e1", "e1", "e1" } +VehicleReinforcements = { "jeep" } +NodPatrol = { "e1", "e1" } + +MissionAccomplished = function() + Mission.MissionOver({ player }, nil, false) + Media.PlayMovieFullscreen("consyard.vqa") +end + +MissionFailed = function() + Mission.MissionOver(nil, { player }, false) + Media.PlayMovieFullscreen("gameover.vqa") +end + +SendNodPatrol = function() + local patrol = Reinforcements.Reinforce(enemy, NodPatrol, nod0.Location, nod1.Location, 0) + for i, soldier in ipairs(patrol) do + Actor.Move(soldier, nod2.Location) + Actor.Move(soldier, nod3.Location) + Actor.Hunt(soldier) + end +end + +SetGunboatPath = function() + Actor.AttackMove(Gunboat, gunboatLeft.Location) + Actor.AttackMove(Gunboat, gunboatRight.Location) +end + +ReinforceFromSea = function(passengers) + local hovercraft, troops = Reinforcements.Insert(player, "lst", passengers, { lstStart.Location, lstEnd.Location }, { lstStart.Location }) + Media.PlaySpeechNotification("Reinforce") +end + +WorldLoaded = function() + player = OpenRA.GetPlayer("GoodGuy") + enemy = OpenRA.GetPlayer("BadGuy") + + Media.PlayMovieFullscreen("gdi1.vqa", function() Media.PlayMovieFullscreen("landing.vqa") 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) +end + +Tick = function() + if Actor.IsIdle(Gunboat) then + SetGunboatPath() + end + + if not Mission.MissionIsOver then + if Mission.RequiredUnitsAreDestroyed(player) then + MissionFailed() + end + if Mission.RequiredUnitsAreDestroyed(enemy) then + MissionAccomplished() + end + end +end \ No newline at end of file diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 1350e10b9e..eb17f57a35 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -284,7 +284,7 @@ Water: 100 SelectionDecorations: Selectable: - Voice: GenericVoice + Voice: VehicleVoice TargetableUnit: TargetTypes: Ground, Water HiddenUnderFog: diff --git a/mods/cnc/voices.yaml b/mods/cnc/voices.yaml index 13e0217c0b..43492bc3bf 100644 --- a/mods/cnc/voices.yaml +++ b/mods/cnc/voices.yaml @@ -1,4 +1,4 @@ -GenericVoice: +GenericVoice: Variants: nod: .v01,.v03 gdi: .v01,.v03 @@ -8,27 +8,27 @@ GenericVoice: Die: nuyell1,nuyell3,nuyell4,nuyell5 DisableVariants: Die -VehicleVoice: +VehicleVoice: Variants: nod: .v00,.v02 gdi: .v00,.v02 Voices: Select: vehic1,yessir1,report1,await1,unit1 - Move: ackno,affirm1,movout1 + Move: ackno,affirm1,movout1 -CivilianMaleVoice: +CivilianMaleVoice: Voices: Select: guyyeah1 Move: guyokay1 Die: nuyell1,nuyell3,nuyell4,nuyell5 -CivilianFemaleVoice: +CivilianFemaleVoice: Voices: Select: girlyeah Move: girlokay Die: nuyell1,nuyell3,nuyell4,nuyell5 -CommandoVoice: +CommandoVoice: Voices: Select: yeah1,yes1,yo1 Move: cmon1,onit1,gotit1 From 4bf5f62ed44257f3843e79bc9d50ca6455e2ec30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 29 Dec 2013 11:38:08 +0100 Subject: [PATCH 2/3] use the original hovercraft art --- mods/cnc/maps/gdi01/map.yaml | 66 +++++++++++++++++++-------------- mods/cnc/maps/gdi01/mission.lua | 10 ++--- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/mods/cnc/maps/gdi01/map.yaml b/mods/cnc/maps/gdi01/map.yaml index 41178ecae6..47a37fd712 100644 --- a/mods/cnc/maps/gdi01/map.yaml +++ b/mods/cnc/maps/gdi01/map.yaml @@ -30,14 +30,14 @@ Options: ConfigurableStartingUnits: False Players: - PlayerReference@BadGuy: - Name: BadGuy + PlayerReference@Nod: + Name: Nod Race: nod ColorRamp: 3,255,127 - Allies: BadGuy - Enemies: GoodGuy,Creeps - PlayerReference@GoodGuy: - Name: GoodGuy + Allies: Nod + Enemies: GDI,Creeps + PlayerReference@GDI: + Name: GDI Playable: True AllowBots: False Required: True @@ -47,8 +47,8 @@ Players: ColorRamp: 31,222,183 LockSpawn: True LockTeam: True - Allies: GoodGuy - Enemies: BadGuy,Creeps + Allies: GDI + Enemies: Nod,Creeps PlayerReference@Neutral: Name: Neutral OwnsWorld: True @@ -58,7 +58,7 @@ Players: Name: Creeps NonCombatant: True Race: Random - Enemies: BadGuy,GoodGuy + Enemies: Nod,GDI Actors: Actor0: sbag @@ -312,110 +312,110 @@ Actors: Owner: Neutral Actor83: gun Location: 46,55 - Owner: BadGuy + Owner: Nod Health: 0.5 Facing: 160 Actor84: gun Location: 41,55 - Owner: BadGuy + Owner: Nod Health: 0.5 Facing: 160 Actor85: gun Location: 49,55 - Owner: BadGuy + Owner: Nod Health: 0.1875 Facing: 160 mcv: mcv Location: 56,53 - Owner: GoodGuy + Owner: GDI Health: 1 Facing: 0 Gunboat: boat Location: 53,59 - Owner: GoodGuy + Owner: GDI Health: 1 Facing: 64 Actor88: e1 Location: 56,55 - Owner: GoodGuy + Owner: GDI Health: 1 Facing: 0 SubCell: 2 Actor89: e1 Location: 56,55 - Owner: GoodGuy + Owner: GDI Health: 1 Facing: 0 SubCell: 4 Actor90: e1 Location: 56,55 - Owner: GoodGuy + Owner: GDI Health: 1 Facing: 0 SubCell: 3 Actor91: e1 Location: 56,55 - Owner: GoodGuy + Owner: GDI Health: 1 Facing: 0 SubCell: 1 Actor92: e1 Location: 57,45 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 160 SubCell: 2 Actor93: e1 Location: 56,41 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 192 SubCell: 2 Actor94: e1 Location: 48,41 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 96 SubCell: 3 Actor95: e1 Location: 59,45 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 160 SubCell: 1 Actor96: e1 Location: 46,50 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 96 SubCell: 3 Actor97: e1 Location: 48,47 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 96 SubCell: 1 Actor98: e1 Location: 38,43 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 128 SubCell: 4 Actor99: e1 Location: 38,43 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 128 SubCell: 1 Actor100: e1 Location: 48,41 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 96 SubCell: 2 Actor101: e1 Location: 41,39 - Owner: BadGuy + Owner: Nod Health: 1 Facing: 96 SubCell: 4 @@ -501,8 +501,18 @@ Rules: InitialStance: AttackAnything RejectsOrders: Except: Attack + OLDLST: + Inherits: LST + -WithRoof: Sequences: + oldlst: + idle: lst + Start: 0 + Facings: 1 + unload: lst + Start: 0 + Facings: 1 VoxelSequences: diff --git a/mods/cnc/maps/gdi01/mission.lua b/mods/cnc/maps/gdi01/mission.lua index 285617c5f6..8c69520958 100644 --- a/mods/cnc/maps/gdi01/mission.lua +++ b/mods/cnc/maps/gdi01/mission.lua @@ -14,11 +14,11 @@ end SendNodPatrol = function() local patrol = Reinforcements.Reinforce(enemy, NodPatrol, nod0.Location, nod1.Location, 0) - for i, soldier in ipairs(patrol) do + Utils.Do(patrol, function(soldier) Actor.Move(soldier, nod2.Location) Actor.Move(soldier, nod3.Location) Actor.Hunt(soldier) - end + end) end SetGunboatPath = function() @@ -27,13 +27,13 @@ SetGunboatPath = function() end ReinforceFromSea = function(passengers) - local hovercraft, troops = Reinforcements.Insert(player, "lst", passengers, { lstStart.Location, lstEnd.Location }, { lstStart.Location }) + local hovercraft, troops = Reinforcements.Insert(player, "oldlst", passengers, { lstStart.Location, lstEnd.Location }, { lstStart.Location }) Media.PlaySpeechNotification("Reinforce") end WorldLoaded = function() - player = OpenRA.GetPlayer("GoodGuy") - enemy = OpenRA.GetPlayer("BadGuy") + player = OpenRA.GetPlayer("GDI") + enemy = OpenRA.GetPlayer("Nod") Media.PlayMovieFullscreen("gdi1.vqa", function() Media.PlayMovieFullscreen("landing.vqa") end) From ec3f44e5364e61c5fd38601213bdbce914023f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Mon, 30 Dec 2013 09:26:05 +0100 Subject: [PATCH 3/3] remove redundant MissionIsOver check in Tick --- mods/cnc/maps/gdi01/mission.lua | 12 +++++------- mods/ra/maps/allies-02-classic/mission.lua | 16 +++++++--------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/mods/cnc/maps/gdi01/mission.lua b/mods/cnc/maps/gdi01/mission.lua index 8c69520958..4cb5b1faa1 100644 --- a/mods/cnc/maps/gdi01/mission.lua +++ b/mods/cnc/maps/gdi01/mission.lua @@ -50,12 +50,10 @@ Tick = function() SetGunboatPath() end - if not Mission.MissionIsOver then - if Mission.RequiredUnitsAreDestroyed(player) then - MissionFailed() - end - if Mission.RequiredUnitsAreDestroyed(enemy) then - MissionAccomplished() - end + if Mission.RequiredUnitsAreDestroyed(player) then + MissionFailed() + end + if Mission.RequiredUnitsAreDestroyed(enemy) then + MissionAccomplished() end end \ No newline at end of file diff --git a/mods/ra/maps/allies-02-classic/mission.lua b/mods/ra/maps/allies-02-classic/mission.lua index 4b5a237368..18834f4241 100644 --- a/mods/ra/maps/allies-02-classic/mission.lua +++ b/mods/ra/maps/allies-02-classic/mission.lua @@ -34,15 +34,13 @@ end Tick = function() Mission.TickTakeOre(ussr) - - if not Mission.MissionIsOver then - if Mission.RequiredUnitsAreDestroyed(player) then - MissionFailed() - end - if not trucksSent and Mission.RequiredUnitsAreDestroyed(ussr) and Mission.RequiredUnitsAreDestroyed(badGuy) then - SendTrucks() - trucksSent = true - end + + if Mission.RequiredUnitsAreDestroyed(player) then + MissionFailed() + end + if not trucksSent and Mission.RequiredUnitsAreDestroyed(ussr) and Mission.RequiredUnitsAreDestroyed(badGuy) then + SendTrucks() + trucksSent = true end end