--Devron Expanse

**** SKIP FRAMES OF ANIMATION - STARTS

--BELOW: establish the initial level rules:
if flag 1 = 0
    settechlevel 1 player [0,1,2,3,4,5,6,7,8,9,11,12,13,14,16,17,18,19,20]
    playercantarget 1 1 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 2 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 3 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 4 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 5 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 6 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 7 [1,2,3,4,5,6,7,8,10]
    playercantarget 1 8 [1,2,3,4,5,6,7,8,10]
--BELOW: Player 10 is used to by the SDF AI units
--who cannot attack the players at first:
    playercantarget 1 10 [0]
    setmaxunits 1 player 15
    setplayermoney 1 player 10000
    cleartasks all playernumber
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

**** PRIMARY SCRIPT FUNCTIONS - START

if flag 1 = 10
and timer 1 >= 2000
and soundchannel 1 is free
--BELOW: turn on the movement of the SDF ship:
    set flag 3 to 1
    playglobalsound 1 99 computer011
    comsatline Computer: New task confirmed. rgb(255,255,0)
    addtask all playernumber sdf_assault pending primary engage SDF forces and survive their assault.
end if

**** PRIMARY SCRIPT FUNCTIONS - END

**** SDF AI - STARTS

--all SDF related command will only be performed by the server (Player 1)

--BELOW: move the SDF ship every 5 minutes around the perimeter of the level:
if flag 3 = 1
and playernumber = 1
and timer 3 >= 60000*5
and totalactiveunits 1 10 >= 1
    setunitdestination 1 10 1 vector(442805,442068,1245)
    reset timer 3
    set flag 3 + 1
    repeat this if
end if

if flag 3 = 2
and playernumber = 1
and timer 3 >= 60000*5
and totalactiveunits 1 10 >= 1
    setunitdestination 1 10 1 vector(466068,93496,1254)
    reset timer 3
    set flag 3 + 1
    repeat this if
end if

if flag 3 = 3
and playernumber = 1
and timer 3 >= 60000*5
and totalactiveunits 1 10 >= 1
    setunitdestination 1 10 1 vector(135443,74308,1239)
    reset timer 3
    set flag 3 + 1
    repeat this if
end if

if flag 3 = 4
and playernumber = 1
and timer 3 >= 60000*5
and totalactiveunits 1 10 >= 1
    setunitdestination 1 10 1 vector(87778,402103,1251)
    reset timer 3
    set flag 3 to 1
    repeat this if
end if

--BELOW: check SDF ship's health
--if the cruiser has been attacked, then allow it to attack all active players
--in the game:
if flag 3 >= 1
and playernumber = 1
and timer 4 >= 10000
and totalactiveunits 1 10 >= 1
and unithealth 1 10 1 <= 99%
    set flag 3 to 0
    set flag 5 to 1
    set flag 10 to 1
    reset timer 10
--BELOW: with the "network" prefix, the drop-cam command will
--be executed by all active players in the game:
    network dropcam 1 10 1 60000 2
    network playglobalsound 1 99 computer041
    network comsatline Computer: All units, fire at will. rgb(255,255,0)
    repeat this if
end if

if flag 3 >= 1
and playernumber = 1
and timer 4 >= 10000
    reset timer 4
    repeat this if
end if

--BELOW: primary SDF attack code:
if flag 5 = 1
and playernumber = 1
and timer 5 >= 15000
--BELOW: allow Player 10 to attack all other players
--the command is triggered with a "network" prefix, thus it will
--affect all active players in the game (and not just the host)
    network playercantarget 1 10 [1,2,3,4,5,6,7,8]
--BELOW: there is no need to use the "network" prefix for the "setai" command
--since the host is responsible for all non-active and non-human players in the game:
    setai 1 10 1 100
    repeat this if
end if

--BELOW: if SDF is defeated, then spawn a new cruiser in 2 minutes:
if flag 6 = 0
and playernumber = 1
and timer 5 >= 15000
and totalplayerunits 1 10 <= 0
--BELOW: assign flag 6 to a random number between 1 and 4:
    set flag 6 to random(4)
    reset timer 6
    network playglobalsound 2 99 computer018
    network comsatline Computer: new threat detected. rgb(255,255,0)
    repeat this if
end if

if playernumber = 1
and timer 5 >= 15000
    reset timer 5
    repeat this if
end if

--BELOW: spawn an SDF ship in one of 4 locations around the map:
if flag 6 = 1
and playernumber = 1
and timer 6 >= 60000*2
    createunit 1 10 sdfdestroyer vector(442805,442068,1245) 0 82 0 -1 0
    network radarbeacon 1 lastvector 60000
    set flag 6 to 10
    reset timer 6
    repeat this if
end if

if flag 6 = 2
and playernumber = 1
and timer 6 >= 60000*2
    createunit 1 10 sdfdestroyer vector(466068,93496,1254) 0 82 0 -1 0
    network radarbeacon 1 lastvector 60000
    set flag 6 to 10
    reset timer 6
    repeat this if
end if

if flag 6 = 3
and playernumber = 1
and timer 6 >= 60000*2
    createunit 1 10 sdfdestroyer vector(135443,74308,1239) 0 82 0 -1 0
    network radarbeacon 1 lastvector 60000
    set flag 6 to 10
    reset timer 6
    repeat this if
end if

if flag 6 = 4
and playernumber = 1
and timer 6 >= 60000*2
    createunit 1 10 sdfdestroyer vector(87778,402103,1251) 0 82 0 -1 0
    network radarbeacon 1 lastvector 60000
    set flag 6 to 10
    reset timer 6
    repeat this if
