[scenario]
	id=19b_Swamp_Of_Dread
	#textdomain wesnoth-httt
	name= _ "Swamp Of Dread"
	map_data="{campaigns/Heir_To_The_Throne/maps/19b_Swamp_Of_Dread.map}"
	{SCENARIO_MUSIC "wanderer.ogg"}
	{TURNS 33 30 27}

	next_scenario=20_North_Elves

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

	{BIGMAP_SWAMP_OF_DREAD}

	[event]
	name=prestart
		[objectives]
		side=1
			[objective]
				description= _ "Defeat the Lich Lord Aimucasur"
				condition=win
			[/objective]
			[objective]
				description= _ "Defeat the Death Knights (Bonus)"
				condition=win
			[/objective]
			[objective]
				description= _ "Death of Konrad"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Delfador"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Li'sar"
				condition=lose
			[/objective]
			[objective]
				description= _ "Death of Kalenz"
				condition=lose
			[/objective]
		[/objectives]
	[/event]

	{campaigns/Heir_To_The_Throne/utils/deaths.cfg}

	[side]
	type=Commander
	description=Konrad
	user_description= _ "Konrad"
	unrenamable=yes
	side=1
	canrecruit=1
	controller=human
	hitpoints=80
	[/side]

#define SWAMP_DREAD_AI_PARAMS
	[ai]
	{ATTACK_DEPTH 5 5 6}
	[/ai]
	[ai]
	time_of_day=dusk
	turns=8-100
	caution=0.25
	aggression=0.8
	[/ai]
	[ai]
	time_of_day=first_watch,second_watch
	caution=0.0
	aggression=1.0
	[/ai]
#enddef

	[side]
	type=Death Knight
	description=Clarustus
	user_description= _ "Clarustus"
	side=2
	controller=ai
	canrecruit=1
	recruit=Walking Corpse
	{GOLD 140 200 260}
		[ai]
		{NO_SCOUTS}
		[/ai]
	{SWAMP_DREAD_AI_PARAMS}
	team_name=undead
	[/side]

	[side]
	type=Death Knight
	description=Merlunius
	user_description= _ "Merlunius"
	side=3
	controller=ai
	canrecruit=1
	recruit=Ghost,Skeleton,Walking Corpse
	{GOLD 140 200 260}
	{SWAMP_DREAD_AI_PARAMS}
	team_name=undead
	[/side]

	[side]
	type=Lich
	description=Aimucasur
	user_description= _ "Aimucasur"
	side=4
	controller=ai
	canrecruit=1
	recruit=Wraith,Vampire Bat,Skeleton
	{GOLD 140 200 260}
	team_name=undead
	{SWAMP_DREAD_AI_PARAMS}
	[/side]

	[side]
	type=Death Knight
	description=Secadius
	user_description= _ "Secadius"
	side=5
	controller=ai
	canrecruit=1
	recruit=Skeleton,Walking Corpse,Ghoul
		[ai]
		{NO_SCOUTS}
		[/ai]
	{SWAMP_DREAD_AI_PARAMS}
	{GOLD 90 150 210}
	team_name=undead
	[/side]

	[side]
	type=Death Knight
	description=Dafeis
	user_description= _ "Dafeis"
	side=6
	controller=ai
	canrecruit=1
	recruit=Skeleton Archer,Walking Corpse,Ghost
	{GOLD 90 150 210}
	team_name=undead
	{SWAMP_DREAD_AI_PARAMS}
	[/side]

	[event]
	name=start
		#For Home of the Northern Elves: where do we come from?
		[set_variable]
		name=A_Choice_Was_Made
		value=b
		[/set_variable]
		[recall]
		description=Delfador
		[/recall]
		[recall]
		description=Li'sar
		[/recall]
		[recall]
		description=Kalenz
		[/recall]
		[message]
		description=Delfador
		message= _ "This land is cursed. Liches have existed here for ages, luring adventurers and soldiers to their deaths and amassing great armies and fortunes."
		[/message]
		[message]
		description=Konrad
		message= _ "Look there! The swamp is infested with all manner of skeletons, corpses, and worse. I hope I have made a wise choice in taking this path."
		[/message]
		[message]
		description=Delfador
		message= _ "These Death Knights appear to be minions enslaved by the Lich Lord. This one must be particularly powerful, since Death Knights are usually strong-willed spirits on their own."
		[/message]
		[message]
		description=Kalenz
		message= _ "I believe we can destroy the master and release the minions. There is much fighting to be done before we can pass through these swamps in peace. May our bones not join these fallen warriors who now oppose us."
		[/message]
	[/event]

#define ENDOWED_KNIGHT NAME
[event]
name=die
	[filter]
	description={NAME}
	type=Death Knight
	[/filter]
	[message]
	speaker=narrator
	image="wesnoth-icon.png"
	message= _ "The Death Knight explodes into a cloud of dust as it is eradicated. Its armor, however, drops to the ground and remains intact. The heavy black steel is polished to a mirror shine."
	[/message]
	[message]
	description=Li'sar
	message= _ "Delfador... that breastplate... how did it end up here?"
	[/message]
	[message]
	description=Delfador
	message= _ "Its owner was surely a famous warrior in life. I wonder who it was. That plate must have a powerful enchantment to have resisted centuries of decay. Choose wisely who will bear it."
	[/message]
	{VARIABLE temp_armor_x $x1}
	{VARIABLE temp_armor_y $y1}
	{OBJ_VOID_ARMOR $temp_armor_x $temp_armor_y void_armor}
