diff --git a/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs index 56c1e344ed..1ae0f96b7d 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/MissionObjectiveProperties.cs @@ -97,6 +97,16 @@ namespace OpenRA.Mods.RA.Scripting return mo.Objectives[id].Description; } + [ScriptActorPropertyActivity] + [Desc("Returns the type of an objective.")] + public string GetObjectiveType(int id) + { + if (id < 0 || id >= mo.Objectives.Count) + throw new LuaException("Objective ID is out of range."); + + return mo.Objectives[id].Type == ObjectiveType.Primary ? "Primary" : "Secondary"; + } + [ScriptActorPropertyActivity] [Desc("Returns true if this player has lost all units/actors that have the MustBeDestroyed trait.")] public bool HasNoRequiredUnits() diff --git a/mods/cnc/maps/gdi01/gdi01.lua b/mods/cnc/maps/gdi01/gdi01.lua index 1cee01a00e..88f6de7228 100644 --- a/mods/cnc/maps/gdi01/gdi01.lua +++ b/mods/cnc/maps/gdi01/gdi01.lua @@ -44,10 +44,9 @@ WorldLoaded = function() player = Player.GetPlayer("GDI") enemy = Player.GetPlayer("Nod") - nodObjective = enemy.AddPrimaryObjective("Destroy all GDI troops") - gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area") - gdiObjective2 = player.AddSecondaryObjective("Establish a beachhead") - + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -69,6 +68,10 @@ WorldLoaded = function() end) end) + nodObjective = enemy.AddPrimaryObjective("Destroy all GDI troops") + gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area") + gdiObjective2 = player.AddSecondaryObjective("Establish a beachhead") + Trigger.OnIdle(Gunboat, function() SetGunboatPath(Gunboat) end) SendNodPatrol() diff --git a/mods/cnc/maps/gdi02/gdi02.lua b/mods/cnc/maps/gdi02/gdi02.lua index 0dce41c867..1fd1bc5e09 100644 --- a/mods/cnc/maps/gdi02/gdi02.lua +++ b/mods/cnc/maps/gdi02/gdi02.lua @@ -33,10 +33,9 @@ WorldLoaded = function() player = Player.GetPlayer("GDI") enemy = Player.GetPlayer("Nod") - nodObjective = enemy.AddPrimaryObjective("Destroy all GDI troops") - gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area") - gdiObjective2 = player.AddSecondaryObjective("Capture the Tiberium Refinery") - + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -58,6 +57,10 @@ WorldLoaded = function() end) end) + nodObjective = enemy.AddPrimaryObjective("Destroy all GDI troops") + gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area") + gdiObjective2 = player.AddSecondaryObjective("Capture the Tiberium Refinery") + Trigger.OnCapture(NodRefinery, function() player.MarkCompletedObjective(gdiObjective2) end) Trigger.OnKilled(NodRefinery, function() player.MarkFailedObjective(gdiObjective2) end) diff --git a/mods/cnc/maps/gdi04c/gdi04c.lua b/mods/cnc/maps/gdi04c/gdi04c.lua index 9b9d6960dc..d9372a1854 100644 --- a/mods/cnc/maps/gdi04c/gdi04c.lua +++ b/mods/cnc/maps/gdi04c/gdi04c.lua @@ -65,10 +65,9 @@ WorldLoaded = function() player = Player.GetPlayer("GDI") nod = Player.GetPlayer("Nod") - nodObjective = nod.AddPrimaryObjective("Destroy all GDI troops") - gdiObjective1 = player.AddPrimaryObjective("Defend the town of BiaƂystok") - gdiObjective2 = player.AddPrimaryObjective("Eliminate all Nod forces in the area") - + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -94,6 +93,10 @@ WorldLoaded = function() end) end) + nodObjective = nod.AddPrimaryObjective("Destroy all GDI troops") + gdiObjective1 = player.AddPrimaryObjective("Defend the town of Bialystok") + gdiObjective2 = player.AddPrimaryObjective("Eliminate all Nod forces in the area") + Trigger.OnExitedFootprint(TownAttackTrigger, function(a, id) if a.Owner == player then Trigger.RemoveFootprintTrigger(id) diff --git a/mods/cnc/maps/nod01/nod01.lua b/mods/cnc/maps/nod01/nod01.lua index c0b80ed880..4ed638fae0 100644 --- a/mods/cnc/maps/nod01/nod01.lua +++ b/mods/cnc/maps/nod01/nod01.lua @@ -21,11 +21,9 @@ WorldLoaded = function() 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.OnObjectiveAdded(nod, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(nod, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -44,6 +42,11 @@ WorldLoaded = function() end) end) + 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.OnKilled(Nikoomba, function() nod.MarkCompletedObjective(NodObjective1) Trigger.AfterDelay(Utils.Seconds(1), function() diff --git a/mods/cnc/maps/nod03a/nod03a.lua b/mods/cnc/maps/nod03a/nod03a.lua index ac0ecdbbe9..8f7e2eb9fd 100644 --- a/mods/cnc/maps/nod03a/nod03a.lua +++ b/mods/cnc/maps/nod03a/nod03a.lua @@ -19,15 +19,9 @@ WorldLoaded = function() player = Player.GetPlayer("Nod") enemy = Player.GetPlayer("GDI") - gdiObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area") - nodObjective1 = player.AddPrimaryObjective("Capture the prison") - nodObjective2 = player.AddSecondaryObjective("Destroy all GDI forces") - - InsertNodUnits() - Trigger.AfterDelay(Utils.Seconds(20), function() SendAttackWave(FirstAttackWave, AttackWaveSpawnA.Location) end) - Trigger.AfterDelay(Utils.Seconds(50), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnB.Location) end) - Trigger.AfterDelay(Utils.Seconds(100), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnC.Location) end) - + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -35,16 +29,6 @@ WorldLoaded = function() Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") end) - Trigger.OnCapture(TechCenter, function() - Trigger.AfterDelay(Utils.Seconds(2), function() - player.MarkCompletedObjective(nodObjective1) - end) - end) - - Trigger.OnKilled(TechCenter, function() - player.MarkFailedObjective(nodObjective1) - end) - Trigger.OnPlayerWon(player, function() Media.PlaySpeechNotification(player, "Win") Trigger.AfterDelay(Utils.Seconds(1), function() @@ -59,6 +43,25 @@ WorldLoaded = function() end) end) + gdiObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area") + nodObjective1 = player.AddPrimaryObjective("Capture the prison") + nodObjective2 = player.AddSecondaryObjective("Destroy all GDI forces") + + Trigger.OnCapture(TechCenter, function() + Trigger.AfterDelay(Utils.Seconds(2), function() + player.MarkCompletedObjective(nodObjective1) + end) + end) + + Trigger.OnKilled(TechCenter, function() + player.MarkFailedObjective(nodObjective1) + end) + + InsertNodUnits() + Trigger.AfterDelay(Utils.Seconds(20), function() SendAttackWave(FirstAttackWave, AttackWaveSpawnA.Location) end) + Trigger.AfterDelay(Utils.Seconds(50), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnB.Location) end) + Trigger.AfterDelay(Utils.Seconds(100), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnC.Location) end) + Media.PlayMovieFullscreen("nod3.vqa") end diff --git a/mods/cnc/maps/nod03b/nod03b.lua b/mods/cnc/maps/nod03b/nod03b.lua index 08a626a56a..37cc32c461 100644 --- a/mods/cnc/maps/nod03b/nod03b.lua +++ b/mods/cnc/maps/nod03b/nod03b.lua @@ -35,11 +35,9 @@ WorldLoaded = function() player = Player.GetPlayer("Nod") enemy = Player.GetPlayer("GDI") - gdiObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area") - nodObjective1 = player.AddPrimaryObjective("Capture the prison") - nodObjective2 = player.AddSecondaryObjective("Destroy all GDI forces") - - InsertNodUnits() + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -47,17 +45,6 @@ WorldLoaded = function() Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") end) - Trigger.AfterDelay(Utils.Seconds(40), function() SendAttackWave(FirstAttackWaveUnits, FirstAttackWave) end) - Trigger.AfterDelay(Utils.Seconds(80), function() SendAttackWave(SecondAttackWaveUnits, SecondAttackWave) end) - Trigger.AfterDelay(Utils.Seconds(140), function() SendAttackWave(ThirdAttackWaveUnits, FirstAttackWave) end) - - Trigger.OnKilled(TechCenter, function() player.MarkFailedObjective(nodObjective1) end) - Trigger.OnCapture(TechCenter, function() - Trigger.AfterDelay(Utils.Seconds(2), function() - player.MarkCompletedObjective(nodObjective1) - end) - end) - Trigger.OnPlayerWon(player, function() Media.PlaySpeechNotification(player, "Win") Trigger.AfterDelay(Utils.Seconds(1), function() @@ -72,6 +59,22 @@ WorldLoaded = function() end) end) + gdiObjective = enemy.AddPrimaryObjective("Eliminate all Nod forces in the area") + nodObjective1 = player.AddPrimaryObjective("Capture the prison") + nodObjective2 = player.AddSecondaryObjective("Destroy all GDI forces") + + Trigger.OnKilled(TechCenter, function() player.MarkFailedObjective(nodObjective1) end) + Trigger.OnCapture(TechCenter, function() + Trigger.AfterDelay(Utils.Seconds(2), function() + player.MarkCompletedObjective(nodObjective1) + end) + end) + + InsertNodUnits() + Trigger.AfterDelay(Utils.Seconds(40), function() SendAttackWave(FirstAttackWaveUnits, FirstAttackWave) end) + Trigger.AfterDelay(Utils.Seconds(80), function() SendAttackWave(SecondAttackWaveUnits, SecondAttackWave) end) + Trigger.AfterDelay(Utils.Seconds(140), function() SendAttackWave(ThirdAttackWaveUnits, FirstAttackWave) end) + Media.PlayMovieFullscreen("nod3.vqa") end diff --git a/mods/ra/maps/allies-01-classic/allies01.lua b/mods/ra/maps/allies-01-classic/allies01.lua index cc7de33d70..55509cb099 100644 --- a/mods/ra/maps/allies-01-classic/allies01.lua +++ b/mods/ra/maps/allies-01-classic/allies01.lua @@ -162,12 +162,9 @@ WorldLoaded = function() england = Player.GetPlayer("England") ussr = Player.GetPlayer("USSR") - FindEinsteinObjective = player.AddPrimaryObjective("Find Einstein.") - SurviveObjective = player.AddPrimaryObjective("Tanya and Einstein must survive.") - england.AddPrimaryObjective("Destroy the soviet base after a successful rescue.") - CivilProtectionObjective = player.AddSecondaryObjective("Protect all civilians.") - DefendObjective = ussr.AddPrimaryObjective("Kill Tanya and keep Einstein hostage.") - + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) Trigger.OnObjectiveCompleted(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") end) @@ -178,6 +175,12 @@ WorldLoaded = function() Trigger.OnPlayerLost(player, MissionFailed) Trigger.OnPlayerWon(player, MissionAccomplished) + FindEinsteinObjective = player.AddPrimaryObjective("Find Einstein.") + SurviveObjective = player.AddPrimaryObjective("Tanya and Einstein must survive.") + england.AddPrimaryObjective("Destroy the soviet base after a successful rescue.") + CivilProtectionObjective = player.AddSecondaryObjective("Protect all civilians.") + DefendObjective = ussr.AddPrimaryObjective("Kill Tanya and keep Einstein hostage.") + Trigger.OnKilled(Lab, LabDestroyed) Trigger.OnKilled(OilPump, OilPumpDestroyed) diff --git a/mods/ra/maps/allies-02-classic/allies02.lua b/mods/ra/maps/allies-02-classic/allies02.lua index 3c3899417b..9fabd9ec51 100644 --- a/mods/ra/maps/allies-02-classic/allies02.lua +++ b/mods/ra/maps/allies-02-classic/allies02.lua @@ -97,6 +97,18 @@ WorldLoaded = function() ussr = Player.GetPlayer("USSR") ukraine = Player.GetPlayer("Ukraine") + Trigger.OnObjectiveAdded(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") + end) + Trigger.OnObjectiveCompleted(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") + end) + Trigger.OnObjectiveFailed(player, function(p, id) + Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") + end) + Trigger.OnPlayerLost(player, MissionFailed) + Trigger.OnPlayerWon(player, MissionAccomplished) + ConquestObjective = player.AddPrimaryObjective("Secure the area.") ussr.AddPrimaryObjective("Defend your base.") ukraine.AddPrimaryObjective("Destroy the convoy.") @@ -109,16 +121,6 @@ WorldLoaded = function() Trigger.AfterDelay(Utils.Minutes(10), SendTrucks) - Trigger.OnPlayerLost(player, MissionFailed) - Trigger.OnPlayerWon(player, MissionAccomplished) - - Trigger.OnObjectiveCompleted(player, function(p, id) - Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed") - end) - Trigger.OnObjectiveFailed(player, function(p, id) - Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed") - end) - Camera.Position = ReinforcementsEntryPoint.CenterPosition Media.PlayMovieFullscreen("ally2.vqa", function() Media.PlayMovieFullscreen("mcv.vqa") end) @@ -129,4 +131,4 @@ WorldLoaded = function() ConvoyTimer(Utils.Minutes(7), "WarningThreeMinutesRemaining") ConvoyTimer(Utils.Minutes(8), "WarningTwoMinutesRemaining") ConvoyTimer(Utils.Minutes(9), "WarningOneMinuteRemaining") -end \ No newline at end of file +end