[scenario]
#textdomain wesnoth-sof
name= _ "The Dragon"
id=8_The_Dragon
turns=-1
map_data="{@campaigns/Sceptre_of_Fire/maps/8_The_Dragon.map}"
next_scenario=9_Caverns_of_Flame
disallow_recall=yes

	{DEFAULT_MUSIC_PLAYLIST}

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

	[side]
	type=Dwarvish Fighter
	description=Rugnur
	side=1
	canrecruit=1
	controller=human
	recruit=
	shroud=yes
	[/side]

	[side]
	type=Elvish Marshal
	description=Landar
	user_description= _ "Landar"
	side=2
	canrecruit=1
	controller=ai
	recruit=Elvish Avenger,Elvish Marshal,Elvish Champion,Elvish Outrider
	gold=1000
	income=50
		[ai]
		aggression=1.0
		caution=0.1
		#grouping causes the dwarves to wait for the elves, who move slower
		grouping=none
		[/ai]
	team_name=bad
	[/side]

	[side]
	type=Fire Dragon
	description=Khrakrahs
	user_description= _ "Khrakrahs"
	side=3
	canrecruit=1
	controller=ai
	{RECRUIT (Vampire Bat) (Vampire Bat) (Vampire Bat,Blood Bat)}
	{GOLD 200 300 400}
		[ai]
		recruitment_pattern=scout
		aggression=0.9
		caution=0.1
		grouping=offensive
		[/ai]
	team_name=bad
	[/side]

	[story]
		[part]
		story= _ "Thus Alanin escaped from his Elvish pursuers. But the dwarves were not so lucky. I would say that, perhaps, their betrayal of Durstorn was coming back to haunt them. For unknown to them, they had entered the caves of Khrakhrahs... the dragon."
		[/part]
		[part]
		background=maps/wesnoth.png
		show_title=yes
		{DOT 322 157}
		{CROSS 335 141}
		[/part]
	[/story]

	{SOF_DEATHS}

	[event]
	name=prestart
		[objectives]
		side=1
			[objective]
			description= _ "Get all heroes to the end of the tunnel"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Rugnur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Krawg"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Thursagan"
			condition=lose
			[/objective]
			[objective]
			description= _ "Time runs out"
			condition=lose
			[/objective]
		[/objectives]
		[terrain]
		x,y=11,7
		letter=Uu^Vu
		[/terrain]
	[/event]

#define RANDOM_MERCENARY TYPE
{RANDOM_TRAIT_UNIT (
type={TYPE}
x,y=2,14
side=2)}
#enddef
	[event]
	name=start
		#recall heroes and recall 12 others with a DARN ANNOYING MACRO
		{HEROMACRO Rugnur}
		{HEROMACRO Baglur}
		{HEROMACRO Krawg}
		{HEROMACRO Thursagan}
		{ROLEMACRO 1}
		{ROLEMACRO 2}
		{ROLEMACRO 3}
		{ROLEMACRO 4}
		{ROLEMACRO 5}
		{ROLEMACRO 6}
		{ROLEMACRO 7}
		{ROLEMACRO 8}
		{ROLEMACRO 9}
		{ROLEMACRO 10}
		{ROLEMACRO 11}
		{ROLEMACRO 12}
		[kill]
		side=1
		[/kill]
		[move_unit_fake]
		type=$tempRugnur.type
		x=7,11
		y=9,7
		[/move_unit_fake]
		[unstore_unit]
		variable=tempRugnur
		[/unstore_unit]
		[clear_variable]
		name=tempRugnur
		[/clear_variable]
		{RECALLMACRO Baglur}
		{RECALLMACRO Krawg}
		{RECALLMACRO Thursagan}
		{RECALLMACRO 1}
		{RECALLMACRO 2}
		{RECALLMACRO 3}
		{RECALLMACRO 4}
		{RECALLMACRO 5}
		{RECALLMACRO 6}
		{RECALLMACRO 7}
		{RECALLMACRO 8}
		{RECALLMACRO 9}
		{RECALLMACRO 10}
		{RECALLMACRO 11}
		{RECALLMACRO 12}
		#the enemy gets mercenaries
		{RANDOM_MERCENARY (Dwarvish Berserker)}
		{RANDOM_MERCENARY (Dwarvish Berserker)}
		{RANDOM_MERCENARY (Dwarvish Berserker)}
		{RANDOM_MERCENARY (Dwarvish Berserker)}
#ifdef EASY
#else
		{RANDOM_MERCENARY (Dwarvish Berserker)}
#endif
#ifdef HARD
		{RANDOM_MERCENARY (Dwarvish Berserker)}
