:autorun
if
then
	title "lev05_title01"
	set energy 0
	unlock 3
	unlock 5
	set popfactor 150
	set meteormessage 99
	set meteor 99
	set meteorand 99
	set flare 3
	set flareevent (((rnd%10000) + 5000) + turn)
	set meteorevent (((rnd%10000) + 10000) + turn)
;EVENTUALLY TO BE REPLACED AS DEFAULT ITEMS
;	discover @teevee
;	discover @clock
;	discover @lavalamp
;	discover @lab_bench
	disable
end

	{missions\00\valmessages00.txt}
	{missions\00\queue00.txt}
	{missions\00\rehabs00.txt}
	{missions\00\peepenergy00.txt}
	{missions\00\losenocollector00.txt}
	{missions\00\upkeep00.txt}

;INTRO****************************************************************************
:Intro50
if
	turn > 1
then
	disallow decks mid_deck
	disallow decks bio_deck
	disable
end

:Intro100
if
	turn > 50
then
	set speech 1 after say "lev05_intro01"
	unlock 5
	disable
end

:Intro200
if
	speech = 1
then
	set speech 2 after say "lev05_intro02"
	disable
end

:intro210
if
	speech = 2
then
	sayx 10 "lev05_objective01"
	placeportable scutter_crate 2 13 sub_deck 100 1
	placeportable scutter_crate 3 13 sub_deck 200 1
	placeportable hard_plan_crate 5 13 sub_deck 600 collector
	placeportable hard_plan_crate 2 15 sub_deck 600 port
	placeportable hard_plan_crate 3 15 sub_deck 900 collector_node
	placeportable hard_plan_crate 4 15 sub_deck 900 charger
	disable
end

:intro215
if
	blueprint_count < 1
	turakken_count > 4
	laboratory_count < 1
	arona_count > 0
then
	say "lev05_discoveries01"
	disable
	end


:intro220
if
	collector_count > 0
	port_count > 0
	collector_node_count > 0
	charger_count > 0
then
	unsayx 10
	disable
end


:intro300
if
	blueprint_count < 1
	speech > 2
	collector_count > 0
	peep_count > 8
	berth_count > 0
then
	say "lev05_intro03"
	set aronacount (turn + 1000)
	disable
end

:intro400
if
	collector_count > 0
	port_count > 0
then
	place_peep karmarama resident skill 3
	place_peep karmarama resident skill 4
	place_peep karmarama resident skill 5
	place_peep karmarama resident skill 4
	set karmarrive 1
	disable
end

:intro600
if
	speech > 4
	normal_peep_count > 4
then
	set facilitysay 1 after say "lev05_intro06"
	placeportable hard_plan_crate 3 15 sub_deck 900 berth
	placeportable hard_plan_crate 3 16 sub_deck 900 vendor
	placeportable hard_plan_crate 3 15 sub_deck 900 lavotron
	disable
end
	

;SEGMENTS COSTING DOSH********************************************************
:Segments100
if
	collector_count > 0
then
	say "lev05_segments01"
	disable
end


;ENERGY100****************************************************************
:Energy100
if
	collector_count > 0
then
	set energy 100000
	disable
end


;PEEPS********************************************************************
:Peeps100
if
	speech > 4
	turn > allowpeeps
then
	set grey_max (segmentdecks + 8)
	set targ_max (segmentdecks + 8)
	set siren_max ((segmentdecks + 6) / 2)
	set male_siren_max ((segmentdecks + 6) / 2)
	set salt_hog_max (segmentdecks + 10)
	set gor_max (segmentdecks + 6)
	set gem_slug_max segmentdecks
	set karmarama_max (segmentdecks + 6)
	set turakken_max (segmentdecks + 6)
	set grey_every (peepola * 6)
	set targ_every (peepola * 6)
	set siren_every (peepola * 22)
	set male_siren_every (peepola * 22)
	set salt_hog_every (peepola * 3)
	set gor_every (peepola * 11)
	set karmarama_every (peepola * 8)
	set turakken_every (peepola * 11)
	set allowpeeps (turn + 2000)
end

