#Scenario 1: The Morning After

[scenario]
#textdomain wesnoth-utbs

id="1_MorningAfter"
name= _ "The Morning After"
label= _ "The Morning After"

{DESERTMAP 1MorningAfter5}

next_scenario=2_HarshSands

#don't display snapshot of map in saved games
snapshot="no"

#max turns in scenario varies depending on difficulty
#ifdef EASY
turns="34"
#endif
#ifdef MEDIUM
turns="32"
#endif
#ifdef HARD
turns="30"
#endif
victory_when_enemies_defeated=no

{DAWN1}
{MORNING1}
{MIDDAY1}
{AFTERNOON1}
{DUSK1}
{SHORTDARK}
{DAWN2}
{MORNING2}
{MIDDAY2}
{AFTERNOON2}
{DUSK2}
{LONGDARK1}
{LONGDARK2}
{LONGDARK3}
{LONGDARK4}

[music]
name=wesnoth-1.ogg
[/music]

[story]
	[part]
	story= _ "Note: This campaign is probably not the best one for beginners. It changes certain Wesnoth standards, such as the elves' stats and the day/night cycle. This campaign emphasizes role-playing elements and tends to have longer scenarios with changing objectives. For these reasons I strongly suggest that you occasionally save your game mid-scenario, so you won't lose all your progress if you get stuck and have to start over."
	[/part]

	[part]
	story= _ "This is the chronicle of the journey of the Quenoth elves from their homeland in the Great Southern Desert. I write this story so that our descendants may know of our travels, and remember the sacrifices we made."
	[/part]

	[part]
	story= _ "Chapter 1: I, Kaleh, grew up amidst the shifting sands, under our two suns Sela and Naia. It was a land of hot dry days and cold nights, of roaming horrors, where water was more valuable than gold. We had lived among the sands ever since the forests fell eons ago. It was a hard savage land, but we were tougher still, and we managed to survive settled around a rare oasis. We had heavily fortified our village against any marauders and we were the biggest encampment we knew of. My uncle, Tanuil, led us for many years, and trained us to be self-sufficient and strong against all enemies. A people struggling in an ocean of sand, we thought we were ready for anything. All that changed one fateful night, when the sky rained fire..."
	[/part]

	[part]
	story= _ "I remember that night as if it were yesterday. I was not prone to dreaming, but as I slept I had a strange vision. I didn't have long to ponder it though, because I was woken in the dark by the sound of deafening crashes, splintering wood and shouting elves. That night the sky rained flaming rocks, boulders bigger than you could imagine. They smote the landscape like lightning bolts, setting fire to whatever could burn and crushing houses, walls, and elves. There was nowhere to hide, nowhere to go for protection. I was so afraid, I thought that if I tried to flee I would be smashed, so I hid and prayed to Eloh. I never prayed before as hard as I did that night. I heard cries and screams outside, but I could not force myself to move. And somehow, eventually the thin yellow tendrils of a sickly dawn stole over the horizon, as if Naia herself were shocked by the devastation she saw."
	[/part]

[/story]

#Elves
[side]
	side=1
	description=Kaleh
	user_description= _ "Kaleh"
	type=Kaleh Fighter
	upkeep=free
	[modifications]
		{TRAIT_RESILIENT}
		{TRAIT_INTELLIGENT}
	[/modifications]
	{IS_HERO}
	canrecruit=1
	gold=0
	{INCOME 4 2 0}
	controller=human
	shroud=yes
	fog=no

	#Start with Kaleh and Nym

	[unit]
	type=Nym Hunter
	description=Nym
	user_description= _ "Nym"
	upkeep=loyal
	side=1
	x=27
	y=22
	[modifications]
		{TRAIT_LOYAL}
		{TRAIT_RESILIENT}
	[/modifications]
	{IS_HERO}
	[/unit]

[/side]

#Monster side, mostly mudcrawlers
[side]
no_leader=yes
side=2
canrecruit=0
controller=ai
shroud=no
fog=no
team_name=evil

#Monsters are very aggressive
[ai]
aggression=1.0
caution=0.0

[/ai]

[/side]

#Undead side, doesn't start with a leader
[side]
	no_leader=yes
	side=3
	canrecruit=1
	controller=ai
	shroud=no
	fog=no
	team_name=evil

	#ifdef EASY
	recruit=Skeleton, Skeleton Archer, Vampire Bat, Ghoul, Dark Adept
	#endif

	#ifdef MEDIUM
	recruit=Skeleton, Skeleton Archer, Blood Bat, Ghoul, Dark Adept
	#endif

	#ifdef HARD
	recruit=Revenant, Blood Bat, Necrophage, Dark Adept
	#endif

	[ai]
		#Need to make undead player more aggressive?
		recruitment_ignore_bad_movement=yes

		#ifdef EASY
		recruitment_pattern=scout,fighter,archer,fighter
		#endif

		#ifdef MEDIUM
		recruitment_pattern=scout,fighter,archer,fighter
		#endif

		#ifdef HARD
		recruitment_pattern=scout,fighter,fighter,fighter,archer
		#endif

		aggression=0.80
		caution=0.10

		# AI will attack a weak unit with a max of 4,5,6 units
		# depending on the difficulty (default=5)
		{ATTACK_DEPTH 4 5 6}

	[/ai]
