
#Scenario 1: The Morning After

[scenario]
#textdomain wesnoth-utbs

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

map_data="{campaigns/Under_the_Burning_Suns/maps/1MorningAfter5.map}"

next_scenario=2_HarshSands

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

{TURNS 34 32 30}

victory_when_enemies_defeated=no

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

[music]
name=revelation.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]
	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
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
	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]
#!***This is used to force ai to recruit something else than bats and ghosts***
		recruitment_ignore_bad_movement=yes

		#ifdef HARD
		recruitment_pattern=scout,fighter,fighter,fighter,archer
		#else
		recruitment_pattern=scout,fighter,archer,fighter
		#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]

	#There are 3 mudcrawler encounter spots, in the NW and SW corner and in the barracks.
	#Depending on which way you circle around the village, you will
	#encounter the NW or barracks first. 

	#At start seen a mudcrawler is false
	{VARIABLE seen_mudcrawler 0}

#!***Scraped $mudcrawlers_killed -> can be done by have_unit check***

	#Can't end scenario until all elves have been rescued and counter=5
	{VARIABLE rescued_elves 0}

[/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]

#!*** Following two events use the same code with only speaking unit change, lets extract it to a macro***
#!*** Or two to be exact, this way it will be useful in barracks encounter***

#define MUDCRAWLER_TALK SPEAKER
		#Hasn't completed #1 encounter, do it now
#!***If (hasn't seen mudcrawler) then (perform what-the-hell-is-that routine)***

		{VARIABLE seen_mudcrawler 1}

		[message]
		description={SPEAKER}
		message= _ "Kaleh, Nym, help us!"
		[/message]
		[message]
		description=Nym
		message= _ "What in Uria's name is that?"
		[/message]
		[message]
		description={SPEAKER}
		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]
#enddef

#define MUDCRAWLER_WARCRY

		#Has completed encounter #1 in SW corner, do #2 encounter
#!***else (Seen mudcrawler, do let's-kick-their-ass performance)*** 
		[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]
#enddef

#define MUDCRAWLER_ROUTINE SPEAKER
	[if]
		[variable]
		name=seen_mudcrawler
		numerical_equals=0
		[/variable]

		[then]
			{MUDCRAWLER_TALK SPEAKER}
		[/then]
		[else]
			{MUDCRAWLER_WARCRY}
		[/else]
	[/if]
#enddef

# 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]

	{ADD rescued_elves 1}

	{CREATE_UNIT 1 "Desert Fighter" 24 25 "Vecnu" (user_description=_"Vecnu" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Archer" 24 27 "Eranor" (user_description=_"Eranor"
 random_traits="yes")}
	{CREATE_UNIT 1 "Desert Archer" 21 25 "Seela" (user_description=_"Seela"
 random_traits="yes"
 gender="female")}

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

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

	#ifdef EASY
	{CREATE_UNIT 2 "Small Mudcrawler" 23 27 "" ()}
	{CREATE_UNIT 2 "Small Mudcrawler" 25 28 "" ()}
	#else
	{CREATE_UNIT 2 "Giant Mudcrawler" 23 27 "" ()}
	{CREATE_UNIT 2 "Small Mudcrawler" 24 28 "" ()}
	#endif

	{MUDCRAWLER_ROUTINE Vecnu}

[/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]

	{CREATE_UNIT 1 "Desert Hunter" 24 34 "Eloshi" (user_description=_"Eloshi" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Archer" 19 33 "Illuvia" (user_description=_"Illuvia" 
random_traits="yes" 
gender="female")}
	{CREATE_UNIT 1 "Desert Hunter" 21 35 "Raynor" (user_description=_"Raynor" 
random_traits="yes")}

	{CREATE_UNIT 2 "Giant Mudcrawler" 25 34 "" ()}
	{CREATE_UNIT 2 "Small Mudcrawler" 21 36 "" ()}

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

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

	{MUDCRAWLER_ROUTINE Eloshi}
