[scenario]
#textdomain wesnoth-sof
name= _ "Searching for the Runecrafter"
id=3_Searching_for_the_Runecrafter
turns=24
map_data="{@campaigns/Sceptre_of_Fire/maps/3_Searching_for_the_Runecrafter.map}"
next_scenario=3t_The_Council_Regathers
victory_when_enemies_defeated=no

	{DEFAULT_MUSIC_PLAYLIST}

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

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

	[side]
	no_leader=yes
	side=2
	[/side]

	[story]
		[part]
		story= _ "Dwarves live longer than men, and so it may perhaps be supposed that a year in their life means less to them. But it is still a great deal of time; and they did have one man with them."
		[/part]
		[part]
		story= _ "And yet it took them a year to reach the far northern wastelands. For the tunnels were winding and treacherous, and the paths were not safe from orcs, or worse. Nevertheless, they did reach the northlands, and began to search for the runesmith named Thursagan - the sage of fire."
		[/part]
		[part]
		background=maps/wesnoth.png
		show_title=yes
		{DOT 271 109}
		{DOT 269 91}
		{DOT 263 76}
		{DOT 256 58}
		{DOT 236 49}
		{CROSS 218 43}
		[/part]
	[/story]

#define WINTERENEMY X Y
[set_variable]
name=typeofenemy
random=Wolf,Ogre,Troll,Wose
[/set_variable]
[unit]
x,y={X},{Y}
generate_description=yes
random_traits=yes
type=$typeofenemy
side=2
[/unit]
[if]
	[variable]
	name=typeofenemy
	equals=Wolf
	[/variable]
	[then]
		[unit]
		x,y={X},{Y}
		type=Wolf
		side=2
		[/unit]
		[unit]
		x,y={X},{Y}
		type=Wolf
		side=2
		[/unit]
#ifdef HARD
		[unit]
		x,y={X},{Y}
		type=Wolf
		side=2
		[/unit]
#endif
	[/then]
[/if]
[clear_variable]
name=typeofenemy
[/clear_variable]
#enddef

	{SOF_DEATHS}

	[event]
	name=prestart
		[objectives]
		side=1
			[objective]
			description= _ "Find Thursagan and convince him to come back to the dwarvish city"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Rugnur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Alanin"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Baglur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Time runs out"
			condition=lose
			[/objective]
		[/objectives]
		{WINTERENEMY 5 5}
		{WINTERENEMY 15 15}
		{WINTERENEMY 25 25}
		{WINTERENEMY 25 10}
#ifdef NORMAL
		{WINTERENEMY 30 18}
#endif
#ifdef HARD
		{WINTERENEMY 30 18}
		{WINTERENEMY 20 2}
