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

name=_ "A Small Favor"
map_data="{campaigns/Descent_Into_Darkness/maps/A_small_favor.map}"
{TURNS 28 26 22}

victory_when_enemies_defeated=no

{STORY_A_SMALL_FAVOR}

{FIRST_WATCH}

[side]
	side=1
	controller=human
	team_name=intruders
	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 170 130 110}
	shroud=no
	fog=yes
[/side]

[side]
	side=2
	colour=2
	controller=ai
	team_name=defenders
	type=General
	description=Taylor
	user_description=_ "Taylor"
	unrenamable=yes
	canrecruit=1
	recruit=Swordsman,Pikeman,Longbowman,Cavalryman,Dragoon,Mage,Heavy Infantryman,Shock Trooper
	gold=0
	village_gold=0
	income=-2
	[ai]
		passive_leader=yes
		aggression=1.0
		caution=0.4
		[protect_area]
			# Manor entrance
			x,y=7,8
			radius=5
			value=4
		[/protect_area]
		[protect_area]
			# Rest of city
			x=3-22
			y=6-22
			radius=1
			value=2
		[/protect_area]
		grouping=offensive
		protect_leader=2
	[/ai]
	shroud=no
	fog=yes
[/side]

[event]
	name=prestart
	[music]
		name=knolls.ogg
	[/music]
	
	[objectives]
		side=1
		[objective]
			condition=win
			description= _ "Malin and Darken Volk enter the Mage Lord's manor"
		[/objective]
		[objective]
			condition=lose
			description= _ "Death of Malin Keshar"
		[/objective]
		[objective]
			condition=lose
			description= _ "Death of Darken Volk"
		[/objective]
	[/objectives]
	
	# Place city pictures
	{PLACE_IMAGE scenery/well.png 17 11}
	{PLACE_IMAGE scenery/well.png 8 12}
	{PLACE_IMAGE items/dummy.png 18 15}
	{PLACE_IMAGE items/dummy.png 19 15}
	{PLACE_IMAGE items/armor.png 19 17}
	{PLACE_IMAGE items/armor.png 21 17}
	{PLACE_IMAGE items/armor.png 22 16}
	{PLACE_IMAGE items/flower2.png 9 19}
	{PLACE_IMAGE items/flower1.png 10 18}
	{PLACE_IMAGE items/flower4.png 12 18}
	{PLACE_IMAGE items/flower4.png 13 19}
	{PLACE_IMAGE scenery/fire1.png 19 23}
	{PLACE_IMAGE scenery/fire1.png 25 20}
	{PLACE_IMAGE scenery/fire1.png 11 8}
	{PLACE_IMAGE scenery/monolith1.png 11 5}
	{PLACE_IMAGE scenery/monolith1.png 12 4}
	{PLACE_IMAGE scenery/monolith1.png 13 5}
	{PLACE_IMAGE items/altar.png 12 5}
	
	# Place manor pictures
	{PLACE_IMAGE items/holy-water.png 5 5}
	{PLACE_IMAGE items/potion-blue.png 5 7}
	{PLACE_IMAGE items/potion-red.png 6 5}
	{PLACE_IMAGE scenery/trapdoor-closed.png 3 7}
	
	# Place city guards
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 11 3}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 17 6}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 23 9}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 25 14}
	{GEN_GUARDIAN Pikeman (Gate Guard) (_ "Gate Guard") 2 20 22}
	{GEN_GUARDIAN Pikeman (Gate Guard) (_ "Gate Guard") 2 24 20}
	{GEN_GUARDIAN (Heavy Infantryman) (Gate Guard) (_ "Gate Guard") 2 19 22}
	{GEN_GUARDIAN (Heavy Infantryman) (Gate Guard) (_ "Gate Guard") 2 24 19}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 13 23}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 7 23}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 4 18}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 2 14}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Night Watchman") 2 16 28}
	
	# More guards, depending on the difficulty
	#ifdef EASY
	{GEN_GUARDIAN Mage (Night Watchman) (_ "Night Watchman") 2 6 8}
	{GEN_GUARDIAN Mage (Night Watchman) (_ "Night Watchman") 2 8 7}
	{GEN_GUARDIAN Sergeant (Head Trainer) (_ "Head Trainer") 2 21 15}
	#endif
	
	#ifdef NORMAL
	{GEN_GUARDIAN (Mage) (Night Watchman) (_ "Night Watchman") 2 6 8}
	{GEN_GUARDIAN (Red Mage) (Night Watchman) (_ "Night Watchman") 2 8 7}
	{PLACE_IMAGE scenery/fire1.png 11 8}
	{GEN_GUARDIAN Spearman (Night Watchman) (_ "Townperson") 2 12 7}
	{GEN_GUARDIAN Lieutenant (Head Trainer) (_ "Head Trainer") 2 21 15}
	#endif
	
	#ifdef HARD
	{GEN_GUARDIAN (Silver Mage) (Night Watchman) (_ "Night Watchman") 2 6 8}
	{GEN_GUARDIAN (Red Mage) (Night Watchman) (_ "Night Watchman") 2 8 7}
	{PLACE_IMAGE scenery/fire1.png 11 8}
	{GEN_GUARDIAN Pikeman (Night Watchman) (_ "Night Watchman") 2 12 7}
	{GEN_GUARDIAN Lieutenant (Head Trainer) (_ "Head Trainer") 2 21 15}
	#endif
	
	# Place Darken Volk
	{VARIABLE_OP darken_volk_store.x value 43}
	{VARIABLE_OP darken_volk_store.y value 14}
	[unstore_unit]
		variable=darken_volk_store
		find_vacant=yes
	[/unstore_unit]
	{CLEAR_VARIABLE darken_volk_store}
	
	# General owns villages in the city
	{STARTING_VILLAGES 2 15}
	
	# Event variables
	{VARIABLE undeadWarning no}

	{MODIFY_UNIT (description=Malin Keshar) profile (portraits/malin-3.png)}
