[scenario]
	id=The_Dragon
	#textdomain wesnoth-trow
	name= _ "The Dragon"
	map_data="{campaigns/The_Rise_Of_Wesnoth/maps/The_Dragon}"
	{TURNS 39 36 33}

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

	next_scenario=Elf_Lords
	victory_when_enemies_defeated=no
	bonus=yes

	[music]
	name="wesnoth-5.ogg"
	[/music]

	{campaigns/The_Rise_Of_Wesnoth/utils/trow-deaths.cfg}

	[story]
		[part]
			background=story/the_great_continent.png
			show_title=yes
			{DOT 315 180}
			{DOT 315 210}
			{DOT 315 240}
			{DOT 315 270}
			{CROSS 310 296}
		[/part]
	[/story]

	[side]
		type=Noble Commander
		description=Prince Haldric
		user_description= _ "Prince Haldric"
		unrenamable=yes
		side=1
		canrecruit=1
		controller=human
		team_name=Haldric
	[/side]

	[side]
		type=Saurian Flanker
		description=Irix
		user_description= _ "Irix"
		side=2
		canrecruit=1
		{GOLD 110 140 160}
		{INCOME 2 4 8}
		team_name=Liz
#ifdef EASY
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif
		[ai]
			#{NO_SCOUTS}
			recruitment_ignore_bad_movement=yes
			recruitment_pattern=scout,archer,scout,scout,healer
			{ATTACK_DEPTH 4 5 5}
		[/ai]
		[ai]
			[protect_location]
				x=20
				y=23
				radius=12
				value=10
			[/protect_location]
		[/ai]
	[/side]

	[side]
		type=Saurian Flanker
		description=Vriss
		user_description= _ "Vriss"
		side=3
		canrecruit=1
		{GOLD 110 140 160}
		{INCOME 2 4 8}
		team_name=Liz
#ifdef EASY
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif
		[ai]
			#{NO_SCOUTS}
			recruitment_ignore_bad_movement=yes
			recruitment_pattern=scout,archer,scout,scout,healer
			{ATTACK_DEPTH 4 5 5}
		[/ai]
		[ai]
			[protect_location]
				x=20
				y=23
				radius=12
				value=10
			[/protect_location]
		[/ai]

	[/side]

	[side]
		type=Saurian Flanker
		description=Axiz
		user_description= _ "Axiz"
		side=4
		canrecruit=1
		{GOLD 110 140 160}
		{INCOME 2 4 8}
		team_name=Liz
#ifdef EASY
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif

		[ai]
			#{NO_SCOUTS}
			recruitment_ignore_bad_movement=yes
			recruitment_pattern=scout,archer,scout,scout,healer
			{ATTACK_DEPTH 4 5 5}
		[/ai]
		[ai]
			[protect_location]
				x=20
				y=23
				radius=12
				value=10
			[/protect_location]
		[/ai]
	[/side]

	[side]
		type=Saurian Flanker
		description=Satras
		user_description= _ "Satras"
		side=5
		canrecruit=1
		{GOLD 110 140 160}
		{INCOME 2 4 8}
		team_name=Liz

#ifdef EASY
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
		recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif
		[ai]
			#{NO_SCOUTS}
			recruitment_ignore_bad_movement=yes
			recruitment_pattern=scout,archer,scout,scout,healer
			{ATTACK_DEPTH 4 5 5}

			[target]
				description=Prince Haldric
				value=15
			[/target]
		[/ai]
	[/side]

	{campaigns/The_Rise_Of_Wesnoth/utils/trow-nlmsg.cfg}

	[event]
	name=prestart

		{STARTING_VILLAGES 2 10}
		{STARTING_VILLAGES 3 10}
		{STARTING_VILLAGES 4 10}
		{STARTING_VILLAGES 5 10}

		{PLACE_IMAGE (misc/mine.png) 20 27}

		[recall]
			description=Lady Jessica
		[/recall]
		[recall]
			description=Burin the Lost
		[/recall]
		[recall]
			description=Sir Ruddry
		[/recall]

		[recall]
			description=Sir Ladoc
		[/recall]

		[recall]
			description=Minister Edmond
		[/recall]
		[set_variable]
			name=dragon_awake
			value=0
		[/set_variable]
		[set_variable]
			name=got_treasure
			value=0
		[/set_variable]
		[set_variable]
			name=got_enemies
			value=0
		[/set_variable]
		[set_variable]
			name=dragon_dead
			value=0
		[/set_variable]

		[objectives]
		side=1
			[objective]
				description= _ "Slay the Dragon"
				condition=win
			[/objective]
			[objective]
				description= _ "Heroic: Slay the Dragon and defeat all enemies"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Prince Haldric"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Lady Jessica"
				condition=lose
			[/objective]
			[objective]
				description= _ "Turns run out"
				condition=lose
			[/objective]
		[/objectives]
	[/event]

	[event]
		name=start
		[message]
			speaker=narrator
			message= _ "After some days of travel Haldric finds himself confronted by a vast expanse of swamp. A small island with a mountain dominates the view. That can only be the home of the dragon."
		[/message]

		[message]
			description=Burin the Lost
			message= _ "Flies, flies, everywhere! Ack!"
		[/message]

		[message]
			description=Prince Haldric
			message= _ "'Prince Haldric the Dragonbane' sounds rather nice."
		[/message]

		[message]
			description=Lady Jessica
			message= _ "We'll see..."
		[/message]

	[/event]

	[event]
		name=victory
		[message]
			description=Prince Haldric
			message= _ "I'm glad that's over. The elves certainly aren't taking it easy on us. It's a miracle any of us are alive at all."
		[/message]

		[message]
			description=Lady Jessica
			message= _ "I'm still not calling you 'the Dragonbane'."
		[/message]

		{VARIABLE_OP num_done add 1}

		[set_variable]
			name=the_dragon
			value=1
		[/set_variable]

		[set_variable]
			name=last_done
			value="Dragon"
		[/set_variable]
		{CLEAR_VARIABLE dragon_awake}
		{CLEAR_VARIABLE got_treasure}
		{CLEAR_VARIABLE got_enemies}
		{CLEAR_VARIABLE dragon_dead}
	[/event]

