--High Orbit
--Domination

**** SKIP FRAMES OF ANIMATION - STARTS

--BELOW: establish the initial level rules:
if flag 1 = 0
    playercantarget 1 1 [2,4,6,8,10]
    playercantarget 1 2 [1,3,5,7,9]
    playercantarget 1 3 [2,4,6,8,10]
    playercantarget 1 4 [1,3,5,7,9]
    playercantarget 1 5 [2,4,6,8,10]
    playercantarget 1 6 [1,3,5,7,9]
    playercantarget 1 7 [2,4,6,8,10]
    playercantarget 1 8 [1,3,5,7,9]
    playercantarget 1 9 [2,4,6,8,10]
    playercantarget 1 10 [1,3,5,7,9]
--pop-cap is kept low on purpose (which will force
--the players to plan and act as a team):
    setmaxunits 1 player 7
    setplayermoney 1 player 3000
    cleartasks all playernumber
    settechlevel 1 player [0,1,2,3,4,5,6,7,8,9,11,12,13,14,16,17,18,19,20]
--turn off the Allies button
    set allies false
    network comsatline >>> Type the word 'score' in COM-SAT to obtain the latest round statistics. rgb(255,255,0)
--BELOW: reset the flags used to keep track of the game score
    set flag 101 to 0
    set flag 102 to 0
    set flag 103 to 0
    addtask all playernumber domination pending primary send your units to capture each of the sector's checkpoint on behalf of your team
end if

--BELOW: calculate the initial game score:
if playernumber = 1
    set flag 99 to 1
end if

if flag 1 < 10
    set flag 1 + 1
    repeat this if
end if

if flag 1 = 3
--BELOW: hide the tactical window (the user should know how to use it by now):
    hide tactical
    set screensize 100 100
    fadehud in 4000
    set flag 1 to 10
    reset timer 1
end if

**** SKIP FRAMES OF ANIMATION - ENDS

**************** CORE LEVEL CREATION STARTS **************
**************** CORE LEVEL CREATION STARTS **************
**************** CORE LEVEL CREATION STARTS **************

clear resources from last level
total memory cleanup
set activeworld 1
resetworld 1

load basic configuration

set landpatch land_verylargespace
set landdeform off
set landheightmap heightmap_verylargespace
set shadows off        --this will make sure no unit shows are shown during gameplay
set unplayableareacheck off        --this will allow all units to exist far beyond the playable area
set heightmapdata off    --space heightmaps are blank, thus there is no need to process them for data
set playerlosscount off	--make sure player defeats are not counted on the QL ladder

set minnewfogdistance 1000000000
set maxviewdistance 1000000000

**** 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

--BELOW: we load the main Quantum Space resource pack which contains
--models, textures, sounds and all other resources related to the space levels:
load resourcepack http://internallink2/ql_quantumspace.cct slot2 quantum_space

replace loadingscreen loadingscreen_highorbit

prepare landpatch

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

load resourcepack http://internallink1/ql_soundpack_blairgeneral.cct slot4 character_speech
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
if nonwebversion
    load resourcepack http://internallink1/ql_musicpack3.cct slot12 music_pack3
end if

**** RESOURCE PACK FILES END

load basic variables

load basic models

--BELOW: a "red" variation of the radar is used
load minimap minimapred
processtexture inner_radar inner_radar_red
processtexture radarring_a radarring_a_red
processtexture radarring_b radarring_b_red
processtexture minimapcamerabox minimapcamerabox_white

--BELOW: team minimap colors:
--BLUE TEAM:
set minimapplayercolor 1 rgb(0,0,255)
set minimapplayercolor 3 rgb(0,0,255)
set minimapplayercolor 5 rgb(0,0,255)
set minimapplayercolor 7 rgb(0,0,255)
set minimapplayercolor 9 rgb(0,0,255)
--RED TEAM:
set minimapplayercolor 2 rgb(252,118,118)
set minimapplayercolor 4 rgb(252,118,118)
set minimapplayercolor 6 rgb(252,118,118)
set minimapplayercolor 8 rgb(252,118,118)
set minimapplayercolor 10 rgb(252,118,118)
--UNIQUE COLOR TO THE ACTIVE PLAYER:
set minimapplayercolor playernumber rgb(0,255,0)
--CHECKPOINTS:
set minimapplayercolor 14 rgb(255,255,255)
--RESOURCES:
set minimapplayercolor 17 rgb(0,0,0)

--BELOW: move the sky-clouds so high up that they are not seen
movemodel sky01 vector(0,0,3000000000)
movemodel sky02 vector(0,0,3000000000)

**** LINKED SCRIPT - STARTS