:peeps300
if
	karmarrive = 1
	turn > peeprate
then
	set peepola (popfactor / decksegmentcount)
	set peeprate (turn + 555)
end

:Peeps410
if
	speech > 4
	turn > peepmod3
	targ_count < 1
then
	place_peep targ
	set peepmod3 (turn + 500)
end

:Peeps420
if
	speech > 4
	turn > peepmod3
	grey_count < 1
then
	place_peep grey
	set peepmod3 (turn + 500)
end

:Peeps430
if
	speech > 4
	turn > peepmod3
	salt_hog_count < 1
then
	place_peep salt_hog
	set peepmod3 (turn + 500)
end

:Peeps440
if
	speech > 4
	turn > peepmod3
	turakken_count < 1
then
	place_peep turakken
	set peepmod3 (turn + 500)
end

:Peeps450
if
	speech > 4
	turn > peepmod3
	siren_count < 1
then
	place_peep siren
	set peepmod3 (turn + 500)
end

;ARONAVISITS*************************************************************
:ARONA100
if
	random = 0
	karmatimer > 5
	turn > aronacount
	aronacount > 0
	cargomission < 1
then
	set aronavisits 1
	trader "arona0501.csv" 60 "lev05_arona00" local
	set aronacount (((rnd%3000) + turn) + 3000)
	set random (rnd%6)
end

:ARONA101
if
	random = 1
	karmatimer > 5
	turn > aronacount
	aronacount > 0
	cargomission < 1
then
	trader "arona0501.csv" 60 "lev05_arona01" local
	set aronacount (((rnd%3000) + turn) + 3000)
	set random (rnd%6)
end

:ARONA102
if
	random = 2
	karmatimer > 5
	turn > aronacount
	aronacount > 0
	cargomission < 1
then
	trader "arona0501.csv" 60 "lev05_arona02" local
	set aronacount (((rnd%3000) + turn) + 3000)
	set random (rnd%6)
end

:ARONA103
if
	random = 3
	karmatimer > 5
	turn > aronacount
	aronacount > 0
	cargomission < 1
then
	trader "arona0501.csv" 60 "lev05_arona03" local
	set aronacount (((rnd%3000) + turn) + 3000)
	set random (rnd%6)
end

:ARONA104
if
	random = 4
	karmatimer > 5
	turn > aronacount
	aronacount > 0
	cargomission < 1
then
	trader "arona0501.csv" 60 "lev05_arona04" local
	set aronacount (((rnd%3000) + turn) + 3000)
	set random (rnd%6)
end

:ARONA105
if
	random = 5
	karmatimer > 5
	turn > aronacount
	aronacount > 0
	cargomission < 1
then
	trader "arona0501.csv" 60 "lev05_arona05" local
	set aronacount (((rnd%3000) + turn) + 3000)
	set random (rnd%6)
end

:ARONA200
if
	random = 0
	turn > aronacount
	aronacount > 0
	speech > 5
then
	trader "arona0502.csv" 60 "lev05_arona00" local
	set aronacount (((rnd%5000) + turn) + 5000)
	set random (rnd%6)
end

:ARONA201
if
	random = 1
	turn > aronacount
	aronacount > 0
	speech > 5
then
	trader "arona0502.csv" 60 "lev05_arona01" local
	set aronacount (((rnd%5000) + turn) + 5000)
	set random (rnd%6)
end

:ARONA202
if
	random = 2
	turn > aronacount
	aronacount > 0
	speech > 5
then
	trader "arona0502.csv" 60 "lev05_arona02" local
	set aronacount (((rnd%5000) + turn) + 5000)
	set random (rnd%6)
end

:ARONA203
if
	random = 3
	turn > aronacount
	aronacount > 0
	speech > 5
then
	trader "arona0502.csv" 60 "lev05_arona03" local
	set aronacount (((rnd%5000) + turn) + 5000)
	set random (rnd%6)
end

:ARONA204
if
	random = 4
	turn > aronacount
	aronacount > 0
	speech > 5
then
	trader "arona0502.csv" 60 "lev05_arona04" local
	set aronacount (((rnd%5000) + turn) + 5000)
	set random (rnd%6)
