--Sector 185 new
clear resources from last level


--SYNOPSIS:
--Script created by Endlessvoid, on June 06, 2k6
--Flag/Timer 1  Intro/outro win/lose dialogue
--Flag/Timer 2  Resource pod depletion
--Flag/Timer 13 Player lose...end game dialogue
--Flag/Timer 19 Marks Player Difficulty Settings (redundant, but allows you the ability to increase/decrease the scripts difficulty, --"on the fly" regardless of players difficulty setting.)
--Flag/Timer 20 Linear Random Encounter Engine (aka: REG) w/ X min. repeating encounter query.
--Flag/Timer 21 Single/Multi-player REG on/off switch.
--Flag/Timer 22 Create_Base engine and task. (active player based)
--Flag/Timer 23 Used to create a forced random encounter every X minutes. (* Flag 23 unused)
--Flag/timer 24 Multi-player Super/Mega Weapon control. (active player based)
--Flag/Timer 25 Game music
--Flag/Timer 26 Computer Low Power dialogue
--Flag/Timer 31 Player Targeting
--Flag/Timer 32 Player Targeting
--Flag/Timer 33 Player Targeting
--Flag/Timer 34 Player Targeting


--RESET ALL TIMERS USED
if timer 1 >= 100
   reset timer 1
   reset timer 2
   reset timer 13
   reset timer 19
   reset timer 20
   reset timer 21
   reset timer 22
   reset timer 23
   reset timer 24
   reset timer 25
   reset timer 26
   setai 1 5 1 100
end if

--Intro Dialogue and tasks
if timer 1 >= 0
    reset timer 1
    set flag 1 to 1
    settechlevel 1 playernumber [0,1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17]
    cleartasks 1 p1real
    addtask 1 p1real defend_dropship pending primary  protect your drop-ship at all costs
    addtask 1 p1real create_base pending primary establish and maintain a preliminary base of operations.
    addtask 1 p1real deplete_resources pending primary  deplete all the resource pods in this sector. 
end if

if flag 1 = 1
and timer 1 >= 5000
and soundchannel 1 is free
    playglobalsound 1 99 computer001
    comsatline Computer: Approach vector confirmed. rgb(255,255,0)
    set flag 1 to 2
    reset timer 1
end if

if flag 1 = 2
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer031
    comsatline Computer: Weather conditions stable. rgb(255,255,0)
    set flag 1 to 3
    reset timer 1
end if

if flag 1 = 3
and timer 1 >= 1000
    playglobalsound 1 99 blair_multi184_001
    comsatline >> Col. Blair: Helm, keep us steady on the initial approach... I want us to be in one piece upon deployment. rgb(255,255,255)
    set flag 1 to 4
    reset timer 1
end if

if flag 1 = 4
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair_multi185_002
    comsatline >> Col. Blair: Welcome to sec' 185 Commander. rgb(255,255,255)
   set flag 1 to 5
   reset timer 1
end if

if flag 1 = 5
and timer 1 >= 100
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi185_003
   comsatline >> Col. Blair: Previous objectives still stand: we have been dispatched to help FTA with resource collection in the disputed zones around Saltus. rgb(255,255,255)
   set flag 1 to 6
   reset timer 1
end if

if flag 1 = 6
and timer 1 >= 100
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_004
   comsatline >> Col. Blair: This is of course where we come in. Our mission is simple; deplete all of the nearby resources in this sector and establish a defensive presence for the Alliance. rgb(255,255,255)
   set flag 1 to 7
   reset timer 1
end if

if flag 1 = 7
and timer 1 >= 100
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_005
   comsatline >> Col. Blair: Let's get those collectors working overtime Commander... the sooner we complete our task, the sooner we can get the hell out of here. rgb(255,255,255)
   highlighthud tasks
   set flag 1 to 8
   reset timer 1
end if

--Game Over
--perfect conditions for winning that must be met.
if flag 1 = 8
and flag 2 = 4
and flag 22 = 2
and timer 1 >= 100
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_016
   comsatline >> Col. Blair: I can't believe it. We've managed to pull it off!... Com, notify HQ that we have secured this sector. They can begin their initial deployment phase as soon as possible. rgb(255,2555,255)
   set flag 21 to 0
   set flag 1 to 10
   reset timer 1
end if

if flag 1 = 10
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 computer016
    comsatline Computer: Mission successful. rgb(255,255,0)
    changetask 1 p1real defend_dropship complete
    changetask 1 p1real deplete_resources complete
    changetask 1 p1real create_base complete
    highlighthud tasks
    set flag 1 to 11
    reset timer 1
end if

if flag 1 = 11
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair_multi185_017
    comsatline >> Col. Blair: Commander, we are done here!... Helm, set a course back to sec' 184, and take us out when ready. rgb(255,2555,255)
    set flag 1 to 12
    reset timer 1
