--Deep Space Delta

**** 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]
    setplayermoney 1 player 9000
    setmaxunits 1 player 15
    playercantarget 1 1 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 2 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 3 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 4 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 5 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 6 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 7 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
    playercantarget 1 8 [1,2,3,4,5,6,7,8,10,11,12,13,14,15]
--BELOW: Player 10 is used to by the Globex AI units:
    playercantarget 1 10 [1,2,3,4,5,6,7,8,11,12,13,14,15]
    cleartasks all playernumber
    network addtask 1 playernumber detached_patrol pending primary detached patrol - your mission is at your own discretion
    reset timer 1
    reset timer 3
    reset timer 4
    reset timer 5
    reset timer 6
 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

**** BASIC AI - STARTS
**** BASIC AI - STARTS

--BELOW: 10 minutes into the game, allow the AI units to actively seek and attack the player
if timer 3 >= 60000*10
and timer 6 >= 20000
and playernumber = 1
    setai 1 10 1 100
    reset timer 6
    repeat this if
end if

if timer 4 >= 60000*10
and playernumber = 1
    network playglobalsound 1 99 computer018
    network comsatline Computer: New threat detected. rgb(255,255,0)
    network dropcam 1 10 1 60000 2
    network radarbeacon 1 vector(490702,493330,500) 60000
    network radarbeacon 1 vector(484498,77079,500) 60000
    network radarbeacon 1 vector(92436,472912,1667) 60000
    reset timer 5
end if

--BELOW: if all of the AI units have been destroyed, create new ones
if timer 5 >= 60000*5
and playernumber = 1
and totalplayerunits 1 10 <= 0
    network playglobalsound 1 99 computer018
    network comsatline Computer: New threat detected. rgb(255,255,0)
    createunit 1 10 centuras vector(490702,493330,500) -47 82 0 -1 0
    createunit 1 10 centuras vector(482256,497531,500) -47 82 0 -1 0
    createunit 1 10 centuras vector(491790,484892,500) -47 82 0 -1 0
    createunit 1 10 centuras vector(484498,77079,500) -47 82 0 -1 0
    createunit 1 10 centuras vector(477261,73366,500) -47 82 0 -1 0
    createunit 1 10 centuras vector(469702,68216,500) -47 82 0 -1 0
--    createunit 1 10 agomenmon vector(92436,472912,1667) -47 82 0 -1 0
--    createunit 1 10 agomenmon vector(100136,474897,1667) -47 82 0 -1 0
--    createunit 1 10 agomenmon vector(107142,476472,1667) -47 82 0 -1 0
    network radarbeacon 1 vector(490702,493330,500) 60000
    network radarbeacon 1 vector(484498,77079,500) 60000
--    network radarbeacon 1 vector(92436,472912,1667) 60000
    set flag 5 to 1
    reset timer 5
    repeat this if
end if

if flag 5 = 1
and playernumber = 1
and totalplayerunits 1 10 >= 4
    network dropcam 1 10 1 60000 2
    set flag 5 to 0
    repeat this if
end if

**** BASIC AI - ENDS
**** BASIC AI - ENDS

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

if flag 1 = 10
and timer 1 >= 5000
and soundchannel 2 is free
and soundchannel 1 is free
    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 blairdm005
    comsatline >> Col. Blair: Commander, I do not currently have any direct orders for this specific region of space. Your mission is at your discretion. Good luck. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

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

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

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: since we are using a "red" tint on the radar
--we change the radar mini-map color of Player 2 to a lighter shade of red:
set minimapplayercolor 2 rgb(252,118,118)

--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 player9 planet_saltus vector(280880,285962,-111288) 82 7.4100 [1]
createmodel player9 planet_star vector(67110,103969,-90672) 12 3.3750 [1]
createmodel player9 asteroidbelt vector(615165,639564,-150117) 45 114.9210 [1]