end

:ARONA205
if
	random = 5
	turn > aronacount
	aronacount > 0
	speech > 5
then
	trader "arona0502.csv" 60 "lev05_arona05" local
	set aronacount (((rnd%5000) + turn) + 5000)
	set random (rnd%6)
end

;ADVICE ON KARMARMA HIRING**********************************************
:Karma100
if
	peepstat race karmarama allunset resident roger > 0
	blueprint_count < 1
	stage < 2
	turn > employee
	((bush_hthm_count + bush_mtlm_count) + (food_supply_crate_count)) < 50
then
	status_message "lev05_karma01"
	set employee (turn + 5000) 
end


;BIODECK*****************************************************************
:Bio100
if
	karmarama_count > 2
then
	set speech 4 after say "lev05_biodeck01"
	disable
end

:Bio200
if
	speech = 4
then
	set speech 5 after say "lev05_biodeck02"
	disable
end

/*
:Bio300
if
	cargomission = 1
then 
	trader "arona0503.csv" 3000 "lev05_biodeck03" local
	set cargomission 3
	set tradewait (turn + 680)
	disable
end
*/

:Bio300
if
	cargomission = 1
then
	status_message "lev05_biodeck03" 
;	incoming local_comms icon 6 "lev05_biodeck03"
	evaporate food_supply_crate 50
	set cargomission 3
	set tradewait (turn + 680)
	disable
end

:Bio400
if
	cargomission = 3
	turn > tradewait
then
	hide_counter food_supply_crate_count 4
	unsayx 13
	unsay 111
	set speech 7 after say "lev05_biodeck04"
	set stage 2
	multitrigger :go
	disable
end

:Bio500
if
	cargomission = 2
then
	lose
	disable
end

:Bonus100
if
	speech = 7
then
	set speech 8 after say "lev05_bonus01"
	disable
end

:Stagetwo100
if
	speech = 8
then
	placeportable hard_plan_crate 4 17 sub_deck 600 dry_dock 
	sayx 14 "lev05_stagetwo01"
	disable
end


;TIMER**********************************************************************
:Timer1000
if
	speech > 4
then
	set karmatimer 100
	allow decks mid_deck
	allow decks bio_deck
	set timerdecrement (turn + (50000 / (((food_supply_crate_count + 50) + bush_hthm_count) + bush_mtlm_count)))
	show_counter karmatimer 6
	show_counter food_supply_crate_count 4
	sayx 13 "lev05_timer10"
	disable
end

:Timer100
if
	karmatimer > 0
	turn > timerdecrement
then
	set karmatimer (karmatimer - 1)
	set timerdecrement (turn + (50000 / (((food_supply_crate_count + 50) + bush_hthm_count) + bush_mtlm_count)))
end


:Timer90
if
	karmatimer = 90
then
	status_message "lev05_timer09"
	disable
end
	
:Timer80
if
	karmatimer = 80
then
	status_message "lev05_timer08"
	disable
end

:Timer70
if
	karmatimer = 70
then
	status_message "lev05_timer07"
	disable
end

:Timer60
if
	karmatimer = 60
then
	status_message "lev05_timer06"
	disable
end

:Timer50
if
	karmatimer = 50
then
	status_message "lev05_timer05"
	disable
end

:Timer40
if
	karmatimer = 40
then
	status_message "lev05_timer04"
	disable
end

:Timer30
if
	karmatimer = 30
then
	status_message "lev05_timer03"
	disable
end

:Timer20
if
	karmatimer = 20
then
	status_message "lev05_timer02"
	disable
end

:Timer10
if
	karmatimer = 10
then
	status_message "lev05_timer01"
	disable
end

:Timer00
if
	mission = 0
	karmatimer < 1
	cargoexists food_supply_crate > 49
then
	hide_counter karmatimer 0
	set aronacount (turn + 5000)
	set mission 1
	set cargomission 1 after say 111 "lev05_timer00"
	disable
end

:Timer01
if
	speech > 4
	mission = 0
	karmatimer < 1
	cargoexists food_supply_crate < 50