end if

if flag 1 = 12
and timer 1 >= 5000
   set flag 1 to 13
   reset timer 1
end if

if flag 1 = 13
    setnewlevelname sector184
    setnewlevelscript txtSec184
    loadnewlevel
end if

--if the drop-ship is destroyed
if flag 1 = 8
and timer 1 >= 100
and unithealth 1 p1real epsilon omnithias < 1
and playerhasnounit 1 p1real epsilon omnithias
    set flag 1 to 300
    reset timer 1
end if

--player lasted more than 35 minutes
if flag 1 = 300
and timer 13 >= 2100000
and soundchannel 1 is free
    playglobalsound 1 99 blairgaun019
    comsatline >> Col. Blair: You didnt quite reach the 45 minute mark Commander, but, its a step in the right direction. Now if only you can concentrate on not dying for a change, wed be all set. Exit when ready. Blair out. rgb(255,255,255)
    set flag 1 to 301
    reset timer 1
end if

--player lasted between 25 and 34 minutes
if flag 1 = 300
and timer 13 >= 1500000
and timer 13 <= 2040000
and soundchannel 1 is free
    playglobalsound 1 99 blairgaun018
    comsatline >> Col. Blair: Youve only lasted 30 minutes Commander. That is quite pathetic, even for you. Perhaps its time to review some of the more basic tutorials, or better yet, let a real officer handle the work. Exit the simulation when ready. Ill see you back at HQ. Blair out. rgb(255,255,255)
    set flag 1 to 301
    reset timer 1
end if

--player lasted less than 20 minutes
if flag 1 = 300
and timer 13 <= 1200000
and soundchannel 1 is free
    playglobalsound 1 99 blairgaun017
    comsatline >> Col. Blair: You did not even last a lousy 20 minutes? I dont know what your thinking Commander, but in the real battle scenario, lives would have been lost. And I for one, would not put my life on the line for such a pathetic display. You may exit when ready. Blair out. rgb(255,255,255)
    set flag 1 to 301
    reset timer 1
end if

if flag 1 = 301
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 2 99 computer015
    comsatline Computer: Mission failed. rgb(255,255,0)
    changetask 1 p1real defend_dropship failed
    changetask 1 p1real create_base failed
    changetask 1 p1real deplete_resources failed
    highlighthud tasks
    set flag 1 to 302
    reset timer 1
end if

if flag 1 = 302
and timer 1 >= 100
and soundchannel 1 is free
    playglobalsound 3 99 threebeeps01
    comsatline ** Mission FAILED. Press Menu and Exit when ready. rgb(0,255,0)
    set flag 1 to 303
    reset timer 1
end if

if flag 1 = 303
and timer 1 >= 10000
    goto mission_failed
end if

--Resourcepods depleted
if flag 2 = 0
and playerhasunit 1 p1real epsilon omnithias
   set flag 2 to 1
   reset timer 2
end if

if flag 2 = 1
and timer 2 >= 100
and playerhasnounit 1 17 resourcepod
    playercantarget 1 p1real [0,p1real,5]
    playercantarget 1 5 [0]
    set flag 2 to 2
    reset timer 2
end if

if flag 2 = 2
and timer 2 >= 100
and soundchannel 1 is free
    playglobalsound 1 99 blair_multi184_007
    comsatline >> Col. Blair: Excellent work Commander! All of the resource pods in this sector have been depleted. rgb(255,255,255)
    set flag 2 to 3
    reset timer 2
end if

if flag 2 = 3
and timer 2 >= 100
and soundchannel 1 is free
    playglobalsound 3 99 null
    changetask 1 p1real deplete_resources complete
    highlighthud tasks
    set flag 2 to 4
    reset timer 2
end if

--*********************************************
--BELOW: Is a default player "create_base" task engine.

--p1real collector creation, allows REG to start if active player is 1
if flag 22 = 0
and timer 22 > 100
and playerhasunit 1 p1real ftacollector payatos
   set flag 22 to 1
   reset timer 22
end if

--p1real create base task and engine
if flag 22 = 1
and timer 22 > 100
and playerpower > 0
and playerhasunit 1 p1real cloakingdevice agomenmon
and playerhasunit 1 p1real radartower sios
and playerhasunit 1 p1real copterstation etros
and playerhasunit 1 p1real ftascrambler globexscrambler
and soundchannel 1 is free
    playglobalsound 1 99 blair_multi184_011
    comsatline >> Col. Blair: Looks like you managed to establish quite a decent base for us Commander... Well done. rgb(255,255,255)
    changetask 1 p1real create_base complete
    highlighthud tasks
    set flag 22 to 2
    reset timer 22
    repeat this if
end if