[/side]


# prestart events:
# set starting scenario objectives
# teleport starting characters
# set starting variables

[event]
name=prestart

# set starting scenario objectives

[objectives]
	summary= _ "Starting Objectives:"
	[objective]
		description= _ "Rescue Surviving Elves"
		condition=win
	[/objective]
	[objective]
		description= _ "Death of Kaleh, Nym, Garak or Zhul"
		condition=lose
	[/objective]
[/objectives]

#Transport leader to starting position and erase keep he was created on
[teleport]
	[filter]
	description=Kaleh
	[/filter]
	x,y=26,22
[/teleport]

[terrain]
	x=1
	y=50
	letter=I
[/terrain]

	#There are 2 mudcrawler encounter spots, in the NW and SW corner.
	#Depending on which way you circle around the village, you will
	#encounter the NW or SW one first. This flag records if you
	#have done encounter #1 already.

	#At start never seen a mudcrawler is true
	[set_variable]
	name=never_seen_mudcrawler
	value=1
	[/set_variable]

	#At start, number of mudcrawlers killed is zero
	[set_variable]
	name=mudcrawlers_killed
	value=0
	[/set_variable]

	#At start encountered druids is false
	[set_variable]
	name=encountered_druids
	value=0
	[/set_variable]

	#At start encountered deep one is false
	[set_variable]
	name=encountered_deep_one
	value=0
	[/set_variable]

	#At start encountered first scout in stable is false
	[set_variable]
	name=encountered_scout
	value=0
	[/set_variable]

	#Can't end scenario until all elves have been rescued and counter=5
	[set_variable]
	name=rescued_elves
	value=0
	[/set_variable]

	#Flag to check if dark sorcerer has appeared yet
	[set_variable]
	name=dark_sorcerer_appeared
	value=0
	[/set_variable]

	#used to make sure that deaths.cfg event fires correctly
	[set_variable]
	name=immortal_hero
	value=0
	[/set_variable]

	#Four outer villages have flags to see if they have been
	#Captured by side 1 or 3. start at 0.
	[set_variable]
	name=village1
	value=0
	[/set_variable]
	[set_variable]
	name=village2
	value=0
	[/set_variable]
	[set_variable]
	name=village3
	value=0
	[/set_variable]
	[set_variable]
	name=village4
	value=0
	[/set_variable]

[/event]

#Dialogue at start of scenario
[event]
	name=start

	[message]
	description=Nym
	message= _ "Hey Kaleh, are you in there?"
	[/message]

	[message]
	description=Kaleh
	message= _ "Nym, is that you?"
	[/message]

	[message]
	description=Nym
	message= _ "Yes, come on out already. The storm has passed. With the morning light Naia has ended the terrible night."
	[/message]

	[message]
	description=Kaleh
	message= _ "Has the sky really stopped falling?"
	[/message]

	[message]
	description=Nym
	message= _ "I already told you, the sky is clear and empty. Now come quickly, silly, others may need our help."
	[/message]

	[message]
	description=Kaleh
	message= _ "What's happened? Oh Eloh, the craters are everywhere, everything is gone, ruined. I can hardly recognize our village. I didn't think it could be this bad."
	[/message]

	[message]
	description=Nym
	message= _ "C'mon Kaleh, we have to go see if anyone is hurt or needs help. I think I hear people calling from the south. Now is not a time for fear, we must be strong. After all you are the nephew of Tanuil, our leader, and you must answer to the call of duty. Perhaps in the light of day things won't be as bad as you think. Let's explore the village and see who else has survived the night."
	[/message]

	[message]
	description=Kaleh
	message= _ "Wait, our keep is just to the east. Our leader Tanuil must surely be recruiting others to help deal with the devastation. Perhaps we should go to the keep, before we explore the rest of the village."
	[/message]

[/event]

# Dialogue when Nym and Kaleh see the ruined keep
[event]
name=moveto

	[filter]
	x=33-40
	y=19-26
	side=1
	[/filter]

	[allow_undo]
	[/allow_undo]

	[message]
		description=Kaleh
		message= _ "Tanuil's keep, our beautiful fortress, it is destroyed. How will we summon our people to battle?"
	[/message]
	[message]
		description=Nym
		message= _ "We must rally those survivors we can find amidst the rubble. It doesn't look like anyone survived, but at least we can thank Eloh it was a quick death. But come on, we can't dwell on the dead, we must help the living."
	[/message]
	[message]
		description=Kaleh
		message= _ "But if Tanuil is dead, who will lead us?"
	[/message]
	[message]
		description=Nym
		message= _ "That's a question for another time. Let's keep exploring the wreckage."
	[/message]
[/event]