createmodel player17 spaceresource vector(77992,473226,0) -69 1 [1]
createmodel player17 spaceresource vector(487820,478301,0) 56 1 [1]
createmodel player17 spaceresource vector(494838,85852,0) -125 1 [1]
createmodel player17 spaceresource vector(170406,96412,0) -115 1 [1]
createmodel player17 spaceresource vector(145414,164021,0) -164 1 [1]
createmodel player17 spaceresource vector(89232,195226,0) 68 1 [1]
createmodel player17 spaceresource vector(414680,286343,0) -129 1 [1]
createmodel player17 spaceresource vector(287825,418523,0) -136 1 [1]
createmodel player17 spaceresource vector(330349,110228,0) -100 1 [1]
createmodel player17 spaceresource vector(136758,365799,0) -31 1 [1]

--BELOW: Globex AI units:
createmodel player10 centuras vector(490702,493330,500) -47 1 [1]
createmodel player10 centuras vector(482256,497531,500) -47 1 [1]
createmodel player10 centuras vector(491790,484892,500) -47 1 [1]
createmodel player10 centuras vector(484498,77079,500) -146 1 [1]
createmodel player10 centuras vector(477261,73366,500) -146 1 [1]
createmodel player10 centuras vector(469702,68216,500) -146 1 [1]
createmodel player10 agomenmon vector(92436,472912,1667) 45 1 [1]
createmodel player10 agomenmon vector(100136,474897,1667) 45 1 [1]
createmodel player10 agomenmon vector(107142,476472,1667) 45 1 [1]

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

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

--BELOW: this statement will replace the Saltus star texture with the alternate version
--if this line is used, the alternate texture will be used at all times regardless of the unit's temporal mod
processtexture chrome_star chrome_star_temporalmod2

--BELOW: replace the Saltus planet texture with the one used by Deep Space Delta:
processtexture chrome_planet texture_deepdelta

--BELOW: replace the Saltus sky/clouds with the ones used by Deep Space Delta:
processtexture texture_planetclouds planetdelta_sky

--BELOW: replace the Saltus atmosphere halo with the ones used by the Deep Space Delta:
processtexture flare_planethalo planetdelta_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: generic camera position
positioncamera vector(3.67935e5,3.49880e5,-100.0000) vector(0.0000,0.0000,151.6530) vector(0.0000,-4.20000e4,2.05124e4) vector(0.0000,0.0000,0.0000)

--BELOW: specific camera positions for players 1 through 4
positioncamera1 vector(2.91584e5,4.16263e5,-100.0000) vector(0.0000,0.0000,143.2853) vector(0.0000,-3.88462e4,2.16754e4) vector(0.0000,0.0000,0.0000)
positioncamera2 vector(1.53666e5,1.63423e5,-100.0000) vector(0.0000,0.0000,-11.8662) vector(0.0000,-3.88462e4,2.16754e4) vector(0.0000,0.0000,0.0000)
positioncamera3 vector(4.12812e5,2.94472e5,-100.0000) vector(0.0000,0.0000,106.4097) vector(0.0000,-3.88462e4,2.16754e4) vector(0.0000,0.0000,0.0000)
positioncamera4 vector(1.29380e5,3.62953e5,-100.0000) vector(0.0000,0.0000,170.9268) vector(0.0000,-3.88462e4,2.16754e4) 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 **************

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

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

if soundchannel 1 is free
and unitstate 1 < 80
and unithealth 1 < 90%
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    reset timer 1
end if

if soundchannel 1 is free
and unitstate 1 < 80
and unithealth 1 < 70%
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    reset timer 1
end if

if soundchannel 1 is free
and unitstate 1 < 80
and unithealth 1 < 50%
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    reset timer 1
end if

if soundchannel 1 is free
and unitstate 1 < 80
and unithealth 1 < 30%
    playglobalsound 2 99 computer034
    comsatline Computer: Drop-ship under fire. rgb(255,255,0)
    reset timer 1
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

*** GENERAL COMPUTER VOICE END
