<?xml version="1.0" standalone="yes" ?> 
<scenario>
	<difficulty value="3"/>
	<players>
		<player control="human" faction="tech" team="1"/>000
		<player control="cpu" faction="tech" team="2"/>1111
		<player control="cpu" faction="tech" team="2"/>2222
		<player control="cpu" faction="tech" team="2"/>	3333	
		<player control="cpu-easy" faction="tech" team="1"/>444
		<player control="cpu" faction="tech" team="1"/>555
		<player control="cpu" faction="tech" team="1"/>666
		<player control="cpu" faction="creatures" team="2"/>777	
	</players>
	<map value="stranded_island"/>
	<tileset value="stranded2"/>
	<tech-tree value="stranded"/>
	<default-resources value="false"/>
	<default-units value="false"/>
	<fog-of-war value="true"/>
	<default-victory-conditions value="false"/>
	<scripts>
		<startup>

			timer_event0 = startTimerEvent()
			timer_eventwater111 = startTimerEvent()

			createUnit('crab', 1, startLocation(7))
					jk= lastCreatedUnit()
			createUnit('turtle', 1, startLocation(7))
			createUnit('crab', 1, startLocation(7))
					jk= lastCreatedUnit()
			createUnit('turtle', 1, startLocation(7))
			kiwi1= lastCreatedUnit()
			createUnit('kiwi', 1, startLocation(7))
			kiwi1= lastCreatedUnit()
			createUnit('kiwi', 1, startLocation(7))
			kiwi1= lastCreatedUnit()
			createUnit('kiwi', 1, startLocation(7))
			kiwi1= lastCreatedUnit()

			createUnit('you', 0, startLocation(0))
			you= lastCreatedUnit()

					togglePauseGame(1);

			showMessage('startup0', 'stranded')
			showMessage('startup1', 'stranded')
			showMessage('startup2', 'stranded')
			showMessage('startup3', 'you')
			showMessage('startup4', 'you')
			showMessage('startup5', 'stranded')
			showMessage('startup6', 'stranded')

<!--"0not real units
			createUnit('native_man', 0, startLocation(0))
			hunter2= lastCreatedUnit()

			createUnit('native_woman', 4, startLocation(4))
			nativew1= lastCreatedUnit()

			createUnit('bamboo_hut', 4, {startLocation(4)[1] - 0, startLocation(4)[2] - 6})
			hut1Unit= lastCreatedUnit()

			createUnit('jaguar', 0, {startLocation(0)[1] + 15, startLocation(0)[2] - 0})
			jag= lastCreatedUnit()

0-->

			disableAi(7)
			disableAi(4)
			disableAi(6)
			disableAi(5)
			disableConsume(1)

			createUnit('castle', 1, {startLocation(5)[1] - 6, 5})
			wining1= lastCreatedUnit()

			createUnit('macaw', 1, {startLocation(5)[1] - 6, startLocation(5)[2] - 100})
			createUnit('macaw', 1, {startLocation(5)[1] - 6, startLocation(5)[2] - 100})
			createUnit('jaguar', 1, {startLocation(5)[1] - 6, startLocation(5)[2] - 100})

			createUnit('jaguar', 1, {startLocation(5)[1] - 6, startLocation(5)[2] + 100})
			createUnit('crab', 1, {startLocation(5)[1] - 6, startLocation(5)[2] + 100})
					jk= lastCreatedUnit()
			createUnit('kiwi', 1, {startLocation(5)[1] - 6, startLocation(5)[2] + 100})
			createUnit('kiwi', 1, {startLocation(5)[1] - 6, startLocation(5)[2] + 100})

			createUnit('kiwi', 3, startLocation(3))
			kiwi1= lastCreatedUnit()

			createUnit('macaw', 3, startLocation(3))
			macaw= lastCreatedUnit()

			createUnit('deer', 2, startLocation(3))
			deer= lastCreatedUnit()

			createUnit('kiwi', 2, startLocation(3))
			deer8= lastCreatedUnit()

			createUnit('kiwi', 2, startLocation(3))
			givePositionCommand(lastCreatedUnit(), 'move', startLocation(1))
			kiwi2= lastCreatedUnit()
			createUnit('water_fountian', 2, {startLocation(3)[1] - 24, startLocation(3)[2] + 30})
			wf1= lastCreatedUnit()

			createUnit('water_fountian', 2, {startLocation(7)[1] + 10 , startLocation(7)[2] + 10})
			wf= lastCreatedUnit()

			createUnit('wreck', 0, {startLocation(0)[1] - 0, startLocation(0)[2] + 12})
			createUnit('wood', 0, {startLocation(0)[1] - 3, startLocation(0)[2] + 10})
			createUnit('wood', 0, {startLocation(0)[1] + 4, startLocation(0)[2] + 5})
			createUnit('wood', 0, {startLocation(0)[1] - 10, startLocation(0)[2] + 6})

			createUnit('crate', 0, {startLocation(0)[1] - 11, startLocation(0)[2] + 0})
			c1= lastCreatedUnit()
			createUnit('barrel', 0, {startLocation(0)[1] - 12, startLocation(0)[2] + 6})
			b1= lastCreatedUnit()
			createUnit('crate', 0, {startLocation(0)[1] - 3, startLocation(0)[2] + 6})
			c2= lastCreatedUnit()
			createUnit('crate', 0, {startLocation(0)[1] + 3, startLocation(0)[2] + 8})
			c3= lastCreatedUnit()

			giveResource('food', 0, 80); 
			giveResource('water', 0, 20); 
			giveResource('wood', 0, 0); 
			giveResource('gold', 0, 0); 
			giveResource('stone', 0, 0); 
			giveResource('leaves', 0, 0); 
			giveResource('furs', 0, 1); 
			giveResource('wheat', 0, 0); 

			createUnit('crab', 1, startLocation(1))
					jk= lastCreatedUnit()
			createUnit('turtle', 1, startLocation(2))
			t1= lastCreatedUnit()
			createUnit('crab', 1, startLocation(1))
					jk= lastCreatedUnit()
			createUnit('crab', 1, startLocation(1))
			jk= lastCreatedUnit()
			createUnit('crab', 1, startLocation(1))
			jk= lastCreatedUnit()
			createUnit('monkey', 3, startLocation(3))
			monk= lastCreatedUnit()


    			 cell_eventlastoneever111 = registerCellTriggerEventForUnitToUnit(you,wining1)
			
		</startup>

		<resourceHarvested>
			if objective=='objective_gold' and resourceAmount('gold', 0)>=20 then

    			 cell_event22 = registerCellTriggerEventForUnitToUnit(you,hunter2)
