--Demon Nebula

**** 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(227277,548795,950) 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 goldenboy vector(206173,562635,950) 2 82 0 -1 0
    createunit 1 10 goldenboy vector(219847,563012,950) 2 82 0 -1 0
    createunit 1 10 goldenboy vector(234614,563411,950) 2 82 0 -1 0
    createunit 1 10 goldenboy vector(249365,563014,950) 2 82 0 -1 0
    createunit 1 10 goldenboy vector(213345,547698,950) 2 82 0 -1 0
    createunit 1 10 goldenboy vector(227277,548795,950) 2 82 0 -1 0
    createunit 1 10 goldenboy vector(242325,548491,950) 2 82 0 -1 0
    network radarbeacon 1 vector(227277,548795,950) 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 blairdm007
    comsatline >> Col. Blair: Commander, I've come to realized that attempting to stay awake as you stumble around in the pointless vastness of space is more of a challenge than I initially predicted. If anyone wants me, I'll be passed out in the officer's lounge on deck 4. rgb(255,255,255)
    set flag 1 + 1
    reset timer 1
end if

--BELOW: if player's drop-ship is under fire
if soundchannel 1 is free
and unitstate 1 < 80
and unithealth 1 < 85%
    playglobalsound 1 99 blairdm007b
    comsatline >> Col. Blair: What the? ... Another haul breach? Commander ... you woke up for this? Get Epsilon repaired as soon as possible ... In the mean time, I'll do my best to drown out the sound of your incompetence ... Blair out. rgb(255,255,255)
    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_demon

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

--BELOW: the star behind the Demon Planet:
createmodel player9 planet_star vector(1094723,2385525,-1437370) -97 16.6860 [1]
--BELOW: the star at the bottom of the sector:
createmodel player9 planet_star vector(220044,-11453,-140510) 46 2.9893 [1]
--BELOW: Demon Planet (which uses the Saltus planet model)
createmodel player9 planet_saltus vector(215051,745104,-426745) 131 18.8587 [1]

createmodel player17 spaceresource vector(477085,451534,0) -79 2.2500 [1]
createmodel player17 spaceresource vector(66942,458899,0) 178 1.5000 [1]
createmodel player17 spaceresource vector(267029,401792,0) 61 1.5000 [1]
createmodel player17 spaceresource vector(132429,300221,0) 81 1 [1]
createmodel player17 spaceresource vector(371703,274738,0) 145 1.5000 [1]
createmodel player17 spaceresource vector(264631,178438,0) 180 1.5000 [1]
createmodel player17 spaceresource vector(456904,71661,0) -44 1.5000 [1]
createmodel player17 spaceresource vector(86547,65390,0) 179 1.5000 [1]

--BELOW: AI units
createmodel player10 goldenboy vector(206173,562635,950) 2 1.5000 [1]
createmodel player10 goldenboy vector(219847,563012,950) 2 1.5000 [1]
createmodel player10 goldenboy vector(234614,563411,950) 2 1.5000 [1]
createmodel player10 goldenboy vector(249365,563014,950) 2 1.5000 [1]
createmodel player10 goldenboy vector(213345,547698,950) 2 1.5000 [1]
createmodel player10 goldenboy vector(227277,548795,950) 2 1.5000 [1]
createmodel player10 goldenboy vector(242325,548491,950) 2 1.5000 [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_space6

--BELOW: replace the Saltus planet texture with the one used by the Demon Planet:
processtexture chrome_planet texture_demonplanet

--BELOW: replace the Saltus sky/clouds with the ones used by the Demon Planet:
processtexture texture_planetclouds planetdemon_sky

--BELOW: replace the Saltus atmosphere halo with the ones used by the Demon Planet:
processtexture flare_planethalo planetdemon_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(2.57589e5,2.42342e5,-100.0000) vector(0.0000,0.0000,-21.4042) vector(0.0000,-2.70000e4,1.39248e4) vector(0.0000,0.0000,0.0000)

--BELOW: specific camera positions for players 1 through 6
positioncamera1 vector(2.71634e5,1.79685e5,-100.0000) vector(0.0000,0.0000,-5.6314) vector(0.0000,-3.88788e4,2.55913e4) vector(0.0000,0.0000,0.0000)
positioncamera2 vector(8.45689e4,7.53026e4,-100.0000) vector(0.0000,0.0000,-19.4862) vector(0.0000,-3.88788e4,2.55913e4) vector(0.0000,0.0000,0.0000)
positioncamera3 vector(4.64679e5,7.74299e4,-100.0000) vector(0.0000,0.0000,-2.1901) vector(0.0000,-3.88788e4,2.55913e4) vector(0.0000,0.0000,0.0000)
positioncamera4 vector(4.81203e5,4.57742e5,-100.0000) vector(0.0000,0.0000,50.9212) vector(0.0000,-3.88788e4,2.55913e4) vector(0.0000,0.0000,0.0000)
positioncamera5 vector(6.00447e4,4.55133e5,-100.0000) vector(0.0000,0.0000,-158.8132) vector(0.0000,-3.88788e4,2.55913e4) vector(0.0000,0.0000,0.0000
positioncamera6 vector(1.24768e5,2.93609e5,-100.0000) vector(0.0000,0.0000,-172.3040) vector(0.0000,-3.88788e4,2.55913e4) 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