then
	hide_counter karmatimer 0
	set aronacount (turn + 5000)
	set mission 1
	set cargomission 2 after say 111 "lev05_timer11"
	disable
end

;50 CRATES ACHIEVED EARLY**************************************************
:Crates200
if
	blueprint_count < 1
	cargomission < 1
	turn > cratelimittimer 
	cratelimit = 0
	cargoexists food_supply_crate > 49
then
	set cratelimit 1 after say "lev05_crates02"
	set cratelimittimer (turn + 500)
end

:Crates300
if
	blueprint_count < 1
	cargomission < 1
	turn > cratelimittimer
	cratelimit = 1
	cargoexists food_supply_crate < 50
then
	set cratelimit 0 after say "lev05_crates03"
	set cratelimittimer (turn + 500)
end 

;ADVICE ON FOOD PLANTS******************************************************
:Plants100
if
	blueprint_count < 1
	stage < 2
	turn > (plantcheck + 10) 
	(bush_hthm_count + bush_mtlm_count) > 30
then
	status_message "lev05_plants01"
	set plantcheck (turn + 5000)
end

:Plants200
if
	turn > 10000
	((((((((tree_mtlm_count + bush_mtlm_count) + tree_htlm_count) + tree_ltmm_count) + tree_htmm_count) + tree_mthm_count) + tree_hthm_count) + bush_hthm_count)  + (food_supply_crate_count)) < 55
	(((((((((bush_ltlm_count + bush_ltmm_count) + bush_lthm_count) + bush_mtmm_count) + bush_mthm_count) + bush_htlm_count) + bush_htmm_count) + tree_ltlm_count) + tree_lthm_count) + tree_mtmm_count) > ((((((((tree_mtlm_count + bush_mtlm_count) + tree_htlm_count) + tree_ltmm_count) + tree_htmm_count) + tree_mthm_count) + tree_hthm_count) + bush_hthm_count)  + (food_supply_crate_count))
	blueprint_count < 1
	stage < 2
	turn > plantcheck
then
	status_message "lev05_plants02"
	set plantcheck (turn + 6333)
end

:Plants300
if
	stage < 2
	cargoexists food_supply_crate < 10
	(bush_hthm_count + bush_mtlm_count) < 10
	karmatimer < 75
	karmatimer > 0
then
	say "lev05_plants03"
	disable
end

;NOTES ON CRATE TYPES**********************************************************
:Crates100
if
	cargoexists food_supply_crate > 0
then
	say "lev05_crates10"
	disable
end

:go
if
	0
then
	disable
end

;ADVICE ON BIOFUN*******************************************************************
:advice100
if
	blueprint_count < 1
	normal_peep_count > 20
then
	say "lev05_advice01"
	disable
	end

:advice200
if
	blueprint_count < 1
	array ownbiodeck 3 > 0
then
	say "lev05_advice02"
	disable
end

:Advice300
if
	blueprint_count < 1
	normal_peep_count > 15
then
	say "lev05_advice03" 
	disable
end

;SELLING GOODS GROWN ON THE BIODECK*************************************************
:Goods100
if
	blueprint_count < 1
	(((((bush_hthm_count + bush_htlm_count) + bush_ltlm_count) + bush_ltmm_count) + bush_lthm_count) + bush_mtmm_count) > 20
	satcom_count < 1
	dry_dock_count < 1
then
	say "lev05_goods01"
	disable
end

:Goods200
if
	stage < 2
	(((((bush_hthm_count + bush_htlm_count) + bush_ltlm_count) + bush_ltmm_count) + bush_lthm_count) + bush_mtmm_count) > 10
	cargoexists food_supply_crate < 1
then
	say "lev05_goods02"
	disable
end

:Goods300
if
	cargo_bay < 1
	(((((bush_hthm_count + bush_htlm_count) + bush_ltlm_count) + bush_ltmm_count) + bush_lthm_count) + bush_mtmm_count) > 20
then
	say "lev05_goods03"
	disable
end

;TRADER STUFF STARTS****************************************************************************

:TraderMulti100
if
	port_count > 0
then
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
	disable
end