end

			if objective=='objective_pie' and resourceAmount('wood', 0)>=300
			and resourceAmount('stone', 0)>=50
			and resourceAmount('leaves', 0)>=40 then

    			 cell_event_piedone = registerCellTriggerEventForUnitToUnit(you,pie)
end

			if objective=='objective_pie88' and resourceAmount('wood', 0)>=280
			and resourceAmount('wheat', 0)>=130
			and resourceAmount('gold', 0)>=100
			and resourceAmount('leaves', 0)>=200 then

    			 cell_event_lastone = registerCellTriggerEventForUnitToUnit(you,pie)
end

		</resourceHarvested>
		
		<unitCreated>					
		</unitCreated>

		<cellTriggerEvent> 

		       if triggeredCellEventId() == cell_eventlastoneever111 then 

			showMessage('ending1', 'stranded')
				setPlayerAsWinner(0)				
				endGame()

 		         unregisterCellTriggerEvent(cell_eventlastoneever111)

		       end  

		       if triggeredCellEventId() == cell_event_lastone then 

				giveResource('wheat', 0, -130); 
				giveResource('leaves', 0, -200); 
				giveResource('gold', 0, -100); 
				giveResource('wood', 0, -280); 
			createUnit('_', 0, startLocation(0))
			showMessage('yyy', 'pirate')
			morphToUnit(you,'fly',1)
 		         unregisterCellTriggerEvent(cell_event_lastone)

		       end  

		       if triggeredCellEventId() == cell_event_lastpie_mission then 

			objective='objective_pie88'
			showMessage('rat1', 'pirate')
			showMessage('rat2', 'you')
			showMessage('rat3', 'pirate')
			showMessage('rat4', 'you')
			showMessage('rat5', 'pirate')
			showMessage('rat6', 'pirate')
			showMessage('rat7', 'you')

 		         unregisterCellTriggerEvent(cell_event_lastpie_mission)

		       end

		       if triggeredCellEventId() == cell_event_piedone then 

			morphToUnit(you,'get_gun',1)

			objective='objective_pie'
			showMessage('pie01', 'pirate')
			showMessage('pie02', 'pirate')
			showMessage('human01', 'you')

			giveResource('gold', 0, 400); 
			giveResource('wood', 0, -300); 
			giveResource('stone', 0, -50); 
			giveResource('leaves', 0, -40); 

 		         unregisterCellTriggerEvent(cell_event_piedone)

		       end  

		       if triggeredCellEventId() == cell_eventpie then 

			objective='objective_pie'
			showMessage('pie1', 'pirate')
			showMessage('human1', 'you')
			showMessage('pie2', 'pirate')
			showMessage('human2', 'you')
			showMessage('pie3', 'pirate')
			showMessage('pie4', 'pirate')
			showMessage('pie5', 'pirate')
			showMessage('human22', 'you')
			showMessage('pie6', 'pirate')
			showMessage('human3', 'you')

 		         unregisterCellTriggerEvent(cell_eventpie)

		       end  


		       if triggeredCellEventId() == event_donek then 

				createUnit('shanty', 5, startLocation(5))
			pie_house= lastCreatedUnit()
				createUnit('pirate', 5, startLocation(5))
			pie= lastCreatedUnit()

    			 cell_eventpie = registerCellTriggerEventForUnitToUnit(you,pie) 

			giveResource('furs', 0, 12); 
			showMessage('you1', 'native')
			showMessage('Brief98', 'you')
			showMessage('you2', 'native')
 		         unregisterCellTriggerEvent(event_donek)
			destroyUnit(bmh88);

		       end

		       if triggeredCellEventId() == cell_event0 then 
			giveResource('water', 0, 100); 
			showMessage('Brief2', 'stranded')
 		         unregisterCellTriggerEvent(cell_event0)

		       end

		       if triggeredCellEventId() == cell_event00 then 
			giveResource('water', 0, 100); 
			showMessage('Brief2', 'stranded')
 		         unregisterCellTriggerEvent(cell_event00)

		       end

		       if triggeredCellEventId() == cell_event1 then 

			enableAi(3)

			destroyUnit(hunter);

			createUnit('native_man', 6, startLocation(2))
			hunter2= lastCreatedUnit()
			giveAttackStoppedCommand(hunter2,'hold_position',1)

			objective='objective_gold'
			showMessage('Brief01', 'you')
			showMessage('Brief001', 'native')
			showMessage('Brief002', 'native')
			showMessage('Brief02', 'you')
			showMessage('Brief003', 'native')
			showMessage('Brief03', 'you')
			setDisplayText('objective2')
				clearDisplayText()
				unregisterCellTriggerEvent(cell_event1)

		       end

		       if triggeredCellEventId() == event_goinhut then 
			disableAi(6)
				showMessage('killman', 'native')
				showMessage('Brief99', 'you')
				showMessage('killman2', 'native')
			disableAi(1)
				disableConsume(1)
				createUnit('bamboo_hut', 1, startLocation(1))
			bmh88= lastCreatedUnit()
				createUnit('unfriendly_native', 1, startLocation(1))
				badUnit= lastCreatedUnit()
				clearDisplayText()
				setDisplayText('kill')
				timer_event1 = startTimerEvent()
				unregisterCellTriggerEvent(event_goinhut)
		       end

		       if triggeredCellEventId() == cell_event22 then 

			disableConsume(6)
			disableConsume(4)

			giveResource('gold', 0, -20); 

			createUnit('bamboo_hut', 4, {startLocation(4)[1] - 0, startLocation(4)[2] - 6})
			hut1Unit= lastCreatedUnit()
			createUnit('bamboo_hut', 4, {startLocation(4)[1] - 4, startLocation(4)[2] - 6})
			createUnit('fire', 4, {startLocation(4)[1] - 2, startLocation(4)[2] - 0})

			createUnit('native_man', 4, startLocation(4))
			nn2Unit= lastCreatedUnit()
			createUnit('native_man', 4, startLocation(4))
			nn1= lastCreatedUnit()
			createUnit('native_woman', 4, startLocation(4))
			nativew1= lastCreatedUnit()
			createUnit('native_woman', 4, startLocation(4))
			createUnit('native_woman', 4, startLocation(4))

			givePositionCommand(hunter2, 'move', startLocation(4))

    			event_goinhut = registerCellTriggerEventForUnitToUnit(you,hut1Unit)

			showMessage('Brief004', 'native')
			showMessage('Brief005', 'native')
			showMessage('Brief006', 'native')
			setDisplayText('objective')
				clearDisplayText()
				unregisterCellTriggerEvent(cell_event22)

		       end



		       if triggeredCellEventId() == cell_event_last22 then 

			showMessage('rude1', 'native')
			showMessage('boyo1', 'you')
			showMessage('rude2', 'native')
			showMessage('boyo2', 'you')
			showMessage('rude3', 'native')
			showMessage('boyo3', 'thoughts')

    			 cell_event_lastpie_mission = registerCellTriggerEventForUnitToUnit(you,pie)

			enableAi(4)


 		         unregisterCellTriggerEvent(cell_event_last22)

		       end 





		       if triggeredCellEventId() == cell_event_bird1 then 


			createUnit('jaguar', 2, {startLocation(5)[1] + 15, startLocation(5)[2] - 0})
			jag= lastCreatedUnit()
			givePositionCommand(lastCreatedUnit(), 'attack', startLocation(3))

			giveAttackStoppedCommand(hunter2,'hold_position88',1)	

			showMessage('01', 'native')
			showMessage('02', 'you')
			showMessage('03', 'native')
			showMessage('04', 'you')
			showMessage('05', 'native')
			showMessage('06', 'native')
			showMessage('07', 'you')
			showMessage('08', 'thoughts')

			giveResource('gold', 0, -50); 


 		         unregisterCellTriggerEvent(cell_event_bird1)

		       end  

		       if triggeredCellEventId() == cell_event_crea then 



			showMessage('nnw1', 'native_woman')
			showMessage('nnw2', 'native_woman')
			showMessage('tho99', 'thoughts')
			showMessage('youttnnw', 'you')
			showMessage('nnw3', 'native_woman')

                     enableAi(7)
 
			createUnit('jako', 7, startLocation(6))
			createUnit('jako', 7, startLocation(6))
			createUnit('jako', 7, startLocation(6))
			createUnit('jako', 7, startLocation(6))
			createUnit('jako', 7, startLocation(6))
			createUnit('jako', 7, startLocation(6))
			createUnit('kitly', 7, startLocation(6))
			kitly= lastCreatedUnit()

			createUnit('jako', 7, startLocation(7))
			createUnit('jako', 7, startLocation(7))
			createUnit('jako', 7, startLocation(7))
			createUnit('jako', 7, startLocation(7))
			createUnit('jako', 7, startLocation(7))
			createUnit('jako', 7, startLocation(7))
			createUnit('kitly', 7, startLocation(7))

			moveToUnit(nativew1, hut1Unit)


 		         unregisterCellTriggerEvent(cell_event_crea)

		       end  






		</cellTriggerEvent> 

		<timerTriggerEvent>
			if triggeredTimerEventId() == timer_event0 then
				if timerEventSecondsElapsed(triggeredTimerEventId()) >= 20 then
    			 cell_event0 = registerCellTriggerEventForUnitToUnit(you,wf)
					stopTimerEvent(timer_event0)
					timer_event0 = startTimerEvent()
				end
			end

			if triggeredTimerEventId() == timer_eventwater111 then
				if timerEventSecondsElapsed(triggeredTimerEventId()) >= 20 then
    			 cell_event00 = registerCellTriggerEventForUnitToUnit(you,wf1)
					stopTimerEvent(timer_eventwater111)
					timer_eventwater111 = startTimerEvent()
				end
			end

			if triggeredTimerEventId() == timer_event1 then
				if timerEventSecondsElapsed(triggeredTimerEventId()) >= 80 then