end if

--BELOW: make sure the SDF ship has appeared in the game:
if flag 6 = 10
and playernumber = 1
and timer 6 >= 20000*1
and totalactiveunits 1 10 >= 1
    network dropcam 1 10 1 60000 2
    set flag 6 to 0
    reset timer 6
    repeat this if
end if

**** SDF AI - 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 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_devron

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 "blue" variation of the radar is used
load minimap minimapblue
processtexture inner_radar inner_radar_blue
processtexture radarring_a radarring_a_blue
processtexture radarring_b radarring_b_blue
processtexture minimapcamerabox minimapcamerabox_white

--BELOW: since we are using a "blue" tint on the radar
--we change the radar mini-map color of Player 1 to a lighter shade of blue:
set minimapplayercolor 1 rgb(0,255,255)

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

createmodel player17 spaceresource vector(279540,315630,0) 0 1.5000 [1]
createmodel player17 spaceresource vector(280004,244433,0) 136 1.5000 [1]
createmodel player17 spaceresource vector(318658,278805,0) 74 1.5000 [1]
createmodel player17 spaceresource vector(239015,278424,0) -58 1.5000 [1]
createmodel player17 spaceresource vector(110979,463975,0) 114 1.5000 [1]
createmodel player17 spaceresource vector(434072,461679,0) -6 1.5000 [1]
createmodel player17 spaceresource vector(103004,127495,0) -84 1.5000 [1]
createmodel player17 spaceresource vector(426506,123366,0) 131 1.5000 [1]

createmodel player9 asteroid vector(284553,-176067,0) -137 61.9134 [1]
--createmodel player9 asteroidbelt vector(284476,4044,-117010) -81 129.7464 [1]

--BELOW: Gas Giant planet: Devron (which uses the Saltus planet model)
createmodel player9 planet_saltus vector(142654,1407241,-444072) -70 45.6186 [1]
--BELOW: this version of the space sky-box will spin in the opposite direction:
createmodel player9 skybox_spacereverse vector(175792,206215,0) -157 9384.3135 [1]

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

--BELOW: replace the default "red grid" of the landscape/sector with a "blue" variation
--processtexture texture_largespace spacegrid_2048_blue

--BELOW: replace the Saltus planet texture with the one used by Devron:
processtexture chrome_planet texture_devron

--BELOW: replace the Saltus sky/clouds with the ones used by Devron:
processtexture texture_planetclouds devron_sky

--BELOW: replace the Saltus atmosphere halo with the ones used by Devron:
processtexture flare_planethalo devron_halo

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

--BELOW: default camera position for all players
positioncamera vector(2.82813e5,2.33508e5,-100.0000) vector(0.0000,0.0000,39.9454) vector(0.0000,-2.70000e4,1.39274e4) vector(0.0000,0.0000,0.0000)

--BELOW: specific camera positions for Players 1 through 6
--the only difference in the syntax of the "positioncamera" fuction, is the addition
--of the player number at the end of the command:
positioncamera1 vector(9.62740e4,1.31041e5,-100.0000) vector(0.0000,0.0000,-23.6163) vector(0.0000,-3.58421e4,2.08164e4) vector(0.0000,0.0000,0.0000)
positioncamera2 vector(1.12057e5,4.50015e5,-100.0000) vector(0.0000,0.0000,-39.9762) vector(0.0000,-3.27600e4,2.11090e4) vector(0.0000,0.0000,0.0000)
positioncamera3 vector(4.39132e5,4.48869e5,-100.0000) vector(0.0000,0.0000,43.7496) vector(0.0000,-3.42000e4,1.95021e4) vector(0.0000,0.0000,0.0000)
positioncamera4 vector(4.16694e5,1.20296e5,-100.0000) vector(0.0000,0.0000,29.1601) vector(0.0000,-3.71053e4,2.06435e4) vector(0.0000,0.0000,0.0000)
positioncamera5 vector(3.05863e5,3.10791e5,-100.0000) vector(0.0000,0.0000,41.8058) vector(0.0000,-4.00909e4,2.28618e4) vector(0.0000,0.0000,0.0000)
positioncamera6 vector(2.60258e5,2.28856e5,-100.0000) vector(0.0000,0.0000,14.2733) vector(0.0000,-3.46364e4,2.13101e4) vector(0.0000,0.0000,0.0000)

--BELOW: the AI SDF ship will reside on the side of Player 10:
createmodel player10 sdfdestroyer vector(320862,109747,4965) -109 1 [1]

set screensize 100 0
fadehud instantout

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

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

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

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

if flag 1 = 20
and soundchannel 1 is free
    playglobalsound 1 99 blairdm013
    comsatline >> Col. Blair: Commander, the SDF destroyers are actively patrolling this sector of space. My advice is ... stay out of their way, and they will stay out of yours. rgb(255,255,255)
    set flag 1 + 1
end if

if flag 1 = 21
and soundchannel 1 is free
    network dropcam 1 10 1 60000 1
    set flag 1 + 1
    highlighthud tasks
end if

if flag 10 = 1
and timer 10 >= 5000
and soundchannel 1 is free
and soundchannel 2 is free
    playglobalsound 1 99 blairdm014
    comsatline >> Col. Blair: Commander, based on your hostile actions, the Defense Force have lifted their ceasefire. I just hope you are prepared to finish what you've started ... rgb(255,255,255)
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

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