if flag 22 >= 1
and timer 22 > 100
and playermoney < 1400
and playerhasnounit 1 p1real ftacollector payatos
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_015
   comsatline >> Col. Blair: Commander, we've just lost our only collector unit! *sigh*... Perhaps you don't quite understand the importance of this mission? ... If you cannot handle a simple task, I suggest we leave this sector before our drop-ship suffers further damage. rgb(255,255,255)
   reset timer 22
end if

if flag 22 = 2
and timer 22 > 100
and playerpower < 10
and soundchannel 1 is free
   playglobalsound 1 99 snd_blair_lowpower2
   comsatline >> Col. Blair: Low power Commander. Lets get more turbines up and running. rgb(255,255,255)
   changetask 1 p1real create_base primary
   highlighthud tasks
   set flag 22 to 3
   reset timer 22
   repeat this if
end if

if flag 22 = 2
and timer 22 > 100
and playerhasnounit 1 p1real radartower sios
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_012
   comsatline >> Col. Blair: Commander, how do you intend to defend against these random attacks if we cant see the enemy? I suggest you create another Radar Tower and do something about our base. rgb(255,255,255)
   changetask 1 p1real create_base primary
   highlighthud tasks
   set flag 22 to 3
   reset timer 22
   repeat this if
end if

if flag 22 = 2
and timer 22 > 100
and playerhasnounit 1 p1real copterstation etros
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_014
   comsatline >> Col. Blair: Commander, I'm getting reports from our pilots that we've just lost our Copter Station. Should I assume that you will be able to handle this matter promptly? rgb(255,255,255)
   changetask 1 p1real create_base primary
   highlighthud tasks
   set flag 22 to 3
   reset timer 22
   repeat this if
end if

if flag 22 = 2
and timer 22 > 100
and playerhasnounit 1 p1real cloakingdevice agomenmon
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_013
   comsatline >> Col. Blair: Commander, we've just lost our Cloaking Device. I don't think I need to tell you of just how crucial it is for us to protect our based. rgb(255,255,255)
   changetask 1 p1real create_base primary
   highlighthud tasks
   set flag 22 to 3
   reset timer 22
   repeat this if
end if

if flag 22 = 2
and timer 22 > 100
and playerhasnounit 1 p1real ftascrambler globexscrambler
and soundchannel 1 is free
   playglobalsound 1 99 blair_multi184_018
   comsatline >> Col. Blair: Commander, The enemy has just destroyed our Scrambler Station. I hope you can manage this problem accordingly. rgb(255,255,255)
   changetask 1 p1real create_base primary
   highlighthud tasks
   set flag 22 to 3
   reset timer 22
   repeat this if
end if

if flag 22 = 3
and timer 22 > 100
   set flag 22 to 1
   reset timer 22
   repeat this if
end if

--**************************************
--BELOW: Multi-Player REG On/Off code.
--single player REG activation
if flag 21 = 0
and p1real = 1
and timer 21 >= 100
--turn REG on
    set flag 21 to 1
    reset timer 21
    repeat this if
end if

--multi-player REG deactivation
if flag 21 = 1
and timer 21 > 100
and totalplayerunits 1 2 >= 1
   set flag 21 to 2
   reset timer 21
   repeat this if
end if

if flag 21 = 1
and timer 21 > 100
and totalplayerunits 1 3 >= 1
   set flag 21 to 2
   reset timer 21
   repeat this if
end if

if flag 21 = 1
and timer 21 > 100
and totalplayerunits 1 4 >= 1
   set flag 21 to 2
   reset timer 21
   repeat this if
end if

if flag 21 = 2
and timer 21 > 100
and totalplayerunits 1 2 < 1
and totalplayerunits 1 3 < 1
and totalplayerunits 1 4 < 1
--turn REG off
   set flag 21 to 0
   reset timer 21
   repeat this if
end if

--*********************************************************************
--BELOW: AI population control dependant upon difficulty setting.
if flag 19 = 1
and p1real = 1
and totalplayerunits 1 5 > 3
and timer 20 >= 5000
--   comsatline >> REG timer delayed. rgb(255,255,255)
   reset timer 20
   repeat this if
end if

if flag 19 = 2
and p1real = 1
and totalplayerunits 1 5 > 4
and timer 20 >= 5000
--   comsatline >> REG timer delayed. rgb(255,255,255)
   reset timer 20
   repeat this if
end if

if flag 19 = 3
and p1real = 1
and totalplayerunits 1 5 > 6
and timer 20 >= 5000
--   comsatline >> REG timer delayed. rgb(255,255,255)
   reset timer 20
   repeat this if
end if

--repeating X min. forced random encounter dependant upon difficulty setting
if p1real = 1
and flag 19 = 1
and flag 21 >= 1
and flag 22 >= 1
and timer 23 > 60000*5
and totalplayerunits 1 5 <= 2
   set flag 20 to 4
   reset timer 23
   repeat this if