[/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]

	{ADD rescued_elves 1}

	{CREATE_UNIT 2 "Giant Mudcrawler" 34 33 "Rocky Horror" (user_description=_"Rocky Horror")}
	{CREATE_UNIT 2 "Giant Mudcrawler" 34 34 "Rocky Horror" (user_description=_"Rocky Horror")}
	{CREATE_UNIT 2 "Small Mudcrawler" 34 35 "Rocky Horror" (user_description=_"Rocky Horror")}

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

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

	[unit]
	type=Desert Captain
	description=Garak
	user_description= _ "Garak"
	profile=portraits/garak.png
	upkeep=full
	x=35
	y=34
	side=1
	hitpoints=44	# A bit less than for a Desert Captain
	[modifications]
		{TRAIT_STRONG}
		{TRAIT_LOYAL}
	[object]
	id=Garak_mod
	[effect]
#!***The unit type restriction does not work, given the bonus for life***
		apply_to=attack
		range=ranged
		increase_damage=1
	[/effect]
	[/object]
	[/modifications]

	{IS_HERO}
	[/unit]

	{CREATE_UNIT 1 "Desert Fighter" 36 33 "Jorazan" (user_description=_"Jorazan" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Fighter" 35 35 "Zyara" (user_description=_"Zyara" 
random_traits="yes" 
gender="female")}

	[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]
	[if]
		[variable]
		name=seen_mudcrawler
		numerical_equals=0
		[/variable]
		[then]
			{MUDCRAWLER_TALK Garak}
		[/then]
		[else]
			[message]
			description=Kaleh
			message= _ "But they are fighting many mud creatures. Quick, we must help them!"
			[/message]
		[/else]
	[/if]

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

	[filter]
	description=Rocky Horror
	[/filter]

	[if]
		[not]
		[have_unit]
		description=Rocky Horror
		[/have_unit]
		[/not]
	[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]
[/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]

	{ADD rescued_elves 1}

	[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]

	{CREATE_UNIT 1 "Desert Shaman" 30 27 "Ryoko" (user_description=_"Ryoko" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Shaman" 32 27 "Yuni" (user_description=_"Yuni" 
random_traits="yes")}

	[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]
	name=moveto

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

	[unit]
	type=Cuttle Fish
	decription="Deep One"
	user_description=_"Deep One"
	unit_description= _ "The Deep Ones are gigantic aquatic monsters that lurk in the dark places of the world. Rarely do they come to the surface, and when they do the best way to survive an encounter with these monsters is to remain ashore. They can grab their opponents with strong tentacles, or spit a poisonous black ink from a distance."
#!***Scraped Deep One custom unit -> a wimpy clone of Cuttle Fish***
	[modifications]
	[trait]
		id=Deep_one
		[effect]
#!***Lowered number of attacks***
				apply_to=attack
				range=melee
				increase_attacks=-4
		[/effect]
		[effect]
#!***Lowered hp***
				apply_to=hitpoints
				increase_total=-27
		[/effect]
		[effect]
#!***Lowered? shallow water def***
				apply_to=defense
				replace=yes
				[defense]
					shallow_water=50
				[/defense]
		[/effect]
	[/trait]
	[/modifications]
	x=32
	y=30
	side=2
	[/unit]

	[message]
	description=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]

	[/event]
[/event]

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

#!***Macro scrapped -> due to translation issues, thanks to Vladimir for pointing that one out***
#!***Macro scrapped -> due to translation issues, thanks to Vladimir for pointing that one out***
[event]
name=moveto
	[filter]
	x=39-44
	y=26-33
	side=1
	[/filter]

	{ADD rescued_elves 1}

	[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]

#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.
[/event]

#First stables encounter
[event]
name=capture
	[filter]
	x=43
	y=29
	side=1
	[/filter]
	[if]
		[have_unit]
		description=Nisa
		[/have_unit]

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

			{CREATE_UNIT 1 "Desert Scout" 43 28 "Naru" (user_description=_"Naru" 
random_traits="yes")}

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

		[else]

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

		{CREATE_UNIT 1 "Desert Scout" 43 28 "Naru" (user_description=_"Naru" 
random_traits="yes")}

		[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]

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