:TraderGrey100
if
	turn > merchantcount
	merchantrand = 1
then
	trader "grey0501.csv" 90 "lev05_tradergrey"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

:TraderSiren100
if
	turn > merchantcount
	merchantrand = 2
then
	trader "siren0501.csv" 90 "lev05_tradersiren"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

:TraderTarg100
if
	turn > merchantcount
	merchantrand = 3
then
	trader "targ0501.csv" 90 "lev05_tradertarg"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

:TraderHog100
if
	turn > merchantcount
	merchantrand = 4
then
	trader "hog0501.csv" 90 "lev05_traderhog"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

:TraderGor100
if
	turn > merchantcount
	merchantrand = 5
then
	trader "gor0501.csv" 90 "lev05_tradergor"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

:Traderkarma100
if
	turn > merchantcount
	merchantrand = 6
then
	trader "karma0501.csv" 90 "lev05_traderkarma"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

:Traderturakken100
if
	turn > merchantcount
	merchantrand = 7
then
	trader "turakken0501.csv" 90 "lev05_traderturakken"
	set merchantcount (turn + (rnd%10000))
	set merchantrand ((rnd%7) + 1)
end

;STAGE TWO********************************************************************************
;Allowing expansion***********************************************************************
:Unlock100
if
	stage = 2
then
	set popfactor 100
	multitrigger :stage	
	unlock 1
	unlock 2
	unlock 6
	unlock 7
	unlock 8
	disable
end

:stage
if
	0
then
	disable
end

;INFORMING THE PLAYER OF THE AI PROGRESS
:AIprogress116
if
	0
then
	status_message "lev05_AI01"
	disable
end

:AIprogress216
if
	0
then
	status_message "lev05_AI02"
	disable
end

:AIprogress316
if
	0
then
	status_message "lev05_AI03"
	disable
end

:AIprogress117
if
	0
then
	status_message "lev05_AI04"
	disable
end

:AIprogress217
if
	0
then
	status_message "lev05_AI05"
	disable
end

:AIprogress317
if
	0
then
	status_message "lev05_AI06"
	disable
end


:AIprogress118
if
	0
then
	status_message "lev05_AI07"
	disable
end

:AIprogress218
if
	0
then
	status_message "lev05_AI08"
	disable
end

:AIprogress318
if
	0
then
	status_message "lev05_AI09"
	disable
end

;WINSTUFF
:win100
if
	array ownsubdeck 1 = 1
	array ownmiddeck 1 = 1
	array ownbiodeck 1 = 1
then
	unsayx 14
	set winner 1
	disable
end

:win200
if
	winner > 0
then
	win "lev05_win01"
	disable
end

:lose100
if
	0
then
	set loser 1
	disable 
end

:lose200
if
	loser = 1
then
	lose "lev05_lose01"
	disable
end

;**************************************************************************
:deathfines100
if
	deathssofar > paiddeaths
then
	addenergy (0 - 1000)
	set paiddeaths (deathssofar)
end

;SOLARFLARE*********************************************************************
:Stellar100
if
	turn > flareevent
then
	set flarecounter (turn + 2000)
	incoming stellar_event respond flare within 1900 "events_flare01"
	set flareevent ((turn + 2000) + (decksegmentcount * 1000))
end

:Stellar120
if
	flare < 2
then
	set flare 3
end

:stellar130
if
	flare = 2
then
	set flareaccept 1
	addenergy 5
end

:stellar140
if
	flarecounter > 0
	flarecounter < turn
then
	set flare 3
end

:stellar150
if
	flareaccept = 1
	flarecounter < turn
then
	status_message "events_flare02"
	set flareaccept 0 
end

;METEOR SHOWER - include a, b, c, e, f in human child scripts **********************
:Stellar000
if
	stage > 1
	turn > meteorevent
then
	set meteorevent (((rnd%10000) + 20000) + turn)
	set meteorand ((rnd%8) + 1)
end

:Stellar201
if
	meteorand = 1
then
	set meteorcounter (turn + 2000)
	multitrigger :stellar201a
end

:stellar201a
if
	0
then
	set meteorand 99
	set meteormessage 1
	set meteor 1
	disable