#define MUDMANIA X Y
		[filter]
			type=Giant Mudcrawler
		[/filter]

		{UNIT (Mudcrawler) () ("") 2 ({X}) ({Y})}
		{UNIT (Mudcrawler) () ("") 3 ({X}) ({Y})}
#enddef

	[event]
		name=die
		first_time_only=no

		{MUDMANIA $x1 $y1}
	[/event]

	[event]
		name=die
		[filter]
			type=Giant Mudcrawler
		[/filter]
		[message]
			description=Prince Haldric
			message= _ "Watch for the big Mudcrawlers. They divide when you kill them."
		[/message]
	[/event]

#define GOLD_TO_BADDIES
		[gold]
			side=2
			amount=40
		[/gold]
		[gold]
			side=3
			amount=40
		[/gold]
		[gold]
			side=4
			amount=40
		[/gold]
		[gold]
			side=5
			amount=60
		[/gold]
#enddef

	[event]
	name=moveto
	first_time_only=no
		[filter]
			side=1
			x=12-26
			y=24-30
		[/filter]

		[if]
			[variable]
				name=dragon_awake
				numerical_equals=0
			[/variable]
			[then]
				{UNIT (Fire Dragon) (Shek'kahan) ( _ "Shek'kahan") 5 20 27}

				[set_variable]
					name=dragon_awake
					value=1
				[/set_variable]
				[message]
					description=Shek'kahan
					message= _ "It is unwise to trifle with dragons, boy!"
				[/message]
				[message]
					description=Prince Haldric
					message= _ "We shall see."
				[/message]
				{GOLD_TO_BADDIES}
			[/then]
		[/if]
	[/event]

	[event]
	name=turn 15
		[if]
			[variable]
				name=dragon_awake
				numerical_equals=0
			[/variable]
			[then]
				{UNIT (Fire Dragon) (Shek'kahan) ( _ "Shek'kahan") 5 20 27}

				[set_variable]
					name=dragon_awake
					value=1
				[/set_variable]
				[message]
					description=Shek'kahan
					message= _ "Who dares disturb Shek'kahan the Terrible?"
				[/message]
				[message]
					description=Prince Haldric
					message= _ "I do, you fiend!"
				[/message]
				{GOLD_TO_BADDIES}
			[/then]
		[/if]
	[/event]

	[event]
	name=moveto
		[filter]
			side=1
			x=20
			y=27
		[/filter]

		{LOOT 200 1}

		[set_variable]
			name=got_treasure
			value=1
		[/set_variable]
	[/event]

	[event]
	name=enemies defeated
		[if]
			[variable]
				name=dragon_dead
				numerical_equals=0
			[/variable]
			[then]
				[message]
					description=Lady Jessica
					message= _ "We still have to slay the dragon!"
				[/message]
			[/then]
			[else]
				[if]
				[variable]
					name=got_treasure
					numerical_equals=0
				[/variable]
				[then]
					[message]
						description=Prince Haldric
						message= _ "The Dragon's Cave has yielded some treasure!"
					[/message]
					{LOOT 200 1}
				[/then]
				[/if]
				[endlevel]
					result=victory
					bonus=yes
				[/endlevel]
			[/else]
		[/if]
		[set_variable]
			name=got_enemies
			value=1
		[/set_variable]
	[/event]

	[event]
		name=die
		[filter]
			description=Shek'kahan
		[/filter]
		[message]
			description=Shek'kahan
			message= _ "No!"
		[/message]
		[set_variable]
			name=dragon_dead
			value=1
		[/set_variable]
		[if]
			[variable]
				name=got_enemies
				numerical_equals=0
			[/variable]
			[then]
				[message]
				description=Prince Haldric
				message= _ "We've slain the Dragon: "

				[option]
				message= _ "Let's get out of here!"
				[command]
					[endlevel]
					result=victory
					bonus=no
					[/endlevel]
				[/command]
				[/option]

				[option]
				message= _ "Let's finish off the rest of these monsters!"
				[/option]
				[/message]
			[/then]
			[else]
				[if]
				[variable]
					name=got_treasure
					numerical_equals=0
				[/variable]
				[then]
					[message]
						description=Prince Haldric
						message= _ "The Dragon's Cave has yielded some treasure!"
					[/message]
					{LOOT 200 1}
				[/then]
				[/if]

				[endlevel]
					result=victory
					bonus=yes
				[/endlevel]
			[/else]
		[/if]
	[/event]

	[event]
		name=time over
		[message]
			description=Prince Haldric
			message= _ "More Saurians are arriving. They've surrounded us! We're doomed."
		[/message]
	[/event]
[/scenario]