end if

if p1real = 1
and flag 19 = 2
and flag 21 >= 1
and flag 22 >= 1
and timer 23 > 60000*4
and totalplayerunits 1 5 <= 2
   set flag 20 to 4
   reset timer 23
   repeat this if
end if

if p1real = 1
and flag 19 = 3
and flag 21 >= 1
and flag 22 >= 1
and timer 23 > 60000*3
and totalplayerunits 1 5 <= 2
   set flag 20 to 4
   reset timer 23
   repeat this if
end if

--***************************************************************
--BELOW: Is a linear REG for 3 factions w/ X min. encounter check.

--repeating X minute random encounter query, dependant upon difficulty setting.
if flag 20 = 0
and flag 19 = 1
and flag 21 >= 1
and flag 22 >= 1
and timer 20 >= 90000
   set flag 20 to random(3)
   reset timer 20
   repeat this if
end if

if flag 20 = 0
and flag 19 = 2
and flag 21 >= 1
and flag 22 >= 1
and timer 20 >= 60000
   set flag 20 to random(3)
   reset timer 20
   repeat this if
end if

if flag 20 = 0
and flag 19 = 3
and flag 21 >= 1
and flag 22 >= 1
and timer 20 >= 30000
   set flag 20 to random(3)
   reset timer 20
   repeat this if
end if

--random encounter check
if flag 20 = 1
--    comsatline >> Random Encounter. rgb(255,255,255)
    set flag 20 to 4
    repeat this if
end if

if flag 20 = 2
--    comsatline >> Null. rgb(255,255,255)
    set flag 20 to 0
    repeat this if
end if

if flag 20 = 3
--    comsatline >> Null. rgb(255,255,255)
    set flag 20 to 0
    repeat this if
end if

-- Faction selection
if flag 20 = 4
   set flag 20 to random(3)+4
   repeat this if
end if

if flag 20 = 5
--    comsatline >> FTA selected. rgb(255,255,255)
    set flag 20 to 8
    repeat this if
end if

if flag 20 = 6
--    comsatline >> GBX selected. rgb(255,255,255)
    set flag 20 to 12
    repeat this if
end if

if flag 20 = 7
--    comsatline >> SDF selected. rgb(255,255,255)
    set flag 20 to 16
    repeat this if
end if

--FTA random spawn
if flag 20 = 8
   set flag 20 to random(3)+8
   repeat this if
end if

if flag 20 = 9
and timer 20 >= 5000
--    comsatline >> FTA spawn. rgb(255,255,255)
    createunit 1 5 bladescout vector(19409,40857,3406) 33.6879 80 0 -1 0
    createunit 1 5 bladescout vector(18547,42086,3436) 33.6879 80 0 -1 0
    createunit 1 5 bladescout vector(17472,43239,3461) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

if flag 20 = 10
and timer 20 >= 5000
--    comsatline >> FTA spawn. rgb(255,255,255)
    createunit 1 5 interceptor vector(16201,72491,714) 33.6879 80 0 -1 0
    createunit 1 5 interceptor vector(15680,70653,785) 33.6879 80 0 -1 0
    createunit 1 5 interceptor vector(12788,71987,844) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

if flag 20 = 11
and timer 20 >= 5000
--    comsatline >> FTA spawn. rgb(255,255,255)
    createunit 1 5 advocate vector(90474,34254,2804) 33.6879 80 0 -1 0
    createunit 1 5 advocate vector(91037,32067,2807) 33.6879 80 0 -1 0
    createunit 1 5 advocate vector(92158,32508,4328) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

--GBX random spawn
if flag 20 = 12
   set flag 20 to random(3)+12
   repeat this if
end if

if flag 20 = 13
and timer 20 >= 5000
--    comsatline >> GBX spawn. rgb(255,255,255)
    createunit 1 5 forsydon vector(90021,103071,446) 33.6879 80 0 -1 0
    createunit 1 5 forsydon vector(91124,102030,1033) 33.6879 80 0 -1 0
    createunit 1 5 forsydon vector(92855,93302,1208) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

if flag 20 = 14
and timer 20 >= 5000
--    comsatline >> GBX spawn. rgb(255,255,255)
    createunit 1 5 forsydon vector(8506,90976,1332) 33.6879 80 0 -1 0
    createunit 1 5 forsydon vector(6609,91385,1613) 33.6879 80 0 -1 0
    createunit 1 5 forsydon vector(9025,93459,1501) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

if flag 20 = 15
and timer 20 >= 5000
and playerhasnounit 1 5 omnithias
--    comsatline >> GBX spawn. rgb(255,255,255)
    createunit 1 5 forsydon vector(90471,34252,2805) 33.6879 80 0 -1 0
    createunit 1 5 forsydon vector(91039,32068,2804) 33.6879 80 0 -1 0
    createunit 1 5 omnithias vector(92151,32503,4324) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