#Second stables encounter
[event]
name=capture
	[filter]
	x=43
	y=32
	side=1
	[/filter]
	[if]
		[have_unit]
		description=Naru
		[/have_unit]

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

			{CREATE_UNIT 1 "Desert Scout" 43 31 "Nisa" (user_description=_"Nisa" 
random_traits="yes")}

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

		[else]

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

		{CREATE_UNIT 1 "Desert Scout" 43 31 "Nisa" (user_description=_"Nisa" 
random_traits="yes")}

		[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]

		[/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

#!***Another space-waste, #ifdef can be used inside [unit]. Upkeep is full by default.***
#define DARKSORCERER_INTRO

	[unit]
	#ifdef HARD
		type=Necromancer
	#else
		type=Dark Sorcerer
	#endif
		description=Xanthos
		user_description= _ "Xanthos"
		canrecruit=1
		x=46
		y=3
		side=3
	[/unit]
	[modify_side]
		side=3
		{GOLD 150 175 200}
		{INCOME 12 15 20}
	[/modify_side]

	[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 Xanthos does not exist and undead gold is unmodified it means he never showed up****
[store_side]
	side=3
	variable=temp
[/store_side]

[if]
	[not]
	[have_unit]
		description=Xanthos
	[/have_unit]
	[/not]
	[variable]
		name=temp.gold
		numerical_equals=100
	[/variable]
	[then]
		{DARKSORCERER_INTRO}
	[/then]

[/if]

{CLEAR_VARIABLE temp}

[/event]

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

	[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]
				[event]
					name=die
					first_time_only=no
					[filter]
						[not]
							side=1
						[/not]
					[/filter]
					[if]
						[variable]
							name=rescued_elves
							numerical_equals=5
						[/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]
		[/then]
		[else]
			[endlevel]
			result=victory
			bonus=yes
			[/endlevel]
		[/else]
	[/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.
#!***To be honest I don't belive this scenario is possible, but levaing it anyway.***
[event]
name=moveto
	[filter]
	x=37-60
	y=1-12
	side=1
	[/filter]

#!***No other checks this time. If necro was killed this event was fired before that happened.***
	[if]
		[not]
		[have_unit]
			side=3
		[/have_unit]
		[/not]

		[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]

	{CREATE_UNIT 1 "Desert Hunter" 29 2 "Pythos" (user_description=_"Pythos" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Fighter" 28 2 "Shea" (user_description=_"Shea" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Fighter" 29 1 "Narn" (user_description=_"Narn" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Scout" 27 2 "Jokli" (user_description=_"Jokli" 
random_traits="yes")}
	{CREATE_UNIT 1 "Desert Archer" 28 1 "Lyia" (user_description=_"Lyia" 
random_traits="yes" 
gender="female")}

	[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]

#!***This is basicaly one event doing the same thing at four different places.***
#!***Turning it into a macro invoked four times saves space again*** 
#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

#define VILLAGE_EVENT X Y TYPE_FOUND NAME_FOUND
[event]
name=capture
	[filter]
		x={X}
		y={Y}
	[/filter]

	[if]

	[variable]
	name=unit.side
	numerical_equals=1
	[/variable]

	[then]
		{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]

			{CREATE_UNIT 1 {TYPE_FOUND} $x1 $y1 {NAME_FOUND} (user_description=_{NAME_FOUND} 
random_traits="yes")}
		[/then]

		[else]

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

		[/else]

		[/if]

	[/then]

	[else]
		[event]
			name=capture
			[filter]
				x={X}
				y={Y}
				side=1
			[/filter]
		[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]
		[/event]
	[/else]

	[/if]
[/event]

#enddef

{VILLAGE_EVENT 57 35 "Desert Scout" "Lrea"}
{VILLAGE_EVENT 51 43 "Desert Scout" "Danu"}
{VILLAGE_EVENT 26 7 "Desert Hunter" "Hamm"}
{VILLAGE_EVENT 17 10 "Desert Archer" "Frea"}

[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 seen_mudcrawler}
	{CLEAR_VARIABLE rescued_elves}
[/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]

#define ALL_LOSE
#enddef

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

#!***Unlinked -> Elyssa does not feature in this scenario***

[/scenario]