end

:stellar201b
if
	array ownbiodeck 1 = 1
	meteormessage = 1
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor01"
	set meteormessage 99
end

:stellar201c
if
	array ownbiodeck 1 = 0
	meteormessage = 1
then
	incoming stellar_event within 1900 icon 9 "events_meteor01a"
	set meteormessage 99
end

:stellar201d
if
	meteor = 1
	meteorcounter < turn
then
	multitrigger :stellar201e
	set meteor 99
	meteor_shower 1 bio_deck ((rnd%4) + 1)
end

:stellar201e
if
	0
then
	status_message "events_meteor01b"
	disable
end

:stellar201f
if
	meteor = 1
	evac = 2
then
	evacuate bio_deck 1 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar202
if
	meteorand = 2
then
	set meteorcounter (turn + 2000)
	multitrigger :stellar202a
end

:stellar202a
if
	0
then
	set meteorand 99
	set meteormessage 2
	set meteor 2
	disable
end

:stellar202b
if
	array ownbiodeck 2 = 1
	meteormessage = 2
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor02"
	set meteormessage 99
end

:stellar202c
if
	array ownbiodeck 2 = 0
	meteormessage = 2
then
	incoming stellar_event within 1900 icon 9 "events_meteor02a"
	set meteormessage 99
end

:stellar202d
if
	meteor = 2
	meteorcounter < turn
then
	multitrigger :stellar202e
	set meteor 99
	meteor_shower 2 bio_deck ((rnd%4) + 1)
end

:stellar202e
if
	0
then
	status_message "events_meteor02b"
	disable
end

:stellar202f
if
	meteor = 2
	evac = 2
then
	evacuate bio_deck 2 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar203
if
	meteorand = 3
then
	set meteorcounter (turn + 2000)
	multitrigger :stellar203a
end

:stellar203a
if
	0
then
	set meteorand 99
	set meteormessage 3
	set meteor 3
	disable
end

:stellar203b
if
	array ownbiodeck 3 = 1
	meteormessage = 3
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor03"
	set meteormessage 99
end

:stellar203c
if
	array ownbiodeck 3 = 0
	meteormessage = 3
then
	incoming stellar_event within 1900 icon 9 "events_meteor03a"
	set meteormessage 99
end

:stellar203d
if
	meteor = 3
	meteorcounter < turn
then
	multitrigger :stellar203e
	set meteor 99
	meteor_shower 3 bio_deck ((rnd%4) + 1)
end

:stellar203e
if
	0
then
	status_message "events_meteor03b"
	disable
end

:stellar203f
if
	meteor = 3
	evac = 2
then
	evacuate bio_deck 3 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar204
if
	meteorand = 4
then
	set meteorcounter (turn + 2000)
	multitrigger :stellar204a
end

:stellar204a
if
	0
then
	set meteorand 99
	set meteormessage 4
	set meteor 4
	disable
end

:stellar204b
if
	array ownbiodeck 4 = 1
	meteormessage = 4
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor04"
	set meteormessage 99
end

:stellar204c
if
	array ownbiodeck 4 = 0
	meteormessage = 4
then
	incoming stellar_event within 1900 icon 9 "events_meteor04a"
	set meteormessage 99
end

:stellar204d
if
	meteor = 4
	meteorcounter < turn
then
	multitrigger :stellar204e
	set meteor 99
	meteor_shower 4 bio_deck ((rnd%4) + 1)
end

:stellar204e
if
	0
then
	status_message "events_meteor04b"
	disable
end

:stellar204f
if
	meteor = 4
	evac = 2
then
	evacuate bio_deck 4 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar205
if
	meteorand = 5
then
	
	set meteorcounter (turn + 2000)
	multitrigger :stellar205a
end

:stellar205a
if
	0
then
	set meteorand 99
	set meteormessage 5
	set meteor 5
	disable
end

:stellar205b
if
	array ownbiodeck 5 = 1
	meteormessage = 5
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor05"
	set meteormessage 99
end

:stellar205c
if
	array ownbiodeck 5 = 0
	meteormessage = 5