--SDF random spawn
if flag 20 = 16
   set flag 20 to random(3)+16
   repeat this if
end if

if flag 20 = 17
and timer 20 >= 5000
--    comsatline >> SDF spawn. rgb(255,255,255)
    createunit 1 5 tryphon vector(19409,40857,3406) 33.6879 80 0 -1 0
    createunit 1 5 tryphon vector(16201,72491,714) 33.6879 80 0 -1 0
    createunit 1 5 tryphon vector(90474,34254,2804) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

if flag 20 = 18
and timer 20 >= 5000
--    comsatline >> SDF spawn. rgb(255,255,255)
    createunit 1 5 tryphon vector(90021,103071,446) 33.6879 80 0 -1 0
    createunit 1 5 tryphon vector(8506,90976,1332) 33.6879 80 0 -1 0
    createunit 1 5 tryphon vector(90471,34252,2805) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if

if flag 20 = 19
and timer 20 >= 5000
--    comsatline >> SDF spawn. rgb(255,255,255)
    createunit 1 5 bladescout vector(16201,72491,714) 33.6879 80 0 -1 0
    createunit 1 5 interceptor vector(15680,70653,785) 33.6879 80 0 -1 0
    createunit 1 5 advocate vector(12788,71987,844) 33.6879 80 0 -1 0
    radarbeacon 1 lastvector 10000
    set flag 20 to 0
    reset timer 20
    repeat this if
end if


--********************************************
--delay FTA super/mega-weapons until at least one guest has established a preliminary base.
if timer 24 >= 100
and playerhasunitcount 1 2 ftascrambler >= 1
    set flag 26 to 2
    reset timer 24
end if

if timer 24 >= 100
and playerhasunitcount 1 3 ftascrambler >= 1
    set flag 26 to 3
    reset timer 24
end if

if timer 24 >= 100
and playerhasunitcount 1 4 ftascrambler >= 1
    set flag 26 to 4
    reset timer 24
end if

--delay GBX super/mega-weapons until at least one guest has established a preliminary base.
if timer 25 >= 100
and playerhasunitcount 1 2 globexscrambler >= 1
    set flag 26 to 2
    reset timer 25
end if

if timer 25 >= 100
and playerhasunitcount 1 3 globexscrambler >= 1
    set flag 26 to 3
    reset timer 25
end if

if timer 25 >= 100
and playerhasunitcount 1 4 globexscrambler >= 1
    set flag 26 to 4
    reset timer 25
end if

--********************************
--Active Player Super/Mega-Weapons unlocked
if p1real >= 1
and flag 26 >= 2
and timer 24 >= 100
and playerhasunitcount 1 p1real ftascrambler >= 1
and soundchannel 1 is free
    playglobalsound 1 99 threebeeps01
    comsatline Computer: Super and / or Mega Weapons now available. rgb(255,255,0)
    settechlevel 1 p1real [0,1,2,3,4,5,6,7,8,9,11,12,13,14,16,17,18]
    set flag 26 to 5
    reset timer 24
end if

if p1real >= 1
and flag 26 >= 2
and timer 25 >= 100
and playerhasunitcount 1 p1real globexscrambler >= 1
and soundchannel 1 is free
    playglobalsound 1 99 threebeeps01
    comsatline Computer: Super and / or Mega Weapons now available. rgb(255,255,0)
    settechlevel 1 p1real [0,1,2,3,4,5,6,7,8,9,11,12,13,14,16,17,18]
    set flag 26 to 5
    reset timer 25
end if

--**********************************************
--**** PLAYER TECH LEVEL and PLAYER TARGETING ****
--**********************************************
--*****     BELOW: BETA TESTER and MOD user test     ****
if theBetaTesterList.findpos(sPlayer1Name) = 0
and theModList.findpos(sPlayer1Name) = 0
and theAdminList.findpos(sPlayer1Name) = 0
   removetechlevel 1 playernumber 19
   removetechlevel 1 playernumber 20
end if
--*****     ABOVE: BETA TESTER and MOD user test     *****


--********** PLAYER TARGETING  *************
--********** PLAYER TARGETING  *************
--********** PLAYER TARGETING  *************
--addplayercantarget 1 1 19
--removeplayercantarget 1 1 [5,6,7]

--Initial player targeting
if p1real >= 1
   playercantarget 1 1 [0,1,5]
   playercantarget 1 2 [0,2,5]
   playercantarget 1 3 [0,3,5]
   playercantarget 1 4 [0,4,5]
   playercantarget 1 5 [0,1,2,3,4]
end if

--Valid player targeting
if totalplayerunits 1 1 > 9
and flag 31 = 0
    set flag 31 to 1
    repeat this if
end if

