Merge pull request #6494 from obrakmann/objectives-fine-tuning
Objectives fine-tuning
This commit is contained in:
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void MarkFailed(Player player, int objectiveID)
|
public void MarkFailed(Player player, int objectiveID)
|
||||||
{
|
{
|
||||||
if (objectiveID >= objectives.Count || objectives[objectiveID].State == ObjectiveState.Failed)
|
if (objectiveID >= objectives.Count || objectives[objectiveID].State != ObjectiveState.Incomplete)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var inous = player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>();
|
var inous = player.PlayerActor.TraitsImplementing<INotifyObjectivesUpdated>();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Eluant;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Scripting;
|
using OpenRA.Scripting;
|
||||||
using OpenRA.Mods.RA;
|
using OpenRA.Mods.RA;
|
||||||
@@ -48,6 +49,9 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
"objectives, (s)he has won the game.")]
|
"objectives, (s)he has won the game.")]
|
||||||
public void MarkCompletedObjective(int id)
|
public void MarkCompletedObjective(int id)
|
||||||
{
|
{
|
||||||
|
if (id < 0 || id >= mo.Objectives.Count)
|
||||||
|
throw new LuaException("Objective ID is out of range.");
|
||||||
|
|
||||||
mo.MarkCompleted(player, id);
|
mo.MarkCompleted(player, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,9 +61,42 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
"influence whatsoever on the outcome of the game.")]
|
"influence whatsoever on the outcome of the game.")]
|
||||||
public void MarkFailedObjective(int id)
|
public void MarkFailedObjective(int id)
|
||||||
{
|
{
|
||||||
|
if (id < 0 || id >= mo.Objectives.Count)
|
||||||
|
throw new LuaException("Objective ID is out of range.");
|
||||||
|
|
||||||
mo.MarkFailed(player, id);
|
mo.MarkFailed(player, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ScriptActorPropertyActivity]
|
||||||
|
[Desc("Returns true if the objective has been successfully completed, false otherwise.")]
|
||||||
|
public bool IsObjectiveCompleted(int id)
|
||||||
|
{
|
||||||
|
if (id < 0 || id >= mo.Objectives.Count)
|
||||||
|
throw new LuaException("Objective ID is out of range.");
|
||||||
|
|
||||||
|
return mo.Objectives[id].State == ObjectiveState.Completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ScriptActorPropertyActivity]
|
||||||
|
[Desc("Returns true if the objective has been failed, false otherwise.")]
|
||||||
|
public bool IsObjectiveFailed(int id)
|
||||||
|
{
|
||||||
|
if (id < 0 || id >= mo.Objectives.Count)
|
||||||
|
throw new LuaException("Objective ID is out of range.");
|
||||||
|
|
||||||
|
return mo.Objectives[id].State == ObjectiveState.Failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ScriptActorPropertyActivity]
|
||||||
|
[Desc("Returns the description of an objective.")]
|
||||||
|
public string GetObjectiveDescription(int id)
|
||||||
|
{
|
||||||
|
if (id < 0 || id >= mo.Objectives.Count)
|
||||||
|
throw new LuaException("Objective ID is out of range.");
|
||||||
|
|
||||||
|
return mo.Objectives[id].Description;
|
||||||
|
}
|
||||||
|
|
||||||
[ScriptActorPropertyActivity]
|
[ScriptActorPropertyActivity]
|
||||||
[Desc("Returns true if this player has lost all units/actors that have the MustBeDestroyed trait.")]
|
[Desc("Returns true if this player has lost all units/actors that have the MustBeDestroyed trait.")]
|
||||||
public bool HasNoRequiredUnits()
|
public bool HasNoRequiredUnits()
|
||||||
|
|||||||
@@ -48,8 +48,12 @@ WorldLoaded = function()
|
|||||||
gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
|
gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
|
||||||
gdiObjective2 = player.AddSecondaryObjective("Establish a beachhead")
|
gdiObjective2 = player.AddSecondaryObjective("Establish a beachhead")
|
||||||
|
|
||||||
Trigger.OnObjectiveCompleted(player, function() Media.DisplayMessage("Objective completed") end)
|
Trigger.OnObjectiveCompleted(player, function(p, id)
|
||||||
Trigger.OnObjectiveFailed(player, function() Media.DisplayMessage("Objective failed") end)
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||||
|
end)
|
||||||
|
Trigger.OnObjectiveFailed(player, function(p, id)
|
||||||
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||||
|
end)
|
||||||
|
|
||||||
Trigger.OnPlayerWon(player, function()
|
Trigger.OnPlayerWon(player, function()
|
||||||
Media.PlaySpeechNotification(player, "Win")
|
Media.PlaySpeechNotification(player, "Win")
|
||||||
|
|||||||
@@ -37,8 +37,12 @@ WorldLoaded = function()
|
|||||||
gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
|
gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
|
||||||
gdiObjective2 = player.AddSecondaryObjective("Capture the Tiberium Refinery")
|
gdiObjective2 = player.AddSecondaryObjective("Capture the Tiberium Refinery")
|
||||||
|
|
||||||
Trigger.OnObjectiveCompleted(player, function() Media.DisplayMessage("Objective completed") end)
|
Trigger.OnObjectiveCompleted(player, function(p, id)
|
||||||
Trigger.OnObjectiveFailed(player, function() Media.DisplayMessage("Objective failed") end)
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||||
|
end)
|
||||||
|
Trigger.OnObjectiveFailed(player, function(p, id)
|
||||||
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||||
|
end)
|
||||||
|
|
||||||
Trigger.OnPlayerWon(player, function()
|
Trigger.OnPlayerWon(player, function()
|
||||||
Media.PlaySpeechNotification(player, "Win")
|
Media.PlaySpeechNotification(player, "Win")
|
||||||
|
|||||||
@@ -82,8 +82,12 @@ WorldLoaded = function()
|
|||||||
gdiObjective1 = player.AddPrimaryObjective("Defend the town of Białystok")
|
gdiObjective1 = player.AddPrimaryObjective("Defend the town of Białystok")
|
||||||
gdiObjective2 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
|
gdiObjective2 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
|
||||||
|
|
||||||
Trigger.OnObjectiveCompleted(player, function() Media.DisplayMessage("Objective completed") end)
|
Trigger.OnObjectiveCompleted(player, function(p, id)
|
||||||
Trigger.OnObjectiveFailed(player, function() Media.DisplayMessage("Objective failed") end)
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||||
|
end)
|
||||||
|
Trigger.OnObjectiveFailed(player, function(p, id)
|
||||||
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||||
|
end)
|
||||||
|
|
||||||
Trigger.OnAllKilled(LoseTriggerHouses, function()
|
Trigger.OnAllKilled(LoseTriggerHouses, function()
|
||||||
player.MarkFailedObjective(gdiObjective1)
|
player.MarkFailedObjective(gdiObjective1)
|
||||||
|
|||||||
@@ -26,8 +26,12 @@ WorldLoaded = function()
|
|||||||
NodObjective3 = nod.AddSecondaryObjective("Destroy all GDI troops in the area")
|
NodObjective3 = nod.AddSecondaryObjective("Destroy all GDI troops in the area")
|
||||||
GDIObjective1 = gdi.AddPrimaryObjective("Eliminate all Nod forces")
|
GDIObjective1 = gdi.AddPrimaryObjective("Eliminate all Nod forces")
|
||||||
|
|
||||||
Trigger.OnObjectiveCompleted(nod, function() Media.DisplayMessage("Objective completed") end)
|
Trigger.OnObjectiveCompleted(nod, function(p, id)
|
||||||
Trigger.OnObjectiveFailed(nod, function() Media.DisplayMessage("Objective failed") end)
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||||
|
end)
|
||||||
|
Trigger.OnObjectiveFailed(nod, function(p, id)
|
||||||
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||||
|
end)
|
||||||
|
|
||||||
Trigger.OnPlayerWon(nod, function()
|
Trigger.OnPlayerWon(nod, function()
|
||||||
Media.PlaySpeechNotification(nod, "Win")
|
Media.PlaySpeechNotification(nod, "Win")
|
||||||
|
|||||||
@@ -28,8 +28,12 @@ WorldLoaded = function()
|
|||||||
Trigger.AfterDelay(Utils.Seconds(50), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnB.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.AfterDelay(Utils.Seconds(100), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnC.Location) end)
|
||||||
|
|
||||||
Trigger.OnObjectiveCompleted(player, function() Media.DisplayMessage("Objective completed") end)
|
Trigger.OnObjectiveCompleted(player, function(p, id)
|
||||||
Trigger.OnObjectiveFailed(player, function() Media.DisplayMessage("Objective failed") end)
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||||
|
end)
|
||||||
|
Trigger.OnObjectiveFailed(player, function(p, id)
|
||||||
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||||
|
end)
|
||||||
|
|
||||||
Trigger.OnCapture(TechCenter, function()
|
Trigger.OnCapture(TechCenter, function()
|
||||||
Trigger.AfterDelay(Utils.Seconds(2), function()
|
Trigger.AfterDelay(Utils.Seconds(2), function()
|
||||||
|
|||||||
@@ -40,8 +40,12 @@ WorldLoaded = function()
|
|||||||
nodObjective2 = player.AddSecondaryObjective("Destroy all GDI forces")
|
nodObjective2 = player.AddSecondaryObjective("Destroy all GDI forces")
|
||||||
|
|
||||||
InsertNodUnits()
|
InsertNodUnits()
|
||||||
Trigger.OnObjectiveCompleted(player, function() Media.DisplayMessage("Objective completed") end)
|
Trigger.OnObjectiveCompleted(player, function(p, id)
|
||||||
Trigger.OnObjectiveFailed(player, function() Media.DisplayMessage("Objective failed") end)
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective completed")
|
||||||
|
end)
|
||||||
|
Trigger.OnObjectiveFailed(player, function(p, id)
|
||||||
|
Media.DisplayMessage(p.GetObjectiveDescription(id), "Objective failed")
|
||||||
|
end)
|
||||||
|
|
||||||
Trigger.AfterDelay(Utils.Seconds(40), function() SendAttackWave(FirstAttackWaveUnits, FirstAttackWave) 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(80), function() SendAttackWave(SecondAttackWaveUnits, SecondAttackWave) end)
|
||||||
|
|||||||
Reference in New Issue
Block a user