then
	incoming stellar_event within 1900 icon 9 "events_meteor05a"
	set meteormessage 99
end

:stellar205d
if
	meteor = 5
	meteorcounter < turn
then
	multitrigger :stellar205e
	set meteor 99
	meteor_shower 5 bio_deck ((rnd%4) + 1)
end

:stellar205e
if
	0
then
	status_message "events_meteor05b"
	disable
end

:stellar205f
if
	meteor = 5
	evac = 2
then
	evacuate bio_deck 5 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar206
if
	meteorand = 6
then
	
	set meteorcounter (turn + 2000)
	multitrigger :stellar206a
end

:stellar206a
if
	0
then
	set meteorand 99
	set meteormessage 6
	set meteor 6
	disable
end

:stellar206b
if
	array ownbiodeck 6 = 1
	meteormessage = 6
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor06"
	set meteormessage 99
end

:stellar206c
if
	array ownbiodeck 6 = 0
	meteormessage = 6
then
	incoming stellar_event within 1900 icon 9 "events_meteor06a"
	set meteormessage 99
end

:stellar206d
if
	meteor = 6
	meteorcounter < turn
then
	multitrigger :stellar206e
	set meteor 99
	meteor_shower 6 bio_deck ((rnd%4) + 1)
end

:stellar206e
if
	0
then
	status_message "events_meteor06b"
	disable
end

:stellar206f
if
	meteor = 6
	evac = 2
then
	evacuate bio_deck 6 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar207
if
	meteorand = 7
then
	
	set meteorcounter (turn + 2000)
	multitrigger :stellar207a
end

:stellar207a
if
	0
then
	set meteorand 99
	set meteormessage 7
	set meteor 7
	disable
end

:stellar207b
if
	array ownbiodeck 7 = 1
	meteormessage = 7
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor07"
	set meteormessage 99
end

:stellar207c
if
	array ownbiodeck 7 = 0
	meteormessage = 7
then
	incoming stellar_event within 1900 icon 9 "events_meteor07a"
	set meteormessage 99
end

:stellar207d
if
	meteor = 7
	meteorcounter < turn
then
	multitrigger :stellar207e
	set meteor 99
	meteor_shower 7 bio_deck ((rnd%4) + 1)
end

:stellar207e
if
	0
then
	status_message "events_meteor07b"
	disable
end

:stellar207f
if
	meteor = 7
	evac = 2
then
	evacuate bio_deck 7 ((meteorcounter - turn) / 24)
	set evac 3
end

:Stellar208
if
	meteorand = 8
then
	
	set meteorcounter (turn + 2000)
	multitrigger :stellar208a
end

:stellar208a
if
	0
then
	set meteorand 99
	set meteormessage 8
	set meteor 8
	disable
end

:stellar208b
if
	array ownbiodeck 8 = 1
	meteormessage = 8
then
	incoming stellar_event respond evac within 1900 icon 9 "events_meteor08"
	set meteormessage 99
end

:stellar208c
if
	array ownbiodeck 8 = 0
	meteormessage = 8
then
	incoming stellar_event within 1900 icon 9 "events_meteor08a"
	set meteormessage 99
end

:stellar208d
if
	meteor = 8
	meteorcounter < turn
then
	multitrigger :stellar208e
	set meteor 99
	meteor_shower 8 bio_deck ((rnd%4) + 1)
end

:stellar208e
if
	0
then
	status_message "events_meteor08b"
	disable
end

:stellar208f
if
	meteor = 8
	evac = 2
then
	evacuate bio_deck 8 ((meteorcounter - turn) / 24)
	set evac 3
end

;***********************************************************************
:berthrotted100
if
	cargoexists hard_plan_crate berth = 1
then
	set berthdelivered 1
	disable
end

:berthrotted200
if
	blueprint_count < 1
	berth_count < 1
	cargoexists hard_plan_crate berth = 0
	berthdelivered = 1
then
	set berthdelivered 2 after say "lev05_facilityrot01"
	placeportable hard_plan_crate 12 18 sub_deck 1024 berth
	disable
end