if totalplayerunits 1 2 > 9
and flag 32 = 0
    set flag 32 to 1
    repeat this if
end if

if totalplayerunits 1 3 > 9
and flag 33 = 0
    set flag 33 to 1
    repeat this if
end if

if totalplayerunits 1 4 > 9
and flag 34 = 0
    set flag 34 to 1
    repeat this if
end if

--self awareness
if flag 31 = 1
and totalplayerunits 1 p1real > 9
    addplayercantarget 1 p1real 1
    set flag 31 to 2
    repeat this if
end if

if flag 32 = 1
and totalplayerunits 1 p1real > 9
    addplayercantarget 1 p1real 2
    set flag 32 to 2
    repeat this if
end if

if flag 33 = 1
and totalplayerunits 1 p1real > 9
    addplayercantarget 1 p1real 3
    set flag 33 to 2
    repeat this if
end if

if flag 34 = 1
and totalplayerunits 1 p1real > 9
    addplayercantarget 1 p1real 4
    set flag 34 to 2
    repeat this if
end if


--no player
if flag 31 = 2
and totalplayerunits 1 1 = 0
    removeplayercantarget 1 p1real 1
    set flag 31 to 0
    repeat this if
end if

if flag 32 = 2
and totalplayerunits 1 2 = 0
    removeplayercantarget 1 p1real 2
    set flag 32 to 0
    repeat this if
end if

if flag 33 = 2
and totalplayerunits 1 3 = 0
    removeplayercantarget 1 p1real 3
    set flag 33 to 0
    repeat this if
end if

if flag 34 = 2
and totalplayerunits 1 4 = 0
    removeplayercantarget 1 p1real 4
    set flag 34 to 0
    repeat this if
end if

--********** END PLAYER TARGETING  *************
--********** END PLAYER TARGETING  *************
--********** END PLAYER TARGETING  *************

--Difficulty Settings
if gamedifficulty = easy
and timer 19 >= 100
    setplayermoney 1 player 4200
    setmaxunits 1 player 25
    set flag 19 to 1
    reset timer 19
end if

if gamedifficulty = medium
and timer 19 >= 100
    setplayermoney 1 player 2800
    setmaxunits 1 player 20
    set flag 19 to 2
    reset timer 19
end if

if gamedifficulty = hard
and timer 19 >= 100
    setplayermoney 1 player 1500
    setmaxunits 1 player 15
    set flag 19 to 3
    reset timer 19
end if

--**********************************************
--**** END PLAYER TECH AND TARGETING ****
--**********************************************

**************** CORE LEVEL CREATION STARTS **************
**************** CORE LEVEL CREATION STARTS **************
**************** CORE LEVEL CREATION STARTS **************
--set maxplayers 1

total memory cleanup
set activeworld 1
resetworld 1

load basic configuration

set landpatch land01_allthings13
set landdeform off
set landheightmap heigtmap_land01_allthings13
set landtexture void

set minnewfogdistance 60000
set maxviewdistance 100000

**** RESOURCE PACK FILES START
if highterraindetail
    load resourcepack http://internallink2/ql_highresterrain_allthings13.cct slot2 highres_terrain
end if
if mediumterraindetail
    load resourcepack http://internallink2/ql_medresterrain_allthings13.cct slot2 medres_terrain
end if
if lowterraindetail
    load resourcepack http://internallink2/ql_lowresterrain_allthings13.cct slot2 lowres_terrain
end if
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

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://internallink2/ql_soundpack_gauntlet.cct slot7 gauntlet_speech
--below: not sure if the pack is used, but it was in the original script made by Endlessvoid
--load resourcepack http://internallink2/ql_soundpack_allthings13.cct slot8 character_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

--set weather rain
prepare landpatch

load basic variables

load basic models
load minimap

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

--** DATABASE and TACTICAL ENTRIES **
-- Mod'ed DB and Tactical entries go HERE!

--copymodel ftatransportgate eastgate
--copymodel ftatransportgate southgate
copymodel ftatransportgate westgate


--TACTICAL ENTRIES

--new tactical entry
--ftatransportgate
--@name DB:fullname /n /n @primary @function /n Transport Gate to Sector ???. /n /n @flaws /n susceptible to premature activation when mobile units are near. /n /n @counter @with /n keeping your forces a safe distance from the gate /n /n @good @against /n Beats having to walk to the adjacent sector /n /n #DETAILED #INFO /n /n @armor /n DB:armor /n /n @power @output /n DB:power
--#end

--new tactical entry
--eastgate
--@name DB:fullname /n /n @primary @function /n Transport Gate to Sector ???. /n /n @flaws /n susceptible to premature activation when mobile units are near. /n /n @counter @with /n keeping your forces a safe distance from the gate /n /n @good @against /n Beats having to walk to the adjacent sector /n /n #DETAILED #INFO /n /n @armor /n DB:armor /n /n @power @output /n DB:power
--#end

