[scenario]
id=Forever_and_Ever_Amen
next_scenario=Forever_and_Ever_Amen
#textdomain wesnoth-did

name=_ "Forever and Ever, Amen"
map_data="{campaigns/Descent_Into_Darkness/maps/Forever_and_ever_amen.map}"
turns=-1

victory_when_enemies_defeated=yes

{STORY_FOREVER_AND_EVER_AMEN}

{UNDERGROUND}

[side]
	side=1
	controller=human
	type=Lich
	description=Mal Keshar
	user_description=_ "Malin Keshar"
	unrenamable=yes
	canrecruit=1
	recruit=Walking Corpse,Vampire Bat,Ghost,Ghoul,Skeleton Archer,Skeleton,Dark Adept
	gold=200
	save_id=Malin Keshar
[/side]

[side]
	# Foolish Hero
	side=2
	controller=ai
	# place leader, grant gold and recruits later
	no_leader=yes
	gold=0
	recruit=
	[ai]
		villages_per_scout=10
		village_value=0.5
	[/ai]
	fog=no
	shroud=no
[/side]

[event]
	name=prestart
	[music]
		name=knolls.ogg
		ms_after=5000
	[/music]
	
	[objectives]
		side=1
		[objective]
			condition=win
			description=_ "Defeat the foolish hero."
		[/objective]
		[objective]
			condition=lose
			description=_ "Destruction of Mal Keshar."
		[/objective]
	[/objectives]
	
	{VARIABLE_OP randomHero random (0..3)}
	{IF_VAR randomHero 0}
		[unit]
			side=2
			type=Royal Guard
			description=Foolish Hero
			user_description=_ "Foolish Hero"
			x,y=20,3
			canrecruit=1
		[/unit]
		{ALLOW_RECRUIT (Spearman,Swordsman,Pikeman,Bowman,Longbowman,Heavy Infantry,Shock Trooper,Mage,Red Mage,White Mage,Horseman,Knight,Lancer)}
	{END_IF_VAR}
	{IF_VAR randomHero 1}
		[unit]
			side=2
			type=Assassin
			description=Foolish Hero
			user_description=_ "Foolish Hero"
			x,y=20,3
			canrecruit=1
		[/unit]
		{ALLOW_RECRUIT (Thug,Bandit,Footpad,Outlaw,Poacher,Trapper,Thief,Rogue)}
	{END_IF_VAR}
	{IF_VAR randomHero 2}
		[unit]
			side=2
			type=Elvish Marshal
			description=Foolish Hero
			user_description=_ "Foolish Hero"
			x,y=20,3
			canrecruit=1
		[/unit]
		{ALLOW_RECRUIT (Elvish Figher,Elvish Hero,Elvish Captain,Elvish Archer,Elvish Ranger,Elvish Marksman,Elvish Shaman,Elvish Sorceress,Elvish Druid,Elvish Scout,Elvish Rider,Wose)}
	{END_IF_VAR}
	{IF_VAR randomHero 3}
		[unit]
			side=2
			type=Dwarvish Lord
			description=Foolish Hero
			user_description=_ "Foolish Hero"
			x,y=20,3
			canrecruit=1
		[/unit]
		{ALLOW_RECRUIT (Dwarvish Figher,Dwarvish Steelclad,Dwarvish Thunderer,Dwarvish Thunderguard,Dwarvish Stalwart,Dwarvish Guardsman,Dwarvish Ulfserker,Dwarvish Berserker,Gryphon Rider,Gryphon Master)}
	{END_IF_VAR}
	
	# Give the foolish hero gold = 40*timesForever + 100
	{VARIABLE_OP heroGold format $timesForever}
	{VARIABLE_OP heroGold multiply 40}
	{VARIABLE_OP heroGold add 100}
	[gold]
		side=2
		amount=$heroGold
	[/gold]
	{CLEAR_VARIABLE heroGold}
	
	[if]
		[variable]
			name=timesForever
			greater_than=0
		[/variable]
		[then]
			[event]
				name=attack_end
				first_time_only=no
				{IF_UNIT_DEAD (Mal Keshar)}
					[role]
						side=2
						[not]
							canrecruit=1
						[/not]
						role=second
					[/role]
					[music]
						name=elf-land.ogg
						play_once=yes
						immediate=yes
						ms_after=10000
					[/music]
					{DIALOGUE_FAEA_END}
					[endlevel]
						result=victory
						next_scenario=null
					[/endlevel]
				{END_IF_DEAD}
			[/event]
		[/then]
	[/if]
	
	{STARTING_VILLAGES 1 6}
	
[/event]


[event]
	name=start
	{IF_VAR randomHero 0}
		{DIALOGUE_FAEA_START0}
	{END_IF_VAR}
	{IF_VAR randomHero 1}
		{DIALOGUE_FAEA_START1}
	{END_IF_VAR}
	{IF_VAR randomHero 2}
		{DIALOGUE_FAEA_START2}
	{END_IF_VAR}
	{IF_VAR randomHero 3}
		{DIALOGUE_FAEA_START3}
	{END_IF_VAR}
	
	# Some more harassment at once the scanario's been played a few times
	{IF_VAR timesForever 7}
		{DIALOGUE_FAEA_SASS1}
	{END_IF_VAR}
[/event]

# In-scenario events defined within the prestart event

# Defeat Conditions
{MAL_DEATH}

[event]
	name=victory
	{VARIABLE_OP timesForever add 1}
	{CLEAR_VARIABLE randomHero}
[/event]

[/scenario]
