Prevent cell triggers in sarin-gas-2 from firing several times

This commit is contained in:
abcdefg30
2019-12-03 23:53:57 +01:00
committed by reaperrr
parent fbfef903ac
commit e1c07d32d5

View File

@@ -6,6 +6,7 @@
the License, or (at your option) any later version. For more the License, or (at your option) any later version. For more
information, see COPYING. information, see COPYING.
]] ]]
TanyaFreed = false TanyaFreed = false
TruckStolen = false TruckStolen = false
SovietImportantGuys = { Officer3, Officer2, Officer1, Scientist1, Scientist2 } SovietImportantGuys = { Officer3, Officer2, Officer1, Scientist1, Scientist2 }
@@ -29,10 +30,12 @@ ObjectiveTriggers = function()
Trigger.OnEnteredFootprint(WinTriggerArea, function(a, id) Trigger.OnEnteredFootprint(WinTriggerArea, function(a, id)
if not EscapeGoalTrigger and a.Owner == greece then if not EscapeGoalTrigger and a.Owner == greece then
EscapeGoalTrigger = true EscapeGoalTrigger = true
greece.MarkCompletedObjective(ExitBase) greece.MarkCompletedObjective(ExitBase)
if Map.LobbyOption("difficulty") == "hard" then if Map.LobbyOption("difficulty") == "hard" then
greece.MarkCompletedObjective(NoCasualties) greece.MarkCompletedObjective(NoCasualties)
end end
if not TanyaFreed then if not TanyaFreed then
greece.MarkFailedObjective(FreeTanya) greece.MarkFailedObjective(FreeTanya)
else else
@@ -65,9 +68,9 @@ ObjectiveTriggers = function()
end end
ConsoleTriggers = function() ConsoleTriggers = function()
Trigger.OnEnteredProximityTrigger(Terminal1.CenterPosition, WDist.FromCells(1), function(actor, trigger1) Trigger.OnEnteredProximityTrigger(Terminal1.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Owner == greece then if actor.Owner == greece then
Trigger.RemoveProximityTrigger(trigger1) Trigger.RemoveProximityTrigger(id)
if not FlameTower1.IsDead then if not FlameTower1.IsDead then
Media.DisplayMessage("Flame Turret deactivated", "Console") Media.DisplayMessage("Flame Turret deactivated", "Console")
FlameTower1.Kill() FlameTower1.Kill()
@@ -75,9 +78,9 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal2.CenterPosition, WDist.FromCells(1), function(actor, trigger2) Trigger.OnEnteredProximityTrigger(Terminal2.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Owner == greece then if actor.Owner == greece then
Trigger.RemoveProximityTrigger(trigger2) Trigger.RemoveProximityTrigger(id)
if not FlameTower2.IsDead then if not FlameTower2.IsDead then
Media.DisplayMessage("Flame Turret deactivated", "Console") Media.DisplayMessage("Flame Turret deactivated", "Console")
FlameTower2.Kill() FlameTower2.Kill()
@@ -85,9 +88,9 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal3.CenterPosition, WDist.FromCells(1), function(actor, trigger3) Trigger.OnEnteredProximityTrigger(Terminal3.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Owner == greece then if actor.Owner == greece then
Trigger.RemoveProximityTrigger(trigger3) Trigger.RemoveProximityTrigger(id)
if not FlameTower3.IsDead then if not FlameTower3.IsDead then
Media.DisplayMessage("Flame Turret deactivated", "Console") Media.DisplayMessage("Flame Turret deactivated", "Console")
FlameTower3.Kill() FlameTower3.Kill()
@@ -95,9 +98,12 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal4.CenterPosition, WDist.FromCells(1), function(actor, trigger4) local gasActive
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(Terminal4.CenterPosition, WDist.FromCells(1), function(actor, id)
Trigger.RemoveProximityTrigger(trigger4) if actor.Owner == greece and not gasActive then
Trigger.RemoveProximityTrigger(id)
gasActive = true
Media.DisplayMessage("Sarin Nerve Gas dispensers activated", "Console") Media.DisplayMessage("Sarin Nerve Gas dispensers activated", "Console")
local KillCamera = Actor.Create("camera", true, { Owner = greece, Location = Sarin2.Location }) local KillCamera = Actor.Create("camera", true, { Owner = greece, Location = Sarin2.Location })
local flare1 = Actor.Create("flare", true, { Owner = england, Location = Sarin1.Location }) local flare1 = Actor.Create("flare", true, { Owner = england, Location = Sarin1.Location })
@@ -122,9 +128,9 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal5.CenterPosition, WDist.FromCells(1), function(actor, trigger5) Trigger.OnEnteredProximityTrigger(Terminal5.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Owner == greece then if actor.Owner == greece then
Trigger.RemoveProximityTrigger(trigger5) Trigger.RemoveProximityTrigger(id)
if not BadCoil.IsDead then if not BadCoil.IsDead then
Media.DisplayMessage("Tesla Coil deactivated", "Console") Media.DisplayMessage("Tesla Coil deactivated", "Console")
BadCoil.Kill() BadCoil.Kill()
@@ -132,9 +138,12 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal6.CenterPosition, WDist.FromCells(1), function(actor, trigger6) local teslaActive
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(Terminal6.CenterPosition, WDist.FromCells(1), function(actor, id)
Trigger.RemoveProximityTrigger(trigger6) if actor.Owner == greece and not teslaActive then
Trigger.RemoveProximityTrigger(id)
teslaActive = true
Media.DisplayMessage("Initialising Tesla Coil defence", "Console") Media.DisplayMessage("Initialising Tesla Coil defence", "Console")
local tesla1 = Actor.Create("tsla", true, { Owner = turkey, Location = TurkeyCoil1.Location }) local tesla1 = Actor.Create("tsla", true, { Owner = turkey, Location = TurkeyCoil1.Location })
local tesla2 = Actor.Create("tsla", true, { Owner = turkey, Location = TurkeyCoil2.Location }) local tesla2 = Actor.Create("tsla", true, { Owner = turkey, Location = TurkeyCoil2.Location })
@@ -149,9 +158,9 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal7.CenterPosition, WDist.FromCells(1), function(actor, trigger7) Trigger.OnEnteredProximityTrigger(Terminal7.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Owner == greece then if actor.Owner == greece then
Trigger.RemoveProximityTrigger(trigger7) Trigger.RemoveProximityTrigger(id)
if not FlameTowerTanya1.IsDead then if not FlameTowerTanya1.IsDead then
Media.DisplayMessage("Flame Turret deactivated", "Console") Media.DisplayMessage("Flame Turret deactivated", "Console")
FlameTowerTanya1.Kill() FlameTowerTanya1.Kill()
@@ -163,9 +172,9 @@ ConsoleTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(Terminal8.CenterPosition, WDist.FromCells(1), function(actor, trigger8) Trigger.OnEnteredProximityTrigger(Terminal8.CenterPosition, WDist.FromCells(1), function(actor, id)
if actor.Owner == greece then if actor.Owner == greece then
Trigger.RemoveProximityTrigger(trigger8) Trigger.RemoveProximityTrigger(id)
if not FlameTowerExit1.IsDead then if not FlameTowerExit1.IsDead then
Media.DisplayMessage("Flame Turret deactivated", "Console") Media.DisplayMessage("Flame Turret deactivated", "Console")
FlameTowerExit1.Kill() FlameTowerExit1.Kill()
@@ -186,9 +195,12 @@ CameraTriggers = function()
end) end)
end) end)
Trigger.OnEnteredProximityTrigger(CameraTrigger1.CenterPosition, WDist.FromCells(8), function(actor, triggercam1) local cam1Triggered
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(CameraTrigger1.CenterPosition, WDist.FromCells(8), function(actor, id)
Trigger.RemoveProximityTrigger(triggercam1) if actor.Owner == greece and not cam1Triggered then
Trigger.RemoveProximityTrigger(id)
cam1Triggered = true
local camera1 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger1.Location }) local camera1 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger1.Location })
Trigger.OnAllKilled(Camera1Towers, function() Trigger.OnAllKilled(Camera1Towers, function()
camera1.Destroy() camera1.Destroy()
@@ -196,9 +208,12 @@ CameraTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(CameraTrigger2.CenterPosition, WDist.FromCells(8), function(actor, triggercam2) local cam2Triggered
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(CameraTrigger2.CenterPosition, WDist.FromCells(8), function(actor, id)
Trigger.RemoveProximityTrigger(triggercam2) if actor.Owner == greece and not cam2Triggered then
Trigger.RemoveProximityTrigger(id)
cam2Triggered = true
local camera2 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger2.Location }) local camera2 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger2.Location })
Utils.Do(Camera2Team, function(actor) Utils.Do(Camera2Team, function(actor)
actor.AttackMove(CameraTrigger1.Location) actor.AttackMove(CameraTrigger1.Location)
@@ -209,9 +224,12 @@ CameraTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(CameraTrigger3.CenterPosition, WDist.FromCells(8), function(actor, triggercam3) local cam3Triggered
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(CameraTrigger3.CenterPosition, WDist.FromCells(8), function(actor, id)
Trigger.RemoveProximityTrigger(triggercam3) if actor.Owner == greece and not cam3Triggered then
Trigger.RemoveProximityTrigger(id)
cam3Triggered = true
local camera3 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger3.Location }) local camera3 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger3.Location })
Actor.Create("apwr", true, { Owner = france, Location = PowerPlantSpawn1.Location }) Actor.Create("apwr", true, { Owner = france, Location = PowerPlantSpawn1.Location })
Actor.Create("apwr", true, { Owner = germany, Location = PowerPlantSpawn2.Location }) Actor.Create("apwr", true, { Owner = germany, Location = PowerPlantSpawn2.Location })
@@ -225,9 +243,12 @@ CameraTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(CameraTrigger4.CenterPosition, WDist.FromCells(9), function(actor, triggercam4) local cam4Triggered
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(CameraTrigger4.CenterPosition, WDist.FromCells(9), function(actor, id)
Trigger.RemoveProximityTrigger(triggercam4) if actor.Owner == greece and not cam4Triggered then
Trigger.RemoveProximityTrigger(id)
cam4Triggered = true
local camera4 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger4.Location }) local camera4 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger4.Location })
Trigger.OnKilled(Mammoth2, function() Trigger.OnKilled(Mammoth2, function()
camera4.Destroy() camera4.Destroy()
@@ -235,9 +256,12 @@ CameraTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(CameraTrigger5.CenterPosition, WDist.FromCells(8), function(actor, triggercam5) local cam5Triggered
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(CameraTrigger5.CenterPosition, WDist.FromCells(8), function(actor, id)
Trigger.RemoveProximityTrigger(triggercam5) if actor.Owner == greece and not cam5Triggered then
Trigger.RemoveProximityTrigger(id)
cam5Triggered = true
local camera5 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger5.Location }) local camera5 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger5.Location })
Trigger.AfterDelay(DateTime.Seconds(10), function() Trigger.AfterDelay(DateTime.Seconds(10), function()
camera5.Destroy() camera5.Destroy()
@@ -245,20 +269,27 @@ CameraTriggers = function()
end end
end) end)
Trigger.OnEnteredProximityTrigger(CameraTrigger6.CenterPosition, WDist.FromCells(11), function(actor, triggercam6) local cam6Triggered
if actor.Owner == greece then Trigger.OnEnteredProximityTrigger(CameraTrigger6.CenterPosition, WDist.FromCells(11), function(actor, id)
Trigger.RemoveProximityTrigger(triggercam6) if actor.Owner == greece and not cam6Triggered then
Trigger.RemoveProximityTrigger(id)
cam6Triggered = true
Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger6.Location }) Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger6.Location })
end end
end) end)
Trigger.OnEnteredFootprint(ExecutionArea, function(actor, triggercam7) local executionTriggered
if actor.Owner == greece then Trigger.OnEnteredFootprint(ExecutionArea, function(actor, id)
Trigger.RemoveFootprintTrigger(triggercam7) if actor.Owner == greece and not executionTriggered then
Trigger.RemoveFootprintTrigger(id)
executionTriggered = true
local camera7 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger7.Location }) local camera7 = Actor.Create("camera", true, { Owner = greece, Location = CameraTrigger7.Location })
Trigger.AfterDelay(DateTime.Seconds(25), function() Trigger.AfterDelay(DateTime.Seconds(25), function()
camera7.Destroy() camera7.Destroy()
end) end)
ScientistExecution() ScientistExecution()
end end
end) end)
@@ -268,6 +299,7 @@ TruckSteal = function()
Trigger.OnInfiltrated(WarFactory1, function() Trigger.OnInfiltrated(WarFactory1, function()
if not TruckStolen and not StealTruck.IsDead then if not TruckStolen and not StealTruck.IsDead then
TruckStolen = true TruckStolen = true
local truckSteal1 = Actor.Create("camera", true, { Owner = greece, Location = TruckDrive1.Location }) local truckSteal1 = Actor.Create("camera", true, { Owner = greece, Location = TruckDrive1.Location })
Trigger.AfterDelay(DateTime.Seconds(10), function() Trigger.AfterDelay(DateTime.Seconds(10), function()
truckSteal1.Destroy() truckSteal1.Destroy()
@@ -278,9 +310,12 @@ TruckSteal = function()
end end
end) end)
Trigger.OnEnteredFootprint({ TruckDrive2.Location }, function(actor, triggertruck1) local trukDestroyed
if actor.Type == "truk" then Trigger.OnEnteredFootprint({ TruckDrive2.Location }, function(actor, id)
Trigger.RemoveFootprintTrigger(triggertruck1) if actor.Type == "truk" and not trukDestroyed then
Trigger.RemoveFootprintTrigger(id)
trukDestroyed = true
actor.Destroy() actor.Destroy()
Trigger.AfterDelay(DateTime.Seconds(3), function() Trigger.AfterDelay(DateTime.Seconds(3), function()
SpyTruckDrive() SpyTruckDrive()
@@ -296,16 +331,21 @@ SpyTruckDrive = function()
truckSteal2.Destroy() truckSteal2.Destroy()
end) end)
Trigger.OnEnteredFootprint({ TruckDrive5.Location }, function(actor, triggertruck2) local spyCreated
if actor.Type == "truk" then Trigger.OnEnteredFootprint({ TruckDrive5.Location }, function(actor, id)
local dogCrewCamera = Actor.Create("camera", true, { Owner = greece, Location = DoggyCam.Location }) if actor.Type == "truk" and not spyCreated then
Trigger.RemoveFootprintTrigger(triggertruck2) Trigger.RemoveFootprintTrigger(id)
spyCreated = true
Spy = Actor.Create("spy", true, { Owner = greece, Location = TruckDrive5.Location }) Spy = Actor.Create("spy", true, { Owner = greece, Location = TruckDrive5.Location })
Spy.DisguiseAsType("e1", ussr) Spy.DisguiseAsType("e1", ussr)
Spy.Move(SpyMove.Location) Spy.Move(SpyMove.Location)
local dogCrewCamera = Actor.Create("camera", true, { Owner = greece, Location = DoggyCam.Location })
Trigger.AfterDelay(DateTime.Seconds(10), function() Trigger.AfterDelay(DateTime.Seconds(10), function()
dogCrewCamera.Destroy() dogCrewCamera.Destroy()
end) end)
Utils.Do(DogCrew, function(actor) Utils.Do(DogCrew, function(actor)
if not actor.IsDead then if not actor.IsDead then
actor.AttackMove(DoggyMove.Location) actor.AttackMove(DoggyMove.Location)
@@ -318,15 +358,18 @@ end
IdleHunt = function(actor) if not actor.IsDead then Trigger.OnIdle(actor, actor.Hunt) end end IdleHunt = function(actor) if not actor.IsDead then Trigger.OnIdle(actor, actor.Hunt) end end
PrisonEscape = function() PrisonEscape = function()
local alarmed
Trigger.OnEnteredFootprint(PrisonAlarm, function(unit, id) Trigger.OnEnteredFootprint(PrisonAlarm, function(unit, id)
if alarmed then
return
end
alarmed = true
Trigger.RemoveFootprintTrigger(id) Trigger.RemoveFootprintTrigger(id)
Media.DisplayMessage("Warning, prisoners are attempting to escape!", "Intercom") Media.DisplayMessage("Warning, prisoners are attempting to escape!", "Intercom")
Media.PlaySoundNotification(greece, "AlertBuzzer") Media.PlaySoundNotification(greece, "AlertBuzzer")
Utils.Do(GuardDogs, function(actor) Utils.Do(GuardDogs, IdleHunt)
if not actor.IsDead then
IdleHunt(actor)
end
end)
end) end)
end end
@@ -364,6 +407,7 @@ end
ScientistRescued = function() ScientistRescued = function()
Media.DisplayMessage("Thanks for the rescue!", "Scientist") Media.DisplayMessage("Thanks for the rescue!", "Scientist")
Trigger.AfterDelay(DateTime.Seconds(5), function() Trigger.AfterDelay(DateTime.Seconds(5), function()
if not ScientistMan.IsDead and not DemoTruck.IsDead then if not ScientistMan.IsDead and not DemoTruck.IsDead then
Media.DisplayMessage("The Soviets have an unstable nuclear device stored here. \n I need to move it out of the facility!", "Scientist") Media.DisplayMessage("The Soviets have an unstable nuclear device stored here. \n I need to move it out of the facility!", "Scientist")
@@ -385,9 +429,11 @@ DemoTruckExit = function()
DemoTruck.Move(waypoint.Location) DemoTruck.Move(waypoint.Location)
end) end)
Trigger.OnEnteredFootprint({ DemoDrive4.Location }, function(actor, demotruckescape) local trukEscaped
if actor.Type == "dtrk" then Trigger.OnEnteredFootprint({ DemoDrive4.Location }, function(actor, id)
Trigger.RemoveFootprintTrigger(demotruckescape) if actor.Type == "dtrk" and not trukEscaped then
Trigger.RemoveFootprintTrigger(id)
trukEscaped = true
actor.Destroy() actor.Destroy()
end end
end) end)