--Out Of Time 5.2

clear resources from last level

--below: we tell QL that 2 sectors will be used
--thus making this a multi-sector level
set totalsectors 2

if timer 1 >= 0
    cleartasks all playernumber
--below: sector the description for the sector jump in the format of: sectorjumpdescription timeperiod description
    sectorjumpdescription ALL sector-jump detected. location:
--below: the name of each sector, which will be stated after the description line above
    sectorname 1 sector 696
    sectorname 2 sector 696
--first sector tech level
    settechlevel 1 1 [0,1,2,3,4,5,6,7,8,9,11,14,18,19]
--second sector tech level
    settechlevel 2 1 [0,1,2,3,4,5,6,7,8,9,11,14,18,19]
--target properties:
    playercantarget 1 1 [3,4,5]
    playercantarget 1 2 [3,4,5]
    playercantarget 1 3 [1,2,7]
    playercantarget 1 4 [1,2,7]
    playercantarget 1 5 [1,2,7]
    playercantarget 1 6 [0]
    playercantarget 1 7 [3,4,5]
    playercantarget 1 8 [7,2]
--below: assign temporal mod to both sectors
--in this case, both sectors will have the mod of: 1
    settemporalmod 1 1 all
    settemporalmod 2 1 all
--below: hide the tactical window (the user should know how to use it by now):
    hide tactical
--make the second Epsilon in the adjacent sector invisible:
    setunitstate 1 1 1 93 0 -1
--make the off-screen FTA Apostle invisible
    setunitstate 1 8 all 93 0 -1
--also set FTA ships 2 & 3 (teams 4 and 5) to "invisible" for now:
    setunitstate 1 4 all 93 0 -1
    setunitstate 1 5 all 93 0 -1
--for now give the first Apostle the "low power" status:
    addspecial 1 3 2 23
--allow the Apostle to target the Globex units as well (not just structures):
--    addcantarget 1 3 2 2
--also make sure that the Quantum Gate is in "lower power" as well:
    addspecial 1 1 2 23
--begin the level:
    set flag 1 to 6
--activate Carter's creation/building code:
    set flag 4 to 5
--activate Carter's Backup Base's creation/building code:
    set flag 5 to 5
--deploy the Globex drip-ships
    setunitstate 1 2 1 20 0 -1
    setunitstate 1 7 1 20 0 -1
--change the music
    playglobalsound 8 99 ql_track_11b
--BELOW: default/medium difficulty stats:
    setplayermoney 1 player 14000
    setplayermoney 2 player 14000
    setmaxunits 1 1 35
    setmaxunits 2 1 35
--turn off the Allies button
    set allies false
end if

--BELOW: change unit-cap and starting funds
--depending on the game difficulty
if gamedifficulty = easy
    setmaxunits 1 1 35
    setmaxunits 2 1 35
    setplayermoney 1 player 15000
    setplayermoney 2 player 15000
end if

if gamedifficulty = hard
    setmaxunits 1 1 30
    setmaxunits 2 1 30
    setplayermoney 1 player 10000
    setplayermoney 2 player 10000
end if

--below: a bunch of IF statements designed to "skip a few frames"
--before the level starts (that way, things will not look as jerky while the level
--is still trying to load)
--this count-down is also written "backwards" (so that a full frame is skipped
--before the next IF is executed)

if flag 1 = 9
    set flag 1 + 1
--BELOW: begin the first level cut-scene
    set flag 2 to 1
--begin the level dialogue:
    set flag 1 to 10
end if

if flag 1 = 8
    set flag 1 + 1
end if

if flag 1 = 7
    set flag 1 + 1
end if

if flag 1 = 6
    set flag 1 + 1
end if

--******** FIRST APOSTLE FIRES
--******** FIRST APOSTLE FIRES

if timer 6 >= 60000
and unitname 1 3 2 = apostle
and unitstate 1 3 2 = 22
    reset timer 6
 --point the drop-cam at the Apostle:
    dropcam 1 3 2 15000 2
    repeat this if
end if

if flag 6 = 0
and timer 6 >= 100
and unitname 1 3 2 = apostle
and unitstate 1 3 2 = 22
and soundchannel 1 is free
    set flag 6 + 1
    reset timer 6
end if

if flag 6 = 1
and timer 6 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52006
    comsatline >> K.C.: Weve got a missile headed our way! rgb(255,100,100)
    set flag 6 + 1
    reset timer 6
end if

if flag 6 = 2
and timer 6 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52015
    comsatline >> Col. Blair: What is the target? rgb(255,255,255)
    set flag 6 + 1
    reset timer 6
end if

if flag 6 = 3
and timer 6 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52007
    comsatline >> K.C.: Unknown! rgb(255,100,100)
    set flag 6 + 1
    reset timer 6
end if

if flag 6 = 4
and timer 6 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52016
    comsatline >> Col. Blair: All units... brace for impact! rgb(255,255,255)
    set flag 6 + 1
    reset timer 6
end if

--******** SECOND APOSTLE FIRES
--******** SECOND APOSTLE FIRES

if timer 7 >= 60000
and unitname 1 4 2 = apostle
and unitstate 1 4 2 = 22
    reset timer 7
 --point the drop-cam at the Apostle:
    dropcam 1 4 2 15000 2
    repeat this if
end if

if flag 7 = 0
and timer 7 >= 100
and unitname 1 4 2 = apostle
and unitstate 1 4 2 = 22
and soundchannel 1 is free
    set flag 7 + 1
    reset timer 7
end if

if flag 7 = 1
and timer 7 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52008
    comsatline >> K.C.: Apostle... in flight! rgb(255,100,100)
    set flag 7 + 1
    reset timer 7
end if

if flag 7 = 2
and timer 7 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52025
    comsatline >> Col. Blair: Commander... I thought I told you to destroy those missiles? rgb(255,255,255)
    set flag 7 + 1
    reset timer 7
end if

if flag 7 = 3
and timer 7 >= 100
and soundchannel 1 is free
    highlighthud tasks
    set flag 7 + 1
    reset timer 7
end if

--******** THIRD APOSTLE FIRES
--******** THIRD APOSTLE FIRES

if timer 16 >= 60000
and unitname 1 5 2 = apostle
and unitstate 1 5 2 = 22
    reset timer 16
 --point the drop-cam at the Apostle:
    dropcam 1 5 2 15000 2
    repeat this if
end if

--******** SECOND APOSTLE APPEARS
--******** SECOND APOSTLE APPEARS

if flag 8 = 0
and timer 8 >= 100
and unitname 1 4 2 = apostle
and soundchannel 1 is free
    playglobalsound 1 99 blair52017
    comsatline >> Col. Blair: Commander, you need to find a way to destroy those missiles before they are launched! rgb(255,255,255)
    set flag 8 + 1
    reset timer 8
 --point the drop-cam at the Apostle:
    dropcam 1 4 2 30000 2
end if

if flag 8 = 1
and timer 8 >= 100
and soundchannel 1 is free
    highlighthud tasks
    set flag 8 + 1
    reset timer 8
end if

--******** FIRST CUTSCENE
--******** FIRST CUTSCENE

if flag 2 = 1
-- ***** camera start *****
cutscene clear
cutscene fadehud instantout 0
cutscene lock keybaord
cutscene lock mouse
-- ***** units move start *****
unitcutscene 1 clear
--below: instead of specifying the unit number, we'll bind the cutscene
--to the first Epsilon unit that the player 1 has
unitcutscene 1 bindtounit 1 epsilon
unitcutscene 1 setunitstate 87

-- Player: 1 Unit: 1
unitcutscene 1 moveunit [0.8160,0.4335,0.3824,0.0000,-0.4692,0.8831,0.0000,0.0000,-0.3377,-0.1794,0.9240,0.0000,-22833.0000,218467.0000,21295.2090,1.0000] 0
cutscene movecamera [-0.8052,-0.3812,-0.4542,0.0000,-0.2947,-0.4076,0.8643,0.0000,-0.5146,0.8298,0.2159,0.0000,-27625.5488,224215.4688,22520.8301,1.0000] 0

cutscene set screensize 100 70

unitcutscene 1 moveunit [0.7005,0.3721,-0.6090,0.0000,-0.4692,0.8831,0.0000,0.0000,0.5378,0.2857,0.7932,0.0000,-1862.4424,182880.9688,16889.6621,1.0000] 5000
cutscene movecamera [-0.7759,-0.5170,0.3615,0.0000,0.4636,-0.0786,0.8826,0.0000,-0.4279,0.8524,0.3006,0.0000,-7740.9746,191992.7969,21028.7324,1.0000] 4500
unitcutscene 1 moveunit [0.8473,0.4501,0.2819,0.0000,-0.4692,0.8831,0.0000,0.0000,-0.2489,-0.1323,0.9594,0.0000,12714.2861,155443.3750,16889.6621,1.0000] 5000
cutscene movecamera [-0.8081,0.3332,-0.4858,0.0000,-0.5860,-0.3701,0.7209,0.0000,0.0604,0.8672,0.4943,0.0000,13792.9258,164389.6250,22672.3730,1.0000] 5000

--saw enemy base

unitcutscene 1 moveunit [0.8341,0.4431,-0.3286,0.0000,-0.4692,0.8831,0.0000,0.0000,0.2902,0.1542,0.9445,0.0000,43717.0664,97088.0078,16889.6621,1.0000] 6000
cutscene movecamera [-0.5822,-0.5117,0.6318,0.0000,0.6755,0.1279,0.7261,0.0000,-0.4524,0.8496,0.2712,0.0000,39125.4492,103225.7188,20079.2383,1.0000] 6000
unitcutscene 1 moveunit [0.5376,0.7902,-0.2942,0.0000,-0.7917,0.5931,0.1464,0.0000,0.2902,0.1542,0.9445,0.0000,83257.3359,67462.6797,9577.1055,1.0000] 6000
cutscene movecamera [0.6780,-0.5613,-0.4745,0.0000,0.4194,-0.2347,0.8769,0.0000,-0.6036,-0.7936,0.0763,0.0000,57310.5938,18519.2891,5377.2744,1.0000] 6000
unitcutscene 1 moveunit [0.6011,0.7135,0.3600,0.0000,-0.7917,0.5932,0.1464,0.0000,-0.1091,-0.3730,0.9214,0.0000,101963.7188,53446.8672,6117.5430,1.0000] 6000
cutscene movecamera [0.2926,0.8176,0.4959,0.0000,-0.2803,-0.4225,0.8619,0.0000,0.9142,-0.3912,0.1055,0.0000,142438.7500,19007.2441,7500.3516,1.0000] 6000
unitcutscene 1 moveunit [0.6443,0.7647,0.0000,0.0000,-0.7647,0.6443,0.0000,0.0000,0.0000,0.0000,1.0000,0.0000,114546.5859,44019.2734,1260.5587,1.0000] 6000
cutscene movecamera [-0.1124,0.9937,0.0000,0.0000,-0.2714,-0.0307,0.9620,0.0000,0.9559,0.1081,0.2731,0.0000,147024.3438,45948.9180,12627.2246,1.0000] 6000

cutscene positioncamera vector(1.02475e5,4.09105e4,-100.0000) vector(0.0000,0.0000,96.4526) vector(0.0000,-4.48333e4,1.27272e4) vector(0.0000,0.0000,0.0000)

unitcutscene 1 setunitstate 86

-- ***** camera end *****
cutscene unlock keybaord
cutscene unlock mouse
cutscene set screensize 100 100
cutscene fadehud in 2000
cutscene set flag 2 to 3
cutscene start
-- ***** units move end *****
unitcutscene 1 start
    reset timer 1
--below: hide the tactical window (the user should know how to use it by now)
    hide tactical
end if

--******** FIRST CUTSCENE ENDS
--******** FIRST CUTSCENE ENDS

if flag 1 = 10
and timer 1 >= 5000
and soundchannel 1 is free
--DEBUG:
--    comsatline DEBUG: Script last updated on: April 22, 2007 rgb(255,255,0)
    playglobalsound 1 99 kc52001
    comsatline >> K.C.: Sir, Im reading multiple drop-ship signatures north of our position! rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 11
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52001
    comsatline >> Col. Blair: Commander, this sector has been breached! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 12
and timer 1 >= 3000
and soundchannel 1 is free
    playglobalsound 1 99 blair52002
    comsatline >> Col. Blair: Deploy Epsilon as soon as possible, and establish defenses to aid the Globex forces! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 13
and timer 1 >= 100
and soundchannel 1 is free
    addtask all playernumber protect_carter pending primary protect General Carter's drop-ship
    addtask all playernumber protect_globex pending secondary protect the secondary Globex drop-ship
    highlighthud tasks
end if

if flag 1 = 13
and timer 1 >= 10000
and soundchannel 1 is free
    playglobalsound 1 99 carter52001
    comsatline General Carter: Glad you could make it Colonel! rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 14
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52003
    comsatline >> Col. Blair: Im beginning to think we were safer at sector 651. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 15
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52002
    comsatline General Carter: SDF is the least of our problems... the Alliance just deployed a number of offensive structures weve never seen before. rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 16
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52004
    comsatline >> Col. Blair: K.C. ... try to get us more info. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 17
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52002
    comsatline >> K.C.: Im on it... rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 18
and timer 1 >= 10000*2
and soundchannel 1 is free
    playglobalsound 1 99 kc52003
    comsatline >> K.C.: Colonel, Im seeing a number of Gamma Cruisers approaching the Globex defenses. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
 --dropcam time player unit life-time type speed xdistance zdistance
    dropcam 1 3 6+random(2) 25000 2
--    dropcam 1 3 8+random(2) 25000 2
    radarbeacon 1 vector(9880,129781,4742) 30000
--turn on the first FTA Base's AI:
    setai 1 3 1 100
    set flag 10 to 5
end if

if flag 1 = 19
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52005
    comsatline >> Col. Blair: Commander... take care of those ships! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 20
and timer 1 >= 60000*1
and soundchannel 1 is free
    playglobalsound 1 99 blair52006
    comsatline >> Col. Blair: So why exactly are we here General? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 21
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52003
    comsatline General Carter: Blair, what do you know about the transport that was lost at Sector 184? rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
--point the drop-cam at Carter's drop-ship
    dropcam 1 2 1 60000*3 3
end if