<!--					giveAttackCommand(hunter2, you)-->
					stopTimerEvent(timer_event1)
				end
			end
		</timerTriggerEvent>  	
		
		<unitDied>

			if lastDeadUnit()==deer8 then


			createUnit('kiwi', 2, startLocation(7))
			createUnit('crab', 2, startLocation(7))
					jk= lastCreatedUnit()
			createUnit('turtle', 2, startLocation(7))
			createUnit('crab', 2, startLocation(7))
					jk= lastCreatedUnit()
			createUnit('kiwi', 2, startLocation(7))
			deer8= lastCreatedUnit()


end

			if lastDeadUnit()==jag then

			enableAi(2)

    			 cell_event_crea = registerCellTriggerEventForUnitToUnit(nativew1,you)

			giveResource('food', 0, 50); 
			giveResource('furs', 0, 5); 

			showMessage('jobdone1', 'native')
			showMessage('jobdone2', 'you')
			showMessage('jobdone3', 'native')
			showMessage('jobdone4', 'thoughts')


			moveToUnit(hunter2, hut1Unit)
			moveToUnit(nativew1, you)


end

			if lastDeadUnit()==kitly then

			enableAi(2)

    			 cell_event_last22 = registerCellTriggerEventForUnitToUnit(you,hunter2)