--new tactical entry
--southgate
--@name DB:fullname /n /n @primary @function /n Transport Gate to Sector ???. /n /n @flaws /n susceptible to premature activation when mobile units are near. /n /n @counter @with /n keeping your forces a safe distance from the gate /n /n @good @against /n Beats having to walk to the adjacent sector /n /n #DETAILED #INFO /n /n @armor /n DB:armor /n /n @power @output /n DB:power
--#end

new tactical entry
westgate
@name DB:fullname /n /n @primary @function /n Transport Gate to Sector 184. /n /n @flaws /n susceptible to premature activation when mobile units are near. /n /n @counter @with /n keeping your forces a safe distance from the gate /n /n @good @against /n Beats having to walk to the adjacent sector /n /n #DETAILED #INFO /n /n @armor /n DB:armor /n /n @power @output /n DB:power
#end

process tactical database

--DATABASE ENTRIES
--new database entry
--ftatransportgate
--affect all temporal mods
--fullname North Transport Gate
--price 2000
--buildtime 30000
--unitflagrequired 1
--maxallowed 1    --cannot build more than one
--techlevel 15
--unitscale 1
--healthratio 7
--modeltype 10
--isabuilding yes
--armor 700
--speed1 0
--speed2 0
--speed3 40
--initialstate 85
--candeploy yes
--maxbuilddistance 10000
--gridtype -2
--deathtype 3
--power +400
--lifetime 0
--sounds deploy ["lowbeep01"]
--sounds indeployment ["transport01_01"]
--addspecial 10    --animation is power dependent
--addspecial 50    --is a Quantum Gate
--addspecial 60    --pointer over will result in "move", and not "target" or "select"
--healthanimation <=20 smoke_and_fire 10000
--healthanimation <=50 slight_smoke 10000
--#end

--new database entry
--eastgate
--affect all temporal mods
--fullname East Transport Gate
--price 2000
--buildtime 30000
--unitflagrequired 1
--maxallowed 1    --cannot build more than one
--techlevel 15
--unitscale 1
--healthratio 7
--modeltype 10
--isabuilding yes
--armor 700
--speed1 0
--speed2 0
--speed3 40
--initialstate 85
--candeploy yes
--maxbuilddistance 10000
--gridtype -2
--deathtype 3
--power +1000
--lifetime 0
--sounds deploy ["lowbeep01"]
--sounds indeployment ["transport01_01"]
--addspecial 10    --animation is power dependent
--addspecial 50    --is a Quantum Gate
--addspecial 60    --pointer over will result in "move", and not "target" or "select"
--healthanimation <=20 smoke_and_fire 10000
--healthanimation <=50 slight_smoke 10000
--#end

--new database entry
--southgate
--affect all temporal mods
--fullname South Transport Gate
--price 2000
--buildtime 30000
--unitflagrequired 1
--maxallowed 1    --cannot build more than one
--techlevel 15
--unitscale 1
--healthratio 7
--modeltype 10
--isabuilding yes
--armor 700
--speed1 0
--speed2 0
--speed3 40
--initialstate 85
--candeploy yes
--maxbuilddistance 10000
--gridtype -2
--deathtype 3
--power +400
--lifetime 0
--sounds deploy ["lowbeep01"]
--sounds indeployment ["transport01_01"]
--addspecial 10    --animation is power dependent
--addspecial 50    --is a Quantum Gate
--addspecial 60    --pointer over will result in "move", and not "target" or "select"
--healthanimation <=20 smoke_and_fire 10000
--healthanimation <=50 slight_smoke 10000
--#end

new database entry
westgate
affect all temporal mods
fullname West Transport Gate
price 2000
buildtime 30000
unitflagrequired 1
maxallowed 1    --cannot build more than one
techlevel 15
unitscale 1
healthratio 7
modeltype 10
isabuilding yes
armor 700
speed1 0
speed2 0
speed3 40
initialstate 85
candeploy yes
maxbuilddistance 10000
gridtype -2
deathtype 3
power +400
lifetime 0
sounds deploy ["lowbeep01"]
sounds indeployment ["transport01_01"]
addspecial 10    --animation is power dependent
addspecial 50    --is a Quantum Gate
addspecial 60    --pointer over will result in "move", and not "target" or "select"
healthanimation <=20 smoke_and_fire 10000
healthanimation <=50 slight_smoke 10000
#end

process database

