[scenario]
	id=Isle_of_the_Damned
	#textdomain wesnoth-httt
	next_scenario=The_Siege_of_Elensefar
	name= _ "Isle of the Damned"
	map_data="{maps/Heir_To_The_Throne/Isle_of_the_Damned}"
	{TURNS 27 24 21}

	{DAWN}
	{MORNING}
	{AFTERNOON}
	{DUSK}
	{FIRST_WATCH}
	{SECOND_WATCH}

	music="wesnoth-3.ogg"

	[event]
	name=prestart
		[objectives]
		side=1
			[objective]
				description= _ "Defeat all enemy leaders"
				condition=win
			[/objective]
			[objective]
				description= _ "Resist until the end of the turns"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Konrad"
				condition=lose
			[/objective]
		[/objectives]
	[/event]

	disallow_recall=yes


	{BIGMAP_ISLE_OF_THE_DAMNED}

	[story]
		[part]
		story= _ "But the voyage did not go as smoothly as had been hoped. A storm blew up and bore down on the ship. Though all hands were on deck working desperately, a sudden gust of wind flung Konrad overboard as he attempted to secure the sails..."
		background=campaigns/Heir_To_The_Throne/story/story9.png
		[/part]
		[part]
		show_title=yes
		story= _ "The mermen finally saved Konrad from the sea, but were unable to get him back to the ship. With great effort though, they reached a nearby island..."
		background="maps/wesnoth.png"
		[/part]
	[/story]

	[side]
	description=Konrad
	user_description= _ "Konrad"
	type=Commander
	unrenamable=yes
	side=1
	canrecruit=1
	recruit=Thug,Poacher,Footpad
	controller=human
	[/side]

	[side]
	description=Haf-Mal
	user_description= _ "Haf-Mal"
	type=Lich
	side=2
	canrecruit=1
	team_name=undead
	recruit=Skeleton,Vampire Bat,Ghost,Dark Adept,Chocobone
		[ai]
		recruitment_pattern=scout,scout,fighter
		{ATTACK_DEPTH 1 3 5}
		[/ai]
	{GOLD 95 140 185}
	[/side]

	[side]
	description=Jarmal-Gorg
	user_description= _ "Jarmal-Gorg"
	type=Lich
	side=3
	canrecruit=1
	team_name=undead
	recruit=Skeleton,Skeleton Archer,Walking Corpse,Vampire Bat,Ghost,Dark Adept
		[ai]
		{ATTACK_DEPTH 1 3 5}
		[/ai]
	{GOLD 95 140 185}
	[/side]


	[event]
	name=prestart

	{PLACE_IMAGE terrain/temple.png 11 13}
	{PLACE_IMAGE terrain/temple.png 10 17}
	{PLACE_IMAGE terrain/temple.png 9 15}

	{UNIT (Merman Fighter) (Kalba) ( _ "Kalba") 1 27 12}
	{UNIT (Merman Fighter) (Gnaba) ( _ "Gnaba") 1 31 14}

	#reset gold held to 100
	[store_gold]
	side=1
	variable=isle_damned_starting_gold
	[/store_gold]
	{VARIABLE_OP isle_damned_starting_gold multiply -1}
	[gold]
	side=1
	amount=$isle_damned_starting_gold
	[/gold]
	[gold]
	side=1
	amount=100
	[/gold]
	{VARIABLE_OP isle_damned_starting_gold multiply -1}

	[disallow_recruit]
	side=1
	type=Elvish Fighter
	[/disallow_recruit]
	[disallow_recruit]
	side=1
	type=Elvish Archer
	[/disallow_recruit]
	[disallow_recruit]
	side=1
	type=Elvish Scout
	[/disallow_recruit]
	[disallow_recruit]
	side=1
	type=Elvish Shaman
	[/disallow_recruit]
	[disallow_recruit]
	side=1
	type=Horseman
	[/disallow_recruit]
	[disallow_recruit]
	side=1
	type=Mage
	[/disallow_recruit]

	[/event]

	[event]
	name=start
		#Add a couple of delays to show Ulaf pops out of the woods...
		[delay]
			time=1000
		[/delay]

		[message]
		description=Konrad
		message= _ "Whew, I survived. But now where am I? Is this island inhabited?"
		[/message]
		[message]
		description=Kalba
		message= _ "We have heard only the worst things about this place, my lord. It is said that the fiends of the undead have come in great numbers and turned the island into an ugly wasteland."
		[/message]
		[message]
		description=Konrad
		message= _ "Let's hope these rumors are not true! I have none of my men with me! How could I defend myself?"
		[/message]
		[message]
		description=Kalba
		message= _ "There are still some bands of humans hiding on the island, my lord. If you recruit some of them to help, we might have some hope of holding off the undead hordes!"
		[/message]

		[move_unit_fake]
		type=Outlaw
		x=20,20,21
		y=10,11,12
		[/move_unit_fake]

		{UNIT (Outlaw) (Urlaf) ( _ "Urlaf") 1 21 12}

		[message]
		description=Urlaf
		message= _ "Maybe we can make a deal! Help us defeat those evil creatures!"
		[/message]

	[/event]

	[event]
	name=turn 2
		[message]
		description=Konrad
		message= _ "There are some ancient temples to the south-west, I wonder what might be inside them!"
		[/message]
	[/event]