:berthrotted300
if
	aronavisits < 1
	blueprint_count < 1
	berth_count < 1
	cargoexists hard_plan_crate berth = 0
	berthdelivered = 2
then
	trigger :rotlosenotice
	disable
end

;***********************************************************************
:portrotted100
if
	cargoexists hard_plan_crate port = 1
then
	set portdelivered 1
	disable
end

:portrotted200
if
	blueprint_count < 1
	port_count < 1
	cargoexists hard_plan_crate port = 0
	portdelivered = 1
then
	set portdelivered 2 after say "lev05_facilityrot01"
	placeportable hard_plan_crate 12 18 sub_deck 1024 port
	disable
end

:portrotted300
if
	aronavisits < 1
	blueprint_count < 1
	port_count < 1
	cargoexists hard_plan_crate port = 0
	portdelivered = 2
then
	trigger :rotlosenotice
	disable
end

;*******************************************************
:collectorrotted100
if
	cargoexists hard_plan_crate collector = 1
then
	set collectordelivered 1
	disable
end

:collectorrotted200
if
	blueprint_count < 1
	collector_count < 1
	cargoexists hard_plan_crate collector = 0
	collectordelivered = 1
then
	set collectordelivered 2 after say "lev05_facilityrot01"
	placeportable hard_plan_crate 12 18 sub_deck 1024 collector
	disable
end

:collectorrotted300
if
	blueprint_count < 1
	collector_count < 1
	cargoexists hard_plan_crate collector = 0
	collectordelivered = 2
then
	trigger :rotlosenotice
	disable
end

;*******************************************************
:droidrotted100
if
	cargoexists scutter_crate 1 = 1
then
	set droiddelivered 1
	disable
end

:droidrotted200
if
	scutter_count < 1
	((cargoexists scutter_crate 1) + (cargoexists scutter_crate 2)) = 0
	droiddelivered = 1
then
	set droiddelivered 2 after say "lev05_droidrot01"
	placeportable scutter_crate 2 13 sub_deck 100 1
	disable
end

:droidrotted300
if
	aronavisits < 1
	scutter_count < 1
	((cargoexists scutter_crate 1) + (cargoexists scutter_crate 2)) = 0
	droiddelivered = 2
then
	trigger :rotlosenotice
	disable
end

;LOSE GAME IF YOU KEEP LETTING STUFF ROT*****************************************
:rotlosenotice
if
	0
then
	set loserino 1 
	disable
end

:rotlose
if
	loserino = 1
then
	lose "lev05_rotter01"
	disable
end

/*
;***************************************************************
:debug11
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 2"
	disable
end

:debug12
if
	0
then
	say "DEBUG The AI is evacuating deck 2"
	disable
end

:debug13
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 2"
	disable
end

:debug21
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 3"
	disable
end

:debug22
if
	0
then
	say "DEBUG The AI is evacuating deck 3"
	disable
end

:debug23
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 3"
	disable
end

:debug31
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 4"
	disable
end

:debug32
if
	0
then
	say "DEBUG The AI is evacuating deck 4"
	disable
end

:debug33
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 4"
	disable
end

:debug41
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 5"
	disable
end

:debug42
if
	0
then
	say "DEBUG The AI is evacuating deck 5"
	disable
end

:debug43
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 5"
	disable
end

:debug51
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 6"
	disable
end

:debug52
if
	0
then
	say "DEBUG The AI is evacuating deck 6"
	disable
end

:debug53
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 6"
	disable
end

:debug61
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 7"
	disable
end

:debug62
if
	0
then
	say "DEBUG The AI is evacuating deck 7"
	disable
end

:debug63
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 7"
	disable
end

:debug71
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 8"
	disable
end

:debug72
if
	0
then
	say "DEBUG The AI is evacuating deck 8"
	disable
end

:debug73
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 8"
	disable
end

:debug81
if
	0
then
	say "DEBUG The AI has got the meteor message for deck 9"
	disable
end

:debug82
if
	0
then
	say "DEBUG The AI is evacuating deck 9"
	disable
end

:debug83
if
	0
then
	say "DEBUG The AI is ignoring the meteors for deck 9"
	disable
end

*/