# North-West mudcrawler/villager encounter
# Elvish fighter and 2 archers fighting
# Easy: 1 giant mudcrawler, 3 small mudcrawlers
# Medium: 2 giant mudcrawler, 2 small mudcrawlers
# Hard: 3 giant mudcrawlers, 2 small mudcrawlers
[event]
name=moveto
	[filter]
	x=17-26
	y=23-28
	side=1
	[/filter]

	[set_variable]
	name=rescued_elves
	add=1
	[/set_variable]

	{UNIT_T (Desert Fighter) (Vecnu) ( _ "Vecnu") 1 24 25}
	{UNIT_T (Desert Archer) (Eranor) ( _ "Eranor") 1 24 27}
	{UNIT_T (Desert Archer) (Seela) ( _ "Seela") 1 21 25}
	#Hack to make Seela female
	[+unit]
		gender=female
	[/unit]

	{CLEAR_VARIABLE tempelf}

	{FREE_UNIT (Giant Mudcrawler) () ("") 2 20 24}

	#ifdef HARD
	{FREE_UNIT (Giant Mudcrawler) () ("") 2 20 25}
	#else
	{FREE_UNIT (Small Mudcrawler) () ("") 2 20 25}
	#endif

	#ifdef EASY
	{FREE_UNIT (Small Mudcrawler) () ("") 2 23 27}
	#else
	{FREE_UNIT (Giant Mudcrawler) () ("") 2 23 27}
	#endif

	#When not easy diff, mudcrawler is spawned on hills, not desert.
	#ifdef EASY
	{FREE_UNIT (Small Mudcrawler) () ("") 2 25 28}
	#else
	{FREE_UNIT (Small Mudcrawler) () ("") 2 24 28}
	#endif

	[if]
		[variable]
		name=never_seen_mudcrawler
		numerical_equals=1
		[/variable]

		[then]
		#Hasn't completed #1 encounter, do it now

		[set_variable]
		name=never_seen_mudcrawler
		value=0
		[/set_variable]

		[message]
		description=Vecnu
		message= _ "Kaleh, Nym, help us!"
		[/message]
		[message]
		description=Nym
		message= _ "What in Uria's name is that?"
		[/message]
		[message]
		description=Vecnu
		message= _ "It came out of the stones that fell from the sky. I know not what it is, but more seem to be emerging from the craters. If we don't stop them there will be nothing left of our village or our people."
		[/message]
		[message]
		description=Kaleh
		message= _ "To battle, my friends! There are still those left who can fight."
		[/message]
		[/then]

		[else]
		#Has completed encounter #1 in SW corner, do #2 encounter

		[message]
		description=Kaleh
		message= _ "There are more of our people fighting the mud monsters!"
		[/message]
		[message]
		description=Nym
		message= _ "Then let's join the battle!"
		[/message]
		[/else]
	[/if]
[/event]


# South-West mudcrawler/villager encounter
# Elvish archer and 2 hunters fighting
# Easy: 4 small mudcrawlers
# Medium: 1 giant mudcrawler, 3 small mudcrawlers
# Hard: 2 giant mudcrawlers, 2 small mudcrawlers
[event]
	name=moveto
	[filter]
	x=17-28
	y=29-36
	side=1
	[/filter]

	[set_variable]
	name=rescued_elves
	add=1
	[/set_variable]

	{UNIT_T (Desert Hunter) (Eloshi) ( _ "Eloshi") 1 24 34}
	{UNIT_T (Desert Archer) (Illuvia) ( _ "Illuvia") 1 19 33}
	{UNIT_T (Desert Hunter) (Raynor) ( _ "Raynor") 1 21 35}

	{FREE_UNIT (Small Mudcrawler) () ("") 2 25 34}

	#ifdef HARD
	{FREE_UNIT (Giant Mudcrawler) () ("") 2 24 35}
	#else
	{FREE_UNIT (Small Mudcrawler) () ("") 2 24 35}
	#endif

	#ifdef EASY
	{FREE_UNIT (Small Mudcrawler) () ("") 2 20 34}
	#else
	{FREE_UNIT (Giant Mudcrawler) () ("") 2 20 34}
	#endif

	{FREE_UNIT (Giant Mudcrawler) () ("") 2 21 36}

	[if]
		[variable]
		name=never_seen_mudcrawler
		numerical_equals=1
		[/variable]

		[then]
		#Hasn't completed #1 encounter, do it now

		[set_variable]
		name=never_seen_mudcrawler
		value=0
		[/set_variable]

		[message]
		description=Eloshi
		message= _ "Kaleh, Nym, help us!"
		[/message]
		[message]
		description=Kaleh
		message= _ "What in Uria's name is that?"
		[/message]
		[message]
		description=Eloshi
		message= _ "It came out of the stones that fell from the sky. I know not what it is, but more seem to be emerging from the craters. If we don't stop them there will be nothing left of our village or our people."
		[/message]
		[message]
		description=Nym
		message= _ "To battle, my friends! There are still those left who can fight."
		[/message]
		[/then]

		[else]
		#Has completed encounter #1 in SW corner, do #2 encounter

		[message]
		description=Kaleh
		message= _ "There are more of our people fighting the mud monsters!"
		[/message]
		[message]
		description=Nym
		message= _ "Then let's join the battle!"
		[/message]
		[/else]
	[/if]
[/event]

