[scenario]
id=Return_to_Halal
next_scenario=A_Small_Favor
#textdomain wesnoth-did

name=_ "Return to Hal'al"
map_data="{campaigns/Descent_Into_Darkness/maps/Return_to_halal.map}"
turns=-1

victory_when_enemies_defeated=no

{STORY_RETURN_TO_HALAL}

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

[side]
	side=1
	controller=human
	type=Apprentice Mage
	description=Malin Keshar
	user_description=_ "Malin Keshar"
	unrenamable=yes
	canrecruit=1
	recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton,Dark Adept DiD
	gold=100
[/side]

[side]
	side=2
	controller=ai
	no_leader=yes
	gold={120 160 200}
	recruit=Wolf Rider,Goblin Knight,Orcish Archer,Orcish Crossbowman,Orcish Grunt,Troll Whelp
	[ai]
		aggression=0.8
		villages_per_scout=8
		village_value=0.5
	[/ai]
[/side]

[side]
	side=3
	controller=ai
	team_name=guardsmen
	type=Lieutenant
	description=Drogan
	user_description="Drogan"
	{GOLD 16 30 45}
	canrecruit=1
	recruit=Spearman,Archer
	[ai]
		aggression=0.2
		caution=0.5
	[/ai]
[/side]

[side]
	side=4
	controller=ai
	team_name=guardsmen
	type=Frontier Baroness
	description=Dela Keshar
	user_description="Dela Keshar"
	gold=200
	income=25
	canrecruit=1
	recruit=Spearman,Archer,Swordsman,Pikeman,Longbowman,Thug,Poacher,Footpad
	[ai]
		[protect_unit]
			description=Drogan
			value=2
		[/protect_unit]
		[target]
			description=Malin Keshar
			value=2
		[/target]
	[/ai]
[/side]

[event]
	name=prestart
	[music]
		name=revelation.ogg
	[/music]
	
	[objectives]
		side=1
		[objective]
			condition=win
			description= _ "Remove the traitor Drogan"
		[/objective]
		[objective]
			condition=lose
			description= _ "Kill any people from Hal'al but Drogan"
		[/objective]
		[objective]
			condition=lose
			description= _ "Death of Malin Keshar"
		[/objective]
	[/objectives]
	
	# Place orcish leader
	[set_variable]
		name=orc_leader_store.x
		value=29
	[/set_variable]
	[set_variable]
		name=orc_leader_store.y
		value=2
	[/set_variable]
	[set_variable]
		name=orc_leader_store.side
		value=2
	[/set_variable]
	[unstore_unit]
		variable=orc_leader_store
		find_vacant=no
	[/unstore_unit]
	{CLEAR_VARIABLE orc_leader_store}
	
	# Place signpost
	{PLACE_IMAGE scenery/signpost.png 27 13}
	
	# Dela owns villages in the town, Drogan those near the river fort
	{STARTING_VILLAGES 4 10}
	{STARTING_VILLAGES 3 6}
	
	# Drogan has some guards at the river fort
	{UNIT (Spearman) (River fort guard) ( _ "River fort guard") 3 30 11}
	{UNIT (Bowman) (River fort guard) ( _ "River fort guard") 3 31 12}
	{UNIT (Spearman) (River fort guard) ( _ "River fort guard") 3 31 13}
	
[/event]

[event]
	name=start
	{CREATE_ADVISOR}
	{DIALOGUE_RTH_START}
[/event]

# In-scenario Events
[event]
	name=moveto
	[filter]
		side=1
		x,y=27,13
	[/filter]
	[message]
		speaker=narrator
		message=_ "Welcome to Hal'al"
	[/message]
[/event]

# Defeat Conditions
[event]
	name=die
	[filter]
		side=3,4
	[/filter]
	[filter_second]
		side=1
	[/filter_second]
	[if]
		[have_unit]
			description=Drogan
		[/have_unit]
		[then]
			[message]
				speaker=Malin Keshar
				message=_ "Now the people of Hal'al will never accept me back!"
			[/message]
			[endlevel]
				result=defeat
			[/endlevel]
		[/then]
	[/if]	
[/event]

{MALIN_DEATH}

# Victory Conditions

#define ESCAPE_EVENT
{PLACE_IMAGE scenery/signpost.png 8 1}
[scroll_to]
	x,y=8,1
[/scroll_to]
[objectives]
	side=1
	[objective]
		condition=win
		description=_ "Escape to the northwest"
	[/objective]
	[objective]
		condition=lose
		description= _ "Death of Malin Keshar"
	[/objective]
[/objectives]
[music]
	name=loyalists.ogg
	append=no
	immediately=yes
[/music]
[event]
	name=moveto
	description=Malin Keshar
	[filter]
		x,y=8,1
	[/filter]
	{DIALOGUE_RTH_END}
	[endlevel]
		bonus=no
		result=continue
	[/endlevel]
[/event]
#enddef

[event]
	name=die
	[filter]
		description=Drogan
	[/filter]
	{DIALOGUE_RTH_DROGANDEATH}
	{ESCAPE_EVENT}
	[event]
		name=die
		[filter]
			side=3,4
			[not]
				description=Drogan
			[/not]
		[/filter]
		[filter_second]
			side=1
		[/filter_second]
		{DIALOGUE_RTH_GUARDDEATH}
	[/event]
[/event]

[/scenario]