if flag 1 = 22
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52007
    comsatline >> Col. Blair: Nothing outside of the standard Intel... the ship passed through the gate, and was never seen again... The last speculation I heard was that it failed to materialize after the transport. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 23
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52004
    comsatline General Carter: What if I were to tell you that we found the remains of that ship? rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 24
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52008
    comsatline >> Col. Blair: Where exactly? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 25
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52005
    comsatline General Carter: My science team have found wreckage of a modified FTA class cruiser, just outside of sec 184... Carbon-dating analysis confirmed that the ship was last operational over 50 years ago... before Saltus was even colonized! rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 26
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52009
    comsatline >> Col. Blair: I'm not sure if I follow... Globex were the first ones to land on this planet... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 27
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52006
    comsatline General Carter: Well rewrite the history later... but I hope you are starting understand the forces that we are dealing with here...  rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 28
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52007
    comsatline General Carter: The experiment at sec 184 succeeded perfectly...but instead of moving through space... we traveled through time!  rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 29
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52010
    comsatline >> Col. Blair: Im not a fan of science-fiction General... so youll excuse me if I dont believe your stories of magic and a time machine which will solve all of our problems. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 30
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52008
    comsatline General Carter: There nothing magical about it! ... *sigh* ... Alright ... we still have a few minutes before we can begin the experiment... Let me at least send you the data we have now so that one of your men can take a look at it. rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 31
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52011
    comsatline >> Col. Blair: K.C... if you would do the honors ...  rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
--instead of "removedropcam" the "killdropcam" command can also be used:
    removedropcam
--change the music
    playglobalsound 8 99 ql_track_12a
end if

if flag 1 = 32
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52004
    comsatline >> K.C.: Yes sir... oh, and Colonel... I think I finally got info on those FTA structures ... they are a part of a brand new line of nuclear-based missiles... code named ... the Apostle. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 33
and timer 1 >= 100
and soundchannel 1 is free
--remove the "low power" status from the Apostle:
    removespecial 1 3 2 23
    set flag 1 + 1
    reset timer 1
    radarbeacon 1 vector(18615,155995,4394) 30000
end if

if flag 1 = 34
and timer 1 >= 2000
and soundchannel 1 is free
    playglobalsound 1 99 blair52012
    comsatline >> Col. Blair: Godamn! ... I suppose its just a matter of time before the atomic research would lead to this! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 35
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52005
    comsatline >> K.C.: The new weapon has been issued to all FTA class drop-ships... I think I might be able to download the specs for Epsilon. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 36
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52013
    comsatline >> Col. Blair: No! We will not break the pact! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 37
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52014
    comsatline >> Col. Blair: Commander... Im not sure when those missiles are going to hit, or how we can stop them... but... let us do our best... and save as many lives as we can! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
 --point the drop-cam at the Apostle:
    dropcam 1 3 2 30000 2
end if

if flag 1 = 38
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer011
    comsatline Computer: New task confirmed. rgb(255,255,0)
    addtask all playernumber destroy_apostle pending primary neutralize all Apostle structures
    set flag 1 + 1
    reset timer 1
--reset the timer responsible for the second FTA wave:
    reset timer 11
end if

if flag 1 = 39
and timer 1 >= 100
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
    highlighthud tasks
end if

--******** SECOND FTA SHIP ENTERS
--******** SECOND FTA SHIP ENTERS

--BELOW: trigger the second ship if the first FTA base is destroyed
if flag 11 = 0
and flag 1 < 150
and playerhasnounit 1 3 epsilon
and totalplayerunits 1 3 <= 3
    set flag 11 to 1
end if

--BELOW: trigger the second ship if Globex is losing
if flag 11 = 0
and flag 1 < 150
and totalplayerunits 1 2 <= 3
    set flag 11 to 1
end if

--BELOW: trigger the second ship if too much time passes - MEDIUM SETTING
if flag 11 = 0
and flag 1 >= 39
and flag 1 < 150
and gamedifficulty = medium
and timer 11 >= 60000*25
    set flag 11 to 1
end if

--BELOW: trigger the second ship if too much time passes - HARD SETTING
if flag 11 = 0
and flag 1 >= 39
and flag 1 < 150
and gamedifficulty = hard
and timer 11 >= 60000*20
    set flag 11 to 1
end if

if flag 11 = 1
and soundchannel 1 is free
-- ***** units move start *****
unitcutscene 1 clear
unitcutscene 1 bindtounit 4 1
unitcutscene 1 setunitstate 87

unitcutscene 1 moveunit [0.9990,0.0452,-0.0042,0.0000,-0.0449,0.9968,0.0666,0.0000,0.0072,-0.0663,0.9978,0.0000,184620.1094,237631.5625,24693.0996,1.0000] 0

unitcutscene 1 moveunit [0.9979,0.0643,-0.0014,0.0000,-0.0634,0.9876,0.1437,0.0000,0.0106,-0.1434,0.9896,0.0000,189005.2813,151809.7813,8666.4355,1.0000] 15000
unitcutscene 1 moveunit [0.9979,0.0643,0.0000,0.0000,-0.0643,0.9979,0.0000,0.0000,0.0000,0.0000,1.0000,0.0000,189325.7031,146785.5469,6542.2241,1.0000] 8000

unitcutscene 1 setunitstate 86

-- ***** units move end *****
unitcutscene 1 start
    set flag 11 + 1
    reset timer 11
    dropcam 1 4 1 40000 2
    playglobalsound 1 99 computer022
    comsatline Computer: New jump signature detected. rgb(255,255,0)
--reset one of the timers responsible for FTA Base 2:
    reset timer 12
--change the music
    playglobalsound 8 99 ql_track_9b
end if

if flag 11 = 2
and flag 1 < 50
and soundchannel 1 is free
    playglobalsound 1 99 blair51079b
    comsatline >> Col. Blair: Fresh meat for the grinder! ... Commander ... take care of it! rgb(255,255,255)
--below: begin the FTA Base 2 attack code:
    set flag 11 to 5
--continue the main script events:
    set flag 1 to 50
    reset timer 11
end if

--******** GLOBEX IS STARTING TO LOSE
--******** GLOBEX IS STARTING TO LOSE

if flag 1 = 50
and timer 1 >= 30000*1
and soundchannel 1 is free
    playglobalsound 1 99 blair52018
    comsatline >> Col. Blair: General, whats the status of your men? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 51
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52009
    comsatline General Carter: Im getting reports of heavy casualties ... rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
--point the drop-cam at Carter's drop-ship
    dropcam 1 2 1 60000*3 3
end if

if flag 1 = 52
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52019
    comsatline >> Col. Blair: We need to pull back. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 53
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52010
    comsatline General Carter: There is no where to go.... we just need a few more minutes to configure the Quantum Gate... rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 54
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52021
    comsatline >> Col. Blair: This is your plan? To go back in time and re-write history? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 55
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52012
    comsatline General Carter: Blair, none of this would have happened if it wasnt for the tactical decisions Globex made when we began the nuclear-weapon research along side FTA. rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 56
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52022
    comsatline >> Col. Blair: Are you saying you knew all of this? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 57
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52013
    comsatline General Carter: It was a calculated risk... both the Corporation and Trade Alliance would have gained greatly from the advancements made in the field of nuclear physics...  advancements that were otherwise banned by the Saltus treaty. rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 58
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52023
    comsatline >> Col. Blair: So thats it? ... You were just going to hide everything from publics eye until it was too late? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 59
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52014
    comsatline General Carter: Bryce had other plans... rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 60
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52015
    comsatline General Carter: Weve made a mistake Colonel ... and I for one want to see them erased. rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 61
and timer 1 >= 100
and soundchannel 1 is free
    addtask all playernumber protect_gate pending optional protect the Quantum Gate
    highlighthud tasks
    removedropcam
    set flag 1 + 1
    reset timer 1
--reset timer responsible for the next script event:
    reset timer 9
--reset the timer responsible for the third FTA wave:
    reset timer 12
end if

--******** BLAIR REFUSES TO HELP CARTER
--******** BLAIR REFUSES TO HELP CARTER

--BELOW: if FTA Base 2 is defeated
if flag 1 = 62
and soundchannel 1 is free
and playerhasnounit 1 4 epsilon
    set flag 1 + 1
    reset timer 1
end if

--BELOW: if too much time passes
if flag 1 = 62
and timer 9 >= 60000*5
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 63
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52016
    comsatline General Carter: Just a few more calculations and well be ready to go... rgb(100,255,100)
--point the drop-cam at Carter's drop-ship
    dropcam 1 2 1 60000*3 3
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 64
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52024
    comsatline >> Col. Blair: General, I hope you realize that my men will not be a part of your time-travel experiment. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 65
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52017
    comsatline General Carter: Blair, you have to! The original gate specifications will only work with an FTA-class vessel! rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
--reset timer responsible for the next script event:
    reset timer 9
end if

if flag 1 = 66
and timer 1 >= 100
and soundchannel 1 is free
    removedropcam
end if

--******** BLAIR AGREES TO BUILD GLOBEX GENERATORS
--******** BLAIR AGREES TO BUILD GLOBEX GENERATORS

--BELOW: if Carter lost most or all of his generators:
if flag 1 = 66
and timer 1 >= 100
and flag 11 >= 1
and playerhasunitcount 1 2 milanos <= 1
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
end if

--BELOW: if too much time passes:
if flag 1 = 66
and flag 11 >= 1
and timer 9 >= 60000*5
    set flag 1 + 1
    reset timer 1
end if

--BELOW: kill off a few of the Milanos Generators if they are still active:
if flag 1 = 67
and timer 1 >= 100
and soundchannel 1 is free
and unitname 1 2 2 = milanos
    setunithealth 1 2 2 0
end if

if flag 1 = 67
and timer 1 >= 100
and soundchannel 1 is free
and unitname 1 2 3 = milanos
    setunithealth 1 2 3 0
end if

if flag 1 = 67
and timer 1 >= 100
and soundchannel 1 is free
and unitname 1 2 4 = milanos
    setunithealth 1 2 4 0
end if

if flag 1 = 67
and timer 1 >= 100
and soundchannel 1 is free
and unitname 1 2 5 = milanos
    setunithealth 1 2 5 0
end if

if flag 1 = 67
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52018
    comsatline General Carter: Damn it! ... Weve lost our fusion generators! rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
--point the drop-cam at Carter's drop-ship
    dropcam 1 2 1 60000*3 3
end if