#Training ground encounter
#Easy: 2 giant mudcrawler, 3 small mudcrawlers
#Medium: 3 giant mudcrawlers, 2 small mudcrawlers
#Hard: 4 giant mudcrawlers, 1 small mudcrawlers
[event]
name=moveto
	[filter]
	x=32-39
	y=32-36
	side=1
	[/filter]

	[capture_village]
		side=1
		x,y=36,34
	[/capture_village]

	[set_variable]
	name=rescued_elves
	add=1
	[/set_variable]

	{FREE_UNIT (Giant Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 34 33}

	#ifdef HARD
	{FREE_UNIT (Giant Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 35 33}
	#else
	{FREE_UNIT (Small Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 35 33}
	#endif

	{FREE_UNIT (Giant Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 34 34}

	#ifdef EASY
	{FREE_UNIT (Small Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 36 32}
	#else
	{FREE_UNIT (Giant Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 36 32}
	#endif

	{FREE_UNIT (Small Mudcrawler) (Rocky Horror) ( _ "Rocky Horror") 2 34 35}

	[unit]
	type=Garak Captain
	description=Garak
	user_description= _ "Garak"
	upkeep=full
	x=35
	y=34
	side=1
	[modifications]
		{TRAIT_STRONG}
		{TRAIT_LOYAL}
	[/modifications]
	{IS_HERO}
	[/unit]

	{UNIT_T (Desert Fighter) (Jorazan) ( _ "Jorazan") 1 36 33}
	{UNIT_T (Desert Fighter) (Zyara) ( _ "Zyara") 1 35 35}

	[message]
	speaker=unit
	message= _ "This is our training ground. And look, there is Garak, the captain of the guard. He and his fighters have survived the night!"
	[/message]

	[message]
	description=Kaleh
	message= _ "But they are fighting many mud creatures. Quick, we must help them!"
	[/message]

[/event]

#Garak's speech when they kill the Giant Mudcrawler
[event]
name=die
first_time_only=no

	[filter]
	description=Rocky Horror
	[/filter]

	[set_variable]
	name=mudcrawlers_killed
	add=1
	[/set_variable]

	[if]
		[variable]
		name=mudcrawlers_killed
		equals=5
		[/variable]

	[then]
	[message]
	speaker=second_unit
	message= _ "Ha! They're destroyed at last."
	[/message]
	[message]
	speaker=Garak
	message= _ "Thanks for the help. I am glad to see that so many have survived the night. But there's no time to talk, we must save the rest of our people and crush any other of these earthen abominations back into the earth."
	[/message]
	[/then]
	[/if]
[/event]

#Approaching bridge dialogue
[event]
name=moveto

	[filter]
	x=30-32
	y=29-35
	side=1
	[/filter]

	[allow_undo]
	[/allow_undo]

	[message]
	speaker=Kaleh
	message= _ "This bridge leads to the holy island at the center of our lake."
	[/message]
	[message]
	speaker=Nym
	message= _ "Hmmmm. Some of the druids that worship on the island may still be alive. We should go check."
	[/message]
	[message]
	speaker=Kaleh
	message= _ "Be careful. The bridge is broken, so we'll have to wade through the shallow water."
	[/message]
[/event]

#Finding druids
[event]
name=moveto

	[filter]
	x=30-32
	y=27-29
	side=1
	[/filter]

	[set_variable]
	name=rescued_elves
	add=1
	[/set_variable]

	[set_variable]
	name=encountered_druids
	value=1
	[/set_variable]

	[message]
	speaker=Kaleh
	message= _ "The great tree! It has been buried under the rocks. Our most holy sanctuary, defiled. Oh, Eloh, what shall we do?"
	[/message]

	[message]
	speaker=Nym
	message= _ "Is anyone still alive?"
	[/message]

	[unit]
	type=Zhul Druid
	description=Zhul
	user_description= _ "Zhul"
	upkeep=full
	x=31
	y=27
	side=1
	[modifications]
		{TRAIT_QUICK}
		{TRAIT_LOYAL}
	[/modifications]
	{IS_HERO}
	[/unit]

	{UNIT_T (Desert Shaman) (Ryoko) ( _ "Ryoko") 1 30 27}
	{UNIT_T (Desert Shaman) (Yuni) ( _ "Yuni") 1 32 27}

	[message]
	speaker=Zhul
	message= _ "Finally! We were worried that no one else had survived."
	[/message]

	[message]
	speaker=Nym
	message= _ "Mother priestess, are you all right?"
	[/message]

	[message]
	speaker=Zhul
	message= _ "There's no time to stand on ceremony. I'm fine. I'm afraid only a few of us survived, but we will lend you what skills we have. Show me to those who need healing."
	[/message]

	[message]
	speaker=Kaleh
	message= _ "But the great tree, it has been destroyed!"
	[/message]

	[message]
	speaker=Zhul
	message= _ "All things of this world come to an end, but the power of Eloh endures. A new one shall grow in its place. Come now, let us see to the needs of our people."
	[/message]
[/event]

#Cuttlefish attacks as player leaves island

[event]
name=moveto
first_time_only=no

	[filter]
	x=30-32
	y=30-34
	side=1
	[/filter]

	[if]
		[variable]
		name=encountered_druids
		numerical_equals=1
		[/variable]

		[variable]
		name=encountered_deep_one
		numerical_equals=0
		[/variable]

		[then]

		[unit]
		type=Deep One
		upkeep=free
		x=32
		y=30
		side=2
		[/unit]

		[message]
		type=Deep One
		message= _ "Raaaar!"
		[/message]

		[message]
		speaker=Nym
		message= _ "What in Uria's name is that?"
		[/message]

		[message]
		speaker=Zhul
		message= _ "I felt a great darkness in this lake, but I knew not what it was. The falling rocks must have woken it from its sleep."
		[/message]

		[message]
		speaker=Kaleh
		message= _ "Protect the priestesses, we shall send this monstrosity back to the depths it came from!"
		[/message]

		[set_variable]
		name=encountered_deep_one
		value=1
		[/set_variable]

		[/then]
	[/if]
[/event]

#Grasslands dialogue, when Kaleh and Nym approach the eastern fields

[event]
name=moveto
	[filter]
	x=39-44
	y=26-33
	side=1
	[/filter]

	[set_variable]
	name=rescued_elves
	add=1
	[/set_variable]

	[message]
		description=Kaleh
		message= _ "These fields seem strangely vacant. Where are the horses?"
	[/message]
	[message]
		description=Nym
		message= _ "Maybe they're hiding in the stables. Let's go check."
	[/message]
[/event]

#Stables Encounters
#These happen when the player moves to the two village hexes.
#Depending on the order, the long dialogue happens at the first stable
#they encounter, and then a short dialogue happens at the second.

#First stables encounter
[event]
name=moveto
	[filter]
	x=43
	y=29
	side=1
	[/filter]
	[if]
		[variable]
		name=encountered_scout
		numerical_equals=0
		[/variable]

		[then]

		[set_variable]
		name=encountered_scout
		value=1
		[/set_variable]

		[message]
		description=Nym
		message= _ "I think I see movement in the stables. Is anyone there?"
		[/message]

		{UNIT_T (Desert Scout) (Naru) ( _ "Naru") 1 43 28}

		[message]
		description=Naru
		message= _ "Is it safe to come out? I was so scared."
		[/message]

		[message]
		description=Kaleh
		message= _ "Where are all the other horses?"
		[/message]

		[message]
		description=Naru
		message= _ "A hunting party left just yesterday, so unless the rocks fell all over the land, many of the horses have probably survived. The few that remained here were scared by the falling rocks and fled into the night. It took all my skill to calm Yasi and keep him from running."
		[/message]

		[message]
		description=Kaleh
		message= _ "We'll need your help in checking to see if the outer settlements are okay. Who knows what kinds of damage they suffered in the night? And perhaps some of the people out in the desert have been able to round up some of the loose horses."
		[/message]

		[message]
		description=Nym
		message= _ "Well, let's hope that hunting party comes back soon."
		[/message]

		[/then]

		[else]

		[message]
		description=Nisa
		message= _ "Hey Naru, the rocks have stopped falling. You can come out now!"
		[/message]

		{UNIT_T (Desert Scout) (Naru) ( _ "Naru") 1 43 28}

		[message]
		description=Naru
		message= _ "Oh, thank Eloh, I thought they would never stop."
		[/message]

		[/else]
	[/if]
[/event]

#Second stables encounter
[event]
name=moveto
	[filter]
	x=43
	y=32
	side=1
	[/filter]
	[if]
		[variable]
		name=encountered_scout
		numerical_equals=0
		[/variable]

		[then]

		[set_variable]
		name=encountered_scout
		value=1
		[/set_variable]

		[message]
		description=Nym
		message= _ "I think I see movement in the stables. Is anyone there?"
		[/message]

		{UNIT_T (Desert Scout) (Nisa) ( _ "Nisa") 1 42 31}

		[message]
		description=Nisa
		message= _ "Is it safe to come out? I was so scared."
		[/message]

		[message]
		description=Kaleh
		message= _ "Where are all the other horses?"
		[/message]

		[message]
		description=Nisa
		message= _ "A hunting party left just yesterday, so unless the rocks fell all over the land, many of the horses have probably survived. The few that remained here were scared by the falling rocks and fled into the night. It took all my skill to calm Yasi and keep him from running."
		[/message]

		[message]
		description=Kaleh
		message= _ "We'll need your help in checking to see if the outer settlements are okay. Who knows what kinds of damage they suffered in the night? And perhaps some of the people out in the desert have been able to round up some of the loose horses."
		[/message]

		[message]
		description=Nym
		message= _ "Well, let's hope that hunting party comes back soon."
		[/message]

		[/then]
		[else]
		[message]
		description=Naru
		message= _ "Hey Nisa, the rocks have stopped falling. You can come out now!"
		[/message]

		{UNIT_T (Desert Scout) (Nisa) ( _ "Nisa") 1 42 31}

		[message]
		description=Nisa
		message= _ "Oh, thank Eloh, I thought they would never stop."
		[/message]

		[/else]
	[/if]

[/event]


#Undead leader shows up on dusk of the first long night, turn 11

# if hard difficulty, create a necromancer instead of dark sorcerer

#define DARKSORCERER_INTRO

	#ifdef HARD
	[unit]
		type=Necromancer
		description=Xanthos
		user_description= _ "Xanthos"
		canrecruit=1
		upkeep=full
		x=46
		y=3
		side=3
	[/unit]
	#else
	[unit]
		type=Dark Sorcerer
		description=Xanthos
		user_description= _ "Xanthos"
		canrecruit=1
		upkeep=full
		x=46
		y=3
		side=3
	[/unit]
	#endif

	[modify_side]
		side=3

		#ifdef EASY
		income=12
		gold=150
		#endif
		#ifdef MEDIUM
		income=15
		gold=175
		#endif
		#ifdef HARD
		income=20
		gold=200
		#endif
	[/modify_side]

	#dark sorcerer has now appeared
	[set_variable]
		name=dark_sorcerer_appeared
		value=1
	[/set_variable]

	[remove_shroud]
		side=1
		x=44-48
		y=1-5
	[/remove_shroud]

	[message]
		description=Xanthos
		message= _ "This place reeks of the stench of death, I could smell it from miles away. Oh how I love it, it is the smell of power, the inevitable triumph of death over life. Puny elves, I shall use the corpses of your families to create an army of undead! All shall bow down before Xanthos the Necromancer!"
	[/message]

	[message]
		description=Nym
		message= _ "His timing couldn't be worse. I know that undead cultists often prey on small targets, but they haven't had the guts to attack us for years. Why has Eloh heaped so much misfortune upon us?"
	[/message]

	[message]
		description=Zhul
		message= _ "Have some more faith girl, the goddess does not give us more than we can handle. With Eloh's grace we shall yet triumph over this pretender."
	[/message]

	[message]
		description=Garak
		message= _ "Bah, I've fought these dark cultists before. They can be killed just like anyone else, and our elvish hunters can easily decimate their skeleton armies."
	[/message]

	[message]
		description=Kaleh
		message= _ "I have heard of your kind, foul necromancer. You travel the sands, daring to bring back and enslave those who have passed on. But we will prove to you that death is not all-powerful. You shall not desecrate the bodies of my kith and kin! You shall learn to fear the wrath of Eloh and the Quenoth elves!"
	[/message]

	[place_shroud]
		side=1
		x=44-48
		y=1-5
	[/place_shroud]

	[objectives]
		summary= _ "New Objectives:"
		show=yes
		[objective]
			description= _ "Rescue Surviving Elves"
			condition=win
		[/objective]
		[objective]
			description= _ "Defeat Xanthos"
			condition=win
		[/objective]
		[objective]
			description= _ "Death of Kaleh, Nym, Garak or Zhul"
			condition=lose
		[/objective]
	[/objectives]

#enddef


[event]
name=turn 11

[if]

	[variable]
	name=dark_sorcerer_appeared
	equals=0
	[/variable]

	[then]
		{DARKSORCERER_INTRO}
	[/then]

[/if]
[/event]

# When dark sorcerer dies, checks to make sure elves have been rescued
# before ending the scenario
[event]
name=die
	[filter]
	description=Xanthos
	[/filter]

	[kill]
	description=Xanthos
	animate=no
	fire_event=no
	[/kill]

	[message]
	description=Kaleh
	message= _ "The necromancer is finally vanquished."
	[/message]

	[message]
	description=Zhul
	message= _ "And at last the dead shall have their rest."
	[/message]

	[if]
		[variable]
		name=rescued_elves
		numerical_not_equals=5
		[/variable]
		[then]
			[message]
			description=Kaleh
			message= _ "The necromancer is dead, but I don't think we've explored the entire village. There may still be elves that need rescuing. We should go back and check. "
			[/message]

		[/then]
		[else]
			[endlevel]
			result=victory
			bonus=yes
			[/endlevel]
		[/else]
	[/if]
[/event]

#This event is used in case the player kills the dark sorcerer
#before rescuing all the elves.
[event]
name=enemies defeated
	first_time_only=no
	[if]
		[variable]
		name=rescued_elves
		numerical_equals=5
		[/variable]

		[variable]
		name=dark_sorcerer_appeared
		equals=1
		[/variable]

		[then]
			[message]
			description=Kaleh
			message= _ "We've explored the village and I think we've rescued the last of the survivors."
			[/message]

			[endlevel]
			result=victory
			bonus=yes
			[/endlevel]
		[/then]
	[/if]
[/event]

#This event prevents player from running to dark sorcerer's base before he shows up on turn 11. If the player approaches his base before turn 11 he appears and attacks. Either way the unit moving into the area also comments on the plight of those elves who lived out in the open sands.

[event]
name=moveto
	[filter]
	x=37-60
	y=1-12
	side=1
	[/filter]

	[if]

		[variable]
		name=dark_sorcerer_appeared
		equals=0
		[/variable]

		[then]
			{DARKSORCERER_INTRO}
		[/then]

	[/if]

	[message]
	speaker=unit
	message= _ "Some of our people felt crowded in the village, and wanted to live out on the open sands. They thought they could flee to the safety of our walls if danger came. I shudder to think what has happened to them."
	[/message]

[/event]


#Elvish hunting party shows up on turn 18 (changed to 16)

[event]
name=turn 16
	[remove_shroud]
	side=1
	x=24-32
	y=1-6
	[/remove_shroud]

	{UNIT_T (Desert Hunter) (Pythos) ( _ "Pythos") 1 29 2}
	{UNIT_T (Desert Fighter) (Shea) ( _ "Shea") 1 28 2}
	{UNIT_T (Desert Fighter) (Narn) ( _ "Narn") 1 29 1}
	{UNIT_T (Desert Scout) (Jokli) ( _ "Jokli") 1 27 2}
	{UNIT_T (Desert Archer) (Lyia) ( _ "Lyia") 1 28 1}
	#Hack to make Lyia female
	[+unit]
		gender=female
	[/unit]

	[message]
	description=Pythos
	message= _ "Hail, is anyone still alive?"
	[/message]

	[message]
	description=Kaleh
	message= _ "Yes, and we could certainly use your help. A necromancer has been attacking us, he intends to use our fallen comrades as fodder for his evil magics. Where have you been?"
	[/message]

	[message]
	description=Pythos
	message= _ "We were out far in the sands, searching for prey and roaming orcs. As soon as we saw the rock storm we raced back as fast as we could. I only wish we could have come sooner."
	[/message]

	[message]
	description=Nym
	message= _ "No use crying over spilt water. But we're sure glad you're here now."
	[/message]

[/event]

#Desert Village events
#Some of the outer villages have elves hiding in them. If the player
#reaches them before the undead do, they can rescue the elves.

#Village coordinates:
#57,35
#51,43
#26,7
#17,10

#Village 1: 57,35
[event]
name=capture
	[filter]
		x=57
		y=35
		side=1
	[/filter]

	[if]

	[variable]
	name=village1
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village1
		value=1
		[/set_variable]

		{RANDOM 1..10}

		[if]

		[variable]
		name=random
		less_than_equal_to=6
		[/variable]

		[then]

			[message]
			speaker=unit
			message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
			[/message]

			{UNIT_T (Desert Scout) (Lrea) ( _ "Lrea") 1 $x1 $y1}

		[/then]

		[else]

		[message]
		speaker=unit
		message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
		[/message]

		[/else]

		[/if]

	[/then]

	[else]
		[message]
		speaker=unit
		message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
		[/message]

	[/else]

	[/if]
[/event]

[event]
name=capture
	[filter]
		x=57
		y=35
		side=3
	[/filter]

	[if]

	[variable]
	name=village1
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village1
		value=3
		[/set_variable]
	[/then]

	[/if]
[/event]

#Village 2: 51,43
[event]
name=capture
	[filter]
		x=51
		y=43
		side=1
	[/filter]

	[if]

	[variable]
	name=village2
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village2
		value=1
		[/set_variable]

		{RANDOM 1..10}

		[if]

		[variable]
		name=random
		less_than_equal_to=6
		[/variable]

		[then]
			[message]
			speaker=unit
			message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
			[/message]

			{UNIT_T (Desert Scout) (Danu) ( _ "Danu") 1 $x1 $y1}
		[/then]

		[else]

			[message]
			speaker=unit
			message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
			[/message]

		[/else]

		[/if]

	[/then]

	[else]
		[message]
		speaker=unit
		message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
		[/message]
	[/else]

	[/if]
[/event]

[event]
name=capture
	[filter]
		x=51
		y=43
		side=3
	[/filter]

	[if]
	[variable]
	name=village2
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village2
		value=3
		[/set_variable]
	[/then]

	[/if]
[/event]

#Village 3: 26,7
[event]
name=capture
	[filter]
		x=26
		y=7
		side=1
	[/filter]

	[if]
	[variable]
	name=village3
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village3
		value=1
		[/set_variable]

		{RANDOM 1..10}

		[if]

		[variable]
		name=random
		less_than_equal_to=6
		[/variable]

		[then]

			[message]
			speaker=unit
			message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
			[/message]

			{UNIT_T (Desert Hunter) (Hamm) ( _ "Hamm") 1 $x1 $y1}

		[/then]

		[else]
			[message]
			speaker=unit
			message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
			[/message]
		[/else]

		[/if]

	[/then]

	[else]
		[message]
		speaker=unit
		message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
		[/message]
	[/else]

	[/if]
[/event]

[event]
name=capture
	[filter]
		x=26
		y=7
		side=3
	[/filter]

	[if]
	[variable]
	name=village3
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village3
		value=3
		[/set_variable]
	[/then]
	[/if]
[/event]


#Village 4: 17,10
[event]
name=capture
	[filter]
		x=17
		y=10
		side=1
	[/filter]

	[if]

	[variable]
	name=village4
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village4
		value=1
		[/set_variable]

		{RANDOM 1..10}

		[if]

		[variable]
		name=random
		less_than_equal_to=6
		[/variable]

		[then]
			[message]
			speaker=unit
			message= _ "Oh good, some elves have survived in this outer settlement. They've agreed to help us search for other survivors."
			[/message]

			{UNIT_T (Desert Archer) (Frea) ( _ "Frea") 1 $x1 $y1}
			#Hack to make frea female
			[+unit]
				gender=female
			[/unit]
		[/then]

		[else]
			[message]
			speaker=unit
			message= _ "The encampment is empty. I wonder what happened to the inhabitants?"
			[/message]
		[/else]

		[/if]

	[/then]

	[else]
		[message]
		speaker=unit
		message= _ "This encampment has been abandoned. There are signs of a struggle and a few bloodstains but nothing else. I fear for those elves who lived out here."
		[/message]
	[/else]
	[/if]
[/event]

[event]
name=capture
	[filter]
		x=17
		y=10
		side=3
	[/filter]

	[if]
	[variable]
	name=village4
	equals=0
	[/variable]

	[then]
		[set_variable]
		name=village4
		value=3
		[/set_variable]

	[/then]

	[/if]
[/event]


[event]
name=victory

	[message]
	description=Nym
	message= _ "It seems that we finally have some peace. But what do we do now?"
	[/message]

	[message]
	description=Garak
	message= _ "Where is Tanuil and his family?"
	[/message]

	[message]
	description=Kaleh
	message= _ "The keep has been crushed by the rocks. We could find no survivors."
	[/message]

	[message]
	description=Zhul
	message= _ "Too many have died this night."
	[/message]

	[message]
	description=Nym
	message= _ "Our village is in ruins. The walls that were built by our ancestors over generations have been demolished in a space of hours. Most of our dwellings are destroyed. And the great tree itself is no more. One thing is obvious, we cannot stay here."
	[/message]

	[message]
	description=Garak
	message= _ "You are a fool to despair. This has always been our home. The water here is good, we know this land. We can rebuild; Eloh willing, we can thrive again."
	[/message]

	[message]
	description=Nym
	message= _ "Think for a moment. Who else has seen the rock storm? What other foes are coming to pick over the remains of our people? There is no mercy in the desert, and we have many enemies who would seek to gain in our time of weakness."
	[/message]

	[message]
	description=Garak
	message= _ "Impudent girl, you should not speak so to your elders, or to your betters."
	[/message]

	[message]
	description=Nym
	message= _ "I have a right to speak my mind!"
	[/message]

	[message]
	description=Zhul
	message= _ "Peace, please calm yourselves. In chaos there is nothing but death and destruction. Even in this time of trial we must show our fortitude, and follow our laws. Without laws we are like beasts in the desert, fighting over scraps of meat. Among the survivors Kaleh is by heritage the closest relative to Tanuil and thus our leader. What say you Kaleh?"
	[/message]

	[message]
	description=Kaleh
	message= _ "Last night, before the rock storm, I heard a voice in my sleep. It sounded like sweet music, and somehow I knew it was Eloh. I still remember her exact words: 'You must be strong, young elf, for you enter a time of peril. The home you know will be destroyed, and you must lead your people to a new land. To the north you will find salvation and peace. Cross the desert and head to the mountains. Fear not, for I will guide you and protect you.' I'm not sure why I'm the one she chose to appeal to, but if this is her will, I will see it done. Our home is gone and the desert is a harsh place. If Eloh has prepared a new home for us, then I will lead us there."
	[/message]

	[message]
	description=Garak
	message= _ "I fear what dangers lurk in the harsh sands and beyond to the north, but because you are our leader, I will follow your counsel."
	[/message]

	[message]
	description=Zhul
	message= _ "Then let us collect what supplies we can from the wreckage and head north with great haste. Our home is protection no longer, we must find a new haven for our people."
	[/message]

	[message]
	description=Nym
	message= _ "What about the bodies of the dead? We can't leave them to be torn by crows or desecrated by other dark mages."
	[/message]

	[message]
	description=Kaleh
	message= _ "I agree, we should not forget our dead. We should build a huge pyre and burn them with proper ceremony, so that the smoke may carry them on to the next realm."
	[/message]

	[message]
	description=Zhul
	message= _ "Kaleh, I don't want to tarry longer than necessary, but I agree that we must see to the dead before we leave. Garak, you and your men start collecting our dead. Nym, help me find oil and wood so that we may build a pyre."
	[/message]

	[message]
	speaker=narrator
	message= _ "And so it was done. The dead were laid reverently on top of what little wood we could find. But the fire was big enough to burn the bodies to ashes and speed their souls to the hereafter. I remember at the time that the death of so many of our people was not the best omen for the start of such a large journey. They were the first of our people to die in this great endeavor, but they were to be far from the last."
	[/message]


	#Clear variables

	#Prestart variables
	{CLEAR_VARIABLE never_seen_mudcrawler}
	{CLEAR_VARIABLE mudcrawlers_killed}
	{CLEAR_VARIABLE encountered_druids}
	{CLEAR_VARIABLE encountered_deep_one}
	{CLEAR_VARIABLE encountered_scout}
	{CLEAR_VARIABLE rescued_elves}
	{CLEAR_VARIABLE dark_sorcerer_appeared}
	{CLEAR_VARIABLE village1}
	{CLEAR_VARIABLE village2}
	{CLEAR_VARIABLE village3}
	{CLEAR_VARIABLE village4}

[/event]

[event]
name=time over
	[message]
		description=Kaleh
		message= _ "What's that to the north? It looks like even more undead! The rock storm must have attracted other necromancers. There's no way we can defeat them all. We've run out of time. There's no escape. Eloh save us!"
	[/message]
[/event]

{@campaigns/Under_the_Burning_Suns/utils/deaths.cfg}

[/scenario]

