[scenario]
	id=The_Drowned_Plains
	#textdomain wesnoth-ei
	name= _ "The Drowned Plains"
	map_data="{campaigns/Eastern_Invasion/maps/Drowned_Plains.map}"
	{TURNS 28 26 24}
	next_scenario=Approaching_Weldyn

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

	{DEFAULT_MUSIC_PLAYLIST}

	{campaigns/Eastern_Invasion/utils/deaths.cfg}

	[side]
	type=Lieutenant
	description=Gweddry
	user_description= _ "Gweddry"
	side=1
	canrecruit=1
	controller=human
	fog=yes
	{GOLD 200 150 100}
	[/side]

	[side]
	no_leader=yes
	side=2
	controller=ai
	team_name=baddies
	[/side]

	[side]
	side=3
	controller=ai
	team_name=baddies
	gold=0
	no_leader=yes
		[ai]
		#don't target any of the default things
		village_value=0
		leader_value=0
		protect_leader=0
		#stay in the middle of the map
			[avoid]
				[not]
				x=14-32
				y=10-45
				[/not]
			[/avoid]
		#and target anyone in it (otherwise it will have nothing to do when
		#it can't attack in the current turn)
			[target]
				#who knows what would happen if it targetted itself
				[not]
				type="Skeletal Dragon"
				[/not]
			x=14-32
			y=10-45
			value=100.0
			[/target]
		#I don't know if this is needed, but it sure would be stupid to use
		#any grouping behavior when there's only one unit on this side!
		grouping=no
		#not sure if this really does anything; it was copied from IP's code
		aggression=1.0
		caution=0.0
		[/ai]

		#give the skeletal dragon something to do when there are no enemies available
		#let it look like it's wandering around semi-randomly
		[ai]
		[leader_goal]
		x,y=14,10
		[/leader_goal]
		time_of_day=dawn
		[/ai]
		[ai]
		[leader_goal]
		x,y=23,26
		[/leader_goal]
		time_of_day=morning
		[/ai]
		[ai]
		[leader_goal]
		x,y=23,26
		[/leader_goal]
		time_of_day=afternoon
		[/ai]
		[ai]
		[leader_goal]
		x,y=32,32
		[/leader_goal]
		time_of_day=dusk
		[/ai]
		[ai]
		[leader_goal]
		x,y=32,10
		[/leader_goal]
		time_of_day=first_watch
		[/ai]
		[ai]
		[leader_goal]
		x,y=14,32
		[/leader_goal]
		time_of_day=second_watch
		[/ai]
		[unit]
		type="Skeletal Dragon"
		description="Khrakrahs"
		user_description= _ "Khrakrahs"
		canrecruit=1
		x=28
		y=23
		[/unit]
	team_name=baddies
	gold=0
	[/side]

#define FAKE_VILLAGE X Y
{RANDOM 1,1,2}
[terrain]
x,y={X},{Y}
letter=Gg^Vh
[/terrain]
[if]
	[variable]
	name=random
	equals=1
	[/variable]
	[then]
		[event]
		name=moveto
			[filter]
			side=1
			x,y={X},{Y}
			[/filter]
			[message]
			speaker=unit
			message= _ "There are still humans in this village! They can help us."
			[/message]
			[unit]
			x,y={X},{Y}
			type=Peasant
			side=1
			description=Villager
			user_description= _ "Villager"
			[/unit]
			[unit]
			x,y={X},{Y}
			type=Peasant
			side=1
			description=Villager
			user_description= _ "Villager"
			[/unit]

		[/event]
	[/then]
	[else]
		[event]
		name=moveto
			[filter]
			side=1
			x,y={X},{Y}
			[/filter]
			[sound]
			name=gold.ogg
			[/sound]
			[message]
			speaker=unit
			message= _ "The undead have killed all the villagers here, but they left their valuables."
			[/message]
			[gold]
			side=1
			amount=20
			[/gold]
		[/event]
		[event]
		name=capture
		first_time_only=no
			[filter]
			x={X}
			y={Y}
			[/filter]
			[allow_undo]
			[/allow_undo]
			[capture_village]
			x={X}
			y={Y}
			[/capture_village]
		[/event]
	[/else]