#endif
		{RANDOM_MERCENARY (Dwarvish Lord)}
		{RANDOM_MERCENARY (Dwarvish Lord)}
		{RANDOM_MERCENARY (Dwarvish Lord)}
		{RANDOM_MERCENARY (Dwarvish Dragonguard)}
		{RANDOM_MERCENARY (Dwarvish Dragonguard)}
		[message]
		description=Rugnur
		message= _ "Well, Thursagan, we've reached the caves, but the elves are hot on our trail. What do we do now?"
		[/message]
		[message]
		description=Thursagan
		message= _ "Well, we have two choices. We may either stand and fight, and assuredly die, or run as quickly as possible down this path into the depths of the cave, where we may find something that will help us. Also, remember, the elves can't run as fast in caves as we can, so we may be able to get ahead of them and perhaps lay a trap."
		[/message]
		[message]
		role=temp1
		message= _ "Why don't we just surrender? All they want is that magic stone!"
		[/message]
		[message]
		description=Rugnur
		message= _ "If we give them the ruby, then what? They'll probably kill us anyway. And, that ruby has the power to do great things, evil things. We can't let it fall into the wrong hands."
		[/message]
		[if]
			[have_unit]
			description=Baglur
			[/have_unit]
			[then]
				[message]
				description=Baglur
				message= _ "So we're running away, eh? I don't like that, but it seems it's our only option."
				[/message]
				[message]
				description=Rugnur
				message= _ "If it makes you feel any better, we'll probably die this way, too."
				[/message]
			[/then]
		[/if]
	[/event]

	[event]
	name=sighted
		[filter]
		type=Fire Dragon
		[/filter]
		[message]
		speaker=Rugnur
		message= _ "Look, there's a dragon in these caves!"
		[/message]
		[message]
		description=Khrakrahs
		message= _ "Ah, fresh meat!"
		[/message]
		[message]
		description=Thursagan
		message= _ "And which of the great dragons are you?"
		[/message]
		[message]
		description=Khrakrahs
		message= _ "I am Khrakrahs, greatest dragon of all time! Haldric killed Shek'kahan my brother, but he was weaker than me, and you will not find me so easy to defeat. Now get out of my volcano!"
		[/message]
		[message]
		description=Rugnur
		message= _ "I'd rather face one powerful dragon than hundreds of mighty elves. Continue!"
		[/message]
	[/event]

	[event]
	name=sighted
		[filter]
		race=dwarf
		side=2
		[/filter]
		[message]
		description=Thursagan
		message= _ "What's this? A dwarf fighting against us with the elves?!"
		[/message]
		[message]
		description=Baglur
		message= _ "It must be one of those Surghan mercenaries. I'll bet those elves have hired more of them. That's bad news for us, for they'll go as fast in caves as we do."
		[/message]
	[/event]

	[item]
	x,y=16,25
	image=items/altar.png
	[/item]

	[event]
	name=moveto
		[filter]
		x,y=16,25
		side=1
		[/filter]
		[message]
		speaker=unit
		message= _ "Look, I've found something here. It looks like a forge, heated by the lava. It looks magic, and it looks hot enough to make the Sceptre."
		[/message]
		[message]
		description=Khrakrahs
		message= _ "That pretty metal rock is mine! Get away from it!"
		[/message]
		[objectives]
		side=1
			[objective]
			description= _ "Move Thursagan to the forge"
			condition=win
			[/objective]
			[objective]
			description= _ "Defend Thursagan until the sceptre is complete"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Rugnur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Krawg"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Thursagan"
			condition=lose
			[/objective]
			[objective]
			description= _ "Time runs out"
			condition=lose
			[/objective]
		[/objectives]
	[/event]

	[event]
	name=moveto
		[filter]
		x,y=16,25
		description=Thursagan
		[/filter]
		[message]
		description=Thursagan
		message= _ "This forge will work perfectly. Give me a few days here, and I can reforge the sceptre to fulfil its purpose."
		[/message]
		[set_variable]
		name=turnsleft
		value=10
		[/set_variable]
		[objectives]
		side=1
			[objective]
			description= _ "Survive for 9 turns"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Rugnur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Krawg"
			condition=lose
			[/objective]
			[objective]
			description= _ "An enemy moves onto the forge"
			condition=lose
			[/objective]
			[objective]
			description= _ "Time runs out"
			condition=lose
			[/objective]
		[/objectives]
		[store_unit]
			[filter]
			description=Thursagan
			[/filter]
		variable=thur
		kill=yes
		[/store_unit]
		[event]
		name=moveto
			[filter]
			x,y=16,25
			side=2,3
			[/filter]
			[message]
			speaker=narrator
			caption=Thursagan
			images=portraits/thursagan.png
			message= _ "You fool, you let the enemy get at me as I was unarmed!"
			[/message]
			[message]
			speaker=narrator
			caption=Thursagan
			images=portraits/thursagan.png
			message= _ "Ayahahh..."
			[/message]
			[endlevel]
			result=defeat
			[/endlevel]
		[/event]
		[event]
		name=new turn
		first_time_only=no
			[set_variable]
			name=turnsleft
			add=-1
			[/set_variable]
			[if]
				[variable]
				name=turnsleft
				numerical_equals=0
				[/variable]
				[then]
					[unstore_unit]
					variable=thur
					[/unstore_unit]
					[message]
					description=Thursagan
					message= _ "I have completed my work. Now it is truly the Sceptre of Fire, a powerful magical artifact."
					[/message]
					[message]
					description=Rugnur
					message= _ "Good. Now, let's get out of this cave, before the elves, dwarves or bats kill us!"
					[/message]
					[clear_variable]
					name=turnsleft
					[/clear_variable]
					[endlevel]
					result=victory
					bonus=no
					[/endlevel]
				[/then]
				[else]
					[message]
					speaker=narrator
					caption=Thursagan
					image=portraits/thursagan.png
					message= _ "In $turnsleft more turns I will have completed the sceptre."
					[/message]
				[/else]
			[/if]
		[/event]
	[/event]
[/scenario]