if flag 1 = 68
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52019
    comsatline General Carter: Blair... we cant proceed with the experiment if we have no power! rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 69
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52026
    comsatline >> Col. Blair: I could have swore I made myself clear... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 70
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 carter52020
    comsatline General Carter: Fine! I will go through the gate myself! ... but I beg you! ... help me just this one time! rgb(100,255,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 71
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52027
    comsatline >> Col. Blair: Alright ... just pass me the specs. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 72
and timer 1 >= 100
and soundchannel 1 is free
--allow the player to build the Milanos Generators
    addtechlevel 1 1 21
    set flag 1 + 1
    reset timer 1
    removedropcam
end if

if flag 1 = 73
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52028
    comsatline >> Col. Blair: Commander... we should now have access to the Fusion Generators ... as soon as you replicate a few of them, well route their power back to the Globex base. rgb(255,255,255)
    removedropcam
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 74
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer011
    comsatline Computer: New task confirmed. rgb(255,255,0)
    addtask all playernumber build_milanos pending primary create a Milanos Fusion Generator
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 75
and timer 1 >= 100
and soundchannel 1 is free
    highlighthud tasks
--highlight the queue:
    highlighthud buffer2
    set flag 1 + 1
    reset timer 1
end if

--******** THIRD FTA SHIP ENTERS
--******** THIRD FTA SHIP ENTERS

--BELOW: trigger the third ship if the second FTA base is destroyed
if flag 12 = 0
and flag 1 >= 62
and flag 1 < 150
and flag 11 >= 2
and playerhasnounit 1 4 epsilon
and timer 12 >= 60000*5
and totalplayerunits 1 4 <= 3
    set flag 12 to 1
end if

--BELOW: trigger the third ship if Globex is losing
if flag 12 = 0
and flag 1 >= 62
and flag 1 < 150
and flag 11 >= 2
and timer 12 >= 60000*10
and totalplayerunits 1 4 <= 3
    set flag 12 to 1
end if

--BELOW: trigger the second ship if too much time passes - MEDIUM DIFFICULTY
if flag 12 = 0
and flag 1 >= 62
and flag 1 < 150
and gamedifficulty = medium
and timer 12 >= 60000*25
    set flag 12 to 1
end if

--BELOW: trigger the second ship if too much time passes - HARD DIFFICULTY
if flag 12 = 0
and flag 1 >= 62
and flag 1 < 150
and gamedifficulty = hard
and timer 12 >= 60000*20
    set flag 12 to 1
end if

if flag 12 = 1
and soundchannel 1 is free
-- ***** units move start *****
unitcutscene 1 clear
unitcutscene 1 bindtounit 5 1
unitcutscene 1 setunitstate 87

unitcutscene 1 moveunit [0.9999,0.0135,0.0000,0.0000,-0.0125,0.9287,0.3706,0.0000,0.0050,-0.3706,0.9288,0.0000,113019.0000,245283.0000,22838.9395,1.0000] 0

unitcutscene 1 moveunit [0.9997,0.0247,0.0045,0.0000,-0.0246,0.9285,0.3706,0.0000,0.0050,-0.3706,0.9288,0.0000,113551.1484,189887.2188,7838.3965,1.0000] 15000
unitcutscene 1 moveunit [0.9997,0.0247,0.0000,0.0000,-0.0247,0.9997,0.0000,0.0000,0.0000,0.0000,1.0000,0.0000,113720.4141,183269.9688,6562.4434,1.0000] 8000

unitcutscene 1 setunitstate 86

-- ***** units move end *****
unitcutscene 1 start
    set flag 12 + 1
    reset timer 11
    dropcam 1 5 1 40000 2
    playglobalsound 1 99 computer022
    comsatline Computer: New jump signature detected. rgb(255,255,0)
--reset one of the timers responsible for FTA Base 3:
    reset timer 13
--change the music
    playglobalsound 8 99 ql_track_9a
end if

if flag 12 = 2
and soundchannel 1 is free
    playglobalsound 1 99 blair51075b
    comsatline >> Col. Blair: Commander, we've got incoming Alliance forces ... tell our men to engage! rgb(255,255,255)
--below: begin the FTA Base 3 attack code:
    set flag 12 to 5
    reset timer 12
end if

--******** TARGETTING STATEMENTS FOR THE OFF-SCREEN APOSTLE
--******** TARGETTING STATEMENTS FOR THE OFF-SCREEN APOSTLE

if flag 1 >= 100
and flag 1 < 200
and timer 14 >= 15000
and playerhasunit 1 7 omnithias
    playercantarget 1 8 [7,2]
    addcantarget 1 8 all 1
    reset timer 14
end if

if flag 1 >= 100
and flag 1 < 200
and timer 14 >= 15000
and playerhasnounit 1 7 omnithias
--allow the off-screen Super Apostle to target Carter's ships
    playercantarget 1 8 [2]
    addcantarget 1 8 all 1
    reset timer 14
end if

if flag 1 >= 100
and flag 1 < 200
and timer 14 >= 15000
and playerhasnounit 1 2 omnithias
--allow the off-screen Super Apostle to target the player
    playercantarget 1 8 [1]
    addcantarget 1 8 all 1
    reset timer 14
end if

if flag 1 >= 100
and flag 1 < 200
and timer 14 >= 15000
    reset timer 14
    repeat this if
end if

--******** PLAYER BUILDS THE FUSION GENERATOR
--******** PLAYER BUILDS THE FUSION GENERATOR

if flag 1 = 76
and timer 1 >= 100
and playerhasunit 1 1 milanos
and soundchannel 1 is free
    addtask all playernumber build_milanos complete primary create a Milanos Fusion Generator
    highlighthud tasks
    set flag 1 to 100
    reset timer 1
--make the Super-Apostle visible:
    setunitstate 1 8 1 82 0 -1
end if

if flag 1 = 100
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52009
    comsatline >> K.C.: Colonel... Im reading more Apostle signatures... just outside of this sector. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 101
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52030
    comsatline >> Col. Blair: Can they target our vector? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 102
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52010
    comsatline >> K.C.: Yes sir... and there is no way we can strike them back without nuclear missiles of our own. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 103
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52031
    comsatline >> Col. Blair: ... my order still stands! ... The last shreds of humanity's accord will not be lost... even if they only live within us! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
--reset timer responsible for bypassing Bryce's conversation:
    reset timer 19
end if

if flag 1 = 104
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52032
    comsatline >> Col. Blair: Commander... we stand our ground! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 105
and timer 1 >= 100
and soundchannel 1 is free
    highlighthud tasks
    set flag 1 + 1
    reset timer 1
end if

--******** SECOND GLOBEX DROP-SHIP DIES
--******** SECOND GLOBEX DROP-SHIP DIES

if flag 1 >= 20
and flag 1 < 200
and flag 14 = 0
and unithealth 1 7 1 <= 0%
    set flag 14 + 1
    reset timer 14
 --point the drop-cam at the Globex ship:
    dropcam 1 7 1 15000 1
end if

if flag 14 = 1
and soundchannel 1 is free
    playglobalsound 1 99 kc52011
    comsatline >> K.C.: Sir, we are losing the second Globex drop-ship! rgb(255,100,100)
    set flag 14 + 1
    reset timer 14
end if

if flag 14 = 2
and soundchannel 1 is free
    playglobalsound 1 99 blair52033
    comsatline >> Col. Blair: They fought well... I just hope someone will be left alive to remember their sacrifice... rgb(255,255,255)
    set flag 14 + 1
    reset timer 14
end if

if flag 14 = 3
and soundchannel 1 is free
    set flag 14 + 1
    reset timer 14
    addtask all playernumber protect_globex failed secondary protect the secondary Globex drop-ship
    highlighthud tasks
end if

--******** GENERAL CARTER DIES
--******** GENERAL CARTER DIES

if flag 1 >= 100
and flag 1 < 200
and flag 15 = 0
and unithealth 1 2 1 <= 10%
    set flag 15 + 1
    reset timer 15
end if

if flag 15 = 1
and soundchannel 1 is free
    playglobalsound 1 99 carter52021
    comsatline General Carter: Damn... were losing containment... {static} ... Blair... you have to finish the experiment... there is no other way to end this! rgb(100,255,100)
--point the drop-cam at Carter's drop-ship
    dropcam 1 2 1 60000*1 3
    set flag 15 + 1
    reset timer 15
end if

if flag 15 = 2
and soundchannel 1 is free
    playglobalsound 1 99 blair52034
    comsatline >> Col. Blair: Carter! rgb(255,255,255)
--make sure Carter is dead:
    setunithealth 1 2 1 0
    set flag 15 + 1
    reset timer 15
end if

if flag 15 = 3
and soundchannel 1 is free
    playglobalsound 1 99 blair52034b
    comsatline >> Col. Blair: Ill see you in a bit ... rgb(255,255,255)
    set flag 15 + 1
    reset timer 15
end if

if flag 15 = 4
and soundchannel 1 is free
    set flag 15 + 1
    reset timer 15
    addtask all playernumber protect_carter failed primary protect General Carter's drop-ship
    highlighthud tasks
end if

--******** BRYCE CONTACS BLAIR
--******** BRYCE CONTACS BLAIR

--BELOW: Bryce's conversation is triggered if
--Carter is dead:
if flag 1 >= 105
and flag 1 < 120
and playerhasnounit 1 2 omnithias
    set flag 1 to 120
    reset timer 1
end if

--OR, if the 3rd FTA wave is defeated:
if flag 1 >= 105
and flag 1 < 120
and flag 12 >= 2
and timer 13 >= 60000*3
and playerhasnounit 1 5 epsilon
    set flag 1 to 120
    reset timer 1
end if

if flag 1 = 120
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52012
    comsatline >> K.C.: Sir... should we try to leave the sector? rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 121
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52035
    comsatline >> Col. Blair: And go where? We are surrounded on all fronts. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 122
and timer 1 >= 10000*3
and soundchannel 1 is free
    playglobalsound 1 99 kc52013
    comsatline >> K.C.: Colonel... I have an incoming transmission from Captain Bryce. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
--give the off-screen Super-Apostle the "low power" status:
    addspecial 1 8 1 23
--make sure that the off-screen Super-Apostle will only target the player:
--    playercantarget 1 8 [1]
--also alow the Super-Apostle to target the player's drop-ship unit:
    addcantarget 1 8 all 1
--change the music
    playglobalsound 8 99 ql_track_6a
end if

if flag 1 = 123
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52036
    comsatline >> Col. Blair: Put him on... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 124
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 bryce52001
    comsatline Capt. Bryce: Blair my man! ... how goes the war? rgb(128,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 125
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52037
    comsatline >> Col. Blair: Pretty good... but its getting kind of bright here with all of these atomic bombs. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 126
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 bryce52002
    comsatline Capt. Bryce: Im sure its a hell of a view! rgb(128,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 127
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52038
    comsatline >> Col. Blair: Oh its great... why dont you come down and see for yourself... youre missing all the action. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 128
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 bryce52003
    comsatline Capt. Bryce: But if Im there, who will give the final orders to end this conflict? rgb(128,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 129
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52039
    comsatline >> Col. Blair: Oh... Im sure we can find some other bastard prick to fill in for you. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 130
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 bryce52004
    comsatline Capt. Bryce: Listen... I have to go... but managed to save a special missile just for you! rgb(128,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 131
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52039b
    comsatline >> Col. Blair: Youre too kind. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 132
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 bryce52005
    comsatline Capt. Bryce: Its for old times... and by the way... say hi to Carter for me... rgb(128,255,255)
    set flag 1 + 1
    reset timer 1
end if

--BELOW: skip dialogue lines of Carter is still alive:
if flag 1 = 133
and timer 1 >= 100
and soundchannel 1 is free
and playerhasunit 1 2 omnithias
    set flag 1 to 135
    reset timer 1
end if

if flag 1 = 133
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52040
    comsatline >> Col. Blair: Hes already dead. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 134
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 bryce52006
    comsatline Capt. Bryce: I know...  rgb(128,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 135
and timer 1 >= 100
and soundchannel 1 is free
--turn Super-Apostle back on:
    removespecial 1 8 1 23
--also deploy the off-screen Super-Apostle so that it's ready to fire:
--    setunitstate 1 8 1 20 0 -1
    set flag 1 + 1
    reset timer 1
end if

--BELOW: wait until the Super-Apostle fires:
if flag 1 = 136
and timer 1 >= 100
and unitstate 1 8 1 = 22
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
end if

--BELOW: or too much time passes:
if flag 1 = 136
and timer 1 >= 60000
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 137
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52014
    comsatline >> K.C.: Apostle IN FLIGHT! ... Its headed right for us! rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 138
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52041
    comsatline >> Col. Blair: All hands, brace for impact! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
--reset the timer for the next event:
    reset timer 18
end if

--******** EPSILON IS DAMAGED
--******** EPSILON IS DAMAGED

if flag 1 >= 138
and flag 1 < 800
and currentsector is 1
and unithealth 1 1 1 <= 40%
and soundchannel 1 is free
    set flag 17 + 1
    reset timer 17
end if

if flag 17 = 1
and soundchannel 1 is free
    playglobalsound 1 99 kc52015
    comsatline >> K.C.: Sir... Epsilon is on its last leg... rgb(255,100,100)
    set flag 17 + 1
    reset timer 17
--point the drop-cam at Epsilon
    dropcam 1 1 1 60000*3 1
end if

if flag 17 = 2
and soundchannel 1 is free
    playglobalsound 1 99 blair52042
    comsatline >> Col. Blair: Damage report... rgb(255,255,255)
    set flag 17 + 1
    reset timer 17
end if

if flag 17 = 3
and soundchannel 1 is free
    playglobalsound 1 99 kc52016
    comsatline >> K.C.: Umm... everything! ... The core can breach at any minute... rgb(255,100,100)
    set flag 17 + 1
    reset timer 17
end if

if flag 17 = 4
and soundchannel 1 is free
    playglobalsound 1 99 blair52043
    comsatline >> Col. Blair: Great... Commander... I guess this is it... we had a good run. rgb(255,255,255)
    set flag 17 + 1
    reset timer 17
    removedropcam
end if

if flag 17 = 5
and soundchannel 1 is free
    playglobalsound 1 99 blair52044
    comsatline >> Col. Blair: I would like to personally thank you for your dedication ... You've stuck by me when most others would not ... if I could give you a medal for this... I would. rgb(255,255,255)
    set flag 17 + 1
    reset timer 17
end if

--*********************************************                                                                       --*********************************************
--******** MAIN LEVEL CREATION *********                                                                        --******** MAIN LEVEL CREATION *********
--*********************************************                                                                       --*********************************************

--*********************************************                                                                       --*********************************************
--******** MAIN LEVEL CREATION *********                                                                        --******** MAIN LEVEL CREATION *********
--*********************************************                                                                       --*********************************************

total memory cleanup
set activeworld 1
resetworld 1

load basic configuration

set landpatch land_outoftime52a
set landdeform off
set landheightmap heightmap_outoftime52a

set minnewfogdistance 50000
set maxviewdistance 80000

**** RESOURCE PACK FILES START
if highmodeldetail
load resourcepack http://internallink1/ql_highres_modelspack.cct slot1 highres_models
end if
if lowmodeldetail
load resourcepack http://internallink1/ql_lowres_modelspack.cct slot1 lowres_models
end if

if highterraindetail
load resourcepack http://internallink2/ql_highresterrain_outoftime52a.cst slot2 highres_terrain
end if
if mediumterraindetail
load resourcepack http://internallink2/ql_medresterrain_outoftime52a.cct slot2 medres_terrain
end if
if lowterraindetail
load resourcepack http://internallink2/ql_lowresterrain_outoftime52a.cct slot2 lowres_terrain
end if

replace loadingscreen loadingscreen_outoftime52
remove loading logo

load texturepack http://internallink1/ql_mega_texturepack.cct slot3 textures

load resourcepack http://internallink1/ql_soundpack_outoftime52.cct slot4 character_speech
--load resourcepack http://internallink1/ql_soundpack_blairgeneral.cct slot4 character_speech

--below: Blair's Personal Log (during the loading)
--playsound blair51000

load resourcepack http://internallink1/ql_soundpack_computer.cct slot5 computer_speech
load resourcepack http://internallink1/ql_soundpack_unitvoices.cct slot6 unit_speech

load resourcepack http://internallink1/ql_musicpack1.cct slot10 music_pack1
load resourcepack http://internallink1/ql_musicpack2.cct slot11 music_pack2
load resourcepack http://internallink1/ql_musicpack3.cct slot12 music_pack3
**** RESOURCE PACK FILES END

--set weather rain
prepare landpatch

load basic variables

load basic models
load minimap

movemodel sky01 vector(0,0,30000)
movemodel sky02 vector(0,0,30000)

--BELOW: in this level, the Apostle structure will auto attack/target enemy units
new database entry
apostle
affect all temporal mods
fullname Apostle
price 5000
buildtime 60000
unitflagrequired 1
maxallowed 1    --cannot build more than one Apostle
techlevel 20
unitscale 1
healthratio 13
modeltype 10
isabuilding yes
unmoving true
armor 2500
speed1 0
speed2 0
speed3 40
initialstate 85
maxbuilddistance 18000
gridtype -2
deathtype 3
power -1000
lifetime 0
cantarget [10]
canattack [1,2,3,4,10,50]
--canbuild 1 [333] ["apostlecheckpoint"]    --state 333 means: can't be built by user
builddelay 60000*5    --the 5 minute delay before the above unit is auto-built
sounds created ["computer_global_121","computer_global_122"]
sounds deploy ["apostle_loud_prime"]
sounds undeploy ["computer_global_120","computer_global_123","computer_global_124","computer_global_126","computer_global_127"]
animationtype 3        --force custom animations even during extremely low FPS
animation 0 0 200 no yes yes        --idle
animation 20 200 400 no no no    --deploy
animation 22 400 950 no no no    --undeploy
deploydelay 6000
undeploydelay 19000
addspecial 10    --animation is power dependent
addspecial 31    --do not target back if attacked
addspecial 40    --being "deployed" is not considered being "idle"
addspecial 59    --create a radar beacon when entered the world
addspecial 63    --player can't tell unit to move
addspecial 64    --player can't tell unit to attack
addspecial 69    --unit will de-cloak 1 minute before the builddelay expires
addspecial 84    --create radar beacon after firing the mega weapon
addspecial 89    --play countdown sample every minute. sound format: "unit_minute"
addspecial 92    --the builddelay timer works when power > 0
addspecial 93    --create the unit after builddelay only locally
addspecial 94    --only build the builddelay unit when "idle"
addspecial 95    --deploy when builddelay runs out
addspecial 82    --fire primary weapon when have a target
addspecial 83    --only fire the weapon when deployed
healthanimation <=0 apostleexplosion 0
healthanimation <=20 smoke_and_fire 10000
healthanimation <=50 slight_smoke 10000
#end

--create a copy of the Apostle under a new name:
copymodel apostle superapostle

--BELOW: the "Super Apostle" will have a lower recharge/prime time
--and will be placed at a vector where it cannot be attacked
new database entry
superapostle
affect all temporal mods
fullname Apostle
price 5000
buildtime 60000
unitflagrequired 1
maxallowed 1    --cannot build more than one Apostle
techlevel 20
unitscale 1
healthratio 13
modeltype 10
isabuilding yes
unmoving true
armor 20000	--increase armor, just in case the player tries to destroy this structure, default: 1200
speed1 0
speed2 0
speed3 40
initialstate 85
maxbuilddistance 18000
gridtype -2
deathtype 3
power +1000    --this Apostle actually generates power
lifetime 0
cantarget [1,2,3,4,10]
canattack [1,2,3,4,10,50]
--canbuild 1 [333] ["apostlecheckpoint"]    --state 333 means: can't be built by user
builddelay 60000*2    --the 2 minute delay before the above unit is auto-built
sounds created ["computer_global_121","computer_global_122"]
sounds deploy ["apostle_loud_prime"]
sounds undeploy ["computer_global_120","computer_global_123","computer_global_124","computer_global_126","computer_global_127"]
animationtype 3        --force custom animations even during extremely low FPS
animation 0 0 200 no yes yes        --idle
animation 20 200 400 no no no    --deploy
animation 22 400 950 no no no    --undeploy
deploydelay 6000
undeploydelay 19000
addspecial 10    --animation is power dependent
addspecial 31    --do not target back if attacked
addspecial 40    --being "deployed" is not considered being "idle"
addspecial 59    --create a radar beacon when entered the world
addspecial 63    --player can't tell unit to move
addspecial 64    --player can't tell unit to attack
addspecial 69    --unit will de-cloak 1 minute before the builddelay expires
addspecial 84    --create radar beacon after firing the mega weapon
addspecial 89    --play countdown sample every minute. sound format: "unit_minute"
addspecial 92    --the builddelay timer works when power > 0
addspecial 93    --create the unit after builddelay only locally
addspecial 94    --only build the builddelay unit when "idle"
addspecial 95    --deploy when builddelay runs out
addspecial 82    --fire primary weapon when have a target
addspecial 83    --only fire the weapon when deployed
healthanimation <=0 apostleexplosion 0
healthanimation <=20 smoke_and_fire 10000
healthanimation <=50 slight_smoke 10000
#end

--BELOW: in this level, the FTA Collector can also build the Milanos Generator
--this option will be unlocked to the player later in the level:
new database entry
ftacollector
affect all temporal mods
fullname FTA Collector
price 1300
buildtime 20000
unitflagrequired 1
techlevel 0
unitscale 1
healthratio 3.5
modeltype 3
armor 450
speed1 800        --was: 700
speed2 200
speed3 400
initialstate 82
gridtype -2
cancollect 1
maxresource 400
collisiontype 0    --no collision check on the unit
canbuild 1 [777] ["bladescout"]    --state 777 means: all states
canbuild 2 [777] ["turbine","milanos"]    --state 777 means: all states
sounds created ["chopper01_acreated1","chopper01_acreated2"]
sounds selected ["chopper01_aselected1","chopper01_aselected2","chopper01_aselected3"]
sounds move ["chopper01_amove1","chopper01_amove2","chopper01_amove3"]
sounds attack ["chopper01_aattack1","chopper01_aattack2","chopper01_aattack2"]
addspecial 90    --is a collector
canattack [2,3,10]    --make sure that unit can't attack dropship
animationtype 2        --has custom animation
animation 0 0 100 no yes yes        --idle
animation 3 100 200 no no no        --move forward
animation 700 200 300 no no no    --before stops
healthanimation <=0 smoke_trail 120000
#end

--BELOW: the Milanos Generator in this level has a tech level of 21
--this way it can be easily unlocked to the player:
new database entry
milanos
affect all temporal mods
fullname Milanos Generator
price 600
buildtime 15000
unitflagrequired 1
techlevel 21        --the default tech-level used to be: 1
unitscale 1
healthratio 6
modeltype 10
isabuilding yes
unmoving true
armor 400
speed1 0
speed2 0
speed3 40
initialstate 85
maxbuilddistance 15000
gridtype -2
deathtype 3
power +600
lifetime 50
--canbuild 2 [777] ["sios","rotiris"]    --in this level, the structure will not build anything
addspecial 10    --animation is power dependent
healthanimation <=20 smoke_and_fire 10000
healthanimation <=50 slight_smoke 10000
#end

--BELOW: this Quantum Gate has unit type of: 99
--thus no other unit in the game will target/attack it
new database entry
ftaquantumgate
affect all temporal mods
fullname Quantum Gate
price 2500
buildtime 30000
unitflagrequired 1
maxallowed 1    --cannot build more than one
techlevel 10
unitscale 1
healthratio 6.5
modeltype 99
isabuilding yes
armor 2500		--increase the armor of the gate in this level, default was: 800
speed1 0
speed2 0
speed3 40
initialstate 85
candeploy yes
maxbuilddistance 15000
gridtype -2
deathtype 3
--power +100        --this gate will actually produce power
lifetime 0
collisiontype 1    --use spherical collision algorithm (makes it easier to collide with)
sounds deploy ["lowbeep01"]
sounds indeployment ["transport01_01"]
addspecial 10    --animation is power dependent
--addspecial 50    --is a Quantum Gate
addspecial 60    --pointer over will result in "move", and not "target" or "select"
addspecial 66    --player can't tell this unit to deploy
healthanimation <=20 smoke_and_fire 10000
healthanimation <=50 slight_smoke 10000
#end

--BELOW: this version of the SDF Destroyer will also target drop-ship units:
new database entry
sdfdestroyer
affect all temporal mods
fullname SDF Destroyer
price 5000
buildtime 60000
unitflagrequired 1
techlevel 2
unitscale 1
healthratio 20
modeltype 1
armor 30000
damage 200
speed1 650
speed2 15
speed3 800
--initialstate 85
initialstate 65
unitflag [1]
unitflagstate [0,1,2,3,20,21,22]
power +100
gridtype -2
cantarget [1,2,3,4,10]
canattack [1,2,3,4,10,50]
sounds created ["sdf_global_destoyer_flyin"]
sounds deploy ["sdf_loud_reload"]
sounds indeployment ["sdf_loud_destroyer_siren1","sdf_loud_destroyer_siren2","sdf_loud_destroyer_siren3"]
sounds selected ["sdf_radio7","sdf_radio1","sdf_radio5"]
sounds move ["sdf_radio2","sdf_radio4","sdf_radio1"]
sounds attack ["sdf_radio3","sdf_radio5","sdf_radio2","sdf_radio6"]
addspecial 1    --has a on-board radar
addspecial 3    --can't be sold
addspecial 7    --fire weapons in chain-fire
--addspecial 41    --jump to state 62 when user picks location in state 60
--addspecial 25    --jump to state 62 after user picks location in state 85
addspecial 42    --become idle after deploying
candeploy yes
deploydelay 2200
undeploydelay 20000
animationtype 3		--force custom animations even during extremely low FPS
animation 0 250 400 no no yes        --idle
animation 3 100 250 no no yes        --move forward
animation 700 250 400 no no yes        --before stops
animation 20 400 450 no no yes        --deploy
--animation 0 0 100 yes yes yes        --idle
#end

**************************************************************
****** CREATION OF THE: GOLDENBOY CRUISER ****** 
**************************************************************

--first, we make a copy of the orginal "gammacruiser" and name it "goldenboy"
--we can do this now since the model-pack for the game units is already loaded

copymodel gammacruiser goldenboy

--now we add a database entry for this new unit
--it is mostly a copy of the original "gammacruiser" entry, but with the addition
--of the "mammoth turbine gas cloud" which will execute upon death of the unit

new database entry
goldenboy
affect all temporal mods
fullname Unknown Cruiser
price 2200
buildtime 35000
unitflagrequired 1
techlevel 11
unitscale 1.5        --unit is 1.5 times bigger
healthratio 5
modeltype 2
armor 2000        --more armor
damage 100        --unit does more damage
speed1 550
speed2 60
speed3 160
initialstate 82
cantarget [1,2,3,10]
canattack [1,2,3,10,50]
gridtype -5
sounds created ["transportgamma_acreated1","transportgamma_aattack3"]
sounds selected ["transportgamma_aattack2","transportgamma_aattack3"]
sounds move ["transportgamma_amove1","transportgamma_amove2","transportgamma_amove3"]
sounds attack ["transportgamma_aattack1","transportgamma_aattack4"]
sounds deploy ["transport01_02"]
sounds undeploy ["transport01_02"]
animationtype 2        --has custom animation
animation 0 0 250 no yes yes        --idle
animation 3 250 500 no no no        --move forward
animation 700 500 750 no no no    --before stops
healthanimation <=0 mammothhazard 0        --hazard cloud will form upon death
healthanimation <=20 smoke_and_fire 10000
healthanimation <=50 slight_smoke 10000
#end

--now we add a new "tactical info" database entry
--so that custom information will be desplayed for the new unit

new tactical entry
goldenboy
@name DB:fullname /n /n @primary @function /n unknown offense powered by Globex class engines /n /n @flaws /n low speed /n /n @good @against /n low and medium flying units, all structures, drop-ships /n /n @counter @with /n swarms of smaller units, defense turrets, other cruisers /n /n #DETAILED #INFO /n /n @armor /n DB:armor /n /n @speed /n DB:speed1 kpq /n /n @primary @weapon /n high-damage plasma torpedo /n /n @damage @yield /n DB:damage /n /n @unable @to @target /n high flying units /n /n @hover @distance /n high
#end

--last, we make a copy of the gammacuriser shadow to be used with the new
--unit (if we skip this step, then a standard "black circle" shadow will be used ....
--also, because all shadows are in the form of "shadow unitname", we put a "~"
--where a space should be (the script will then auto-replace "~" character with a space)

copyobject shadow~gammacruiser shadow~goldenboy

--and now, the new GoldenBoy Cruiser is complete!

**************************************************************
****** CREATION OF THE: GOLDENBOY CRUISER ****** 
**************************************************************

--BELOW: process all of the new database entries
process database
process tactical database

--PRE-BUFFERING OF UNITS
if displayextramodels
    createmodel player0 ftacollector vector(-10000,-10000,-10000) 0 0 [1]
    createmodel player0 turbine vector(-11000,-11000,-10000) 0 0 [1]
    createmodel player0 radartower vector(-15000,-15000,-10000) 0 0 [1]
    createmodel player0 flakturret vector(-16000,-16000,-10000) 0 0 [1]
    createmodel player0 mammothturbine vector(-17000,-17000,-10000) 0 0 [1]
    createmodel player0 gammacruiser vector(-18000,-18000,-10000) 0 0 [1]
    createmodel player0 bowgerus vector(-19000,-19000,-10000) 0 0 [1]
    createmodel player0 milanos vector(-20000,-20000,-10000) 0 0 [1]
--    createmodel player0 sios vector(-21000,-21000,-10000) 0 0 [1]
    createmodel player0 tryphon vector(-22000,-22000,-10000) 0 0 [1]
    createmodel player0 farseer vector(-23000,-23000,-10000) 0 0 [1]
    createmodel player0 hazardchopper vector(-24000,-24000,-10000) 0 0 [1]
--    createmodel player0 hazardbeacon vector(-25000,-25000,-10000) 0 0 [1]
    createmodel player0 ftascrambler vector(-26000,-26000,-10000) 0 0 [1]
    createmodel player0 copterstation vector(-27000,-27000,-10000) 0 0 [1]
    createmodel player0 davinci vector(-28000,-28000,-10000) 0 0 [1]
    createmodel player0 farseeruplink vector(-29000,-29000,-10000) 0 0 [1]
    createmodel player0 bc45 vector(-30000,-30000,-10000) 0 0 [1]
    createmodel player0 ftatransportgate vector(-31000,-31000,-10000) 0 0 [1]
end if

if displayextramodels
    createmodel player16 s_tree01 vector(54715,56456,-144) 20.5300 5.0625 [2]
    createmodel player16 s_tree02 vector(100766,74411,-1420) -34.9197 5.3811 [2]
    createmodel player16 s_tree01 vector(165378,61017,1840) 177.8633 5.0625 [2]
    createmodel player16 s_tree01 vector(43939,156462,100) -86.9989 4.8919 [2]
    createmodel player16 s_tree01 vector(153643,155506,2151) -119.6460 5.0119 [2]
    createmodel player16 s_tree02 vector(97079,148048,2036) 97.1365 5.5687 [2]
end if

if displayextramodels and highterraindetail
    createmodel player16 s_tree02 vector(-11335,26894,-5695) 43.8116 11.3906 [2]
    createmodel player16 s_tree01 vector(75472,-21928,-10314) 72.1801 11.3906 [2]
    createmodel player16 s_tree02 vector(177382,-2146,-6328) 141.8829 11.3906 [2]
    createmodel player16 s_tree01 vector(226452,139897,-1733) 166.2146 7.5938 [2]
    createmodel player16 s_tree01 vector(-27792,123316,-5056) 17.9387 9.1884 [2]
    createmodel player16 s_tree02 vector(-16574,200932,-3947) -12.5808 8.2696 [2]
    createmodel player16 s_tree02 vector(94574,226563,-8863) -77.2761 10.2516 [2]
    createmodel player16 s_tree02 vector(191674,203623,-3466) -111.1895 8.3531 [2]
end if

--PODS:
createmodel player17 resourcepod vector(119701,36068,43) 94 1 [1]
createmodel player17 resourcepod vector(108330,64699,43) -62 1 [1]
createmodel player17 resourcepod vector(57927,23329,98) 49 1 [1]
createmodel player17 resourcepod vector(-1102,61325,3634) 0 1 [1]
createmodel player17 resourcepod vector(11734,125820,3672) 3 1 [1]
createmodel player17 resourcepod vector(77061,176635,5132) -44 1 [1]
createmodel player17 resourcepod vector(188370,127018,5149) 93 1 [1]
--multiplayer only pods:
--createmodel player17 resourcepod vector(81211,103008,728) -2 1 [1]
--createmodel player17 resourcepod vector(113480,140169,2506) -69 1 [1]
--createmodel player17 resourcepod vector(147493,178772,3706) -120 1 [1]
--createmodel player17 resourcepod vector(203233,60830,4865) -144 1 [1]

--*** PLAYER'S SHIPS:
createmodel player1 epsilon vector(0,0,0) 94 1 [1]
--createmodel player1 epsilon vector(116429,44074,1242) 94 1 [1]
createmodel player1 ftaquantumgate vector(110712,27347,111) 102 1 [1]

--***** CARTER'S SHIPS
createmodel player2 omnithias vector(100215,28469,1460) 136 1 [1]
createmodel player2 milanos vector(69965,22437,111) 98 1 [1]
createmodel player2 milanos vector(69102,30296,172) 98 1 [1]
createmodel player2 milanos vector(75946,23309,-8) 98 1 [1]
createmodel player2 milanos vector(75466,31022,87) 98 1 [1]
createmodel player2 milanos vector(81371,24686,-8) 104 1 [1]
createmodel player2 milanos vector(80578,31805,-8) 104 1 [1]
--createmodel player2 etros vector(87279,33414,120) -178 1 [1]
createmodel player2 etros vector(69069,35214,120) 180 1 [1]
--gnerators used to be:
--createmodel player2 milanos vector(70656,15397,-8) 102 1 [1]
--createmodel player2 milanos vector(69965,22437,79) 98 1 [1]
--createmodel player2 milanos vector(69102,30296,172) 98 1 [1]
--createmodel player2 milanos vector(76768,16052,-8) 98 1 [1]
--createmodel player2 milanos vector(75946,23309,-8) 98 1 [1]
--createmodel player2 milanos vector(75466,31022,55) 98 1 [1]
--createmodel player2 milanos vector(82659,17579,-8) 104 1 [1]
--createmodel player2 milanos vector(81371,24686,-8) 104 1 [1]
--createmodel player2 milanos vector(80578,31805,-8) 104 1 [1]
createmodel player2 sios vector(92198,21336,0) 93 1 [1]
createmodel player2 atanos vector(68200,40243,421) -179 1 [1]
createmodel player2 atanos vector(83365,41198,377) 177 1 [1]
createmodel player2 atanos vector(97248,33780,377) -180 1 [1]

--***** CARTER'S BACKUP
createmodel player7 omnithias vector(75871,37662,1680) 102 1 [1]
--createmodel player7 bowgerus vector(93041,36947,550) -178 1 [1]
--createmodel player7 bowgerus vector(88539,39737,550) -178 1 [1]
createmodel player7 bowgerus vector(78266,42219,624) -180 1 [1]
createmodel player7 bowgerus vector(72975,42026,550) -180 1 [1]

--**** FTA ATTACK FORCE 1 - LEFT
createmodel player3 epsilon vector(13440,135966,5061) -12 1 [1]
createmodel player3 apostle vector(18615,155995,4394) -38 1 [1]
createmodel player3 flakturret vector(13761,133651,3743) 12 1 [1]
createmodel player3 mammothturbine vector(12260,145266,3741) -12 1 [1]
createmodel player3 mammothturbine vector(16072,144389,3710) -10 1 [1]
--createmodel player3 hazardbeacon vector(26103,131919,87) 27 1 [1]
--createmodel player3 hazardbeacon vector(19208,115234,580) 27 1 [1]
createmodel player3 copterstation vector(9259,126217,3742) 38 1 [1]
--createmodel player3 turbinecopter vector(9880,129781,5593) 28 1.3000 [1]
--createmodel player3 hazardchopper vector(11561,132076,6923) 12 1 [1]
createmodel player3 gammacruiser vector(9880,129781,4742) 28 1.3000 [1]
createmodel player3 gammacruiser vector(11561,132076,4742) 12 1 [1]

--**** FTA ATTACK FORCE 2 - RIGHT
createmodel player4 epsilon vector(0,0,0) 4 1 [1]
--createmodel player4 epsilon vector(189324,146786,6231) 4 1 [1]
--createmodel player4 apostle vector(182685,157802,5342) -51 1 [1]
--createmodel player4 mammothturbine vector(188815,155043,5435) 6 1 [1]
--createmodel player4 mammothturbine vector(180554,165217,5306) -17 1 [1]
--createmodel player4 flakturret vector(177718,159135,5018) -17 1 [1]
--createmodel player4 flakturret vector(182398,152445,5026) -17 1 [1]
--createmodel player4 flakturret vector(183645,146425,4965) -17 1 [1]
--createmodel player4 gammacruiser vector(186747,141840,6075) -18 1 [1]
--createmodel player4 hazardchopper vector(189057,138183,8385) -18 1 [1]

--**** FTA ATTACK FORCE 3 - MIDDLE
createmodel player5 epsilon vector(1000,0,0) 1 1 [1]
--createmodel player5 epsilon vector(113720,183270,6559) 1 1 [1]
--createmodel player5 apostle vector(101547,184309,5368) -91 1 [1]
--createmodel player5 mammothturbine vector(93052,183826,5229) -80 1 [1]
--createmodel player5 mammothturbine vector(120815,183033,4981) -14 1 [1]
--createmodel player5 flakturret vector(113654,180083,4995) -3 1 [1]
--createmodel player5 flakturret vector(104608,180320,5068) -3 1 [1]
--createmodel player5 flakturret vector(93671,180090,5109) 9 1 [1]
--createmodel player5 flakturret vector(120122,178767,4943) -14 1 [1]
--createmodel player5 farseer vector(85791,185313,5222) 6 1 [1]
--createmodel player5 bc45 vector(89736,181200,13047) 10 1 [1]
--createmodel player5 gammacruiser vector(125441,177246,6040) -1 1 [1]
--createmodel player5 hazardchopper vector(108368,183118,8223) 0 1 [1]

--**** OFF-SCREEN FTA SUPER-APOSTLE
createmodel player8 superapostle vector(-45354,241825,3140) 111 1 [1]

--**** SDF
--createmodel player3 sdfdestroyer vector(-12424,127610,9856) 44 1 [1]
--createmodel player3 sdfdestroyer vector(24661,194926,16942) 18 1 [1]
--createmodel player3 sdfdestroyer vector(208180,167351,17899) -34 1 [1]

set activeworld 1

positioncamera vector(1.01761e5,8.64233e4,-100.0000) vector(0.0000,0.0000,12.4016) vector(0.0000,-6.50000e4,1.17554e4) vector(0.0000,0.0000,0.0000)

clear startingunit

******************************
******************************
**** SECOND SECTOR ****
******************************
******************************

set activeworld 2

load basic configuration
load basic models

set landpatch land_outoftime52b
set landdeform off
set landheightmap heightmap_outoftime52b

set minnewfogdistance 50000
set maxviewdistance 80000

**** RESOURCE PACK FILES START
if highterraindetail
load resourcepack http://internallink2/ql_highresterrain_outoftime52b.cst slot7 highres_terrain
end if
if mediumterraindetail
load resourcepack http://internallink2/ql_medresterrain_outoftime52b.cct slot7 medres_terrain
end if
if lowterraindetail
load resourcepack http://internallink2/ql_lowresterrain_outoftime52b.cct slot7 lowres_terrain
end if
**** RESOURCE PACK FILES END

--set weather rain
prepare landpatch

load basic variables

load basic models
load minimap

movemodel sky01 vector(0,0,30000)
movemodel sky02 vector(0,0,30000)

--PODS:
--createmodel player17 resourcepod vector(123860,60505,150043) -165 1 [1]
createmodel player17 resourcepod vector(124923,59615,150043) -171 1 [1]
createmodel player17 resourcepod vector(76250,47326,150405) 45 1 [1]
createmodel player17 resourcepod vector(85391,140526,154625) -94 1 [1]
--multiplayer only pods:
--createmodel player17 resourcepod vector(177805,69807,165904) -138 1 [1]
--createmodel player17 resourcepod vector(165812,159058,155758) 7 1 [1]
--createmodel player17 resourcepod vector(41165,171529,155642) -64 1 [1]
--createmodel player17 resourcepod vector(27804,102592,160559) 156 1 [1]

--*** PLAYER'S SHIP:
--createmodel player1 epsilon vector(107409,69145,151347) 148 1 [1]

set activeworld 1

set screensize 100 0
fadehud instantout
set maxplayers 1

--*********************************************                                                                       --*********************************************
--******** MAIN LEVEL CREATION *********                                                                        --******** MAIN LEVEL CREATION *********
--*********************************************                                                                       --*********************************************

--******** QUANTUM GATE IS ACTIVATED
--******** QUANTUM GATE IS ACTIVATED

--BELOW: if too much time passes, and Carter is still alive:
if flag 1 >= 104
and flag 1 < 200
and flag 1 < 150
and timer 19 >= 60000*25
and playerhasunit 1 2 omnithias
and playerhasunit 1 1 ftaquantumgate
and soundchannel 1 is free
    set flag 1 to 150
    reset timer 1
--remove the "low power" special from the Quantum Gate:
    removespecial 1 1 2 23
end if

--BELOW: the gate is still alive after Bryce's conversation:
if flag 1 >= 138
and flag 1 < 200
and flag 1 < 150
and timer 18 >= 60000*3
and playerhasunit 1 1 ftaquantumgate
and soundchannel 1 is free
    set flag 1 to 150
    reset timer 1
--remove the "low power" special from the Quantum Gate:
    removespecial 1 1 2 23
end if

if flag 1 = 150
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52017
    comsatline >> K.C.: Colonel... the Quantum Gate just went online... it's trajectory seems stable... I think we can pass through. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
 --point the drop-cam at the Quantum Gate:
    dropcam 1 1 2 60000 1
end if

if flag 1 = 151
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52045
    comsatline >> Col. Blair: Well ... it's what would have made Carter happy. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

--BELOW: only executed if Carter is still alive:
if flag 1 = 152
and timer 1 >= 100
and playerhasunit 1 2 omnithias
and soundchannel 1 is free
    playglobalsound 1 99 carter12009b
    comsatline General Carter: Thank you colonel. rgb(100,255,100)
--remove the drop-cam from the gate
    removedropcam
--and point it at general Carter:
    dropcam 1 2 1 15000 3
end if

if flag 1 = 152
and timer 1 >= 100
and playerhasunit 1 2 omnithias
and soundchannel 1 is free
--remove the drop-cam from the gate
    removedropcam
--and point it at the Quantum Gate:
    dropcam 1 1 2 40000 1
end if

if flag 1 = 152
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52046
    comsatline >> Col. Blair: Alright... Commander, un-deploy our drop-ship and set a course for that that gate... we have nothing to lose at this point... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 153
and timer 1 >= 100
and soundchannel 1 is free
    highlighthud tasks
    addtask all playernumber protect_gate pending primary tell Epsilon to approach the Quantum Gate
    set flag 1 + 1
    reset timer 1
end if

--BELOW: drop-ship is close enough to the gate:
if flag 1 = 154
and timer 1 >= 100
and distancebetween 1 1 2 1 1 1 <= 5500
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
end if

--BELOW: deploy the drop-ship if it's isn't:
if flag 1 = 155
and timer 1 >= 100
and unitstate 1 1 1 < 20
and soundchannel 1 is free
    setunitstate 1 1 1 20 0 -1
end if

if flag 1 = 155
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52018
    comsatline >> K.C.: Thats close enough Sir... Im preparing Epsilon for long-range transport. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
    removedropcam
 --point the drop-cam at the Quantum Gate:
    dropcam 1 1 2 60000 1
--give the off-screen Super-Apostle the "low power" status:
    addspecial 1 8 1 23
--from this point on, the player can no longer
--tell Epsilon to move or deploy:
    addspecial 1 1 1 63
    addspecial 1 1 1 66
--begin the Gate-Jump cut-scene:
    set flag 21 to 1
--change the music
    playglobalsound 8 99 ql_track_12b
end if

if flag 1 = 156
and timer 1 >= 7000
and soundchannel 1 is free
--play the Apostle "fire" sound:
    playglobalsound 2 99 apostle_loud_fire
--    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 157
and timer 1 >= 5000
and soundchannel 1 is free
    playglobalsound 1 99 computer_global_124
    comsatline Computer: Apostle launch detected. rgb(255,255,0)
--    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 158
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52047
    comsatline >> Col. Blair: Anytime now would be good. rgb(255,255,255)
--    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 159
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer_global_125
    comsatline Computer: All units, brace for impact. rgb(255,255,0)
    set flag 1 + 1
    reset timer 1
    removedropcam
end if

if flag 1 = 160
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52019
    playglobalsound 2 99 snd_qgate01
    comsatline >> K.C.: Got it! rgb(255,100,100)
--    set flag 1 + 1
    reset timer 1
--make the Quantum Gate perform the transport animation:
    setunitstate 1 1 2 301 0 -1
--tell Epsilon to jump/fade out:
    setunitstate 1 1 1 69 0 -1
end if

--if flag 1 = 161
--and timer 1 >= 100
--and soundchannel 1 is free
--    set flag 1 to 200
--    reset timer 1
--end if

--******** PLAYER LOSES THE QUANTUM GATE
--******** PLAYER LOSES THE QUANTUM GATE

if flag 1 >= 20
and flag 1 < 200
and flag 20 = 0
and playerhasunit 1 1 ftaquantumgate
and soundchannel 1 is free
and unithealth 1 1 2 <= 50%
    playglobalsound 1 99 kc52020
    comsatline >> K.C.: Sir, were losing the Quantum Gate! rgb(255,100,100)
 --point the drop-cam at Quantum Gate:
    dropcam 1 1 2 15000 1
end if

if flag 1 >= 20
and flag 1 < 200
and flag 20 = 0
and playerhasunit 1 1 ftaquantumgate
and soundchannel 1 is free
and unithealth 1 1 2 <= 10%
    playglobalsound 1 99 kc52021
    comsatline >> K.C.: Colonel... the Gates core just breached ... weve lost the structure! rgb(255,100,100)
 --point the drop-cam at Quantum Gate:
    dropcam 1 1 2 15000 1
    set flag 20 + 1
    reset timer 20
end if

--BELOW: alternate check if the Gate is already destroyed:
if flag 1 >= 20
and flag 1 < 200
and flag 20 = 0
and playerhasnounit 1 1 ftaquantumgate
and soundchannel 1 is free
    playglobalsound 1 99 kc52021
    comsatline >> K.C.: Colonel... the Gates core just breached ... weve lost the structure! rgb(255,100,100)
    set flag 20 + 1
    reset timer 20
end if

if flag 20 = 1
and soundchannel 1 is free
    playglobalsound 1 99 blair52048
    comsatline >> Col. Blair: Dont worry... it was junk anyway... along with the rest of this time-travel business. rgb(255,255,255)
--make sure the Quantum Gate is destroyed:
    setunithealth 1 1 2 0
    set flag 20 + 1
    reset timer 20
end if

if flag 20 = 2
and soundchannel 1 is free
    changetask all playernumber protect_gate failed
    highlighthud tasks
    set flag 20 + 1
    reset timer 20
    reset timer 1
--take player towards mission failure by SDF:
    set flag 1 to 700
end if

--******** MISSION FAILURE - SDF ENTERS
--******** MISSION FAILURE - SDF ENTERS

if flag 1 = 700
and timer 1 >= 60000*1
and soundchannel 1 is free
    createunit 1 3 sdfdestroyer vector(-12424,127610,9856) 44 82 0 -1 0
    createunit 1 3 sdfdestroyer vector(24661,194926,16942) 18 82 0 -1 0
    createunit 1 3 sdfdestroyer vector(208180,167351,17899) -34 82 0 -1 0
    playglobalsound 1 99 kc41013b
    comsatline >> K.C.: Sir, we have multiple jump signatures headed our way! ... It's the Defense Force! rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 701
and timer 1 >= 100
and soundchannel 1 is free
    radarbeacon 1 vector(-12424,127610,9856) 30000
    radarbeacon 1 vector(24661,194926,16942) 30000
    radarbeacon 1 vector(208180,167351,17899) 30000
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 702
and timer 1 >= 100
and playerhasunit 1 3 sdfdestroyer
and soundchannel 1 is free
--    playglobalsound 2 99 sdf_global_destoyer_flyin
--    comsatline Computer: SDF Destroyer approaching. rgb(255,255,0)
--point the drop-cam at one of the SDF ships
    dropcam 1 3 random(2) 25000 2
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 703
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair51080b
    comsatline >> Col. Blair: Goddamn it! ... The radar just lit up ... All wings, neutralize the threat! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 704
and timer 1 >= 10000
and soundchannel 1 is free
    highlighthud tasks
    addtask all playernumber hold_sdf secondary stand your ground against overwhelming SDF forces
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 705
and timer 1 >= 10000
and soundchannel 1 is free
    playglobalsound 2 99 sdf_loud_destroyer_siren3
    set flag 1 + 1
    reset timer 1
end if

--BELOW: keep resetting the AI to make sure that SDF targets the player:
if flag 1 >= 702
and flag 1 <= 710
and timer 20 >= 20000
    setai 1 3 1 100
    reset timer 20
    repeat this if
end if

--******** MISSION FAILURE - EPSILON IS DESTROYED
--******** MISSION FAILURE - EPSILON IS DESTROYED

if flag 1 >= 20
and flag 1 < 800
and currentsector is 1
and unithealth 1 1 1 <= 0%
    set flag 1 to 800
end if

--BELOW: alternate check 1:
if flag 1 >= 20
and flag 1 < 200
and currentsector is 1
and playerhasnounit 1 1 epsilon
    set flag 1 to 800
end if

--BELOW: alternate check 2:
if flag 1 >= 20
and flag 1 >= 700
and flag 1 < 800
and currentsector is 1
and playerhasnounit 1 1 epsilon
    set flag 1 to 800
end if

if flag 1 = 800
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52022
    comsatline >> K.C.: Sir, this is it! ... The core is breached! Were losing Epsilon! rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
--point the drop-cam at Epsilon:
    dropcam 1 1 1 15000 3
end if

if flag 1 = 801
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52048b
    comsatline >> Col. Blair: Commander... I may not get another chance to say this... but it has been an honor serving with you! Let us hope that we are remembered by history as men who did not ... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 802
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer015
    comsatline Computer: Mission failed. rgb(255,255,0)
    set flag 1 + 1
    reset timer 1
    highlighthud tasks
end if

if flag 1 = 803
and timer 1 >= 10000
and soundchannel 1 is free
    goto mission_failed2
    set flag 1 + 1
    reset timer 1
end if

--******** JUMP TO ADJACENT TIME CUT-SCENE
--******** JUMP TO ADJACENT TIME CUT-SCENE

if flag 21 = 1
-- ***** camera start *****
cutscene clear
cutscene fadehud instantout 0
cutscene lock keybaord
cutscene lock mouse

cutscene movecamera [-0.8852,0.2716,0.3777,0.0000,0.2462,-0.4153,0.8757,0.0000,0.3947,0.8682,0.3008,0.0000,132381.5781,77149.1563,14177.9990,1.0000] 0

cutscene set screensize 100 70

cutscene movecamera [-0.3702,0.6797,-0.6333,0.0000,-0.6999,0.2442,0.6712,0.0000,0.6109,0.6917,0.3853,0.0000,137534.7813,58311.9766,14177.9990,1.0000] 5000
cutscene movecamera [0.8000,0.4785,0.3619,0.0000,-0.4200,0.0158,0.9074,0.0000,0.4285,-0.8779,0.2136,0.0000,116892.7656,14912.3145,4462.2417,1.0000] 5000

--fast flying starts

--trigger the "field of view" camera effect
cutscene set flag 21 to 2

cutscene movecamera [0.6734,0.6968,-0.2469,0.0000,0.0967,0.2480,0.9639,0.0000,0.7329,-0.6730,0.0996,0.0000,98765.3125,36912.1523,5995.5752,1.0000] 3000
cutscene movecamera [0.7860,0.2323,0.5729,0.0000,-0.5986,0.0547,0.7992,0.0000,0.1543,-0.9711,0.1821,0.0000,35914.1875,75077.5313,11170.5752,1.0000] 3000
cutscene set flag 1 to 156
cutscene movecamera [0.8761,-0.4660,-0.1236,0.0000,0.1934,0.1049,0.9755,0.0000,-0.4416,-0.8786,0.1821,0.0000,17812.5508,134278.2188,11170.5752,1.0000] 3000
cutscene set flag 1 to 157
cutscene movecamera [-0.9286,-0.1021,0.3567,0.0000,0.3698,-0.1741,0.9127,0.0000,-0.0310,0.9794,0.1994,0.0000,135314.2656,214566.7500,21443.9082,1.0000] 4000

cutscene set flag 1 to 158

cutscene movecamera [-0.6870,0.1721,-0.7059,0.0000,-0.7159,0.0056,0.6982,0.0000,0.1242,0.9851,0.1194,0.0000,140517.3281,103498.5391,12627.2412,1.0000] 5000

--trigger the Quantum Gate Transport animation:
cutscene set flag 1 to 159

cutscene movecamera [-0.5318,0.8101,0.2467,0.0000,0.1258,-0.2126,0.9690,0.0000,0.8375,0.5463,0.0112,0.0000,111139.0156,28336.9082,1323.7856,1.0000] 5000

-- ***** camera end *****

--cutscene unlock keybaord
--cutscene unlock mouse
cutscene set screensize 100 0
--cutscene fadehud in 2000
cutscene set flag 1 to 200
cutscene start
    reset timer 1
--hide the cloud models (since they tend to look "odd"
--with the new "field of view" effects:
    hidemodel sky01_1
    hidemodel sky02_1
    hidemodel sky01_2
    hidemodel sky02_2
end if

if flag 21 = 2
--first we reset the Field-of-View (or FOV) of the game camera
--to a value that is 4 times lager than default
    set fieldofview 33.7500*4
--now we change the FOV adjust-speed (default is: 0.01)
    set fieldofviewspeed 4
--    set flag 21 + 1
end if

--******** FIRST CUT-SCENE IN ADJACENT SECTOR
--******** FIRST CUT-SCENE IN ADJACENT SECTOR

if flag 22 = 1
-- ***** camera start *****
cutscene clear
--cutscene fadehud instantout 0
cutscene lock keybaord
cutscene lock mouse

cutscene movecamera [0.4574,0.7450,0.4856,0.0000,-0.4211,-0.2995,0.8561,0.0000,0.7833,-0.5961,0.1767,0.0000,230603.5000,-24559.1133,167630.7500,1.0000] 0

cutscene set screensize 100 70

cutscene movecamera [0.6147,0.6801,-0.3995,0.0000,0.1083,0.4289,0.8968,0.0000,0.7813,-0.5946,0.1900,0.0000,169824.2188,21693.8438,169010.7500,1.0000] 5000
cutscene movecamera [0.3823,0.8558,0.3484,0.0000,-0.6278,-0.0361,0.7776,0.0000,0.6781,-0.5160,0.5234,0.0000,109675.2422,67467.2031,169010.7500,1.0000] 5000
cutscene movecamera [0.6131,-0.6221,-0.4869,0.0000,0.7194,0.1850,0.6695,0.0000,-0.3264,-0.7608,0.5610,0.0000,20388.4180,117142.5391,170982.1875,1.0000] 5000
cutscene movecamera [-0.1209,-0.8848,0.4499,0.0000,0.6698,0.2618,0.6949,0.0000,-0.7326,0.3854,0.5610,0.0000,69291.8438,153264.4688,170982.1875,1.0000] 5000

cutscene movecamera [-0.5024,0.7253,-0.4708,0.0000,-0.7296,-0.0634,0.6809,0.0000,0.4640,0.6856,0.5610,0.0000,139089.1719,109489.6484,170982.1875,1.0000] 5000

--reset "field of view" back to default:
cutscene set flag 22 to 2

cutscene movecamera [-0.8282,0.5605,0.0000,0.0000,-0.1652,-0.2441,0.9556,0.0000,0.5356,0.7914,0.2948,0.0000,129536.1094,101931.2422,165730.5313,1.0000] 5000
cutscene positioncamera vector(1.00770e5,5.94292e4,1.49900e5) vector(0.0000,0.0000,145.9095) vector(0.0000,-5.13214e4,1.58305e4) vector(0.0000,0.0000,0.0000)

--deploy the user's drop-ship:
cutscene set flag 23 to 1

-- ***** camera end *****

cutscene unlock keybaord
cutscene unlock mouse
cutscene set screensize 100 100
cutscene fadehud in 2000
cutscene start
    reset timer 1
end if

if flag 22 = 2
--first we reset the Field-of-View (or FOV) of the game camera
--back to default:
    set fieldofview 33.7500
    set fieldofviewspeed 4
   set flag 22 + 1
 end if

--BELOW: we set the FOV speed back to default:
if flag 22 = 3
and timer 39 >= 3000
and fieldofview = 33.7500
    set fieldofviewspeed 0.01
end if

--BELOW: the two IF statements make sure that the player's
--drop-ship is deployed in the new sector:
if flag 23 = 1
and unitstate 1 1 1 < 20
    setunitstate 2 1 1 20 0 -1
end if

if flag 23 = 1
and unitstate 1 1 1 >= 20
   set flag 23 + 1
end if

--******** PLAYER ENTERS ADJACENT SECTOR
--******** PLAYER ENTERS ADJACENT SECTOR

if flag 1 = 200
and timer 1 >= 100
and soundchannel 1 is free
--kill all units for all players in the first sector
--this should improve FPS:
    setunitstate 1 1 all 75 0 -1
    setunitstate 1 2 all 75 0 -1
    setunitstate 1 3 all 75 0 -1
    setunitstate 1 4 all 75 0 -1
    setunitstate 1 5 all 75 0 -1
    setunitstate 1 6 all 75 0 -1
    setunitstate 1 7 all 75 0 -1
    setunitstate 1 8 all 75 0 -1
--create the player's drop-ship in the adjacent sector:
    createunit 2 1 epsilon vector(107409,69145,151347) 148 61 0 -1 0
--take player into the second sector:
    jump sector
--begin the cut-scene for the second sector:
    set flag 22 to 1
    set flag 1 + 1
    reset timer 1
--clear all tasks:
    cleartasks all playernumber
end if

if flag 1 = 201
and timer 1 >= 5000
and soundchannel 1 is free
    playglobalsound 1 99 blair52050
    comsatline >> Col. Blair: Tactical... report! ... where the hell are we? rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 202
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52023
    comsatline >> K.C.: The sensors say we didnt move. rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 203
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52051
    comsatline >> Col. Blair: No... that cant be... were in the middle of some goddamn desert! rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 204
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52053
    comsatline >> Col. Blair: K.C. ... try to contact any nearby Globex ships... tell em we need assistance... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 205
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52024
    comsatline >> K.C.: Im trying ... but... Im getting no response...  rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 206
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52054
    comsatline >> Col. Blair: Just try to get a hold of anyone on COM-SAT. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 207
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52024b
    comsatline >> K.C.: Sir... thats the problem... I cant connect to the COM-SAT satellite.  rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 208
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52055
    comsatline >> Col. Blair: Bash was right... this ship is like an old mule... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 209
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52056
    comsatline >> Col. Blair: Commander, looks like the long-range COM is completely offline... establish a small base and get a radar up as soon as possible. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 210
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer011
    comsatline Computer: New task confirmed. rgb(255,255,0)
    addtask all playernumber establish_base pending primary estabalish a base peremeter and Radar Tower communication
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 211
and timer 1 >= 100
and soundchannel 1 is free
    highlighthud tasks
    set flag 1 + 1
    reset timer 1
--bring back the clouds:
    showmodel sky01_1
    showmodel sky02_1
    showmodel sky01_2
    showmodel sky02_2
end if

--BELOW: once player builds a Radar Tower:
if flag 1 = 212
and timer 1 >= 100
and soundchannel 1 is free
and playerhasunit 2 1 radartower
    playglobalsound 1 99 computer009
    comsatline Computer: objective complete. rgb(255,255,0)
    addunlock 61
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 213
and timer 1 >= 100
and soundchannel 1 is free
    highlighthud tasks
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 214
and timer 1 >= 5000
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
--begin the final cut-scene:
    set flag 24 to 1
end if

if flag 1 = 215
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52025
    comsatline >> K.C.: Wait... Im picking up something on the sensors... rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
--change the music
    playglobalsound 8 99 ql_theme_full
end if

if flag 1 = 216
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52026
    comsatline >> K.C.: Multiple ships... theyre FTA! rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 217
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52057
    comsatline >> Col. Blair: You know, for a second there I actually thought we managed to get away... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 218
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52058
    comsatline >> Col. Blair: Alright... prep our pilots and replicate a couple of Interceptors... rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 219
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 kc52027
    comsatline >> K.C.: All hands... proceed to deck 5 for immediate insertion! rgb(255,100,100)
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 220
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair52059
    comsatline >> Col. Blair: Commander! ... When those ships arrive... lets give them a fight they wont soon forget! rgb(255,255,255)
    set flag 1 to 250
    reset timer 1
end if


--******** FINAL CUT-SCENE
--******** FINAL CUT-SCENE

if flag 24 = 1
-- ***** camera start *****
cutscene clear
cutscene fadehud instantout 0
cutscene lock keybaord
cutscene lock mouse

cutscene movecamera [-0.6938,-0.7202,0.0000,0.0000,0.1660,-0.1599,0.9731,0.0000,-0.7008,0.6751,0.2305,0.0000,84754.7266,90358.3672,159384.9063,1.0000] 0

cutscene set screensize 100 70

cutscene movecamera [0.8351,-0.2936,0.4651,0.0000,-0.2619,0.5313,0.8057,0.0000,-0.4837,-0.7947,0.3668,0.0000,88541.9609,38735.6250,165691.0156,1.0000] 15000
cutscene movecamera [0.8473,-0.3471,-0.4021,0.0000,0.4492,0.0644,0.8911,0.0000,-0.2834,-0.9356,0.2105,0.0000,90787.4531,10908.9453,168698.0000,1.0000] 15000

cutscene movecamera [0.8703,-0.3227,0.3721,0.0000,-0.2759,0.3065,0.9110,0.0000,-0.4081,-0.8955,0.1777,0.0000,78542.0703,-10296.2969,165671.7656,1.0000] 15000

cutscene set flag 1 to 251


-- ***** camera end *****

--cutscene unlock keybaord
--cutscene unlock mouse
cutscene set screensize 100 0
--cutscene fadehud in 2000
cutscene start
    reset timer 1
end if

if flag 1 = 250
and timer 1 >= 7000
and soundchannel 1 is free
    set flag 1 + 1
    reset timer 1
end if

if flag 1 = 251
and timer 1 >= 100
and soundchannel 1 is free
    goto temp_game_end
--    setnewlevelname Out of Time 5.2
--    setnewlevelscript txtOutOfTime52
--    loadnewlevel
    addunlock 61
    set flag 1 + 1
    reset timer 1
end if

--zzz

*** GENERAL COMPUTER VOICE START

if soundchannel 1 is free
if flag 19 = 0
and unitstate 1 < 80
and timer 19 >= 60000
and playerpower < 0
    set flag 19 to random(2)
    reset timer 19
    repeat this if
end if

if flag 19 = 1
    playglobalsound 2 99 computer025
    comsatline Computer: Low Power. rgb(255,255,0)
    highlighthud power
    set flag 19 to 3
    repeat this if
end if

if flag 19 = 2
    playglobalsound 2 99 computer026
    comsatline Computer: New generators required. rgb(255,255,0)
    highlighthud power
    set flag 19 to 3
    repeat this if
end if

if flag 19 = 3
and playerpower > 1
    set flag 19 to 0
    repeat this if
end if

--BELOW: epsilon health checks: FIRST SECTOR

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 1 1 epsilon <= 90%
and flag 18 = 0
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 1 1 epsilon <= 70%
and flag 18 = 1
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 1 1 epsilon <= 50%
and flag 18 = 2
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 1 1 epsilon <= 30%
and flag 18 = 3
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

--BELOW: epsilon health checks: SECOND SECTOR

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 2 1 epsilon <= 90%
and flag 18 = 0
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 2 1 epsilon <= 70%
and flag 18 = 1
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 2 1 epsilon <= 50%
and flag 18 = 2
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

if soundchannel 1 is free
and flag 1 >= 15
and unithealth 2 1 epsilon <= 30%
and flag 18 = 3
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    set flag 18 + 1
end if

*** GENERAL COMPUTER VOICE END

*** CARTER'S BASE - ATTACK & CREATION CODE - STARTS
*** CARTER'S BASE - ATTACK & CREATION CODE - STARTS

--BELOW: if the Globex drop-ship is active, begin Attack & Creation
if flag 4 <= 9
and flag 4 >= 5
and playerhasunit 1 2 omnithias
    set flag 4 to 10
    reset timer 4
    repeat this if
end if

--BELOW: turn off Attack & Creation if player has no drop-ship
if flag 4 >= 10
and playerhasnounit 1 2 omnithias
    set flag 4 to 9
    reset timer 4
    repeat this if
end if

--every 20-40 seconds, Globex will build a missing unit in their base
--in the following order:

    --**** EASY GAME DIFFICULTY CODE - (more help to player)
    --**** EASY GAME DIFFICULTY CODE - (more help to player)

if flag 4 = 10
and timer 4 >= 30000
and gamedifficulty = easy
and totalplayerunits 1 2 <= 4
    set flag 4 to 11
    repeat this if
end if

if flag 4 = 10
and timer 4 >= 35000
and gamedifficulty = easy
and totalplayerunits 1 2 <= 9
    set flag 4 to 11
    repeat this if
end if

if flag 4 = 10
and timer 4 >= 40000
and gamedifficulty = easy
and totalplayerunits 1 2 >= 10
    set flag 4 to 11
    repeat this if
end if

    --**** MEDIUM GAME DIFFICULTY CODE:
    --**** MEDIUM GAME DIFFICULTY CODE:

if flag 4 = 10
and timer 4 >= 35000
and gamedifficulty = medium
and totalplayerunits 1 2 <= 4
    set flag 4 to 11
    repeat this if
end if

if flag 4 = 10
and timer 4 >= 40000
and gamedifficulty = medium
and totalplayerunits 1 2 <= 9
    set flag 4 to 11
    repeat this if
end if

if flag 4 = 10
and timer 4 >= 50000
and gamedifficulty = medium
and totalplayerunits 1 2 >= 10
    set flag 4 to 11
    repeat this if
end if

    --**** HARD GAME DIFFICULTY CODE - (less help to player)
    --**** HARD GAME DIFFICULTY CODE - (less help to player)

if flag 4 = 10
and timer 4 >= 45000
and gamedifficulty = hard
and totalplayerunits 1 2 <= 4
    set flag 4 to 11
    repeat this if
end if

if flag 4 = 10
and timer 4 >= 55000
and gamedifficulty = hard
and totalplayerunits 1 2 <= 9
    set flag 4 to 11
    repeat this if
end if

if flag 4 = 10
and timer 4 >= 60000
and gamedifficulty = hard
and totalplayerunits 1 2 >= 10
    set flag 4 to 11
    repeat this if
end if

    --**** REST OF CODE:
    --**** REST OF CODE:

if flag 4 = 11
and playerhasunitcount 1 2 etros = 0
and totalplayerunits 1 2 <= 6
    createunit 1 2 etros vector(87279,33414,120) -178 82 0 -1 0
    set flag 4 to 10
    reset timer 4
    repeat this if
end if

if flag 4 = 11
and playerhasunitcount 1 2 etros = 1
and totalplayerunits 1 2 <= 5
    createunit 1 2 etros vector(69069,35214,120) 180 82 0 -1 0
    set flag 4 to 10
    reset timer 4
    repeat this if
end if

if flag 4 = 11
and playerhasunitcount 1 2 atanos = 0
and gamedifficulty = easy
and totalplayerunits 1 2 <= 5
    createunit 1 2 atanos vector(68200,40243,421) -179 82 0 -1 0
    set flag 4 to 10
    reset timer 4
    repeat this if
end if

--if flag 4 = 11
--and playerhasunitcount 1 2 atanos = 1
--    createunit 1 2 atanos vector(83365,41198,377) 177 82 0 -1 0
--    set flag 4 to 10
--    reset timer 4
--    repeat this if
--end if

--if flag 4 = 11
--and playerhasunitcount 1 2 atanos = 2
--    createunit 1 2 atanos vector(83365,41198,377) 177 82 0 -1 0
----    createunit 1 2 atanos vector(97248,33780,377) -180 82 0 -1 0
--    set flag 4 to 10
--    reset timer 4
--    repeat this if
--end if

--reset Flag and timer 4 if none of the above conditions are met
if flag 4 = 11
    set flag 4 to 10
    reset timer 4
    repeat this if
end if

*** CARTER'S BASE - ATTACK & CREATION CODE - ENDS
*** CARTER'S BASE - ATTACK & CREATION CODE - ENDS

*** CARTER'S BACKUP BASE - ATTACK & CREATION CODE - STARTS
*** CARTER'S BACKUP BASE - ATTACK & CREATION CODE - STARTS

--BELOW: if the Globex drop-ship is active, begin Attack & Creation
if flag 5 <= 9
and flag 5 >= 5
and playerhasunit 1 7 omnithias
    set flag 5 to 10
    reset timer 5
    repeat this if
end if

--BELOW: turn off Attack & Creation if player has no drop-ship
if flag 5 >= 10
and playerhasnounit 1 7 omnithias
    set flag 5 to 9
    reset timer 5
    repeat this if
end if

    --every 20-40 seconds, Globex will build a missing unit in their base
--in the following order:

    --**** EASY GAME DIFFICULTY CODE - (more help to player)
    --**** EASY GAME DIFFICULTY CODE - (more help to player)

if flag 5 = 10
and timer 5 >= 30000
and gamedifficulty = easy
and totalplayerunits 1 7 <= 4
    set flag 5 to 11
    repeat this if
end if

if flag 5 = 10
and timer 5 >= 35000
and gamedifficulty = easy
and totalplayerunits 1 7 <= 9
    set flag 5 to 11
    repeat this if
end if

if flag 5 = 10
and timer 5 >= 40000
and gamedifficulty = easy
and totalplayerunits 1 7 >= 10
    set flag 5 to 11
    repeat this if
end if

    --**** MEDIUM GAME DIFFICULTY CODE:
    --**** MEDIUM GAME DIFFICULTY CODE:

if flag 5 = 10
and timer 5 >= 35000
and gamedifficulty = medium
and totalplayerunits 1 7 <= 4
    set flag 5 to 11
    repeat this if
end if

if flag 5 = 10
and timer 5 >= 40000
and gamedifficulty = medium
and totalplayerunits 1 7 <= 9
    set flag 5 to 11
    repeat this if
end if

if flag 5 = 10
and timer 5 >= 50000
and gamedifficulty = medium
and totalplayerunits 1 7 >= 10
    set flag 5 to 11
    repeat this if
end if

    --**** HARD GAME DIFFICULTY CODE - (less help to player)
    --**** HARD GAME DIFFICULTY CODE - (less help to player)

if flag 5 = 10
and timer 5 >= 45000
and gamedifficulty = hard
and totalplayerunits 1 7 <= 4
    set flag 5 to 11
    repeat this if
end if

if flag 5 = 10
and timer 5 >= 55000
and gamedifficulty = hard
and totalplayerunits 1 7 <= 9
    set flag 5 to 11
    repeat this if
end if

if flag 5 = 10
and timer 5 >= 60000
and gamedifficulty = hard
and totalplayerunits 1 7 >= 10
    set flag 5 to 11
    repeat this if
end if

    --**** REST OF CODE:
    --**** REST OF CODE:

if flag 5 = 11
and playerhasunitcount 1 7 bowgerus = 0
    createunit 1 7 bowgerus vector(93041,36947,550) -178 82 0 -1 0
    set flag 5 to 10
    reset timer 5
    repeat this if
end if

if flag 5 = 11
and playerhasunitcount 1 7 bowgerus = 1
    createunit 1 7 bowgerus vector(88539,39737,550) -178 82 0 -1 0
    set flag 5 to 10
    reset timer 5
    repeat this if
end if

--if the primary drop-ship is low on health, concentrate on creation of Bowgeri'
if flag 5 = 11
and unithealth 1 7 1 <= 60%
and playerhasunitcount 1 7 bowgerus < 3
    createunit 1 7 bowgerus vector(88539,39737,550) -178 82 0 -1 0
    set flag 4 to 10
    reset timer 4
    repeat this if
end if

--reset Flag and timer 5 if none of the above conditions are met
if flag 5 = 11
    set flag 5 to 10
    reset timer 5
    repeat this if
end if

*** CARTER'S BACKUP BASE - ATTACK & CREATION CODE - ENDS
*** CARTER'S BACKUP BASE - ATTACK & CREATION CODE - ENDS

*** FTA ENEMY 1 - LEFT SIDE - STARTS
*** FTA ENEMY 1 - LEFT SIDE - STARTS

--BELOW: if the FTA drop-ship is active, begin Attack & Creation
if flag 10 <= 9
and flag 10 >= 5
and playerhasunit 1 3 epsilon
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

--BELOW: turn off Attack & Creation if player has no drop-ship
if flag 10 >= 10
and playerhasnounit 1 3 epsilon
    set flag 10 to 9
    reset timer 10
    repeat this if
end if

--every 20-40 seconds, FTA will build a missing unit in their base
--in the following order:

    --**** EASY GAME DIFFICULTY CODE
    --**** EASY GAME DIFFICULTY CODE

if flag 10 = 10
and timer 10 >= 40000
and gamedifficulty = easy
and totalplayerunits 1 3 <= 4
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

if flag 10 = 10
and timer 10 >= 45000
and gamedifficulty = easy
and totalplayerunits 1 3 <= 9
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

if flag 10 = 10
and timer 10 >= 50000
and gamedifficulty = easy
and totalplayerunits 1 3 >= 10
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

    --**** MEDIUM GAME DIFFICULTY CODE:
    --**** MEDIUM GAME DIFFICULTY CODE:

if flag 10 = 10
and timer 10 >= 35000
and gamedifficulty = medium
and totalplayerunits 1 3 <= 4
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

if flag 10 = 10
and timer 10 >= 40000
and gamedifficulty = medium
and totalplayerunits 1 3 <= 9
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

if flag 10 = 10
and timer 10 >= 50000
and gamedifficulty = medium
and totalplayerunits 1 3 >= 10
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

    --**** HARD GAME DIFFICULTY CODE
    --**** HARD GAME DIFFICULTY CODE

if flag 10 = 10
and timer 10 >= 25000
and gamedifficulty = hard
and totalplayerunits 1 3 <= 4
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

if flag 10 = 10
and timer 10 >= 30000
and gamedifficulty = hard
and totalplayerunits 1 3 <= 9
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

if flag 10 = 10
and timer 10 >= 35000
and gamedifficulty = hard
and totalplayerunits 1 3 >= 10
    set flag 10 to 11
    setai 1 3 1 100
    repeat this if
end if

    --**** REST OF CODE:
    --**** REST OF CODE:

if flag 10 = 11
and playerhasunitcount 1 3 apostle = 0
and timer 40 >= 25000
    createunit 1 3 apostle vector(18615,155995,4394) -38 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 mammothturbine = 0
and timer 40 >= 25000
    createunit 1 3 mammothturbine vector(12260,145266,3741) -12 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 flakturret < 1
and flag 30 >= 3
and gamedifficulty = hard
and timer 40 >= 25000
    createunit 1 3 flakturret vector(13761,133651,3743) 12 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 flakturret < 2
and flag 30 >= 4
and gamedifficulty = hard
and timer 40 >= 25000
    createunit 1 3 flakturret vector(13761,133651,3743) 12 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 mammothturbine = 1
and timer 40 >= 25000
    createunit 1 3 mammothturbine vector(16072,144389,3710) -10 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 hazardchopper < 2
and timer 40 >= 25000
    createunit 1 3 hazardchopper vector(11561,132076,6923) 12 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 copterstation = 0
and timer 40 >= 25000
    createunit 1 3 copterstation vector(9259,126217,3742) 38 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 gammacruiser < 2
and timer 40 >= 25000
    createunit 1 3 gammacruiser vector(9880,129781,4742) 28 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

if flag 10 = 11
and playerhasunitcount 1 3 hazardchopper < 3
and flag 30 = 2
and timer 40 >= 25000
    createunit 1 3 hazardchopper vector(9880,129781,4742) 28 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

--if the primary drop-ship is low on health, concentrate on creation of Gamma's
if flag 10 = 11
and unithealth 1 3 1 <= 60%
and playerhasunitcount 1 3 copterstation >= 1
and playerhasunitcount 1 3 gammacruiser < 4
and timer 40 >= 30000
    createunit 1 3 gammacruiser vector(9880,129781,4742) 28 82 0 -1 0
    reset timer 40
    set flag 10 to 10
    reset timer 4
    repeat this if
end if

--reset Flag and timer 10 if none of the above conditions are met
if flag 10 = 11
and timer 40 >= 25000
    set flag 10 to 10
    reset timer 10
    repeat this if
end if

*** FTA ENEMY 1 - LEFT SIDE - ENDS
*** FTA ENEMY 1 - LEFT SIDE - ENDS

*** FTA ENEMY 2 - RIGHT SIDE - STARTS
*** FTA ENEMY 2 - RIGHT SIDE - STARTS

--BELOW: if the FTA drop-ship is active, begin Attack & Creation
if flag 11 <= 9
and flag 11 >= 5
and playerhasunit 1 4 epsilon
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

--BELOW: turn off Attack & Creation if player has no drop-ship
if flag 11 >= 10
and playerhasnounit 1 4 epsilon
    set flag 11 to 9
    reset timer 11
    repeat this if
end if

--BELOW: speed up the creation of units for the first 3 minutes
--since the FTA drop-ship just entered the sector:
if flag 11 = 10
and timer 11 >= 20000
and timer 12 <= 60000*3
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

--every 20-40 seconds, FTA will build a missing unit in their base
--in the following order:

    --**** EASY GAME DIFFICULTY CODE
    --**** EASY GAME DIFFICULTY CODE

if flag 11 = 10
and timer 11 >= 40000
and gamedifficulty = easy
and totalplayerunits 1 4 <= 4
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

if flag 11 = 10
and timer 11 >= 45000
and gamedifficulty = easy
and totalplayerunits 1 4 <= 9
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

if flag 11 = 10
and timer 11 >= 50000
and gamedifficulty = easy
and totalplayerunits 1 4 >= 10
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

    --**** MEDIUM GAME DIFFICULTY CODE:
    --**** MEDIUM GAME DIFFICULTY CODE:

if flag 11 = 10
and timer 11 >= 30000
and gamedifficulty = medium
and totalplayerunits 1 4 <= 4
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

if flag 11 = 10
and timer 11 >= 40000
and gamedifficulty = medium
and totalplayerunits 1 4 <= 9
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

if flag 11 = 10
and timer 11 >= 50000
and gamedifficulty = medium
and totalplayerunits 1 4 >= 10
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

    --**** HARD GAME DIFFICULTY CODE
    --**** HARD GAME DIFFICULTY CODE

if flag 11 = 10
and timer 11 >= 25000
and gamedifficulty = hard
and totalplayerunits 1 4 <= 4
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

if flag 11 = 10
and timer 11 >= 30000
and gamedifficulty = hard
and totalplayerunits 1 4 <= 9
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

if flag 11 = 10
and timer 11 >= 35000
and gamedifficulty = hard
and totalplayerunits 1 4 >= 10
    set flag 11 to 11
    setai 1 4 1 100
    repeat this if
end if

    --**** REST OF CODE:
    --**** REST OF CODE:

if flag 11 = 11
and playerhasunitcount 1 4 apostle = 0
and timer 41 >= 30000
    createunit 1 4 apostle vector(182685,157802,5342) -51 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 mammothturbine = 0
and timer 41 >= 30000
    createunit 1 4 mammothturbine vector(188815,155043,5435) 6 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 mammothturbine = 1
and timer 41 >= 30000
    createunit 1 4 mammothturbine vector(180554,165217,5306) -17 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 flakturret = 0
and flag 30 >= 3
and timer 41 >= 30000
    createunit 1 4 flakturret vector(177718,159135,5018) -17 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 gammacruiser < 1
and timer 41 >= 30000
    createunit 1 4 gammacruiser vector(186747,141840,6075) -18 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 flakturret = 1
and flag 30 >= 4
and timer 41 >= 30000
    createunit 1 4 flakturret vector(182398,152445,5026) -17 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 flakturret = 2
and flag 30 >= 4
and timer 41 >= 30000
--and gamedifficulty = hard
    createunit 1 4 flakturret vector(183645,146425,4965) -17 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 gammacruiser < 2
and timer 41 >= 30000
    createunit 1 4 gammacruiser vector(186747,141840,6075) -18 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 gammacruiser < 4
and playerhasunitcount 1 1 farseeruplink >= 1
and timer 41 >= 30000
    createunit 1 4 gammacruiser vector(186747,141840,6075) -18 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 hazardchopper < 2
and timer 41 >= 30000
    createunit 1 4 hazardchopper vector(189057,138183,8385) -18 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

if flag 11 = 11
and playerhasunitcount 1 4 hazardchopper < 4
and flag 30 = 2
and timer 41 >= 30000
    createunit 1 4 hazardchopper vector(189057,138183,8385) -18 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 11
    repeat this if
end if


--if the primary drop-ship is low on health, concentrate on creation of Gamma's
if flag 11 = 11
and unithealth 1 4 1 <= 40%
and playerhasunitcount 1 4 gammacruiser < 4
and timer 41 >= 30000
    createunit 1 4 gammacruiser vector(186747,141840,6075) -18 82 0 -1 0
    reset timer 41
    set flag 11 to 10
    reset timer 4
    repeat this if
end if

--reset Flag and timer 11 if none of the above conditions are met
if flag 11 = 11
    set flag 11 to 10
    reset timer 11
    repeat this if
end if

*** FTA ENEMY 2 - RIGHT SIDE - ENDS
*** FTA ENEMY 2 - RIGHT SIDE - ENDS

*** FTA ENEMY 3 - TOP - STARTS
*** FTA ENEMY 3 - TOP - STARTS

--BELOW: if the FTA drop-ship is active, begin Attack & Creation
if flag 12 <= 9
and flag 12 >= 5
and playerhasunit 1 5 epsilon
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

--BELOW: turn off Attack & Creation if player has no drop-ship
if flag 12 >= 10
and playerhasnounit 1 5 epsilon
    set flag 12 to 9
    reset timer 12
    repeat this if
end if

--BELOW: speed up the creation of units for the first 3 minutes
--since the FTA drop-ship just entered the sector:
if flag 12 = 10
and timer 12 >= 20000
and timer 13 <= 60000*3
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

--every 20-40 seconds, FTA will build a missing unit in their base
--in the following order:

    --**** EASY GAME DIFFICULTY CODE
    --**** EASY GAME DIFFICULTY CODE

if flag 12 = 10
and timer 12 >= 40000
and gamedifficulty = easy
and totalplayerunits 1 5 <= 4
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

if flag 12 = 10
and timer 12 >= 45000
and gamedifficulty = easy
and totalplayerunits 1 5 <= 9
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

if flag 12 = 10
and timer 12 >= 50000
and gamedifficulty = easy
and totalplayerunits 1 5 >= 10
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

    --**** MEDIUM GAME DIFFICULTY CODE:
    --**** MEDIUM GAME DIFFICULTY CODE:

if flag 12 = 10
and timer 12 >= 30000
and gamedifficulty = medium
and totalplayerunits 1 5 <= 4
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

if flag 12 = 10
and timer 12 >= 40000
and gamedifficulty = medium
and totalplayerunits 1 5 <= 9
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

if flag 12 = 10
and timer 12 >= 50000
and gamedifficulty = medium
and totalplayerunits 1 5 >= 10
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

    --**** HARD GAME DIFFICULTY CODE
    --**** HARD GAME DIFFICULTY CODE

if flag 12 = 10
and timer 12 >= 25000
and gamedifficulty = hard
and totalplayerunits 1 5 <= 4
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

if flag 12 = 10
and timer 12 >= 30000
and gamedifficulty = hard
and totalplayerunits 1 5 <= 9
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

if flag 12 = 10
and timer 12 >= 35000
and gamedifficulty = hard
and totalplayerunits 1 5 >= 10
    set flag 12 to 11
    setai 1 5 1 100
    repeat this if
end if

    --**** REST OF CODE:
    --**** REST OF CODE:

if flag 12 = 11
and playerhasunitcount 1 5 apostle = 0
and timer 42 >= 25000
    createunit 1 5 apostle vector(101547,184309,5368) -91 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 mammothturbine = 0
and timer 42 >= 25000
    createunit 1 5 mammothturbine vector(93052,183826,5229) -80 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 flakturret = 0
and timer 42 >= 25000
    createunit 1 5 flakturret vector(113654,180083,4995) -3 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 goldenboy < 2
and timer 42 >= 25000
    createunit 1 5 goldenboy vector(125441,177246,6040) -1 82 0 -1 0 [2]
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 goldenboy < 3
and flag 30 = 2
and timer 42 >= 25000
    createunit 1 5 goldenboy vector(125441,177246,6040) -1 82 0 -1 0 [2]
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 mammothturbine = 1
and timer 42 >= 25000
    createunit 1 5 mammothturbine vector(120815,183033,4981) -14 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 flakturret = 1
and flag 30 >= 3
and timer 42 >= 25000
    createunit 1 5 flakturret vector(104608,180320,5068) -3 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 flakturret = 2
and flag 30 >= 4
and timer 42 >= 25000
    createunit 1 5 flakturret vector(93671,180090,5109) 9 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 flakturret = 3
and flag 30 >= 4
and timer 42 >= 25000
--and gamedifficulty = hard
    createunit 1 5 flakturret vector(120122,178767,4943) -14 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 hazardchopper < 2
and timer 42 >= 25000
    createunit 1 5 hazardchopper vector(108368,183118,8223) 0 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 hazardchopper < 4
and flag 30 = 2
and timer 42 >= 25000
    createunit 1 5 hazardchopper vector(108368,183118,8223) 0 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 farseer = 0
and timer 42 >= 25000
    createunit 1 5 farseer vector(85791,185313,5222) 6 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

if flag 12 = 11
and playerhasunitcount 1 5 goldenboy < 4
and playerhasunitcount 1 1 farseeruplink >= 1
and timer 42 >= 25000
    createunit 1 5 goldenboy vector(125441,177246,6040) -1 82 0 -1 0 [2]
    reset timer 42
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

--if the primary drop-ship is low on health, concentrate on creation of Gamma's
if flag 12 = 11
and unithealth 1 5 1 <= 40%
and playerhasunitcount 1 5 goldenboy < 4
and timer 42 >= 30000
    createunit 1 5 goldenboy vector(125441,177246,6040) -1 82 0 -1 0
    reset timer 42
    set flag 12 to 10
    reset timer 4
    repeat this if
end if

--reset Flag and timer 12 if none of the above conditions are met
if flag 12 = 11
    set flag 12 to 10
    reset timer 12
    repeat this if
end if

*** FTA ENEMY 3 - TOP - ENDS
*** FTA ENEMY 3 - TOP - ENDS

*** DETERMINE PLAYER'S STRATEGY
*** DETERMINE PLAYER'S STRATEGY

--STRATEGY: Other
if timer 30 >= 20000
    set flag 30 to 0
end if

--STRATEGY: Advocates
if timer 30 >= 20000
and playerhasunitcount 1 1 advocate >= 5
    set flag 30 to 1
end if

--STRATEGY: Gamma Cruisers
if timer 30 >= 20000
and playerhasunitcount 1 1 gammacruiser >= 5
    set flag 30 to 1
end if

--STRATEGY: Hazard Choppers
if timer 30 >= 20000
and playerhasunitcount 1 1 hazardchopper >= 5
    set flag 30 to 3
end if

--STRATEGY: Turbine Copters
if timer 30 >= 20000
and playerhasunitcount 1 1 turbinecopter >= 5
    set flag 30 to 3
end if

--STRATEGY: Advocate Overkill
if timer 30 >= 20000
and playerhasunitcount 1 1 advocate >= 10
    set flag 30 to 2
end if

--STRATEGY: Gamma Overkill
if timer 30 >= 20000
and playerhasunitcount 1 1 gammacruiser >= 10
    set flag 30 to 2
end if

--STRATEGY: Hazard Choppers Overkill
if timer 30 >= 20000
and playerhasunitcount 1 1 hazardchopper >= 10
    set flag 30 to 4
end if

--STRATEGY: Turbine Copters Overkill
if timer 30 >= 20000
and playerhasunitcount 1 1 turbinecopter >= 10
    set flag 30 to 4
end if

--RESET THE TIMER:
if timer 30 >= 20000
    reset timer 30
end if

--------------
-- MUSIC
--------------

if soundchannel 8 is free
and timer 2 >= 20000
    addmusic ql_track_10a
    addmusic ql_track_8b
    addmusic ql_track_6c
    addmusic ql_track_8c
    addmusic ql_track_10c
    addmusic ql_track_6b
    addmusic ql_track_12b
    addmusic ql_track_8a
    addmusic ql_track_11a
    addmusic ql_track_10c
    addmusic ql_track_6b
    addmusic ql_track_12b
    addmusic ql_track_8a
    addmusic ql_track_11a
    addmusic ql_track_10b
    addmusic ql_track_10a
    addmusic ql_track_8b
    addmusic ql_track_10b
    addmusic ql_track_6c
    addmusic ql_track_8c
--
    addmusic ql_track_9a
    addmusic ql_track_12a
    addmusic ql_track_11b
    addmusic ql_track_9b
    addmusic ql_track_6a
    pause between tracks 10000
    reset timer 2
end if

--------------
-- MUSIC END
--------------