--NOTICE: all Quantum Space levels feed their modification data from a single Space Unit Database script
--(feel free to load the script in your browser via the http:// link below in order to study it's data)

--BELOW: First we stream the script:
load media http://quantumlegacy.com/sdk/scripts/quantumspace/spaceunitdatabase.txt slot1 quantum_space

--Then we process it (notice that as always, the ".txt " suffix is left out):
process script spaceunitdatabase

--BELOW: SDK Dev-Only: as an alternate method, instead of streaming the above public script
--the internal development script can be processed via the command:
--process script txtSpaceUnitDatabase

**** LINKED SCRIPT - ENDS

--BELOW: standard space sky-box:
createmodel player15 skybox_space vector(175792,206215,0) -157 9384.3135 [1]

--BELOW: replace the default "blue space" texture with another variation
processtexture texture_space texture_space8

createmodel player15 planet_saltus vector(253331,274164,-160084) 147 8.9668 [1]
createmodel player15 planet_star vector(-521515,-500404,-439375) 87 4.8258 [1]

**** DIRECT-X 5 FIX - STARTS
--BELOW: a problem has been identified with most video cards which are only capable of
--running QL in the outdated "Direct X 5.0+" video render mode, when attempting to display
--the layer of "clouds" on any of the Quantum Space planets (in the game model: "planet_saltus")
--as a temporary fix, the cloud layer is simply replaced with a blank texture (thus making it invisible
--and in turn removing the undesired broken texture video effect).
--The below IF statement should not affect most players who will run QL in either OpenGL or Direct X 7.0+
if renderer = directx5
--BELOW: replace the clouds used by the planet in this level with a blank-transparent texture
    processtexture texture_planetclouds blankalphatexture
end if
**** DIRECT-X 5 FIX - ENDS

createmodel player17 spaceresource vector(125214,278839,0) 92 1 [1]
createmodel player17 spaceresource vector(395052,286191,0) 92 1 [1]
createmodel player17 spaceresource vector(259216,421808,0) 92 1 [1]
createmodel player17 spaceresource vector(245717,142822,0) 92 1 [1]
createmodel player17 spaceresource vector(92533,457570,0) 92 1 [1]
createmodel player17 spaceresource vector(456807,446102,0) 92 1 [1]
createmodel player17 spaceresource vector(472805,104083,0) 92 1 [1]
createmodel player17 spaceresource vector(69262,83644,0) 92 1 [1]

--generic camera position:
positioncamera vector(4.08247e5,3.35741e5,-100.0000) vector(0.0000,0.0000,125.8760) vector(0.0000,-3.75511e4,2.22224e4) vector(0.0000,0.0000,0.0000)

--Blue Team: starting camera positions:
positioncamera1 vector(4.51140e5,4.49196e5,-100.0000) vector(0.0000,0.0000,148.7069) vector(0.0000,-3.32609e4,2.08164e4) vector(0.0000,0.0000,0.0000)
positioncamera3 vector(3.99154e5,2.98132e5,-100.0000) vector(0.0000,0.0000,77.6698) vector(0.0000,-3.59739e4,2.19730e4) vector(0.0000,0.0000,0.0000)
positioncamera5 vector(4.67284e5,1.14266e5,-100.0000) vector(0.0000,0.0000,65.4807) vector(0.0000,-3.63913e4,1.96450e4) vector(0.0000,0.0000,0.0000)
positioncamera7 vector(2.72232e5,4.19642e5,-100.0000) vector(0.0000,0.0000,140.6613) vector(0.0000,-3.50000e4,2.14210e4) vector(0.0000,0.0000,0.0000)
positioncamera9 vector(4.62668e5,4.23273e5,-100.0000) vector(0.0000,0.0000,94.7447) vector(0.0000,-3.43846e4,2.06142e4) vector(0.0000,0.0000,0.0000)

--Red Team: starting camera positions:
positioncamera2 vector(8.15053e4,9.42218e4,-100.0000) vector(0.0000,0.0000,-69.3569) vector(0.0000,-3.71538e4,2.11220e4) vector(0.0000,0.0000,0.0000)
positioncamera4 vector(9.22101e4,4.47850e5,-100.0000) vector(0.0000,0.0000,-116.4864) vector(0.0000,-3.37200e4,2.06050e4) vector(0.0000,0.0000,0.0000)
positioncamera6 vector(1.16349e5,2.71607e5,-100.0000) vector(0.0000,0.0000,-92.8304) vector(0.0000,-3.44615e4,1.88450e4) vector(0.0000,0.0000,0.0000)
positioncamera8 vector(2.32764e5,1.41342e5,-100.0000) vector(0.0000,0.0000,-21.9635) vector(0.0000,-3.53953e4,2.03650e4) vector(0.0000,0.0000,0.0000)
positioncamera10 vector(7.23926e4,1.05238e5,-100.0000) vector(0.0000,0.0000,-61.7169) vector(0.0000,-3.75231e4,2.23552e4) vector(0.0000,0.0000,0.0000)

set screensize 100 0
fadehud instantout

**************** CORE LEVEL CREATION ENDS **************
**************** CORE LEVEL CREATION ENDS **************
**************** CORE LEVEL CREATION ENDS **************

**** TEAM COLORS - START
**** TEAM COLORS - START

--BELOW: Players 1 through 10 are split into teams (Blue and Red)
--as a result, all of team's engine colors will be the same

--ODD players are "blue" (same as Player 1):
processtexture flare_epsilon01~1 flare_epsilon01~1
processtexture flare_epsilon01~3 flare_epsilon01~1
processtexture flare_epsilon01~5 flare_epsilon01~1
processtexture flare_epsilon01~7 flare_epsilon01~1
processtexture flare_epsilon01~9 flare_epsilon01~1

--EVEN players are "red" (same as Player 2):
processtexture flare_epsilon01~2 flare_epsilon01~2
processtexture flare_epsilon01~4 flare_epsilon01~2
processtexture flare_epsilon01~6 flare_epsilon01~2
processtexture flare_epsilon01~8 flare_epsilon01~2
processtexture flare_epsilon01~10 flare_epsilon01~2

--BELOW: we determine if the player is on the "Blue" team (odd = 1)
--or the "Red" team (even = 2)

if playernumber = 1
    set flag 40 to 1
end if
if playernumber = 3
    set flag 40 to 1
end if
if playernumber = 5
    set flag 40 to 1
end if
if playernumber = 7
    set flag 40 to 1
end if
if playernumber = 9
    set flag 40 to 1
end if

--BELOW: if player is on the even "Red" team, we will set flag 40 to the value: 2

if playernumber = 2
    set flag 40 to 2
end if
if playernumber = 4
    set flag 40 to 2
end if
if playernumber = 6
    set flag 40 to 2
end if
if playernumber = 8
    set flag 40 to 2
end if
if playernumber = 10
    set flag 40 to 2
end if

--BELOW: we give a different engine color to the player's ships
--(a different variation of a "blue" or "red" engine flares) so that the player is
--able to distinguish his ships from his teammates with ease:

if flag 40 = 1
--BELOW: texture "flare_epsilon01 10" will replace the player's texture
--(the term "playernumber" will be automatically substituted with the correct value)
    processtexture flare_epsilon01~playernumber flare_epsilon01~10
end if

if flag 40 = 2
--BELOW: texture "flare_epsilon01 16" will replace the player's texture
--(the term "playernumber" will be automatically substituted with the correct value)
    processtexture flare_epsilon01~playernumber flare_epsilon01~13
end if

**** TEAM COLORS - END
**** TEAM COLORS - END

******** CHECKPOINTS - START
******** CHECKPOINTS - START

--By default, standard checkpoints (Temporal Mod 1) are "blue"
--Temporal Mod 2 are "green", and Temporal Mod 3 are "red"

--All three color checkpoints will reside in the exact same spot
--and will be made either "invisible" or "visible" as needed

--BELOW: Checkpoint 1 (in order: "blue", "red" and "green")
--AKA: Player 14's units: 1, 2, 3
createmodel player14 checkpoint01 vector(100104,413205,172) 0 120 [1]
createmodel player14 checkpoint01 vector(100104,413205,172) 0 120 [3]
createmodel player14 checkpoint01 vector(100104,413205,172) 0 120 [2]

--BELOW: Checkpoint 2 (in order: "blue", "red" and "green")
--AKA: Player 14's units: 4, 5, 6
createmodel player14 checkpoint01 vector(107464,136866,172) 0 120 [1]
createmodel player14 checkpoint01 vector(107464,136866,172) 0 120 [3]
createmodel player14 checkpoint01 vector(107464,136866,172) 0 120 [2]

--BELOW: Checkpoint 3 (in order: "blue", "red" and "green")
--AKA: Player 14's units: 7, 8, 9
createmodel player14 checkpoint01 vector(395567,150698,172) 0 120 [1]
createmodel player14 checkpoint01 vector(395567,150698,172) 0 120 [3]
createmodel player14 checkpoint01 vector(395567,150698,172) 0 120 [2]

--BELOW: Checkpoint 4 (in order: "blue", "red" and "green")
--AKA: Player 14's units: 10, 11, 12
createmodel player14 checkpoint01 vector(376893,414847,172) 0 120 [1]
createmodel player14 checkpoint01 vector(376893,414847,172) 0 120 [3]
createmodel player14 checkpoint01 vector(376893,414847,172) 0 120 [2]

--BELOW: we make all of the "blue" and "red" checkpoints invisible
--only leaving the "green" checkpoints active in the level
--(this event will also be triggered each time flag 49 is set to 0)
if timer 1 >= 0
and flag 49 = 0
and playernumber = 1
    set flag 49 to 1
--BELOW: we make all of the checkpoints invisible:
    setunitstate 1 14 all 93 0 -1
--BELOW: make each of the green checkpoints visible:
    setunitstate 1 14 3 81 0 -1
    setunitstate 1 14 6 81 0 -1
    setunitstate 1 14 9 81 0 -1
    setunitstate 1 14 12 81 0 -1
--BELOW: reset the counter flags:
    set flag 51 to 0
    set flag 52 to 0
    set flag 53 to 0
    set flag 54 to 0
    set flag 61 to 0
    set flag 62 to 0
    set flag 63 to 0
    set flag 64 to 0
    set flag 71 to 0
    set flag 72 to 0
    set flag 73 to 0
    set flag 74 to 0
    set flag 81 to 0
    set flag 82 to 0
    set flag 83 to 0
    set flag 84 to 0
    set flag 91 to 0
    set flag 92 to 0
    set flag 93 to 0
    set flag 94 to 0
--BELOW: flags 41 through 44 are used to make sure that the "acquiring checkpoint"
--voice samples are not heard over and over again in a constant loop
    set flag 41 to 0
    set flag 42 to 0
    set flag 43 to 0
    set flag 44 to 0
--BELOW: flag 103 (which can also be called with flag[103] command) is used to keep track of the round number:
    set flag 103 + 1
--BELOW: timer 3 will keep track of when the current round started
    reset timer 3
    repeat this if
end if

--NOTE: Flags 51, 52, 53 and 54 will indicate which team
--controls the corresponding checkpoint
--(example: if flag 51 = 0, this means that "Checkpoint 1" does not belong
--to anyone and is "green", while flag 52 = 1 means that "Checkpoint 2"
--is being held by the "Blue Team")

--Flags 61, 62, 63 and 64 will count how many members of the "blue" team
--control the corresponding checkpoints, while flags 71,72,73,74 will count
--how many players from the "red" team are holding each of the corresponding
--checkpoints.

--Flags 81, 82, 83 and 84 will be used to keep track of how long the "blue" team
--is holding a particular checkpoint, while flags 91,92,93 and 94 will do the same
--for the "red" team. 

--All checkpoint related checks are only done by "Player 1" (the host)
--in turn, all commands which should affect other players in the game
--will use the "network" prefix.
--as an optional variable, the "network" command can be followed by
--the player number (or an array of numbers) for whom the command should apply
--if this information is missing, the "network" command will be executed by
--all active players in the game.

    **** CHECKPOINT 1 - CAPTURE CHECK - STARTS
    **** CHECKPOINT 1 - CAPTURE CHECK - STARTS

--BELOW: we check every 5 seconds to see how many players from each
--team are close to (and thus, are "holding") CHECKPOINT 1:
if timer 61 >= 5000
and playernumber = 1
--reset the checkpoint counter for the "blue" team:
    set flag 61 to 0
--reset the checkpoint counter for the "red" team:
    set flag 71 to 0
    repeat this if
end if

--*** Player 1 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 1 any <= 5000
    set flag 61 + 1
    repeat this if
end if

--*** Player 2 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 2 any <= 5000
    set flag 71 + 1
    repeat this if
end if

--*** Player 3 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 3 any <= 5000
    set flag 61 + 1
    repeat this if
end if

--*** Player 4 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 4 any <= 5000
    set flag 71 + 1
    repeat this if
end if

--*** Player 5 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 5 any <= 5000
    set flag 61 + 1
    repeat this if
end if

--*** Player 6 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 6 any <= 5000
    set flag 71 + 1
    repeat this if
end if

--*** Player 7 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 7 any <= 5000
    set flag 61 + 1
    repeat this if
end if

--*** Player 8 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 8 any <= 5000
    set flag 71 + 1
    repeat this if
end if

--*** Player 9 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 9 any <= 5000
    set flag 61 + 1
    repeat this if
end if

--*** Player 10 distance check:
if timer 61 >= 5000
and playernumber = 1
and distancebetween 1 14 1 1 10 any <= 5000
    set flag 71 + 1
    repeat this if
end if

--BELOW: flag 61 is greater than flag 71
--(meaning: more players from the "blue" team are holding the checkpoint)
--we also make sure that the "blue" team is not currently holding the checkpoint
--(this information is held by flag 51)
if timer 61 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 61 > flag 71
--BELOW: increase the count for the "blue" team holding this particular checkpoint
    set flag 81 + 1
--BELOW: decrease the corresponding variable for the "red" team (since they
--are currently losing this checkpoint)
    set flag 91 - 1
    repeat this if
end if

--BELOW: flag 71 is greater than flag 61
--(meaning: more players from the "red" team are holding the checkpoint)
--we also make sure that the "red" team is not currently holding the checkpoint
--(this information is held by flag 51)
if timer 61 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 71 > flag 61
--BELOW: increase the count for the "red" team holding this particular checkpoint
    set flag 91 + 1
--BELOW: decrease the corresponding variable for the "blue" team (since they
--are currently losing this checkpoint)
    set flag 81 - 1
    repeat this if
end if

--BELOW: the checkpoint is captured by the "blue" team
--when flag 81 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 61 >= 5000
and playernumber = 1
and flag 51 <> 1
and flag 81 >= 12
--BELOW: reset the capture counter for the red team:
    set flag 91 to 0
--BELOW: set all versions of "CHECKPOINT 1" to "invisible"
    setunitstate 1 14 1 93 0 -1
    setunitstate 1 14 2 93 0 -1
    setunitstate 1 14 3 93 0 -1
--BELOW: make the "blue" version of "CHECKPOINT 1" visible:
    setunitstate 1 14 1 81 0 -1
--BELOW: indicate that the "blue" team has captured the checkpoint:
    set flag 51 to 1
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 1 30000 1 -1 20000
    network radarbeacon 1 vector(100104,413205,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer206
    network [1,3,5,7,9] comsatline Computer: Checkpoint captured. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer208
    network [2,4,6,8,10] comsatline Computer: Checkpoint lost. rgb(255,255,0)
    set flag 41 to 0
    repeat this if
end if

--BELOW: the checkpoint is captured by the "red" team
--when flag 81 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 61 >= 5000
and playernumber = 1
and flag 51 <> 2
and flag 91 >= 12
--BELOW: reset the capture counter for the blue team:
    set flag 81 to 0
--BELOW: set all versions of "CHECKPOINT 1" to "invisible"
    setunitstate 1 14 1 93 0 -1
    setunitstate 1 14 2 93 0 -1
    setunitstate 1 14 3 93 0 -1
--BELOW: make the "red" version of "CHECKPOINT 1" visible:
    setunitstate 1 14 2 81 0 -1
--BELOW: indicate that the "red" team has captured the checkpoint:
    set flag 51 to 2
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 2 30000 1 -1 20000
    network radarbeacon 1 vector(100104,413205,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer208
    network [1,3,5,7,9] comsatline Computer: Checkpoint lost. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer206
    network [2,4,6,8,10] comsatline Computer: Checkpoint captured. rgb(255,255,0)
    set flag 41 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never below zero:
if timer 61 >= 5000
and playernumber = 1
and flag 81 < 0
    set flag 81 to 0
    repeat this if
end if

if timer 61 >= 5000
and playernumber = 1
and flag 91 < 0
    set flag 91 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never above 12:
if timer 61 >= 5000
and playernumber = 1
and flag 81 > 12
    set flag 81 to 6
    repeat this if
end if

if timer 61 >= 5000
and playernumber = 1
and flag 91 > 12
    set flag 91 to 6
    repeat this if
end if

if timer 61 >= 5000
    reset timer 61
    repeat this if
end if

    **** CHECKPOINT 1 - CAPTURE CHECK - ENDS
    **** CHECKPOINT 1 - CAPTURE CHECK - ENDS

    **** CHECKPOINT 2 - CAPTURE CHECK - STARTS
    **** CHECKPOINT 2 - CAPTURE CHECK - STARTS

--BELOW: we check every 5 seconds to see how many players from each
--team are close to (and thus, are "holding") CHECKPOINT 2:
if timer 62 >= 5000
and playernumber = 1
--reset the checkpoint counter for the "blue" team:
    set flag 62 to 0
--reset the checkpoint counter for the "red" team:
    set flag 72 to 0
    repeat this if
end if

--*** Player 1 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 1 any <= 5000
    set flag 62 + 1
    repeat this if
end if

--*** Player 2 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 2 any <= 5000
    set flag 72 + 1
    repeat this if
end if

--*** Player 3 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 3 any <= 5000
    set flag 62 + 1
    repeat this if
end if

--*** Player 4 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 4 any <= 5000
    set flag 72 + 1
    repeat this if
end if

--*** Player 5 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 5 any <= 5000
    set flag 62 + 1
    repeat this if
end if

--*** Player 6 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 6 any <= 5000
    set flag 72 + 1
    repeat this if
end if

--*** Player 7 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 7 any <= 5000
    set flag 62 + 1
    repeat this if
end if

--*** Player 8 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 8 any <= 5000
    set flag 72 + 1
    repeat this if
end if

--*** Player 9 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 9 any <= 5000
    set flag 62 + 1
    repeat this if
end if

--*** Player 10 distance check:
if timer 62 >= 5000
and playernumber = 1
and distancebetween 1 14 4 1 10 any <= 5000
    set flag 72 + 1
    repeat this if
end if

--BELOW: flag 62 is greater than flag 72
--(meaning: more players from the "blue" team are holding the checkpoint)
--we also make sure that the "blue" team is not currently holding the checkpoint
--(this information is held by flag 52)
if timer 62 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 62 > flag 72
--BELOW: increase the count for the "blue" team holding this particular checkpoint
    set flag 82 + 1
--BELOW: decrease the corresponding variable for the "red" team (since they
--are currently losing this checkpoint)
    set flag 92 - 1
    repeat this if
end if

--BELOW: flag 72 is greater than flag 62
--(meaning: more players from the "red" team are holding the checkpoint)
--we also make sure that the "red" team is not currently holding the checkpoint
--(this information is held by flag 52)
if timer 62 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 72 > flag 62
--BELOW: increase the count for the "red" team holding this particular checkpoint
    set flag 92 + 1
--BELOW: decrease the corresponding variable for the "blue" team (since they
--are currently losing this checkpoint)
    set flag 82 - 1
    repeat this if
end if

--BELOW: the checkpoint is captured by the "blue" team
--when flag 82 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 62 >= 5000
and playernumber = 1
and flag 52 <> 1
and flag 82 >= 12
--BELOW: reset the capture counter for the red team:
    set flag 92 to 0
--BELOW: set all versions of "CHECKPOINT 2" to "invisible"
    setunitstate 1 14 4 93 0 -1
    setunitstate 1 14 5 93 0 -1
    setunitstate 1 14 6 93 0 -1
--BELOW: make the "blue" version of "CHECKPOINT 2" visible:
    setunitstate 1 14 4 81 0 -1
--BELOW: indicate that the "blue" team has captured the checkpoint:
    set flag 52 to 1
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 4 30000 1 -1 20000
    network radarbeacon 1 vector(107464,136866,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer206
    network [1,3,5,7,9] comsatline Computer: Checkpoint captured. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer208
    network [2,4,6,8,10] comsatline Computer: Checkpoint lost. rgb(255,255,0)
    set flag 42 to 0
    repeat this if
end if

--BELOW: the checkpoint is captured by the "red" team
--when flag 82 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 62 >= 5000
and playernumber = 1
and flag 52 <> 2
and flag 92 >= 12
--BELOW: reset the capture counter for the blue team:
    set flag 82 to 0
--BELOW: set all versions of "CHECKPOINT 2" to "invisible"
    setunitstate 1 14 4 93 0 -1
    setunitstate 1 14 5 93 0 -1
    setunitstate 1 14 6 93 0 -1
--BELOW: make the "red" version of "CHECKPOINT 2" visible:
    setunitstate 1 14 5 81 0 -1
--BELOW: indicate that the "red" team has captured the checkpoint:
    set flag 52 to 2
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 5 30000 1 -1 20000
    network radarbeacon 1 vector(107464,136866,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer208
    network [1,3,5,7,9] comsatline Computer: Checkpoint lost. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer206
    network [2,4,6,8,10] comsatline Computer: Checkpoint captured. rgb(255,255,0)
    set flag 42 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never below zero:
if timer 62 >= 5000
and playernumber = 1
and flag 82 < 0
    set flag 82 to 0
    repeat this if
end if

if timer 62 >= 5000
and playernumber = 1
and flag 92 < 0
    set flag 92 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never above 12:
if timer 62 >= 5000
and playernumber = 1
and flag 82 > 12
    set flag 82 to 6
    repeat this if
end if

if timer 62 >= 5000
and playernumber = 1
and flag 92 > 12
    set flag 92 to 6
    repeat this if
end if

if timer 62 >= 5000
    reset timer 62
    repeat this if
end if

    **** CHECKPOINT 2 - CAPTURE CHECK - ENDS
    **** CHECKPOINT 2 - CAPTURE CHECK - ENDS

    **** CHECKPOINT 3 - CAPTURE CHECK - STARTS
    **** CHECKPOINT 3 - CAPTURE CHECK - STARTS

--BELOW: we check every 5 seconds to see how many players from each
--team are close to (and thus, are "holding") CHECKPOINT 3:
if timer 63 >= 5000
and playernumber = 1
--reset the checkpoint counter for the "blue" team:
    set flag 63 to 0
--reset the checkpoint counter for the "red" team:
    set flag 73 to 0
    repeat this if
end if

--*** Player 1 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 1 any <= 5000
    set flag 63 + 1
    repeat this if
end if

--*** Player 2 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 2 any <= 5000
    set flag 73 + 1
    repeat this if
end if

--*** Player 3 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 3 any <= 5000
    set flag 63 + 1
    repeat this if
end if

--*** Player 4 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 4 any <= 5000
    set flag 73 + 1
    repeat this if
end if

--*** Player 5 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 5 any <= 5000
    set flag 63 + 1
    repeat this if
end if

--*** Player 6 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 6 any <= 5000
    set flag 73 + 1
    repeat this if
end if

--*** Player 7 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 7 any <= 5000
    set flag 63 + 1
    repeat this if
end if

--*** Player 8 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 8 any <= 5000
    set flag 73 + 1
    repeat this if
end if

--*** Player 9 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 9 any <= 5000
    set flag 63 + 1
    repeat this if
end if

--*** Player 10 distance check:
if timer 63 >= 5000
and playernumber = 1
and distancebetween 1 14 7 1 10 any <= 5000
    set flag 73 + 1
    repeat this if
end if

--BELOW: flag 63 is greater than flag 73
--(meaning: more players from the "blue" team are holding the checkpoint)
--we also make sure that the "blue" team is not currently holding the checkpoint
--(this information is held by flag 53)
if timer 63 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 63 > flag 73
--BELOW: increase the count for the "blue" team holding this particular checkpoint
    set flag 83 + 1
--BELOW: decrease the corresponding variable for the "red" team (since they
--are currently losing this checkpoint)
    set flag 93 - 1
    repeat this if
end if

--BELOW: flag 73 is greater than flag 63
--(meaning: more players from the "red" team are holding the checkpoint)
--we also make sure that the "red" team is not currently holding the checkpoint
--(this information is held by flag 53)
if timer 63 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 73 > flag 63
--BELOW: increase the count for the "red" team holding this particular checkpoint
    set flag 93 + 1
--BELOW: decrease the corresponding variable for the "blue" team (since they
--are currently losing this checkpoint)
    set flag 83 - 1
    repeat this if
end if

--BELOW: the checkpoint is captured by the "blue" team
--when flag 83 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 63 >= 5000
and playernumber = 1
and flag 53 <> 1
and flag 83 >= 12
--BELOW: reset the capture counter for the red team:
    set flag 93 to 0
--BELOW: set all versions of "CHECKPOINT 3" to "invisible"
    setunitstate 1 14 7 93 0 -1
    setunitstate 1 14 8 93 0 -1
    setunitstate 1 14 9 93 0 -1
--BELOW: make the "blue" version of "CHECKPOINT 3" visible:
    setunitstate 1 14 7 81 0 -1
--BELOW: indicate that the "blue" team has captured the checkpoint:
    set flag 53 to 1
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 7 30000 1 -1 20000
    network radarbeacon 1 vector(395567,150698,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer206
    network [1,3,5,7,9] comsatline Computer: Checkpoint captured. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer208
    network [2,4,6,8,10] comsatline Computer: Checkpoint lost. rgb(255,255,0)
    set flag 43 to 0
    repeat this if
end if

--BELOW: the checkpoint is captured by the "red" team
--when flag 83 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 63 >= 5000
and playernumber = 1
and flag 53 <> 2
and flag 93 >= 12
--BELOW: reset the capture counter for the blue team:
    set flag 83 to 0
--BELOW: set all versions of "CHECKPOINT 3" to "invisible"
    setunitstate 1 14 7 93 0 -1
    setunitstate 1 14 8 93 0 -1
    setunitstate 1 14 9 93 0 -1
--BELOW: make the "red" version of "CHECKPOINT 3" visible:
    setunitstate 1 14 8 81 0 -1
--BELOW: indicate that the "red" team has captured the checkpoint:
    set flag 53 to 2
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 8 30000 1 -1 20000
    network radarbeacon 1 vector(395567,150698,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer208
    network [1,3,5,7,9] comsatline Computer: Checkpoint lost. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer206
    network [2,4,6,8,10] comsatline Computer: Checkpoint captured. rgb(255,255,0)
    set flag 43 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never below zero:
if timer 63 >= 5000
and playernumber = 1
and flag 83 < 0
    set flag 83 to 0
    repeat this if
end if

if timer 63 >= 5000
and playernumber = 1
and flag 93 < 0
    set flag 93 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never above 12:
if timer 63 >= 5000
and playernumber = 1
and flag 83 > 12
    set flag 83 to 6
    repeat this if
end if

if timer 63 >= 5000
and playernumber = 1
and flag 93 > 12
    set flag 93 to 6
    repeat this if
end if

if timer 63 >= 5000
    reset timer 63
    repeat this if
end if

    **** CHECKPOINT 3 - CAPTURE CHECK - ENDS
    **** CHECKPOINT 3 - CAPTURE CHECK - ENDS

    **** CHECKPOINT 4 - CAPTURE CHECK - STARTS
    **** CHECKPOINT 4 - CAPTURE CHECK - STARTS

--BELOW: we check every 5 seconds to see how many players from each
--team are close to (and thus, are "holding") CHECKPOINT 4:
if timer 64 >= 5000
and playernumber = 1
--reset the checkpoint counter for the "blue" team:
    set flag 64 to 0
--reset the checkpoint counter for the "red" team:
    set flag 74 to 0
    repeat this if
end if

--*** Player 1 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 1 any <= 5000
    set flag 64 + 1
    repeat this if
end if

--*** Player 2 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 2 any <= 5000
    set flag 74 + 1
    repeat this if
end if

--*** Player 3 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 3 any <= 5000
    set flag 64 + 1
    repeat this if
end if

--*** Player 4 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 4 any <= 5000
    set flag 74 + 1
    repeat this if
end if

--*** Player 5 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 5 any <= 5000
    set flag 64 + 1
    repeat this if
end if

--*** Player 6 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 6 any <= 5000
    set flag 74 + 1
    repeat this if
end if

--*** Player 7 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 7 any <= 5000
    set flag 64 + 1
    repeat this if
end if

--*** Player 8 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 8 any <= 5000
    set flag 74 + 1
    repeat this if
end if

--*** Player 9 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 9 any <= 5000
    set flag 64 + 1
    repeat this if
end if

--*** Player 10 distance check:
if timer 64 >= 5000
and playernumber = 1
and distancebetween 1 14 10 1 10 any <= 5000
    set flag 74 + 1
    repeat this if
end if

--BELOW: flag 64 is greater than flag 74
--(meaning: more players from the "blue" team are holding the checkpoint)
--we also make sure that the "blue" team is not currently holding the checkpoint
--(this information is held by flag 54)
if timer 64 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 64 > flag 74
--BELOW: increase the count for the "blue" team holding this particular checkpoint
    set flag 84 + 1
--BELOW: decrease the corresponding variable for the "red" team (since they
--are currently losing this checkpoint)
    set flag 94 - 1
    repeat this if
end if

--BELOW: flag 74 is greater than flag 64
--(meaning: more players from the "red" team are holding the checkpoint)
--we also make sure that the "red" team is not currently holding the checkpoint
--(this information is held by flag 54)
if timer 64 >= 5000
and timer 100 >= 30000
and playernumber = 1
and flag 74 > flag 64
--BELOW: increase the count for the "red" team holding this particular checkpoint
    set flag 94 + 1
--BELOW: decrease the corresponding variable for the "blue" team (since they
--are currently losing this checkpoint)
    set flag 84 - 1
    repeat this if
end if

--BELOW: the checkpoint is captured by the "blue" team
--when flag 84 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 64 >= 5000
and playernumber = 1
and flag 54 <> 1
and flag 84 >= 12
--BELOW: reset the capture counter for the red team:
    set flag 94 to 0
--BELOW: set all versions of "CHECKPOINT 4" to "invisible"
    setunitstate 1 14 10 93 0 -1
    setunitstate 1 14 11 93 0 -1
    setunitstate 1 14 12 93 0 -1
--BELOW: make the "blue" version of "CHECKPOINT 4" visible:
    setunitstate 1 14 10 81 0 -1
--BELOW: indicate that the "blue" team has captured the checkpoint:
    set flag 54 to 1
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 10 30000 1 -1 20000
    network radarbeacon 1 vector(376893,414847,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer206
    network [1,3,5,7,9] comsatline Computer: Checkpoint captured. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer208
    network [2,4,6,8,10] comsatline Computer: Checkpoint lost. rgb(255,255,0)
    set flag 44 to 0
    repeat this if
end if

--BELOW: the checkpoint is captured by the "red" team
--when flag 84 >= 12 (meaning: the checkpoint was held
--for about 60 seconds, since all of the checkpoint checks are done
--every 5000 milliseconds)
if timer 64 >= 5000
and playernumber = 1
and flag 54 <> 2
and flag 94 >= 12
--BELOW: reset the capture counter for the blue team:
    set flag 84 to 0
--BELOW: set all versions of "CHECKPOINT 4" to "invisible"
    setunitstate 1 14 10 93 0 -1
    setunitstate 1 14 11 93 0 -1
    setunitstate 1 14 12 93 0 -1
--BELOW: make the "red" version of "CHECKPOINT 4" visible:
    setunitstate 1 14 11 81 0 -1
--BELOW: indicate that the "red" team has captured the checkpoint:
    set flag 54 to 2
--point the drop-cam at the captured checkpoint
    network dropcam 1 14 11 30000 1 -1 20000
    network radarbeacon 1 vector(376893,414847,172) 30000
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer208
    network [1,3,5,7,9] comsatline Computer: Checkpoint lost. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer206
    network [2,4,6,8,10] comsatline Computer: Checkpoint captured. rgb(255,255,0)
    set flag 44 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never below zero:
if timer 64 >= 5000
and playernumber = 1
and flag 84 < 0
    set flag 84 to 0
    repeat this if
end if

if timer 64 >= 5000
and playernumber = 1
and flag 94 < 0
    set flag 94 to 0
    repeat this if
end if

--BELOW: we make sure that each of the checkpoint-count flags
--are never above 12:
if timer 64 >= 5000
and playernumber = 1
and flag 84 > 12
    set flag 84 to 6
    repeat this if
end if

if timer 64 >= 5000
and playernumber = 1
and flag 94 > 12
    set flag 94 to 6
    repeat this if
end if

if timer 64 >= 5000
    reset timer 64
    repeat this if
end if

    **** CHECKPOINT 4 - CAPTURE CHECK - ENDS
    **** CHECKPOINT 4 - CAPTURE CHECK - ENDS

*** ALL CHECK POINTS HAVE BEEN CAPTURED - STARTS
*** ALL CHECK POINTS HAVE BEEN CAPTURED - STARTS

--BELOW: count how many checkpoints are held by the blue team
--and store the value inside flag 78
if timer 65 >= 5000
and playernumber = 1
    set flag 78 to 0
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 51 = 1
    set flag 78 + 1
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 52 = 1
    set flag 78 + 1
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 53 = 1
    set flag 78 + 1
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 54 = 1
    set flag 78 + 1
    repeat this if
end if

--BELOW: count how many checkpoints are held by the red team
--and store the value inside flag 79
if timer 65 >= 5000
and playernumber = 1
    set flag 79 to 0
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 51 = 2
    set flag 79 + 1
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 52 = 2
    set flag 79 + 1
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 53 = 2
    set flag 79 + 1
    repeat this if
end if

if timer 65 >= 5000
and playernumber = 1
and flag 54 = 2
    set flag 79 + 1
    repeat this if
end if

--NOTICE: we will keep each team's score inside
--a flag which will be referenced with the syntax: flag[number].
--this will allow us to reference the variable later on in a "comsatline" or "recontext" statements

--BELOW: capture done by the "blue" team:
if timer 65 >= 5000
and playernumber = 1
and flag 78 = 4
and flag 79 = 0
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer209
    network [1,3,5,7,9] comsatline Computer: All checkpoints captured. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer210
    network [2,4,6,8,10] comsatline Computer: All checkpoints lost. rgb(255,255,0)
--BELOW: flag 49 means: reset all checkpoint counters, and set all checkpoints to "green"
    set flag 49 to 0
--BELOW: we add another win to the "blue" team, via: flag101]
    set flag 101 + 1
--BELOW: let all of the players know the latest team score:
    set flag 99 to 1
--BELOW: network command that will be executed by all active players on the "blue" team:
    network set flag 58 to 1
    network reset timer 58
--BELOW: network command that will be executed by all active players on the "red" team:
    network set flag 68 to 1
    network reset timer 68
--BELOW: inform everyone that the "blue" team has won the round:
    network set flag 104 to 1
--BELOW: on top of the above network command, the host (Player 1)
--will attempt to kill any units left in the game:
    network setunitstate 1 1 all 69 0 -1
    network setunitstate 1 2 all 69 0 -1
    network setunitstate 1 3 all 69 0 -1
    network setunitstate 1 4 all 69 0 -1
    network setunitstate 1 5 all 69 0 -1
    network setunitstate 1 6 all 69 0 -1
    network setunitstate 1 7 all 69 0 -1
    network setunitstate 1 8 all 69 0 -1
    network setunitstate 1 9 all 69 0 -1
    network setunitstate 1 10 all 69 0 -1
--BELOW: timer 100 keeps track of the last time all checkpoints have been captured:
    reset timer 100
    repeat this if
end if

--BELOW: capture done by the "red" team:
if timer 65 >= 5000
and playernumber = 1
and flag 78 = 0
and flag 79 = 4
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer210
    network [1,3,5,7,9] comsatline Computer: All checkpoints lost. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer209
    network [2,4,6,8,10] comsatline Computer: All checkpoints captured. rgb(255,255,0)
--BELOW: flag 49 means: reset all checkpoint counters, and set all checkpoints to "green"
    set flag 49 to 0
--BELOW: we add another win to the "red" team, via: flag[102]
    set flag 102 + 1
--BELOW: let all of the players know the latest team score:
    set flag 99 to 1
--BELOW: network command that will be executed by all active players on the "blue" team:
    network set flag 58 to 1
    network reset timer 58
--BELOW: network command that will be executed by all active players on the "red" team:
    network set flag 68 to 1
    network reset timer 68
--BELOW: inform everyone that the "blue" team has won the round:
    network set flag 104 to 2
--BELOW: on top of the above network command, the host (Player 1)
--will attempt to kill any units left in the game:
    network setunitstate 1 1 all 69 0 -1
    network setunitstate 1 2 all 69 0 -1
    network setunitstate 1 3 all 69 0 -1
    network setunitstate 1 4 all 69 0 -1
    network setunitstate 1 5 all 69 0 -1
    network setunitstate 1 6 all 69 0 -1
    network setunitstate 1 7 all 69 0 -1
    network setunitstate 1 8 all 69 0 -1
    network setunitstate 1 9 all 69 0 -1
    network setunitstate 1 10 all 69 0 -1
--BELOW: timer 100 keeps track of the last time all checkpoints have been captured:
    reset timer 100
    repeat this if
end if

*** BLUE TEAM RESET - STARTS

--BELOW: "blue" team is reset
--(all of their units will be erased, forcing them to start from scratch)
--as before, flag 40 will hold the player's team (1 = blue, 2 = red)
if flag 58 = 1
and timer 58 >= 10000
and flag 40 = 1
    set flag 58 to 0
    set flag 59 to 1
    repeat this if
end if

if flag 58 = 1
and timer 58 >= 10000
    set flag 58 to 0
    repeat this if
end if

--BELOW: local unit deletion code
if flag 59 = 1
    reset timer 59
    set flag 59 + 1
    setunitstate 1 playernumber all 69 0 -1
    repeat this if
end if

--BELOW: create a new starting unit 30 seconds later:
if flag 59 = 2
and timer 59 >= 25000
and timer 101 >= 60000
    playglobalsound 2 99 computer231
    comsatline Computer: Get ready. rgb(255,255,0)
    reset timer 101
    repeat this if
end if

if flag 59 = 2
and timer 59 >= 30000
and playeralliance = fta
    createunit 1 playernumber epsilon vector(1000*playernumber,0,0) 0 85 0 -1 0
    reset timer 59
    set flag 59 to 0
    repeat this if
end if

if flag 59 = 2
and timer 59 >= 30000
and playeralliance = globex
    createunit 1 playernumber omnithias vector(1000*playernumber,0,0) 0 85 0 -1 0
    reset timer 59
    set flag 59 to 0
    repeat this if
end if

if flag 59 = 2
and timer 59 >= 30000
and playeralliance = sdf
    createunit 1 playernumber sdfscout vector(1000*playernumber,0,0) 0 85 0 -1 0
    reset timer 59
    set flag 59 to 0
    repeat this if
end if

*** BLUE TEAM RESET - ENDS

*** RED TEAM RESET - STARTS

--BELOW: "red" team is reset
--(all of their units will be erased, forcing them to start from scratch)
--as before, flag 40 will hold the player's team (1 = blue, 2 = red)
if flag 68 = 1
and timer 68 >= 10000
and flag 40 = 2
    set flag 68 to 0
    set flag 69 to 1
    repeat this if
end if

if flag 68 = 1
and timer 68 >= 10000
    set flag 68 to 0
    repeat this if
end if

--BELOW: local unit deletion code
if flag 69 = 1
    reset timer 69
    set flag 69 + 1
    setunitstate 1 playernumber all 69 0 -1
    repeat this if
end if

--BELOW: create a new starting unit 30 seconds later:
if flag 69 = 2
and timer 69 >= 25000
and timer 101 >= 60000
    playglobalsound 2 99 computer231
    comsatline Computer: Get ready. rgb(255,255,0)
    reset timer 101
    repeat this if
end if

if flag 69 = 2
and timer 69 >= 30000
and playeralliance = fta
    createunit 1 playernumber epsilon vector(1000*playernumber,0,0) 0 85 0 -1 0
    reset timer 69
    set flag 69 to 0
    repeat this if
end if

if flag 69 = 2
and timer 69 >= 30000
and playeralliance = globex
    createunit 1 playernumber omnithias vector(1000*playernumber,0,0) 0 85 0 -1 0
    reset timer 69
    set flag 69 to 0
    repeat this if
end if

if flag 69 = 2
and timer 69 >= 30000
and playeralliance = sdf
    createunit 1 playernumber sdfscout vector(1000*playernumber,0,0) 0 85 0 -1 0
    reset timer 69
    set flag 69 to 0
    repeat this if
end if

*** RED TEAM RESET - ENDS

if timer 65 >= 5000
    reset timer 65
    repeat this if
end if

*** ALL CHECK POINTS HAVE BEEN CAPTURED - ENDS
*** ALL CHECK POINTS HAVE BEEN CAPTURED - ENDS

***** ALERTS AND SOUNDS - START
***** ALERTS AND SOUNDS - START

--BELOW: any player can request to see the latest score by
--sending a chat/com-sat message which contains the word "score"
--(this check will only be performed by Player 1, and will be permitted
--only once every 5 seconds)
if playernumber = 1
and timer 99 >= 5000
and lastchat contains score
    reset timer 99
    set flag 99 to 1
--BELOW: we clear the info from the last COM-SAT chat message
--otherwise this IF statement will be executed again:
    clear lastchat
    repeat this if
end if

--BELOW: flag 99 will send the latest score to the COM-SAT:
if flag 99 = 1
and playernumber = 1
    network comsatline >>> SCORE: Blue Team: flag[101] wins, Red Team: flag[102] wins rgb(255,255,0)
--BELOW: create new info for the Recon section of the hud
--(the "network" prefix is used so that information is visible to all players)
--also note that the same "tactical window" color codes are used the "recon" window
--(see any of the entries in the tactical database for more info)
    network clear recontext
    network recontext
    network recontext @SCORE @AND @ROUND @INFORMATION
    network recontext
    network recontext Current Round: flag[103]
    network recontext
    network recontext Blue Team: flag[101] wins
    network recontext Red Team: flag[102] wins
    network recontext
--BELOW: make sure that the recon text is refreshed, even if the recon window is already visible:
    network refreshrecontext
    network highlighthud recon
    set flag 99 to 0
    repeat this if
end if

if flag 2 = 0
and flag 1 >= 10
    reset timer 2
end if

if flag 2 = 0
and flag 1 >= 10
and timer 2 >= 5000
and soundchannel 2 is free
    playglobalsound 2 99 computer012
    comsatline Computer: Sector sync confirmed. rgb(255,255,0)
    reset timer 2
    set flag 2 + 1
end if

if flag 2 = 1
and flag 40 = 1
and timer 2 >= 100
and soundchannel 2 is free
    playglobalsound 2 99 computer201
    comsatline Computer: Team designation: blue rgb(255,255,0)
    reset timer 2
    set flag 2 + 1
end if

if flag 2 = 1
and flag 40 = 2
and timer 2 >= 100
and soundchannel 2 is free
    playglobalsound 2 99 computer202
    comsatline Computer: Team designation: red rgb(255,255,0)
    reset timer 2
    set flag 2 + 1
end if

*** CHECKPOINT ACQUIRE ALERT - STARTS

--BELOW: blue team is capturing checkpoint 1, while the
--red team has no claim on it:
if playernumber = 1
and timer 81 >= 10000
and flag 81 = 1
and flag 91 = 0
and flag 41 = 0
    set flag 41 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer203
    network [1,3,5,7,9] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer204
    network [2,4,6,8,10] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(100104,413205,172) 30000
    reset timer 81
    repeat this if
end if

--BELOW: red team is capturing checkpoint 1, while the
--blue team has no claim on it:
if playernumber = 1
and timer 81 >= 10000
and flag 91 = 1
and flag 81 = 0
and flag 41 = 0
    set flag 41 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer204
    network [1,3,5,7,9] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer203
    network [2,4,6,8,10] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(100104,413205,172) 30000
    reset timer 81
    repeat this if
end if

--BELOW: blue team is capturing checkpoint 2, while the
--red team has no claim on it:
if playernumber = 1
and timer 82 >= 10000
and flag 82 = 1
and flag 92 = 0
and flag 42 = 0
    set flag 42 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer203
    network [1,3,5,7,9] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer204
    network [2,4,6,8,10] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(107464,136866,172) 30000
    reset timer 82
    repeat this if
end if

--BELOW: red team is capturing checkpoint 2, while the
--blue team has no claim on it:
if playernumber = 1
and timer 82 >= 10000
and flag 92 = 1
and flag 82 = 0
and flag 42 = 0
    set flag 42 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer204
    network [1,3,5,7,9] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer203
    network [2,4,6,8,10] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(107464,136866,172) 30000
    reset timer 82
    repeat this if
end if

--BELOW: blue team is capturing checkpoint 3, while the
--red team has no claim on it:
if playernumber = 1
and timer 83 >= 10000
and flag 83 = 1
and flag 93 = 0
and flag 43 = 0
    set flag 43 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer203
    network [1,3,5,7,9] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer204
    network [2,4,6,8,10] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(395567,150698,172)30000
    reset timer 83
    repeat this if
end if

--BELOW: red team is capturing checkpoint 3, while the
--blue team has no claim on it:
if playernumber = 1
and timer 83 >= 10000
and flag 93 = 1
and flag 83 = 0
and flag 43 = 0
    set flag 43 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer204
    network [1,3,5,7,9] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer203
    network [2,4,6,8,10] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(395567,150698,172) 30000
    reset timer 83
    repeat this if
end if

--BELOW: blue team is capturing checkpoint 4, while the
--red team has no claim on it:
if playernumber = 1
and timer 84 >= 10000
and flag 84 = 1
and flag 94 = 0
and flag 44 = 0
    set flag 44 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer203
    network [1,3,5,7,9] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer204
    network [2,4,6,8,10] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(376893,414847,172) 30000
    reset timer 84
    repeat this if
end if

--BELOW: red team is capturing checkpoint 4, while the
--blue team has no claim on it:
if playernumber = 1
and timer 84 >= 10000
and flag 94 = 1
and flag 84 = 0
and flag 44 = 0
    set flag 44 to 1
--BELOW: to be executed by players on the blue team:
    network [1,3,5,7,9] playglobalsound 2 99 computer204
    network [1,3,5,7,9] comsatline Computer: The enemy is acquiring, our checkpoint. rgb(255,255,0)
--BELOW: to be executed by players on the red team:
    network [2,4,6,8,10] playglobalsound 2 99 computer203
    network [2,4,6,8,10] comsatline Computer: Acquiring checkpoint. rgb(255,255,0)
--BELOW: to be executed by all players:
    network radarbeacon 1 vector(376893,414847,172) 30000
    reset timer 84
    repeat this if
end if

*** CHECKPOINT ACQUIRE ALERT - ENDS

*** DOMINATION CHECK - STARTS

--BELOW: blue team has won the round
if flag 104 = 1
and soundchannel 2 is free
    playglobalsound 2 99 computer211
    comsatline Computer: Blue team is victorious. rgb(255,255,0)
    set flag 104 to 10
    repeat this if
end if

--BELOW: red team has won the round
if flag 104 = 2
and soundchannel 2 is free
    playglobalsound 2 99 computer212
    comsatline Computer: Red team is victorious. rgb(255,255,0)
    set flag 104 to 10
    repeat this if
end if

if flag 104 = 10
and soundchannel 2 is free
    playglobalsound 2 99 computer228
    comsatline Computer: New round-begins in 30 seconds. rgb(255,255,0)
    set flag 104 + 1
    repeat this if
end if

--BELOW: blue team is dominating:
if flag 104 = 11
and soundchannel 2 is free
and flag[101] > flag[102]+1
    playglobalsound 2 99 computer215
    comsatline Computer: Blue team is dominating. rgb(255,255,0)
    set flag 104 + 1
    repeat this if
end if

--BELOW: red team is dominating:
if flag 104 = 11
and soundchannel 2 is free
and flag[102] > flag[101]+1
    playglobalsound 2 99 computer216
    comsatline Computer: Red team is dominating. rgb(255,255,0)
    set flag 104 + 1
    repeat this if
end if

*** DOMINATION CHECK - ENDS

***** ALERTS AND SOUNDS - END
***** ALERTS AND SOUNDS - END

******** CHECKPOINTS - END
******** CHECKPOINTS - END

******** OTHER LEVEL SAMPLES - START
******** OTHER LEVEL SAMPLES - START

if flag 1 = 10
and flag 2 >= 2
and timer 1 >= 5000
and soundchannel 2 is free
and soundchannel 1 is free
    set flag 1 to 12
    reset timer 1
end if

if flag 1 = 12
and soundchannel 1 is free
    playglobalsound 1 99 blairdo001
    comsatline >> Col. Blair: Commander ... welcome back to: Domination! rgb(255,255,255)
    set flag 1 + 1
end if

if flag 1 = 13
and soundchannel 1 is free
    playglobalsound 1 99 blairdo002
    comsatline >> Col. Blair: Head on over to the Tasks menu of your HUD if you require more info, otherwise, I will assume you are aware of the basics. rgb(255,255,255)
    set flag 1 + 1
end if

if flag 1 = 14
and soundchannel 1 is free
    highlighthud tasks
    set flag 1 + 1
end if

--BELOW: Blair tell player more about the level:
if timer 99 >= 5000
and flag 1 >= 14
and lastbuttonclicked tasks show
--BELOW: we clear the info from the last HUD button click
--otherwise this IF statement will be executed again:
    clear lastbuttonclicked
    set flag 1 to 20
    reset timer 99
    repeat this if
end if

if flag 1 = 20
and soundchannel 1 is free
    playglobalsound 1 99 blairdo003
    comsatline >> Col. Blair: Alright Commander ... there are quite a few rules and objectives for you to keep in mind, so make sure you are paying attention. rgb(255,255,255)
    set flag 1 + 1
end if

if flag 1 = 21
and soundchannel 1 is free
    playglobalsound 1 99 blairdo004
    comsatline >> Col. Blair: You and your ships will be assigned to one of two teams: either Blue or Red. It is your goal to capture each of the checkpoints located throughout this sector on behalf of your team. rgb(255,255,255)
    set flag 1 + 1
end if

if flag 1 = 22
and soundchannel 1 is free
    playglobalsound 1 99 blairdo005
    comsatline >> Col. Blair: Once all checkpoints are secured, any remaining units in the sector will be erased, and a new round will begin. Also, if your team's score visibly surpasses your enemy's, you will begin to dominate the opposing team. rgb(255,255,255)
    set flag 1 + 1
end if

--BELOW: the sample is only played the player is a host:
if flag 1 = 23
and playernumber = 1
and soundchannel 1 is free
    playglobalsound 1 99 blairdo006
    comsatline >> Col. Blair: Lastly ... if no human opponents join the map, the Globex drones will be more than happy to keep you busy. rgb(255,255,255)
    set flag 1 + 1
end if

if flag 1 = 23
and playernumber <> 1
and soundchannel 1 is free
    set flag 1 + 1
end if

if flag 1 = 24
and soundchannel 1 is free
    playglobalsound 1 99 blairdo007
    comsatline >> Col. Blair: The Recon menu will have further details Commander ... Now get to it! rgb(255,255,255)
    highlighthud recon
    set flag 1 + 1
end if

******** OTHER LEVEL SAMPLES - END
******** OTHER LEVEL SAMPLES - END

--------------
-- 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
    randomize music
    reset timer 2
end if

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

******** GLOBEX AI - STARTS
******** GLOBEX AI - STARTS

--NOTICE: all of the Globex AI units will belong to Player 10
--and will be automatically erased if other human players join the game

--BELOW: if the round started at least 2 minutes ago
--and there are no active human players in the game except for the host (Player 1)
--(the syntax of the command used is: "playerisactive playernumber = true")
if playernumber = 1
and timer 3 >= 60000*2
and flag 3 = 0
and playerisactive 2 = false
and playerisactive 3 = false
and playerisactive 4 = false
    set flag 3 to 1
    reset timer 6
    repeat this if
end if

--BELOW: spawn the AI units if they do not yet exist:
if flag 3 = 1
and soundchannel 1 is free
    network playglobalsound 1 99 computer018
    network comsatline Computer: New threat detected. rgb(255,255,0)
    createunit 1 10 forsydon vector(490702,493330,500) -47 82 0 -1 0
    createunit 1 10 forsydon vector(490702,493330,500) -47 82 0 -1 0
    createunit 1 10 agomenmon vector(490702,493330,500) -47 82 0 -1 0
    createunit 1 10 agomenmon vector(490702,493330,500) -47 82 0 -1 0
    network dropcam 1 10 1 60000 2
    network radarbeacon 1 lastvector 60000
    set flag 3 to 10
    reset timer 4
    repeat this if
end if

--BELOW: if CHECKPOINT 4 does not belong to the red team
--set a course toward it
if flag 3 = 10
and timer 4 >= 10000
and flag 54 <> 2
    setunitdestination 1 10 all vector(376893,414847,172)
    set flag 3 to 11
    reset timer 4
    repeat this if
end if

--BELOW: if CHECKPOINT 1 does not belong to the red team
--set a course toward it
if flag 3 = 10
and timer 4 >= 10000
and flag 51 <> 2
    setunitdestination 1 10 all vector(100104,413205,172)
    set flag 3 to 11
    reset timer 4
    repeat this if
end if

--BELOW: if CHECKPOINT 2 does not belong to the red team
--set a course toward it
if flag 3 = 10
and timer 4 >= 10000
and flag 52 <> 2
    setunitdestination 1 10 all vector(107464,136866,172)
    set flag 3 to 11
    reset timer 4
    repeat this if
end if

--BELOW: if CHECKPOINT 3 does not belong to the red team
--set a course toward it
if flag 3 = 10
and timer 4 >= 10000
and flag 53 <> 2
    setunitdestination 1 10 all vector(395567,150698,172)
    set flag 3 to 11
    reset timer 4
    repeat this if
end if

--BELOW: reset timer 4 in the event that the above IF statements did not execute
if timer 4 >= 10000
and flag 3 >= 10
and flag 3 <= 20
    set flag 3 to 10
    reset timer 4
    repeat this if
end if

--BELOW: if Player 2 is an active human player, stop the AI cycle:
if timer 5 >= 10000
and timer 6 >= 60000*1
and playerisactive 2 = true
and flag 3 >= 10
and flag 3 <= 20
    set flag 3 to 30
    repeat this if
end if

--BELOW: if Player 3 is an active human player, stop the AI cycle:
if timer 5 >= 10000
and timer 6 >= 60000*1
and playerisactive 3 = true
and flag 3 >= 10
and flag 3 <= 20
    set flag 3 to 30
    repeat this if
end if

--BELOW: if Player 4 is an active human player, stop the AI cycle:
if timer 5 >= 10000
and timer 6 >= 60000*1
and playerisactive 4 = true
and flag 3 >= 10
and flag 3 <= 20
    set flag 3 to 30
    repeat this if
end if

--BELOW: if the Globex AI lost all of it's units, then reset the cycle
if timer 5 >= 10000
and timer 6 >= 60000*1
and flag 3 >= 10
and flag 3 <= 20
and totalplayerunits 1 10 <= 0
    set flag 3 to 0
    reset timer 3
    reset timer 4
    reset timer 5
    repeat this if
end if

--BELOW: reset timer 5 (used by above events)
if timer 5 >= 10000
and flag 3 >= 10
and flag 3 <= 20
    reset timer 5
    repeat this if
end if

--BELOW: trigger the stop of the AI cycle since there are other human players in the game
if flag 3 = 30
    set flag 3 to 0
--BELOW: kill all of the AI units:
    setunitstate 1 10 all 69 0 -1
    reset timer 3
    reset timer 4
    reset timer 5
    repeat this if
end if

if playernumber = 1
and sinceenemyjump <= 10000
and timer 10 >= 15000
    network playglobalsound 2 99 computer022
    network comsatline Computer: New jump signature detected. rgb(255,255,0)
    reset timer 10
    repeat this if
end if

******** GLOBEX AI - ENDS
******** GLOBEX AI - ENDS