end

			if lastDeadUnit()==hunter2 then

			giveAttackCommand(nn1, you)
			giveAttackCommand(nn2, you)

			showMessage('ndie1', 'native_tribe')
			showMessage('ndie2', 'native_tribe')
			showMessage('ndie3', 'native_tribe')

end

			if lastDeadUnit()==macaw then

			giveResource('food', 0, 8); 
			giveResource('furs', 0, 1); 

    			 cell_event_bird1 = registerCellTriggerEventForUnitToUnit(hunter2,you)

			moveToUnit(hunter2, you)

			disableAi(2)

end


			if lastDeadUnit()==t1 then
			giveResource('food', 0, 11); 
			giveResource('furs', 0, 1); 

				math.randomseed(os.time())
				rtime = math.random(1, 2)
				if rtime == 1 then
					createUnit('turtle', 2, startLocation(1))
			t1= lastCreatedUnit()
				elseif rtime == 2 then
					createUnit('turtle', 2, startLocation(2))
			t1= lastCreatedUnit()
				end

end

			if lastDeadUnit()==deer then

			disableAi(3)

			giveResource('food', 0, 50); 
			giveResource('furs', 0, 2);

			createUnit('native_man', 3, startLocation(2))
			hunter= lastCreatedUnit()

			giveAttackStoppedCommand(hunter,'hold_position',1)

    			 cell_event1 = registerCellTriggerEventForUnitToUnit(you,hunter) 

