fix redeploying failing the secondary objective

code cleanup
This commit is contained in:
Matthias Mailänder
2014-12-22 09:46:35 +01:00
parent b294816489
commit c04bb13e71
2 changed files with 18 additions and 22 deletions

View File

@@ -48,21 +48,11 @@ Reinforce = function(units)
ReinforceWithLandingCraft(units, lstStart.Location, lstEnd.Location, reinforcementsTarget.Location)
end
triggerAdded = false
CheckForBase = function()
baseBuildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
return actor.Type == "fact" or actor.Type == "pyle" or actor.Type == "nuke"
end)
Utils.Do(baseBuildings, function(building)
if not triggerAdded and building.Type == "fact" then
Trigger.OnRemovedFromWorld(building, function()
player.MarkFailedObjective(gdiObjective2)
end)
triggerAdded = true
end
end)
return #baseBuildings >= 3
end
@@ -89,9 +79,8 @@ WorldLoaded = function()
Media.PlaySpeechNotification(player, "Lose")
end)
nodObjective = enemy.AddPrimaryObjective("Destroy all GDI troops")
gdiObjective1 = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
gdiObjective2 = player.AddSecondaryObjective("Establish a beachhead")
secureAreaObjective = player.AddPrimaryObjective("Eliminate all Nod forces in the area")
beachheadObjective = player.AddSecondaryObjective("Establish a beachhead")
ReinforceWithLandingCraft(MCVReinforcements, lstStart.Location + CVec.New(2, 0), lstEnd.Location + CVec.New(2, 0), mcvTarget.Location)
Reinforce(InfantryReinforcements)
@@ -104,20 +93,17 @@ WorldLoaded = function()
Trigger.AfterDelay(DateTime.Seconds(60), function() Reinforce(VehicleReinforcements) end)
end
tick = 0
baseEstablished = false
Tick = function()
tick = tick + 1
if enemy.HasNoRequiredUnits() then
player.MarkCompletedObjective(gdiObjective1)
player.MarkCompletedObjective(secureAreaObjective)
end
if tick > DateTime.Seconds(5) and player.HasNoRequiredUnits() then
enemy.MarkCompletedObjective(nodObjective)
if DateTime.GameTime > DateTime.Seconds(5) and player.HasNoRequiredUnits() then
player.MarkFailedObjective(beachheadObjective)
player.MarkFailedObjective(secureAreaObjective)
end
if not baseEstablished and tick % DateTime.Seconds(1) == 0 and CheckForBase() then
baseEstablished = true
player.MarkCompletedObjective(gdiObjective2)
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not player.IsObjectiveCompleted(beachheadObjective) and CheckForBase() then
player.MarkCompletedObjective(beachheadObjective)
end
end

View File

@@ -487,6 +487,16 @@ Rules:
GenericVisibility: Enemy, Ally, Neutral
GenericStancePrefix: false
ShowOwnerRow: false
NUKE:
-Sellable:
Buildable:
BuildLimit: 1
PYLE:
-Sellable:
Buildable:
BuildLimit: 1
FACT:
-Sellable:
PROC:
Buildable:
Prerequisites: ~disabled