[/event]
#enddef

#
# 1.1.7 PROBLEMS: if you kill the endowed knight last, the lich event doesn't fire.
#

[event]
name=prestart
	{VARIABLE_OP armored_knight random (Clarustus,Merlunius,Secadius,Dafeis)}
	{ENDOWED_KNIGHT ($armored_knight)}
[/event]

#
# Reward the player for killing all 4 Death Knights - the Lich is weaker
#
[event]
name=prestart
	{VARIABLE dk_kill_count 0}
[/event]
[event]
name=die
first_time_only=no
	[filter]
	type=Death Knight
	[/filter]
	{VARIABLE_OP dk_kill_count add 1}

	[if]
	[variable]
	name=dk_kill_count
	numerical_equals=4
	[/variable]
	[then]
		[message]
		speaker=narrator
		image="wesnoth-icon.png"
		message= _ "As the last Death Knight falls, an ear-splitting screech escapes from the Lich. It is clear that controlling such powerful spirits has drained it significantly, and it is seething in anger towards you."
		[/message]
		[store_unit]
		variable=Lich_store
			[filter]
			type=Lich
			[/filter]
		[/store_unit]
		{VARIABLE_OP Lich_store.hitpoints multiply 0.4}
		[unstore_unit]
		variable=Lich_store
		[/unstore_unit]
		{CLEAR_VARIABLE Lich_store}
	[/then]
	[/if]
[/event]

[event]
name=die
	[filter]
	type=Lich
	[/filter]
	[kill]
	type=Death Knight
	[/kill]
	[message]
	speaker=narrator
	image="wesnoth-icon.png"
	message= _ "A final blow destroys the Lich, releasing a small shockwave of energy outwards. The Death Knights silently fall to the ground, inanimate. A giant cloud of dust bellows out as the remnants of the Lich's once-mortal skin and centuries of grime and gristle are lodged loose for the last time."
	[/message]
	[message]
	speaker=Delfador
	message= _ "Aimucasur's lordship over this cursed ground is broken."
	[/message]
	[message]
	speaker=Konrad
	message= _ "Aimucasur? So you know of this Lich Lord? Did you know him? He was a powerful mage?"
	[/message]
	[message]
	speaker=Delfador
	message= _ "Yes, very powerful. I was not certain of his identity at first, but it is certain now. He lived centuries ago... he appears in our histories, a former headmaster on Anduin. He was reported to have disappeared, and now we know what happened to him."
	[/message]
	[message]
	speaker=Li'sar
	message= _ "He was just someone who couldn't handle the power given to him."
	[/message]
	[message]
	speaker=Kalenz
	message= _ "You would do well to learn the lesson he did not."
	[/message]
	[message]
	speaker=Li'sar
	message= _ "Move along, Elf, unless you enjoy making camp in this slimy bog. I, for one, do not!"
	[/message]
	[message]
	speaker=Kalenz
	message= _ "Indeed..."
	[/message]
	[message]
	speaker=Li'sar
	message= _ "Listen, you whose eyes are fair but hide a vacuum, do you not think I know what power does to one's soul? What evils a person is capable of when truth and righteousness are but scrolls that can be rewritten when a queen grows tired of them?"
	[/message]
	[message]
	speaker=Li'sar
	message= _ "I spent my entire childhood listening to my mother give orders and commanding armies around. I hid in the throne room as a little girl as she met with her generals. I now know she was having people killed... entire towns of people killed!"
	[/message]
	[message]
	speaker=Li'sar
	message= _ "I became my mother's most trusted aide-de-camp. I was sent to quiet the worst of the rebellion. Of course they fought back. I never knew who these people were or why they fought my mother. Konrad, you are lucky. You do not know what Wesnoth has been like these past many years. There is no peace. I have never known peace."
	[/message]
	[message]
	speaker=Delfador
	message= _ "I do know the cup of bitterness poured out on Wesnoth by your mother, child. The land has been torn apart. The elves know this. The orcs know this. Undead can feel it. Large armies of men march across the plains hunting each other, and when no men remain, outsiders will claim Wesnoth as their home."
	[/message]
	[message]
	speaker=Konrad
	image=portraits/konrad-angry.png
	message= _ "Enough! I can listen to no more of this. Princess, you may want to end your mother's rule, but I will end her life as she ended the life of my father and my brothers. Asheviere's masterwork of treachery will end, and it will end by my blade!"
	[/message]
	[endlevel]
	result=victory
	{CLEAR_VARIABLE temp_armor_x}
	{CLEAR_VARIABLE temp_armor_y}
	{CLEAR_VARIABLE armor_taken}
	[/endlevel]

[/event]

[/scenario]