#define MOREMIRMU_TRAP X Y
	[event]
	name=moveto
		[filter]
		side=1
		x={X}
		y={Y}
		[/filter]
		[message]
		speaker=unit
		message= _ "Looks like there is somebody hidden in the temple."
		[/message]
		[unit]
		description=Moremirmu
		user_description= _ "Moremirmu"
		side=1
		type=White Mage
		x={X}
		y={Y}

			#Moremirmu has a special sword which makes him
			#especially deadly against undead.
			[modifications]
				[object]
					[effect]
					apply_to=attack
					range=short
					set_name=holy sword
					set_type=holy
					multiply_damage=2
					increase_attacks=2
					[/effect]
				[/object]
				{TRAIT_LOYAL}
			[/modifications]
		[/unit]
		#set the variable to say the Moremirmu is alive
		[set_variable]
		name=moremirmu
		value=1
		[/set_variable]
		[message]
		description=Moremirmu
		message= _ "I was hiding in this holy place, planning how to defeat the evil undead. Now with your help, I can destroy them."
		[/message]
	[/event]
#enddef

#define XAKAE_TRAP X Y
	[event]
	name=moveto
		[filter]
		side=1
		x={X}
		y={Y}
		[/filter]
		[message]
		speaker=unit
		message= _ "Looks like there is somebody hidden in the temple."
		[/message]

		[unit]
			type=Revenant
			description=Xakae
			user_description= _ "Xakae"
			side=2
			x={X}
			y={Y}
			[modifications]
				{TRAIT_UNDEAD}
				{TRAIT_LOYAL}
			[/modifications]
		[/unit]

		{UNDEAD_UNIT (Walking Corpse) 2 ({X}) ({Y})}
		{UNDEAD_UNIT (Walking Corpse) 2 ({X}) ({Y})}
#ifdef HARD
		{UNDEAD_UNIT (Walking Corpse) 2 ({X}) ({Y})}
#endif

		[message]
		description=Xakae
		message= _ "Surprise! Searching for magi, and all I get is these foul humans!"
		[/message]
	[/event]
#enddef

	[event]
	name=start
		{RANDOM 1..2}
		[if]
			[variable]
			name=random
			numerical_equals=1
			[/variable]
			[then]
				{MOREMIRMU_TRAP 11 13}
				{XAKAE_TRAP 10 17}
			[/then]
			[else]
				{MOREMIRMU_TRAP 10 17}
				{XAKAE_TRAP 11 13}
			[/else]
			
		[/if]
	[/event]

	[event]
	name=moveto
		[filter]
		side=1
		x=9
		y=15
		[/filter]
		[message]
		speaker=unit
		message= _ "The temple seems to be empty."
		[/message]
	[/event]

	[event]
	name=die
		[filter]
		description=Moremirmu
		[/filter]

		[message]
		speaker=unit
		message= _ "Fight on against the undead without me, friends!"
		[/message]
		[set_variable]
		name=moremirmu
		value=0
		[/set_variable]
	[/event]

#define ISLE_GALLEON_ARRIVE

		[move_unit_fake]
			type=Galleon
			x=33,32,31,30,29,28,27
			y=7,7,8,7,7,7,8
		[/move_unit_fake]

		{PLACE_IMAGE galleon.png 27 8}

		[allow_recruit]
		side=1
		type=Elvish Fighter
		[/allow_recruit]
		[allow_recruit]
		side=1
		type=Elvish Archer
		[/allow_recruit]
		[allow_recruit]
		side=1
		type=Elvish Scout
		[/allow_recruit]
		[allow_recruit]
		side=1
		type=Elvish Shaman
		[/allow_recruit]
		[allow_recruit]
		side=1
		type=Horseman
		[/allow_recruit]
		[allow_recruit]
		side=1
		type=Mage
		[/allow_recruit]
		[disallow_recruit]
		side=1
		type=Thug
		[/disallow_recruit]
		[disallow_recruit]
		side=1
		type=Poacher
		[/disallow_recruit]
		[disallow_recruit]
		side=1
		type=Footpad
		[/disallow_recruit]
#enddef

#define ISLE_RESTORE_GOLD
	[gold]
	side=1
	amount=$isle_damned_starting_gold
	[/gold]
	#Add WML to clear the Variable 
	{CLEAR_VARIABLE isle_damned_starting_gold}
#enddef

	[event]
	name=enemies defeated
		[message]
		description=Konrad
		message= _ "We have wrested control of the island from the evil undead! Now all we have to do is wait for the ship to arrive, so we can make our way to Elensefar!"
		[/message]

		{ISLE_GALLEON_ARRIVE}
		{ISLE_RESTORE_GOLD}

		[if]
			[variable]
			name=moremirmu
			equals=1
			[/variable]
			[then]
				[message]
				description=Moremirmu
				message= _ "Together we have vanquished the foul undead! Come, I will join you on your noble quest."
				[/message]
				[set_variable]
				name=moremirmu
				value=2
				[/set_variable]
			[/then]
		[/if]

	[/event]

	[event]
	name=time over
		{ISLE_GALLEON_ARRIVE}
		{ISLE_RESTORE_GOLD}
		[message]
		speaker=narrator
		image=elvish-fighter.png
		message= _ "Thank goodness we have found you, sir! Come aboard quickly, we shall take you away from this horrible island!"
		[/message]
		[message]
		description=Konrad
		message= _ "It's a shame complete victory could not be ours, but thank goodness I am rescued! On to Elensefar!"
		[/message]
		[if]
			[variable]
			name=moremirmu
			equals=1
			[/variable]
			[then]
				[message]
				description=Moremirmu
				message= _ "Thank you for your assistance here brothers. I will stay to continue resisting the foul undead. May fate be with you in your noble quest, and may we meet again some day!"
				[/message]
				[kill]
				description=Moremirmu
				[/kill]
			[/then]
		[/if]
		[endlevel]
		result=victory
		[/endlevel]
	[/event]

	{scenarios/Heir_To_The_Throne/utils/deaths.cfg}
[/scenario]