[/event]

[event]
	name=start
	{DIALOGUE_ASF_START}
[/event]

# In-scenario Events
[event]
	# Sentry attacks an undead
	# This would be better to do when a sentry can see my units on his turn, but Wesnoth doesn't generate a "sighted" event if I move into their sight range during my turn
	name=attack
	first_time_only=no
	[filter]
		side=2
	[/filter]
	[filter_second]
		side=1
	[/filter_second]
	[if]
		[variable]
			name=undeadWarning
			equals=no
		[/variable]
		[then]
			# Sound a warning and give gold to the general
			{DIALOGUE_ASF_ALARM}
			{VARIABLE undeadWarning yes}
			[modify_side]
				side=2
				{GOLD 300 700 700}
			[/modify_side]
		[/then]
	[/if]
[/event]

[event]
	# undead unit kicks the holy water
	name=moveto
	[filter]
		x,y=5,5
		race=undead
	[/filter]
	# NEED SOME DIALOGUE
	[kill]
		x,y=5,5
		animate=yes
		trigger_event=yes
	[/kill]
	[removeitem]
		x,y=5,5
	[/removeitem]
[/event]

# Defeat Conditions
{MALIN_DEATH}
{VOLK_DEATH}

[event]
	name=time over
	[message]
		speaker=narrator
		message=_ "Day break and stuff."
	[/message]
	[endlevel]
		result=defeat
	[/endlevel]
[/event]

# Victory Conditions
[event]
	name=moveto
	first_time_only=no
	[filter]
		description=Malin Keshar
		x=3,4,5,6
		y=7,6,5-7,5-6
	[/filter]
	[if]
		[have_unit]
			description=Darken Volk
			x=3,4,5,6
			y=7,6,5-7,5-6
		[/have_unit]
		[then]
			[endlevel]
				bonus=no
				result=continue
			[/endlevel]
		[/then]
	[/if]
[/event]

[event]
	name=moveto
	first_time_only=no
	[filter]
		description=Darken Volk
		x=3,4,5,6
		y=7,6,5-7,5-6
	[/filter]
	[if]
		[have_unit]
			description=Malin Keshar
			x=3,4,5,6
			y=7,6,5-7,5-6
		[/have_unit]
		[then]
			[endlevel]
				bonus=no
				result=continue
			[/endlevel]
		[/then]
	[/if]
[/event]

[event]
	name=victory
	{CLEAR_VARIABLE undeadWarning}
	[store_unit]
		[filter]
			race=undead
			x=1-50
			y=1-29
		[/filter]
		variable=ASFUnit_store
		kill=yes
	[/store_unit]
	[store_unit]
		[filter]
			description=Darken Volk
		[/filter]
		variable=darkenVolkStore
		kill=yes
	[/store_unit]
[/event]
	
[/scenario]
