define script setGlobals
define script StartScript
define script TownDesires

run script MainScript

begin script MainScript
	rand = number from 0 to 10
start

	//if Rand == 0
		start music "aztecmarchingsmall_01" loop forever
/*	elseif Rand == 1
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 2
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 3
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 4
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 5
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 6
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 7
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 8
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 9
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 10
		start music "aztecmarchingsmall_01" loop forever
	elseif Rand == 11
*/

//wait 5 seconds
	run script ResearchStandardBuildings
	run script setGlobals
	run background script HurricaneScript
	run background script VolcanoScript
	run background script EarthquakeScript
	run background script SirenScript
	run background script KalevFPS
	run background script ImmortalManScript	
	run script EvilCreatures
	
	run script CreatureSelect

	run background script GateHouseControl
	run background script CreaturePen
	run background script AttackBarrels
	run background script TakeOverStatus
	run background script StartScript
	run background script TownDesires
	//run background script Objectives1

	set toolbar state to MENU_TOOLBAR_STATE_CLOSED
	stop music with fadetime 15
	disable global influence
	disable load screen
	set fade in time 0
	wait until 1!= 1
end script MainScript

/////////////////
begin script setGlobals
	Cnt = 0
	Ctr = 0
	Gates = 0
	Temp = 0
	Check[NUMBER_OF_TOWNS]
start

	force while Cnt < NUMBER_OF_TOWNS 
		Check[Cnt] = get town with id Cnt
		if Check[Cnt] exists

			// Built the Town[] array
			Town[Ctr] = Check[Cnt]

			// Set playerTown as player 0 town
			if get Check[Cnt] player == 0
				playerTown = Check[Cnt]
				wait 1 seconds
			end if
			Ctr++
		end if
		Cnt++
	end while
	
	// townCount is a global variable with the number of towns
	townCount = Ctr
	wait 1 seconds

/*	// For setting the amount and order of the ojective classes
	set player 0 objective class TRIBUTE_OBJECTIVE_CLASS_SPECIAL amount 12
	set player 0 objective class TRIBUTE_OBJECTIVE_CLASS_RESOURCES amount 12
	set player 0 objective class TRIBUTE_OBJECTIVE_CLASS_TOWN amount 12
	set player 0 objective class TRIBUTE_OBJECTIVE_CLASS_ARMY amount 12
	set player 0 objective class TRIBUTE_OBJECTIVE_CLASS_CREATURE amount 12
*/

end script setGlobals

begin script StartScript

String = 0
start	

	begin loop
		wait 10 seconds
		until get tech level of town playerTown == 2 or RunAI != 0
	end loop

	increment tribute by 911
	begin dialogue
		say "Your world is at war!!!"
		wait 5 seconds
		say "It's time to prepare for the onslaught."
		wait 5 seconds
		clear dialogue
		close dialogue
	end dialogue
	run script CreateTownArray
	run background script RunTownAIForAll

end script StartScript

begin script TownDesires
	Switch = 1
start
	enable town playerTown desire speech
	begin loop
		if Switch == 1
			wait until key KB_K down
			disable town playerTown desire speech
			begin dialogue
				say "Ok, we'll shut up"
				wait 2 seconds
				close dialogue
			end dialogue
			Switch = 0
		elsif Switch == 0
			wait until key KB_K down
			enable town playerTown desire speech
			begin dialogue
				say "Let's tell the Great One what we think."
				wait 2 seconds
				close dialogue
			end dialogue
			Switch = 1
		end if
	end loop
end script TownDesires



