<?xml version="1.0" standalone="yes" ?> 
<scenario>
	<difficulty value="1"/>
	<players>
		<player control="cpu" faction="moon" team="1"/>
		<player control="human" faction="moon" team="1"/>
		<player control="cpu" faction="moon" team="2"/>
		<player control="cpu" faction="moon" team="2"/>		
	</players>
	<map value="in_the_forest"/>
	<tileset value="winter"/>
	<tech-tree value="moon_alpha"/>
	<default-resources value="false"/>
	<default-units value="false"/>
	<default-victory-conditions value="false"/>
	<scripts>
				<startup>
			--Make sure we disable it so that we can modify the scenario!
			disableAi(0)
			disableAi(2)
			disableAi(3)
			
			--Remember team 0 is our ally and team 1 is us. Team 2 and 3 are the enemies!
			
			--ALLY
			
			--Give the ally some units and shit
			
			--Make sure we have the base here
			createUnit('base', 0, startLocation(1))
			baseUnit= lastCreatedUnit()
			
			--Now create a small outpost in the area we last sieged
			createUnit('research_centre', 0, startLocation(2))
			
			--Some resources incase our ally makes something
			giveResource('gold', 0, 1000); 
			giveResource('wood', 0, 1000);
			giveResource('stone', 0, 1000);
			giveResource('detirium', 0, 1000);
			
			--We need to create a turret incase we get owned
			createUnit('particle_cannon', 0, startLocation(1))	
			
			--Create a few more buildings that won't do shit, just to make the base look big
			createUnit('detirium_tank', 0, startLocation(1))
			createUnit('particle_cannon', 0, startLocation(1))
			
			--Now create the Astral Telescope all the way in the mountains which needs to be protected
			createUnit('telescope', 0, startLocation(0))
			astralUnit= lastCreatedUnit()
			
			--PLAYER
			
			--Now it is time to create some units for us
			
			--Though this mission is edit from the moon a beggining you start off with more units
			
			--Create 12 MELEE units first
			for i=1, 12 do
				createUnit('energy_soldier', 1, startLocation(1))
			end	
			
			--Now create 6 RANGED units
			for i=1, 6 do
				createUnit('plasma_gunner', 1, startLocation(1))
			end			
			
			--Create some units to be placed near the research center
				createUnit('energy_soldier', 1, startLocation(2))
				createUnit('energy_soldier', 1, startLocation(2))
				createUnit('energy_soldier', 1, startLocation(2))
			
			--Create research center garrison
				createUnit('phaser', 0, startLocation(2))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))
				
			--Create telescope garrison
				createUnit('energy_soldier', 0, startLocation(0))
			
			--The enterprise is in ally hands now
				createUnit('grav_tank',0, startLocation(1))
				enterpriseUnit= lastCreatedUnit()
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(3))
				
			--ENEMY
			
			--Create the fortress for the enemy
			createUnit('base', 3, startLocation(3))
			evilUnit= lastCreatedUnit()
			createUnit('particle_cannon', 3, startLocation(3))
			createUnit('detirium_tank', 3, startLocation(3))
			createUnit('garage', 3, startLocation(3))
			garageUnit= lastCreatedUnit()
			createUnit('detirium_tank', 3, startLocation(3))
			createUnit('research_centre', 3, startLocation(3))
			
			for i=1, 12 do
			createUnit('energy_soldier', 3, startLocation(3))
			end
			
			createUnit('plasma_gunner', 3, startLocation(3))
			
			--We will now create an introduction screen where the player will know what to do
			
			--This will set the camera position on the base.
			setCameraPosition(unitPosition(baseUnit))
			--This will put our objective, NOTE this is a variable and has nothing to do with actual gameplay
			objective='defend_attack_1'
			--Show messages
			showMessage('Brief1', 'moon_astral')
			showMessage('Brief2', 'moon_objectives')
			--Show display text of mission
			setDisplayText('ObjectiveDefend1')
			
			--Send the Enterprise in to lead us to battle!

			--Create the squad that will attempt to kill the telescope!
			
			--NOTE that this unit can be changed but MUST BE A FUCKING MELEE UNIT!!!
			for i=1, 8 do
			createUnit('energy_soldier', 3, startLocation(3))
			givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))
			end
			
		</startup>
		
		<unitDied>
		--3 units that we cannot lose
		
		--If we lose our tank which is the so called Enterprise then we lose
			if lastDeadUnit()==enterpriseUnit then
				clearDisplayText()
				setPlayerAsWinner(2)
				setPlayerAsWinner(3)				
				endGame()
			end

		--If we lose our telescope then research is over!
			if lastDeadUnit()==astralUnit then
				clearDisplayText()
				setPlayerAsWinner(2)
				setPlayerAsWinner(3)				
				endGame()
			end
			
				--If we lose our base then we are defeseless!
			if lastDeadUnit()==baseUnit then
				clearDisplayText()
				setPlayerAsWinner(2)
				setPlayerAsWinner(3)				
				endGame()
			end
		
		--If garage dies say a message :D
			if lastDeadUnit()== garageUnit then
				showMessage('Brief3', 'moon_destroyed')
				end
			
		--If the enemy base dies, then we win!
			if unitCount(3)==0 then
				clearDisplayText()
				setPlayerAsWinner(0)
				setPlayerAsWinner(1)				
				endGame()
			end
				
		</unitDied>		
	</scripts>		
</scenario>