<?xml version="1.0" standalone="yes" ?> 
<scenario>
<difficulty value="2"/>
<players>
	<player control="human" faction="aztec" team="1"/>
	<player control="cpu"  faction="aztec" team="1"/>
	<player control="cpu" faction="goths" team="3"/>
	<player control="cpu" faction="goths" team="3"/>
</players>
<map value="forest_hunt"/>
<tileset value="forest"/>
<tech-tree value="vbros_pack_5"/>
	<default-resources value="true"/>	
	<default-units value="false"/>
	<default-victory-conditions value="false"/>
	<scripts>
		<startup>

			--disable AI
			disableAi(0)
			disableAi(2)
			disableAi(3)

			--player units

			createUnit('stick_warrior', 0, startLocation(0))
			createUnit('food', 0, startLocation(0))
			createUnit('food', 0, startLocation(1))
			createUnit('food', 0, startLocation(2))
			createUnit('food', 0, startLocation(3))
			createUnit('blow_pipe_man', 0, startLocation(0))
			createUnit('blow_pipe_man', 0, startLocation(0))
			createUnit('club_fighter', 0, startLocation(0))
			createUnit('club_fighter', 0, startLocation(0))
			createUnit('club_fighter', 0, startLocation(0))
			createUnit('spearman', 0, startLocation(0))
			createUnit('spearman', 0, startLocation(0))
			createUnit('stone_grainery', 0, startLocation(0))	
			sgUnit= lastCreatedUnit()

			for i=1, 1 do
				createUnit('stone_grainery', 1, startLocation(0))
			end

			for i=1, 1 do
				createUnit('pyramid', 1, startLocation(0))
			end

			for i=1, 1 do
				createUnit('laborer', 1, startLocation(0))
			end

			--enemy units village
			createUnit('spider', 3, startLocation(1))
			createUnit('bull_pen', 3, startLocation(1))
			createUnit('sonrab', 3, startLocation(1))	
			spiderUnit= lastCreatedUnit()

			--create enemy attackers
			for i=1, 4 do
				createUnit('swordsman', 3, startLocation(1))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))	
			end
			for i=1, 2 do
				createUnit('spear_thrower', 3, startLocation(1))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))	
			end

			--objectives
			objective='destroy_the_goths'
			showMessage('Brief1', 'Storming')
			showMessage('Brief2', 'Storming')
			setDisplayText('lesson1')

		</startup>
		
		<unitDied>
			--check for spider dying
			if lastDeadUnit()==sgUnit then
				clearDisplayText()
				setPlayerAsWinner(2)
				setPlayerAsWinner(3)				
				endGame()
			end
	
			--check for first village destroyed
			if lastDeadUnit()==spiderUnit then	
		
				
				--create next village
				createUnit('priest', 2, startLocation(2))	
				createUnit('buzau', 2, startLocation(2))
				createUnit('bull', 2, startLocation(2))
				createUnit('spider', 2, startLocation(2))
			        createUnit('bull_pen', 2, startLocation(2))	
			spider2Unit= lastCreatedUnit()

				--change objective
				objective='destroy_gothic_village'
				setDisplayText('lesson1')				
			end	

			--check for village destroyed
			if lastDeadUnit()==spider2Unit then	
		
				
				--create next village
				createUnit('shadow_knight', 3, startLocation(3))	
				createUnit('kochi_camp', 3, startLocation(3))
				createUnit('bull', 3, startLocation(3))
				createUnit('spear_thrower', 3, startLocation(3))
				createUnit('swordsman', 3, startLocation(3))
				createUnit('swordsman', 3, startLocation(3))
			        createUnit('bull_pen', 3, startLocation(3))	
			        createUnit('sonrab', 3, startLocation(3))
			spider3Unit= lastCreatedUnit()

			--create free army
			for i=1, 5 do
				createUnit('club_fighter', 0, startLocation(0))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))	
			end

			--create enemy attackers
			for i=1, 2 do
				createUnit('swordsman', 3, startLocation(3))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(3))	
			end

			for i=1, 2 do
				createUnit('swordsman', 3, startLocation(3))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))	
			end

				--change objective
				objective='destroy_gothic_village'
				setDisplayText('lesson2')				
			end

			--check for village destroyed
			if lastDeadUnit()==spider3Unit then	
		
				
				--create next village
				createUnit('shadow_knight', 2, startLocation(2))	
				createUnit('kochi_camp', 2, startLocation(2))
				createUnit('fire_swordsman', 2, startLocation(2))
				createUnit('kochi_camp', 2, startLocation(2))
				createUnit('bull', 2, startLocation(2))
				createUnit('bull', 2, startLocation(2))
				createUnit('spear_thrower', 2, startLocation(2))
				createUnit('spider', 2, startLocation(2))
				createUnit('swordsman', 2, startLocation(2))
			        createUnit('bull_pen', 2, startLocation(2))	
			        createUnit('sonrab', 2, startLocation(2))
			spider4Unit= lastCreatedUnit()

			--create free army
			for i=1, 6 do
				createUnit('shielded_stick_warrior', 0, startLocation(3))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))	
			end

			--create enemy attackers
			for i=1, 3 do
				createUnit('shadow_knight', 2, startLocation(2))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))	
			end

			for i=1, 5 do
				createUnit('swordsman', 2, startLocation(2))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(3))	
			end

				--change objective
				objective='destroy_gothic_village'
				setDisplayText('lesson2')				
			end

			--check for village destroyed
			if lastDeadUnit()==spider4Unit then	
		
				
				--create next village
				createUnit('axe_man', 3, startLocation(3))	
				createUnit('kochi_camp', 3, startLocation(3))
				createUnit('fire_swordsman', 3, startLocation(3))
				createUnit('bat', 3, startLocation(3))
				createUnit('bull', 3, startLocation(3))
				createUnit('bull', 3, startLocation(3))
				createUnit('bull_pen', 3, startLocation(3))
				createUnit('spider', 3, startLocation(3))
				createUnit('spider', 3, startLocation(3))
				createUnit('swordsman', 3, startLocation(3))
				createUnit('swordsman', 3, startLocation(3))
				createUnit('swordsman', 3, startLocation(3))
			        createUnit('bull_pen', 3, startLocation(3))	
			        createUnit('sonrab', 3, startLocation(3))
			spider5Unit= lastCreatedUnit()

			--create free army

			createUnit('pyramid', 0, startLocation(0))
			createUnit('laborer', 0, startLocation(0))

			for i=1, 2 do
				createUnit('shielded_stick_warrior', 0, startLocation(0))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))	
			end

			--create enemy attackers
			for i=1, 2 do
				createUnit('shadow_knight', 3, startLocation(3))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(2))	
			end

			for i=1, 2 do
				createUnit('priest', 3, startLocation(3))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(0))	
			end

			for i=1, 8 do
				createUnit('swordsman', 3, startLocation(3))
				givePositionCommand(lastCreatedUnit(), 'attack', startLocation(1))	
			end

				--change objective
				objective='destroy_gothic_village'
				setDisplayText('lesson2')				
			end

		
			--check for last village destroyed
			if lastDeadUnit()==spider5Unit then
				clearDisplayText()
				setPlayerAsWinner(0)
				setPlayerAsWinner(1)				
				endGame()
			end

			
		</unitDied>		
	</scripts>		
</scenario>
