<?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="moon"/>
	<tech-tree value="space"/>
	<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()
			
			--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))
			
			--PLAYER
			
			--Now it is time to create some units for us
			
			--Create 3 MELEE units first
			for i=1, 3 do
				createUnit('energy_soldier', 1, startLocation(1))
			end	
			
			--Now create 2 RANGED units
			for i=1, 2 do
				createUnit('plasma_gunner', 1, startLocation(1))
			end			
			
			--ENEMY
			
			--Create a small base for the enemy
			createUnit('detirium_tank', 2, startLocation(2))
			build1Unit= lastCreatedUnit()
			for i=1, 3 do
			createUnit('energy_soldier', 2, startLocation(2))
			end
			
			--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_beginning')
			showMessage('Brief2', 'moon_objectives')
			--Show display text of mission
			setDisplayText('ObjectiveDefend1')
			
			--Create the army of 1
			
			--NOTE that this unit can be changed but MUST BE A FUCKING MELEE UNIT!!!
			createUnit('energy_soldier', 3, startLocation(2))
			wave1Unit= lastCreatedUnit()
			givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))
			--Give this unit a name NOTE THIS WONT APPEAR IN GAME, ITS JUST A VARIABLE
			
			
		</startup>
		
		<unitDied>
		--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 the army of 1 (wave 1) has been killed, create a new wave!
			if lastDeadUnit()==wave1Unit then
				clearDisplayText()
				--NOW CREATE THE STARSHIP ENTERPRISE WHICH MUST BE PROTECTED
					createUnit('grav_tank',1, startLocation(1))
					enterpriseUnit= lastCreatedUnit()
					--Give it the Attention
					setCameraPosition(unitPosition(enterpriseUnit))
					showMessage('Brief3', 'moon_enterprise')
					setDisplayText('ObjectiveDefend2')
					
					objective = 'defend_attack_2'
					
				--Create multiple enemies NOTE THIS UNIT MUST BE A MELEE UNIT
					createUnit('energy_soldier', 2, startLocation(2))
					givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))
					createUnit('energy_soldier', 2, startLocation(2))
					givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))
					createUnit('energy_soldier', 2, startLocation(2))
					givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))
					createUnit('energy_soldier', 2, startLocation(2))
					givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))
					createUnit('energy_soldier', 3, startLocation(2))
					givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))

			end
		--Once the squad has died, give the player a command to clear the place!
			if objective=='defend_attack_2' and unitCount(3)==0 then
			
				--Change the objective
				
				setDisplayText('ObjectiveDefend3')
				createUnit('energy_soldier', 0, startLocation(2))
				
				objective = 'defend_attack_3'

				end
			
		--Make sure the player knows where he is attacking.
		
		--If build1Unit is dead, player gets a message lol
			if lastDeadUnit()== build1Unit then
			showMessage('Brief4', 'moon_destroyed')
				clearDisplayText()
				setPlayerAsWinner(0)
				setPlayerAsWinner(1)				
				endGame()
			end
		
			
		</unitDied>		
	</scripts>		
</scenario>