[/if]
[clear_variable]
name=random
[/clear_variable]
#enddef

	[event]
	name=prestart
		[objectives]
		side=1
			[objective]
			description= _ "Defeat Khrakrahs, the Skeletal Dragon"
			condition=win
			[/objective]
			[objective]
			description= _ "Death of Gweddry"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Dacyn"
			condition=lose
			[/objective]
			[objective]
			description= _ "Death of Owaec"
			condition=lose
			[/objective]
		[/objectives]
		{FAKE_VILLAGE 42 4}
		{FAKE_VILLAGE 40 9}
		{FAKE_VILLAGE 37 12}
		{FAKE_VILLAGE 33 12}
		{FAKE_VILLAGE 33 15}
		{FAKE_VILLAGE 28 14}
		{FAKE_VILLAGE 41 13}
		{FAKE_VILLAGE 21 15}
#ifdef NORMAL
		{FAKE_VILLAGE 17 24}
#endif
#ifdef EASY
		{FAKE_VILLAGE 17 24}
		{FAKE_VILLAGE 36 20}
#endif
	[/event]

	[event]
	name=start
		[recall]
		description=Dacyn
		[/recall]
		[recall]
		description=Owaec
		[/recall]
		[recall]
		description=Grug
		[/recall]
		[recall]
		description=Engineer
		[/recall]
		[message]
		description=Owaec
		message= _ "Now, we have reached the fair homeland of my people. They may be able to help us in - "
		[/message]
		[message]
		description=Owaec
		message= _ "What?! Swamps?! Those Undead have destroyed the grasslands of my House, and they shall pay for it!"
		[/message]
		[message]
		description=Dacyn
		message= _ "The lich-lord must have flooded the valley. The undead like the swamp. It is death, decay, everything that they are themselves."
		[/message]
		[message]
		description=Engineer
		message= _ "I s'ppose we'll hav' to wade across it... ugh. An' with dis mist from de swamp, we can't e'en see any 'nemies."
		[/message]
		[message]
		description=Khrakrahs
		message= _ "Findshhhh... slayhhhh... killhhhh..."
		[/message]
		[message]
		description=Gweddry
		message= _ "What is that?!?"
		[/message]
		[message]
		description=Dacyn
		message= _ "I do not know, but my guess is the dragon Khrakrahs. He was a powerful beast indeed, in the time of Haldric, living in the Northern Mountains. But he does not sound alive. I know not what happened, but we must destroy him."
		[/message]
	[/event]

#define UNDEAD X Y
[set_variable]
name=type
{QUANTITY random (Bone Shooter,Revenant,Shadow,Wraith,Necrophage,Bone Shooter,Revenant,Shadow,Wraith,Necrophage,Soul Shooter) (Bone Shooter,Revenant,Shadow,Wraith,Necrophage,Bone Shooter,Revenant,Shadow,Wraith,Necrophage,Soul Shooter,Spectre,Nightgaunt) (Bone Shooter,Revenant,Shadow,Wraith,Necrophage,Soul Shooter,Spectre,Nightgaunt)}
[/set_variable]
[unit]
x={X}
y={Y}
type=$type
side=2
[/unit]
[clear_variable]
name=type
[/clear_variable]
#enddef

	[event]
	name=moveto
	first_time_only=no
		[filter]
		side=1
		[/filter]
		#ifdef EASY
		{RANDOM 1..20}
		#endif
		#ifdef NORMAL
		{RANDOM 1..18}
		#endif
		#ifdef HARD
		{RANDOM 1..15}
		#endif
		[if]
			[variable]
			name=random
			numerical_equals=1
			[/variable]
			[then]
				[set_variable]
				name=tempx
				value=$x1
				[/set_variable]
				{RANDOM -3,-2,-1,1,2,3}
				[set_variable]
				name=tempx
				add=$random
				[/set_variable]
				[set_variable]
				name=tempy
				value=$y1
				[/set_variable]
				{RANDOM -3,-2,-1,1,2,3}
				[set_variable]
				name=tempy
				add=$random
				[/set_variable]
				{UNDEAD $tempx $tempy}
				{UNDEAD $tempx $tempy}
				{UNDEAD $tempx $tempy}
#ifdef HARD
				{UNDEAD $tempx $tempy}
#endif
				[clear_variable]
				name=tempx
				[/clear_variable]
				[clear_variable]
				name=tempy
				[/clear_variable]
				[message]
				speaker=unit
				message= _ "Undead, undead are rising out of the ground!"
				[/message]
			[/then]
		[/if]
		[clear_variable]
		name=random
		[/clear_variable]
	[/event]

	[event]
	name=sighted
		[filter]
		description=Khrakrahs
		[/filter]
		[message]
		description=Dacyn
		message= _ "Aha! I see what they have done. They have raised him as a dragon. But he does not appear to be weak to my arcane flame... this is strange magic indeed."
		[/message]
	[/event]
[/scenario]