end

			if lastDeadUnit()==kiwi2 then
			giveResource('food', 0, 8); 
end

			if lastDeadUnit()==kiwi1 then

			giveResource('food', 0, 8); 

				math.randomseed(os.time())
				rtime = math.random(1, 4)
				if rtime == 1 then
					createUnit('kiwi', 1, {startLocation(3)[1] - 10, startLocation(3)[2] - 7})
					kiwi1= lastCreatedUnit()
				elseif rtime == 2 then
					createUnit('kiwi', 1, {startLocation(3)[1] + 5, startLocation(3)[2] - 10})
					kiwi1= lastCreatedUnit()
				elseif rtime == 3 then
					createUnit('kiwi', 1, {startLocation(0)[1] + 8, startLocation(0)[2] + 5})
					kiwi1= lastCreatedUnit()
				elseif rtime == 4 then
					createUnit('kiwi', 1, {startLocation(0)[1] + 11, startLocation(0)[2] + 0})
					kiwi1= lastCreatedUnit()
				end

			end

			if lastDeadUnit()==c1 then

			showMessage('Brief0', 'stranded')
			giveResource('food', 0, 3); 

end

			if lastDeadUnit()==c2 then

			showMessage('Brief1', 'stranded')
			giveResource('wood', 0, 50); 
			giveResource('furs', 0, 1); 

end

			if lastDeadUnit()==c3 then

			showMessage('Brief3', 'stranded')

end

			if lastDeadUnit()==b1 then

			showMessage('Brief4', 'stranded')
			giveResource('food', 0, 10); 
			giveResource('leaves', 0, 20); 

end


			if lastDeadUnit()==you then

				setPlayerAsWinner(3)				
				endGame()
end

			if lastDeadUnit()==badUnit then
				giveAttackStoppedCommand(hunter2,'hold_position',1)
				showMessage('igh', 'you')
				clearDisplayText()
    				event_donek = registerCellTriggerEventForUnitToUnit(you,hunter2) 
			end

			if lastDeadUnit()==jk then

			giveResource('food', 0, 6); 

				math.randomseed(os.time())
				rtime = math.random(1, 4)
				if rtime == 1 then
					createUnit('crab', 1, {startLocation(1)[1] - 10, startLocation(1)[2] - 7})
					jk= lastCreatedUnit()
				elseif rtime == 2 then
					createUnit('crab', 1, {startLocation(1)[1] + 5, startLocation(1)[2] - 10})
					jk= lastCreatedUnit()
				elseif rtime == 3 then
					createUnit('crab', 1, {startLocation(2)[1] + 8, startLocation(2)[2] + 5})
					jk= lastCreatedUnit()
				elseif rtime == 4 then
					createUnit('crab', 1, {startLocation(2)[1] + 11, startLocation(2)[2] + 0})
					jk= lastCreatedUnit()
				end

			end

			if lastDeadUnit()==monk then
				giveResource('food', 0, 20); 
				giveResource('furs', 0, 2); 
				math.randomseed(os.time())
				rtime = math.random(1, 4)
				if rtime == 1 then
					createUnit('monkey', 3, startLocation(3))
					monk= lastCreatedUnit()
				elseif rtime == 2 then
					createUnit('monkey', 3, {startLocation(3)[1] + 5, startLocation(3)[2] - 10})
					monk= lastCreatedUnit()
				elseif rtime == 3 then
					createUnit('monkey', 3, {startLocation(3)[1] + 8, startLocation(3)[2] + 5})
					monk= lastCreatedUnit()
				elseif rtime == 4 then
					createUnit('monkey', 3, {startLocation(3)[1] + 11, startLocation(3)[2] + 0})
					monk= lastCreatedUnit()
				end

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