--** CREATE ENVIRONMENT **
if displayextramodels
    createmodel player16 s_tree01 vector(9740,7902,5020) 57.1897 5.2684 [1]
    createmodel player16 s_tree02 vector(11480,62702,256) 69.4551 6.3816 [1]
    createmodel player16 s_tree02 vector(11550,100785,2986) 30.7410 7.1919 [1]
    createmodel player16 s_tree02 vector(42258,146486,546) 160.0783 6.5111 [1]
    createmodel player16 s_tree01 vector(11974,188343,-242) -53.7787 11.9864 [1]
    createmodel player16 s_tree02 vector(92350,193563,4267) -96.9052 8.2696 [1]
    createmodel player16 s_tree01 vector(84525,135214,1003) -147.2982 6.5112 [1]
    createmodel player16 s_tree01 vector(93869,61092,2114) -177.2872 5.8495 [1]
    createmodel player16 s_tree01 vector(73463,41825,876) -137.7930 4.4139 [1]
    createmodel player16 s_tree01 vector(90693,8981,-116) 150.9800 7.3987 [1]
    createmodel player16 s_tree01 vector(54404,196506,4734) -81.7242 4.7662 [1]
    createmodel player16 plant02 vector(51173,35507,5677) -118.0383 2.5913 [1]
end if

--PRE-BUFFER
if displayextramodels
    createmodel player0 ftatransportgate vector(-10000,-15000,-10000) 0 0 [1]
    createmodel player0 ftacollector vector(-10000,-10000,-10000) 0 0 [1]
    createmodel player0 turbine vector(-11000,-11000,-10000) 0 0 [1]
    createmodel player0 bladescout vector(-12000,-12000,-10000) 0 0 [1]
    createmodel player0 interceptor vector(-13000,-13000,-10000) 0 0 [1]
    createmodel player0 advocate vector(-14000,-14000,-10000) 0 0 [1]
    createmodel player0 radartower vector(-15000,-15000,-10000) 0 0 [1]
    createmodel player0 flakturret vector(-16000,-16000,-10000) 0 0 [1]
end if

--west gate
createmodel player8 westgate vector(8377,112818,1411) -82.5628 1.0000 [1]
--resource pods
createmodel player17 resourcepod vector(82777,149039,1425) -167.2863 1.0000 [1]
createmodel player17 resourcepod vector(27522,116773,1442) 17.5962 1.0000 [1]
--createmodel player17 resourcepod vector(43854,101105,3272) 118.3017 1.0000 [1]
createmodel player17 resourcepod vector(86898,19947,106) 128.1137 1.0000 [1]
createmodel player17 resourcepod vector(22143,64162,625) 14.2975 1.0000 [1]
createmodel player17 resourcepod vector(58632,178789,161) -60.7087 1.0000 [1]


set activeworld 1

positioncamera vector(4.95624e4,7.94332e4,-100.0000) vector(0.0000,0.0000,0.8835) vector(0.0000,-3.10000e4,7.94253e3) vector(0.0000,0.0000,0.0000)

clear startingunit
add startingunit epsilon omnithias

clear bonusunit
add bonusunit ["bladescout","interceptor"] ["forsydon","tryphon"]


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

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

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

--*** TRANSPORT GATE ***
if unitpassedgate 1 8 1 epsilon omnithias
    playglobalsound 2 99 computer007
    comsatline Computer: Checkpoint reached. rgb(255,255,0)
    changetask 1 p1real deploy_dropship complete
    highlighthud tasks
    set flag 1 to 11
end if

-- **** GENERAL BLAIR SAMPLES ****
if soundchannel 1 is free
and playermoney < 300
    playglobalsound 1 99 snd_blair_lowmoney1
    comsatline >> Col. Blair: We are running low on funds. See if you can create new Collector units and scout the area for more resources. rgb(255,255,255)
    reset timer 1
end if

if soundchannel 1 is free
and unithealth 1 < 80%
    playglobalsound 1 99 snd_blair_lowdropshiphealth1
    comsatline >> Col. Blair: The drop-ship is under attack. We need reinforcements back here. rgb(255,255,255)
    reset timer 1
end if

if soundchannel 1 is free
and unithealth 1 < 30%
    playglobalsound 1 99 snd_blair_lowdropshiphealth2
    comsatline >> Col. Blair: Commander, the drop-ship is almost destroyed. I dont know what you are doing, but consider putting it on hold and building us more reinforcements. rgb(255,255,255)
    reset timer 1
end if


if soundchannel 1 is free
and sinceenemyjump <= 10000
    playglobalsound 1 99 snd_blair_enemyjump2
    comsatline >> Col. Blair: Enemy is approaching this sector. Alert our forces commander. rgb(255,255,255)
    reset timer 1
end if
-- **** GENERAL BLAIR SAMPLES END****

--*** GENERAL COMPUTER VOICE START

if flag 26 = 0
and flag 22 >= 1
and timer 26 >= 60000
and playerpower <= 0
    set flag 26 to random(2)
    reset timer 26
    repeat this if
end if

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

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

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

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

--*** GENERAL COMPUTER VOICE END