#endif
	[/event]

	[event]
	name=turn 5
		{WINTERENEMY 10 10}
		{WINTERENEMY 20 20}
		{WINTERENEMY 30 30}
	[/event]

	[event]
	name=turn 15
		{WINTERENEMY 18 6}
		{WINTERENEMY 30 7}
	[/event]


	[event]
	name=start
		[recall]
		description=Baglur
		[/recall]
		[recall]
		description=Alanin
		[/recall]
		[message]
		description=Alanin
		message= _ "Now where are we going, anyway? We were in those caves, taking wrong turns and fighting orcs, for a whole year. This trip better have a good payoff to be worth that."
		[/message]
		[message]
		description=Baglur
		message= _ "We need to find the mage Thursagan and convince him to return to the citadel with us. He's somewhere up here."
		[/message]
		[message]
		description=Rugnur
		message= _ "Well, how are we supposed to find him?"
		[/message]
		[message]
		description=Baglur
		message= _ "His will probably be the only house up here. No one else is insane enough to live this far north! Even the elves won't challenge us here."
		[/message]
		[message]
		description=Alanin
		message= _ "Except for trolls and ogres, right? They live in the far northlands. They're probably lurking around here somewhere."
		[/message]
		[message]
		description=Baglur
		message= _ "Right. We'll probably have to fight our way through to his house."
		[/message]
		{RANDOM 1..5}
		[if]
			[variable]
			name=random
			equals=1
			[/variable]
			[then]
				[set_variable]
				name=thur_x
				value=2
				[/set_variable]
				[set_variable]
				name=thur_y
				value=6
				[/set_variable]
			[/then]
		[/if]
		[if]
			[variable]
			name=random
			equals=2
			[/variable]
			[then]
				[set_variable]
				name=thur_x
				value=15
				[/set_variable]
				[set_variable]
				name=thur_y
				value=2
				[/set_variable]
			[/then]
		[/if]
		[if]
			[variable]
			name=random
			equals=3
			[/variable]
			[then]
				[set_variable]
				name=thur_x
				value=27
				[/set_variable]
				[set_variable]
				name=thur_y
				value=9
				[/set_variable]
			[/then]
		[/if]
		[if]
			[variable]
			name=random
			equals=4
			[/variable]
			[then]
				[set_variable]
				name=thur_x
				value=28
				[/set_variable]
				[set_variable]
				name=thur_y
				value=16
				[/set_variable]
			[/then]
		[/if]
		[if]
			[variable]
			name=random
			equals=5
			[/variable]
			[then]
				[set_variable]
				name=thur_x
				value=29
				[/set_variable]
				[set_variable]
				name=thur_y
				value=30
				[/set_variable]
			[/then]
		[/if]
		[clear_variable]
		name=random
		[/clear_variable]
		[terrain]
		x,y=$thur_x,$thur_y
		letter=Aa^Vha
		[/terrain]
		#this is here so that a hacky "location sighted" event can take place
		#the unit will never actually be seen by the player
		[unit]
		side=2
		type=Galleon
		x,y=$thur_x,$thur_y
		ai_special=guardian
			[modifications]
				[effect]
				apply_to=movement
				set=0
				[/effect]
			[/modifications]
		[/unit]
	[/event]

	[event]
	name=moveto
		[filter]
		x=1-32,17-32
		y=1-21,1-31
		side=1
		[/filter]
		[move_unit_fake]
		type=Gryphon
		x=1,5
		y=16,24
		[/move_unit_fake]
		[unit]
		type=Gryphon
		description=Krawg
		user_description= _ "Krawg"
		{IS_HERO}
		x,y=5,24
		side=1
		[/unit]
		[message]
		description=Krawg
		message= _ "Kwill yooo spakkk wit uuus?!?"
		[/message]
		[message]
		description=Alanin
		message= _ "Aah! What is that?!?"
		[/message]
		[message]
		description=Baglur
		message= _ "Is that... is that a gryphon?"
		[/message]
		[message]
		description=Krawg
		message= _ "Kwes! Yooo spakkk wit uuus nuu?"
		[/message]
		[message]
		description=Rugnur
		message= _ "It's talking to us! What do you want, gryphon?"
		[/message]
		[message]
		description=Krawg
		message= _ "Myy namm ees Krawgg. Yooo ees oooking forr a uunmasta?"
		[/message]
		[message]
		description=Rugnur
		message= _ "Well, um, yes. Why, can you help us?"
		[/message]
		[message]
		description=Krawg
		message= _ "Ess... if yooo ills ka rolls aan ogras, us'll elp yoo!"
		[/message]
		[message]
		description=Baglur
		message= _ "Sure, we'll help you fight trolls and ogres."
		[/message]
		[message]
		description=Krawg
		message= _ "Kwe... yoo ants to ide uuus, nooa? Kwe, uus kan..."
		[/message]
		[objectives]
		side=1
			[objective]
			description= _ "Find Thursagan and convince him to come back to the dwarvish city, then bring him back to the caves"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Rugnur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Alanin"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Baglur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Krawg"
			condition=lose
			[/objective]
			[objective]
			description= _ "Time runs out"
			condition=lose
			[/objective]
		[/objectives]
		[move_unit_fake]
		type=Gryphon Rider
		x=1,5
		y=16,28
		[/move_unit_fake]
		{RANDOM_TRAIT_UNIT (
		description=Kawn
		user_description= _ "Kawn"
		type=Gryphon Rider
		x,y=5,28
		side=1)}
		[allow_recruit]
		type=Gryphon Rider
		[/allow_recruit]

	[/event]

	[event]
	name=sighted
		[filter]
		type=Galleon
		[/filter]
		[kill]
		x,y=$x1,$y1
		[/kill]
		[message]
		speaker=second_unit
		message= _ "I see a house in the distance!"
		[/message]
	[/event]

	[event]
	name=moveto
		[filter]
		x,y=$thur_x,$thur_y
		side=1
		type=Gryphon Rider,Gryphon
		[/filter]
		[message]
		speaker=narrator
		caption=Thursagan
		image=portraits/thursagan.png
		message= _ "Go away, you birds! Or I shall burn you out of the air!"
		[/message]
		[message]
		description=Baglur
		message= _ "He doesn't want to talk to the gryphons, apparently. I think we'll have to get someone there he will talk to..."
		[/message]
	[/event]

	[event]
	name=moveto
		[filter]
		x,y=$thur_x,$thur_y
		side=1
			[not]
			type=Gryphon Rider,Gryphon
			[/not]
		[/filter]
		[unit]
		x,y=$thur_x,$thur_y
		side=1
		type=Dwarvish Runemaster_alt
		description=Thursagan
		user_description= _ "Thursagan"
		{IS_HERO}
		profile=portraits/thursagan.png
		[/unit]
		[message]
		description=Thursagan
		message= _ "What do you people want!? Leave me alone!"
		[/message]
		[message]
		description=Rugnur
		message= _ "Old mage, we come with a message from Lord Durstorn. He asks you to come back to the city."
		[/message]
		[message]
		description=Thursagan
		message= _ "Ha! That fool thinks he can order me around. Why does he want me to go back, anyway?"
		[/message]
		[message]
		description=Baglur
		message= _ "We have entered into a bargain with the king of Wesnoth to craft a sceptre for him."
		[/message]
		[message]
		description=Thursagan
		message= _ "Oh, and now I suppose Durstorn wants me to craft it, eh? Well I'm not going to."
		[/message]
		[message]
		description=Rugnur
		message= _ "You don't want to make a sceptre to contain the power of the ruby of fire? Very well, your choice is made."
		[/message]
		[message]
		description=Thursagan
		message= _ "The ruby of fire, what is that, some worthless Wesnothian gem?"
		[/message]
		[message]
		description=Baglur
		message= _ "It is a Wesnothian gem, but it is also supposedly the most powerful magical artifact ever seen. Even an untrained hand can use it to cast fiery bolts as powerful as those of arch mages."
		[/message]
		[message]
		description=Thursagan
		message= _ "Oh, really? And what does Haldric want us to do with it?"
		[/message]
		[message]
		description=Rugnur
		message= _ "Contain and intensify its power."
		[/message]
		[message]
		description=Thursagan
		message= _ "I see. Fine then, I will help you craft this sceptre... into the most powerful magic artifact ever seen. This will be a true test of my skill. I expect it will take many years."
		[/message]
		[message]
		description=Baglur
		message= _ "Good. Now, there are still wild animals here... we have to get back into the caves."
		[/message]
		{WINTERENEMY 19 31}
		{WINTERENEMY 1 21}
		{WINTERENEMY 31 21}
		{WINTERENEMY 1 15}
#ifdef NORMAL
		{WINTERENEMY 32 1}
#endif
#ifdef HARD
		{WINTERENEMY 32 1}
		{WINTERENEMY 32 31}
#endif
		[item]
		x,y=4,28
		image=scenery/signpost.png
		[/item]
		[objectives]
		side=1
			[objective]
			description= _ "Move Thursagan to the signpost"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Rugnur"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Alanin"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Baglur"
			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=4,28
		description=Thursagan
		[/filter]
		[message]
		description=Thursagan
		message= _ "Well, now we are in the caves again! Come on, back south, to the city."
		[/message]
		[store_unit]
			[filter]
			description=Baglur
			[/filter]
		variable=baglur
		kill=yes
		[/store_unit]
		[variable]
		name=baglur.overlays
		value=
		[/variable]
		[unstore_unit]
		variable=baglur
		[/unstore_unit]
		[clear_variable]
		name=baglur
		[/clear_variable]
		[endlevel]
		result=victory
		bonus=yes
		[/endlevel]
	[/event]
[/scenario]
