# Scenario 2: Across the Harsh Sands

[scenario]
#textdomain wesnoth-utbs

id="2_HarshSands"
name= _ "Across the Harsh Sands"
label= _ "Across the Harsh Sands"

{DESERTMAP 2HarshSands12}

next_scenario=3_LongNight

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

#max turns in scenario varies depending on difficulty
#ifdef EASY
turns="62"
#endif
#ifdef MEDIUM
turns="60"
#endif
#ifdef HARD
turns="58"
#endif
victory_when_enemies_defeated=no

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

[music]
name=gameplay02.ogg
[/music]

[label]
    x,y=21,9
    text= _ "Pinnacle Rock"
[/label]

[story]
    [part]
    story= _ "Chapter 2: When I was fifteen I went on my first raid, against an orcish incursion to the west. A large band of orcs under some new banner had come out of the northern foothills and were rampaging across the sands, killing anything they could get their filthy hands on."
    [/part]

    [part]
    story= _ "Sneaking amidst the dunes we crept up to their camp and ambushed them at dawn. To a young boy the fighting was overwhelming: crashing blades, blood, battle cries, friend and foe struggling back and forth. The orcs rallied around their leader, their greater numbers countering our superior skill at combat. It was my father who finally fought his way to the foul orc leader and slew him on the ochre sand, stained with blood. The surviving orcs, showing their true colors, fled from the battlefield. It seemed a glorious victory, and I hardly noticed our elven brethren lying dead in the sand."
    [/part]

    [part]
    story= _ "I was giddy on the journey back home, my heart pumping with elation and pride. I had fought my first battle; now I was a man like my father. Then one night during the long dark a harsh wind came up, moaning and howling around our tents. By dawn it had only gotten worse; I wondered if some dark god was trying to avenge the massacre of the orcs. I'd seen sandstorms before, but I had never experienced one like this. I hid in my tent praying to Eloh as if my life depended on it. The air grew thick with sand, and everything grew dark and hazy..."
    [/part]

    [part]
    story= _ "The next thing I remember, someone was bending over me shaking me awake. I was half buried in sand, and I felt weak but alive. Our equipment was scattered across the dunes or buried in the sand. Looking around I only saw a few of my companions, who were digging in the sand, fervently hoping to find other survivors. I dug furiously at the sand with my bare hands and yelled until I was hoarse, but try as I might, I could not find my father. They told me he had been swallowed by the sand, but I would not be consoled. In one instant my world crumbled; I never looked at the sands quite the same way again. I learned that day that the desert can be fickle and fierce, and death is always lurking just over the horizon."
    [/part]

    [part]
    story= _ "Now I journeyed out again across the sands, but this time it was not just myself, but my entire people that I had to protect. They were depending on my judgment, and I was only too aware of the weight on my narrow shoulders. Thinking of the last time we had gone out in force, I made a silent prayer to my father to watch over us. There was nowhere to go but north."
    [/part]
[/story]

#elves
[side]
    side=1
    description=Kaleh
    type=Desert Fighter
    canrecruit=1
    {INCOME 13 10 8}
    controller=human
    recruit=Desert Fighter, Desert Archer, Desert Hunter, Desert Shaman, Desert Scout
    shroud=yes
    fog=yes

[/side]

#Outlaw side
[side]
    side=2
    description=Thorn
    unit_description= _ "Thorn"
    type=Outlaw
    gender=female
    upkeep=free
    ai_special=guardian
    [modifications]
        {TRAIT_INTELLIGENT}
        {TRAIT_STRONG}
    [/modifications]
    canrecruit=1
    income=0
    gold=0
    controller=ai
    shroud=no
    fog=no
    team_name=evil

    #ifdef EASY
    recruit=Thug, Bandit, Poacher, Trapper, Footpad
    #endif

    #ifdef MEDIUM
    recruit=Bandit, Poacher, Footpad, Outlaw
    #endif

    #ifdef HARD
    recruit=Bandit, Trapper, Footpad, Outlaw
    #endif

    [ai]
    #keep leader from charging out in battle

    #ifdef HARD
    passive_leader=yes
    #endif

    aggression=0.8
    caution=0.2

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

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

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

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

    [target]
    side=1
    value=3
    [/target]

    [/ai]

[/side]

#Random monster side: ogres, scorpions
[side]
    no_leader=yes
    side=3
    canrecruit=0
    controller=ai
    shroud=no
    fog=no
    team_name=evil

    #monsters are aggressive
    [ai]
        aggression=1.0
        caution=0.00

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

        [protect_location]
        x=17
        y=37
        radius=100
        value=1000
        [/protect_location]
    [/ai]

[/side]

#undead side, used to control wandering ghosts and walking dead
[side]
    no_leader=yes
    side=4
    canrecruit=0
    controller=ai
    shroud=no
    fog=no
    team_name=undead

    [ai]
        #undead are aggressive
        aggression=1.0
        caution=0.0

        grouping=no

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

        [target]
        side=1
        value=3
        [/target]

        [target]
        side=2
        value=1
        [/target]

        [target]
        side=3
        value=1
        [/target]

        # keeps undead from attacking outlaw leader
        [avoid]
        x=15-30
        y=1-12
        [/avoid]
    [/ai]
[/side]

#side for vengeful wraith lord and his minions
[side]
    no_leader=yes
    side=5
    canrecruit=1
    recruit=Skeleton, Skeleton Archer, Ghost, Walking Dead, Ghoul
    gold=0
    income=0
    controller=ai
    shroud=no
    fog=no
    team_name=undead

    [ai]
        recruitment_pattern=fighter,fighter,archer

        #undead are aggressive
        aggression=0.9
        caution=0.1

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

        # keeps undead from attacking outlaw leader
        [avoid]
        x=15-30
        y=1-13
        [/avoid]

        #encourage AI kill any units in keep
        [protect_location]
        x=32-36
        y=25-28
        [/protect_location]
    [/ai]
[/side]

# prestart events:
# Set starting scenario objectives
# Recall Nym, Zhul and Garak
# Prestart variable initiation
# capture starting villages for elf player

[event]
name=prestart

# Set starting scenario objectives

[objectives]
    summary= _ "Starting Objectives:"
    [objective]
        description= _ "Kaleh Must Reach the Northern Edge of the Desert"
        condition=win
    [/objective]
    [objective]
        description= _ "Death of Kaleh, Nym, Garak or Zhul"
        condition=lose
    [/objective]
[/objectives]

# Recall Nym, Zhul and Garak

[recall]
    description=Nym
[/recall]
[recall]
    description=Zhul
[/recall]
[recall]
    description=Garak
[/recall]

# Prestart variable initiation

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

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

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

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

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

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

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

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

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

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

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

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

#used to make sure that deaths.cfg event fires correctly

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


# clock variable, starts at 1
[set_variable]
    name=time_of_day
    value=1
[/set_variable]

# flag to store if it is daytime
[set_variable]
    name=daytime
    value=1
[/set_variable]

# quick variable used to print a message telling how much damage you take
#ifdef EASY
[set_variable]
    name=desert_damage
    value=-4
[/set_variable]
#endif

#ifdef MEDIUM
[set_variable]
    name=desert_damage
    value=-5
[/set_variable]
#endif

#ifdef HARD
[set_variable]
    name=desert_damage
    value=-6
[/set_variable]
#endif

# add more undead at higher difficulty levels

# Easy:  8 ghosts
# Medium: 10 ghosts
# Hard: 12 ghosts

#ifdef EASY

    [set_variable]
    name=number_ghost
    value=8
    [/set_variable]

#endif

#ifdef MEDIUM

    [set_variable]
    name=number_ghost
    value=10
    [/set_variable]

#endif

#ifdef HARD

    [set_variable]
    name=number_ghost
    value=12
    [/set_variable]

#endif

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

#ifdef EASY
[set_variable]
    name=nightly_limit
    value=3
[/set_variable]
#endif

#ifdef MEDIUM
[set_variable]
    name=nightly_limit
    value=4
[/set_variable]
#endif

#ifdef HARD
[set_variable]
    name=nightly_limit
    value=5
[/set_variable]
#endif

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

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

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


[capture_village]
        side=1
        x,y=6,70
[/capture_village]
[capture_village]
        side=1
        x,y=7,73
[/capture_village]

[/event]


[event]
name=start

[remove_shroud]
    side=1
    x=1-8
    y=65-74
[/remove_shroud]

[message]
description=Garak
message= _ "I have crossed these sands long ago, when I was a youth, and we went on a great raid against a foul necromancer who was hiding out in one of the ruins, creating an army of undead. It was a nasty battle, especially after nightfall, but all his magics couldn't save him when we cut off his head. Ah, those were the days..."
[/message]

[message]
description=Kaleh
message= _ "Do you remember anything about these sands?"
[/message]

[message]
description=Garak
message= _ "Do you see that brown spot sticking up on the northern horizon? That's Pinnacle Rock. It's the highest land for miles around, and has a spring at its base, or did the last time I camped there. If we make it to Pinnacle Rock we will be just a few miles from the edge of the mountains."
[/message]

[message]
description=Garak
message= _ "But between here and there is a particularly barren stretch of the sands, with only a few oases and watering holes. Luckily I think there used to be an old caravan route leading north, which went from oasis to oasis. The oases aren't easy to find but occasionally the sands blow away, revealing old stone roads that lead from oasis to oasis. Once the path must have formed a great thoroughfare for commerce. "
[/message]

[message]
description=Zhul
message= _ "I believe that there was once a great empire in these lands, long ago, before the sands came."
[/message]

[message]
description=Garak
message= _ "I've seen the ancient remains of stone castles and markers in the sands. The paths of the ancients may serve us yet again. If we follow the paths from oasis to oasis, we may be able to survive the thirst and heat of the desert. But there are worse dangers in these sands than thirst."
[/message]

[message]
description=Nym
message= _ "Unfortunately, because of our hasty flight from our village, we are short on waterskins and rations. We'll have enough if we move quickly and eat as little as possible, but we won't last long in the wastes if we can't find more sources of water. As it is, between the heat of the day and the cold of the night, this journey will be hard on our people."
[/message]

[set_variable]
name=temp_damage
value=$desert_damage
[/set_variable]

[set_variable]
name=temp_damage
multiply=-1
[/set_variable]

[message]
speaker=narrator
message= _ "During the daytime (Dawn, Morning, Mid-day, Afternoon, and Dusk) at the end of each your turns, every unit in a sand, road, rubble or sand dune hex will take $temp_damage damage. While dehydration can severely damage your units, it will never lower them below 1 hit point. Also, at the start of your turn, each unit in an oasis (shallow water) hex will gain 8 hit points."
[/message]

{CLEAR_VARIABLE temp_damage}

[message]
description=Zhul
message= _ "The other shamans and I can provide minor healing to ease the exhaustion and dehydration of the desert journey. But oases like the one next to us are the key to our survival; their fresh water will heal our people much faster and better than any of our powers."
[/message]

[message]
description=Nym
message= _ "Also Kaleh, be careful you don't recruit too many guards to go with us. I doubt we're going to find any other villages out in the sands, so the income that we have right now is all we're going to get. Remember that as our people get more experienced they often require more support, so we don't want to run out of supplies halfway across the desert."
[/message]

[message]
description=Kaleh
message= _ "Well, the sooner we reach Pinnacle Rock, the better. Onwards!"
[/message]

[/event]

# I NEED THE CLOCK FUNCTION TO GO FIRST BECAUSE LATER EVENTS CHECK TO SEE
# WHAT TIME IT IS

#clock function
#Step 0: if blackhand sign hasn't appeared, make sure leader has no gold
#Step 1: if we are going into night or day, flip daytime boolean
#Step 2: advance clock

#first day
#dawn       1
#morning    2
#mid-day    3
#afternoon  4
#dusk       5
#shortdark  6

#second day
#dawn       -1
#morning    -2
#mid-day    -3
#afternoon  -4
#dusk       -5
#longdark 1 -6
#longdark 2 -7
#longdark 3 -8
#longdark 4 -9

[event]
name=new turn
first_time_only=no

#I need the blackhand leader to appear at the beginning of the scenario,
#so that side2 is called each turn, but I want to make sure he can't
#gain money and summon units until the player enters his territory

[if]
    [variable]
    name=blackhandsign_appeared
    numerical_equals=0
    [/variable]

    [then]
        [modify_side]
        side=2
        gold=0
        [/modify_side]
    [/then]
[/if]

[if]
    [variable]
        name=time_of_day
        numerical_equals=6
    [/variable]

    [then]

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

    [/then]

[/if]

[if]
    [variable]
        name=time_of_day
        numerical_equals=-9
    [/variable]

    [then]

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

    [/then]

[/if]

[if]
    [variable]
        name=time_of_day
        numerical_equals=5
    [/variable]

    [then]

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

    [/then]

[/if]

[if]
    [variable]
        name=time_of_day
        numerical_equals=-5
    [/variable]

    [then]

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

    [/then]

[/if]


[if]
    [variable]
        name=time_of_day
        numerical_equals=-9
    [/variable]

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

[/then]

[else]

    [if]

        [variable]
            name=time_of_day
            numerical_equals=6
        [/variable]

    [then]
        [set_variable]
            name=time_of_day
            value=-1
        [/set_variable]

    [/then]

    [else]
        [if]
            [variable]
                name=time_of_day
                greater_than=0
            [/variable]

        [then]
            [set_variable]
                name=time_of_day
                add=1
            [/set_variable]

        [/then]

        [else]
            [set_variable]
                name=time_of_day
                add=-1
            [/set_variable]

        [/else]
        [/if]

    [/else]
    [/if]

[/else]
[/if]

[/event]



# Special Encounter events

# Encounter 1: Scorpions attack

# randomly generate area where scorpions will attack, and then when unit
# moves into area, set flag

# the top of the boundary (57-58) is narrow because it seems unlikely that
# anyone would do north and then curved around southwest to hit
# the scorpions

[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]
# was:
# x variation 20-25
# y variation 62-67 to 48-53

#is now:
# was:
# x variation 20-25
# y variation 64-67 to 57-58

{RANDOM 20..25}

[set_variable]
name=loc_x
value=$random
[/set_variable]

{RANDOM 57..58}

[set_variable]
name=loc_y_top
value=$random
[/set_variable]

{RANDOM 64..67}

[set_variable]
name=loc_y_bottom
value=$random
[/set_variable]

[if]
    [variable]
    name=scorpions_appeared
    numerical_equals=0
    [/variable]

    [variable]
    name=x1
    greater_than_equal_to=$loc_x
    [/variable]

    [variable]
    name=y1
    greater_than_equal_to=$loc_y_top
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=$loc_y_bottom
    [/variable]

    [then]

    #[message]
    #speaker=narrator
    #message= _ "x coor: $loc_x y coor: $loc_y"
    #[/message]

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

    [set_variable]
    name=scorpy_x
    value=$x1
    [/set_variable]

    [set_variable]
    name=scorpy_y
    value=$y1
    [/set_variable]

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

    #[message]
    #speaker=unit
    #message= _ "Tripped scorpion encounter"
    #[/message]

    [/then]
[/if]

[/event]

#at beginning of player 1's turn, scorpions appear
[event]
name=side turn
first_time_only=no

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

    [variable]
    name=side_number
    numerical_equals=1
    [/variable]

    [then]

    [set_variable]
    name=scorpions_appeared
    value=2
    [/set_variable]

    #Easy 3 scorpions, Medium 5, Hard 6

    [set_variable]
    name=number_scorpions
    value=3
    [/set_variable]

    {FREE_UNIT (Giant Scorpion) (Scorpion) ( _ "Scorpion") 3 $scorpy_x $scorpy_y}
    {FREE_UNIT (Giant Scorpion) (Scorpion) ( _ "Scorpion") 3 $scorpy_x $scorpy_y}
    {FREE_UNIT (Giant Scorpion) (Scorpion) ( _ "Scorpion") 3 $scorpy_x $scorpy_y}

    #ifdef MEDIUM

    [set_variable]
    name=number_scorpions
    value=5
    [/set_variable]

    {FREE_UNIT (Giant Scorpion) (Scorpion) ( _ "Scorpion") 3 $scorpy_x $scorpy_y}
    {FREE_UNIT (Giant Scorpion) (Scorpion) ( _ "Scorpion") 3 $scorpy_x $scorpy_y}

    #endif

    #ifdef HARD

    [set_variable]
    name=number_scorpions
    value=6
    [/set_variable]

    {FREE_UNIT (Giant Scorpion) (Scorpion) ( _ "Scorpion") 3 $scorpy_x $scorpy_y}

    #endif

    [if]

        [have_unit]
        x=$scorpy_x
        y=$scorpy_y
        [/have_unit]

        [then]
            [message]
                x=$scorpy_x
                y=$scorpy_y
                message= _ "Scorpions! We must have stumbled across a nest of them."
            [/message]
        [/then]

        [else]
            [message]
                speaker=Kaleh
                message= _ "We've hit a nest of scorpions!"
            [/message]
        [/else]
    [/if]

    [/then]
[/if]

[/event]

#when all the scorpions are dead, reveal a ring as a reward
[event]
name=die
first_time_only=no
    [filter]
    type=Giant Scorpion
    [/filter]

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

    [if]
        [variable]
        name=scorpion_deaths
        numerical_equals=$number_scorpions
        [/variable]

        [then]
        #create a ring (immune to desert damage) as a reward

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

        [item]
        x=$x1
        y=$y1
        image=items/ring2.png
        [/item]

        [set_variable]
        name=ring_x
        value=$x1
        [/set_variable]

        [set_variable]
        name=ring_y
        value=$y1
        [/set_variable]

        # test to make sure player killed ogre before displaying
        # victory message
        [store_unit]
            [filter]
            x=$x2
            y=$y2
            side=1
            [/filter]
        variable=temp
        [/store_unit]

        [if]
            [variable]
            name=temp.length
            value=1
            [/variable]

            [then]

            [message]
            speaker=second_unit
            message= _ "The scorpions were devouring some poor person's body. There doesn't seem to be much of him or her left, but wait...what's this? It looks like a tiny gold ring. I think I see elvish runes on the inside, but I can barely make them out. This seems to be a ring of travel! Those who wear it will not suffer from thirst or hunger, nor cold nor heat. I've heard tales of such magical items, and we can certainly use it now."
            [/message]

            [/then]
            [else]

            [message]
            speaker=Kaleh
            message= _ "The scorpions were devouring some poor person's body. There doesn't seem to be much of him or her left, but wait...what's this? It looks like a tiny gold ring. And there are elvish runes on the inside, I can barely make them out. This seems to be a ring of travel, those who wear it will not suffer from thirst or hunger, nor cold nor heat. I've heard tales of such magical items, we can certainly use it now."
            [/message]

            [/else]
        [/if]

        [message]
        speaker=narrator
        message= _ "One unit wearing this ring is immune to any damage caused during the day by the heat of the desert."
        [/message]

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

#unit gets ring, is immune to desert damage
[event]
name=moveto
first_time_only=no

[filter]
x=$ring_x
y=$ring_y
side=1
[/filter]

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

    [then]

    [set_variable]
    name=ring_appeared
    value=2
    [/set_variable]

    [object]
        id=Travelring
        name= _ "Traveler's Ring"
        image=items/ring2.png
        description= _ "At the end of each turn, this unit takes no damage from the desert."
        [filter]
            x=$ring_x
            y=$ring_y
            side=1
        [/filter]

    [/object]

    [removeitem]
        x=$ring_x
        y=$ring_y
    [/removeitem]

    [store_unit]
        [filter]
        x,y=$ring_x,$ring_y
        [/filter]
    variable=ringstats
    [/store_unit]

    [set_variable]
    name=ringstats.role
    value=immune
    [/set_variable]

    [unstore_unit]
    variable=ringstats
    [/unstore_unit]

    {CLEAR_VARIABLE ringstats}

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


#Encounter 1.5: Second Oasis, remind player of healing properties

[event]
name=moveto

[filter]
x=25-40
y=52-68
side=1
[/filter]

    [message]
    speaker=unit
    message= _ "Look, an oasis! Its refreshing water will heal any of our wounded people who enter it, and others can rest safely on the grass during the heat of the day."
    [/message]

# usually player sets off scorpion encounter at the same time, so this
# undo is negated
[allow_undo]
[/allow_undo]
[/event]


#Encounter #2 Ogre Ambush
#y coor: 1 to (50-53)

#May want to lower y value, so encounter ogres before reaching second oasis

#Ogres are dumb, so they ambush the players right before their turn

[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]
# was:
# y variation 52-54

#is now:
# y variation 51-53

{RANDOM 51..53}

[set_variable]
name=loc_y
value=$random
[/set_variable]

[if]    #OFF
    [variable]
    name=ogres_appeared
    numerical_equals=1
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=$loc_y
    [/variable]

    [then]

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

    [set_variable]
    name=ogre_x
    value=$x1
    [/set_variable]

    [set_variable]
    name=ogre_y
    value=$y1
    [/set_variable]

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

    #[message]
    #speaker=unit
    #message= _ "Tripped ogre encounter"
    #[/message]

    [/then]
[/if]

[/event]

#at beginning of player 1's  next turn, ogres appear
# I added if clauses so that if the unit is on the left or right edge
# of the map, instead of 2 of the ogres being drawn off the edge of the
# map, all the ogres form a semi-circle against the egde of the map
# (that is, if ogre is going to be drawn off the edge of the map, flip
# him over to the other side of the circle)
[event]
name=side turn
first_time_only=no

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

    [variable]
    name=ogres_appeared
    numerical_equals=1
    [/variable]

    [then]

    [set_variable]
    name=ogres_appeared
    value=2
    [/set_variable]

    [set_variable]
    name=temp_loc_x
    value=$ogre_x
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$ogre_y
    [/set_variable]

    #Easy: 1 ogre, 4 young ogres
    #Medium: 2 ogres, 3 young ogres
    #Hard: 3 Ogres: 3 young ogres

    #ifdef HARD
    [set_variable]
    name=number_ogres
    value=6
    [/set_variable]
    #else
    [set_variable]
    name=number_ogres
    value=5
    [/set_variable]
    #endif

    [set_variable]
    name=temp_loc_x
    add=-2
    [/set_variable]

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

    [if]
        [variable]
        name=temp_loc_x
        less_than=1
        [/variable]

        [then]

        [set_variable]
        name=temp_loc_x
        add=4
        [/set_variable]

        {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}

        [set_variable]
        name=temp_loc_y
        add=-2
        [/set_variable]

        {FREE_UNIT (Ogre) (Ogre Chief) ( _ "Ogre Chief") 3 $temp_loc_x $temp_loc_y}

        [set_variable]
        name=temp_loc_x
        add=-4
        [/set_variable]

        [/then]

        [else]

        {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}

        [set_variable]
        name=temp_loc_y
        add=-2
        [/set_variable]

        {FREE_UNIT (Ogre) (Ogre Chief) ( _ "Ogre Chief") 3 $temp_loc_x $temp_loc_y}

        [/else]
    [/if]


    [set_variable]
    name=temp_loc_x
    add=2
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=-1
    [/set_variable]

    {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}

    [set_variable]
    name=temp_loc_x
    add=2
    [/set_variable]

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

    [if]
        [variable]
        name=temp_loc_x
        greater_than=39
        [/variable]

        [then]

        [set_variable]
        name=temp_loc_x
        add=4
        [/set_variable]

        #ifdef HARD
        {FREE_UNIT (Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #else
        {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #endif

        [set_variable]
        name=temp_loc_y
        add=2
        [/set_variable]

        #ifdef EASY
        {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #else
        {FREE_UNIT (Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #endif

        [set_variable]
        name=temp_loc_x
        add=-4
        [/set_variable]

        [/then]

        [else]

        #ifdef HARD
        {FREE_UNIT (Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #else
        {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #endif

        [set_variable]
        name=temp_loc_y
        add=2
        [/set_variable]

        #ifdef EASY
        {FREE_UNIT (Young Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #else
        {FREE_UNIT (Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}
        #endif

        [/else]
    [/if]

    # if HARD put a ogre behind the unit, blocking his escape
    #ifdef HARD

    [set_variable]
    name=temp_loc_x
    add=-2
    [/set_variable]

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

    {FREE_UNIT (Ogre) (Ogre Hunter) ( _ "Ogre Hunter") 3 $temp_loc_x $temp_loc_y}

    #endif

    [if]

        [have_unit]
        x=$ogre_x
        y=$ogre_y
        [/have_unit]

        [then]
            [message]
                x=$ogre_x
                y=$ogre_y
                message= _ "Ambush! Ogres!"
            [/message]
        [/then]

        [else]
            [message]
                description=Kaleh
                message= _ "Ogre ambush!"
            [/message]
        [/else]
    [/if]


    [message]
        description=Ogre Chief
        message= _ "Fresh meat!"
    [/message]

    [if]

        [have_unit]
        x=$ogre_x
        y=$ogre_y
        [/have_unit]

        [then]
            [message]
                x=$ogre_x
                y=$ogre_y
                message= _ "Ugh, they smell as bad as they look. And they're huge! Well, the bigger they are, the harder they fall."
            [/message]
        [/then]

    [/if]

    [/then]
[/if]

[/event]

#define OGRE_DEATH_COUNT

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

    # test to make sure player killed ogre before displaying
    # victory message
    [store_unit]
        [filter]
        x=$x2
        y=$y2
        side=1
        [/filter]
    variable=temp
    [/store_unit]

    [if]
        [variable]
        name=ogre_deaths
        numerical_equals=$number_ogres
        [/variable]

        [then]

        [if]

            [variable]
            name=temp.length
            numerical_equals=1
            [/variable]

            [then]

            [message]
            speaker=second_unit
            message= _ "That's the last of them. This looks like a raiding party, they must have a camp around here somewhere."
            [/message]
            [/then]
            [else]
            [message]
            speaker=Kaleh
            message= _ "That's the last of them. This looks like a raiding party, they must have a camp around here somewhere."
            [/message]
            [/else]
        [/if]
        [/then]
    [/if]

#enddef


#ogre death counter
[event]
name=die
first_time_only=no
    [filter]
    description=Ogre Hunter
    [/filter]

    {OGRE_DEATH_COUNT}

    [/event]

#ogre death counter
[event]
name=die
first_time_only=no
    [filter]
    description=Ogre Chief
    [/filter]

    {OGRE_DEATH_COUNT}

    [/event]


#Encounter #3: Black Hand Ambush
#when player moves to hexes around oasis, trips ambush flag

[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]

#x coor: 1 to 12-14
#y coor: 40-42 to 46-48

{RANDOM 12..14}

[set_variable]
name=loc_x
value=$random
[/set_variable]

{RANDOM 40..42}

[set_variable]
name=loc_y_top
value=$random
[/set_variable]

{RANDOM 46..48}

[set_variable]
name=loc_y_bottom
value=$random
[/set_variable]

[if]
    [variable]
    name=oasis_ambush
    numerical_equals=0
    [/variable]

    [variable]
    name=x1
    less_than_equal_to=$loc_x
    [/variable]

    [variable]
    name=y1
    greater_than_equal_to=$loc_y_top
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=$loc_y_bottom
    [/variable]

    [then]

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

    [set_variable]
    name=oasis_x
    value=$x1
    [/set_variable]

    [set_variable]
    name=oasis_y
    value=$y1
    [/set_variable]

    #[message]
    #speaker=unit
    #message= _ "Tripped oasis ambush"
    #[/message]

    [/then]
[/if]

[/event]


#Black Hand Ambushes player right after before moves
#All: 1 trapper, 2 thugs, 2 poachers
#Easy: +1 thug, +1 poacher
#Medium: +1 bandit, +1 thug, +1 poacher
#Hard: +1 trapper, +2 bandits

#totals:
#Easy: 1 trapper, 3 thugs, 3 poachers
#Medium: 1 trapper, 1 bandit, 3 thugs, 3 poachers
#Hard: 2 trappers, 2 bandits, 2 thugs, 2 poachers

[event]
name=side turn
first_time_only=no

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

    [variable]
    name=side_number
    numerical_equals=1
    [/variable]

    [then]

    [set_variable]
    name=oasis_ambush
    value=2
    [/set_variable]

    #Easy coordinates for 1 trapper, 3 thugs, 3 archers
    #trapper (3,45)
    #thugs (4,46) (11,45) (12,42)
    #pochers (7,41) (10,46) (7,45)

    #extra for med/hard(8,47)

    #for all difficulties

    {FREE_UNIT (Trapper) (Black Lieutenant) ( _ "Black Lieutenant") 2 9 46}
    {FREE_UNIT (Thug) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 11 41}
    {FREE_UNIT (Thug) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 11 45}
    {FREE_UNIT (Poacher) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 8 42}
    {FREE_UNIT (Poacher) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 11 47}

    #ifdef EASY
    {FREE_UNIT (Thug) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 12 42}
    {FREE_UNIT (Poacher) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 7 45}
    #endif

    #ifdef MEDIUM
    {FREE_UNIT (Thug) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 12 42}
    {FREE_UNIT (Poacher) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 7 45}
    {FREE_UNIT (Bandit) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 8 47}
    #endif

    #ifdef HARD
    {FREE_UNIT (Bandit) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 12 42}
    {FREE_UNIT (Trapper) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 7 45}
    {FREE_UNIT (Bandit) (Black Hand Ruffian) ( _ "Black Hand Ruffian") 2 8 47}
    #endif

    [message]
        type=Thug
        message= _ "This is our oasis, and we will water it with your blood!"
    [/message]

    [message]
        description=Black Lieutenant
        message= _ "We don't know who you are, and we don't much care. Tremble before the might of the Black Hand!"
    [/message]

    [if]
        [have_unit]
        x=$oasis_x
        y=$oasis_y
        [/have_unit]

        [then]
            [message]
                x=$oasis_x
                y=$oasis_y
                message= _ "We need that water, and if we have to go through you to get it, so be it."
            [/message]
        [/then]

        [else]
            [message]
                speaker=Kaleh
                message= _ "We need that water, and if we have to go through you to get it, so be it."
            [/message]
        [/else]
    [/if]

    [/then]
[/if]

[/event]

#Encounter #4 Undead Fire Mage combat
#y coor: 1 to (35-39)

#Easy: 2 Skeletons, 1 Revenant, 2 Skeleton Archers, 1 Bone Shooter
#Medium: 1 Skeletons, 2 Revenants, 1 Skeleton Archers, 2 Bone Shooters
#Hard: 1 Skeleton, 1 Revenant, 1 Draug, 1 Skeleton Archer, 2 Bone Shooters

#All: 1 Skeleton, 1 Skeleton Archer, 1 Revenant, 1 Bone Shooter
#Easy: +1 Skeleton, +1 Skeleton Archer,
#Medium: +1 Revenant, +1 Skeleton Archer
#Hard: +1 Revenant, +1 Bone Shooters

#Encounter happens right after player moves to the location

[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]

# y variation 35-39

{RANDOM 35..39}

[set_variable]
name=loc_y
value=$random
[/set_variable]

[if]
    [variable]
    name=firemage_appeared
    numerical_equals=0
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=$loc_y
    [/variable]

    [then]

    #[message]
    #speaker=narrator
    #message= _ "firemage: y coor: $loc_y"
    #[/message]

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

    [set_variable]
    name=temp_loc_x
    value=$x1
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$y1
    [/set_variable]

    #undead are created up to 5 hexes to the right of the unit


    #Create Red Mage

    [set_variable]
    name=temp_loc_x
    add=3
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=-2
    [/set_variable]

    # ERROR CHECK:
    # If mage is so far to the right that she would be off the map
    # then just kick her back 6 hexes in the opposite direction
    # that is, 3 hexes to the left instead of to the right.
    # This happens when unit that triggers encounter if on the
    # right edge of the map.
    [if]
        [variable]
        name=temp_loc_x
        greater_than=37
        [/variable]

        [then]

        [set_variable]
        name=temp_loc_x
        add=-6
        [/set_variable]

        [/then]
    [/if]


    # on EASY and MEDIUM, Elyssa is 1 hex closer to elves and a bit
    # farther away from undead pursuers

    #ifdef HARD
    #else
        [set_variable]
        name=temp_loc_x
        add=-1
        [/set_variable]

        [set_variable]
        name=temp_loc_y
        add=1
        [/set_variable]
    #endif

    [unit]
    type=Elyssa Red Mage
    description=Elyssa
    user_description= _ "Elyssa"
    gender=female
    upkeep=full
    experience=15
    [modifications]
        {TRAIT_QUICK}
        {TRAIT_INTELLIGENT}
    [/modifications]
    x=$temp_loc_x
    y=$temp_loc_y
    side=1
    [/unit]

    #ifdef HARD
    #else
        [set_variable]
        name=temp_loc_x
        add=1
        [/set_variable]

        [set_variable]
        name=temp_loc_y
        add=-1
        [/set_variable]
    #endif


    #center undead gang around location of red mage

    [set_variable]
    name=number_undead_gang
    value=6
    [/set_variable]

    #save location of red mage
    [set_variable]
    name=mage_loc_x
    value=$temp_loc_x
    [/set_variable]

    [set_variable]
    name=mage_loc_y
    value=$temp_loc_y
    [/set_variable]

    #all difficulties: create 1 skeleton, 1 revenant (Go'hag),
    # 1 skele archer and 1 bone shooter

    [set_variable]
    name=temp_loc_x
    value=$mage_loc_x
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

    [set_variable]
    name=temp_loc_x
    add=-2
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=-1
    [/set_variable]

    #ifdef HARD

    [unit]
        type=Draug
        description=Go'hag
        user_description= _ "Go-hag"
        side=4
        upkeep=free
        x=$temp_loc_x
        y=$temp_loc_y
        hitpoints=42
    [/unit]

    #else
    {FREE_UNIT (Revenant) (Go'hag) ( _ "Go'hag") 4 $temp_loc_x $temp_loc_y}
    #endif


    [set_variable]
    name=temp_loc_x
    value=$mage_loc_x
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

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

    [set_variable]
    name=temp_loc_y
    add=-1
    [/set_variable]

    {FREE_UNIT (Skeleton) (Undead Raider) ( _ "Undead Raider") 4 $temp_loc_x $temp_loc_y}

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=-2
    [/set_variable]

    {FREE_UNIT (Skeleton Archer) (Undead Raider) ( _ "Undead Raider") 4 $mage_loc_x $temp_loc_y}

    [set_variable]
    name=temp_loc_x
    value=$mage_loc_x
    [/set_variable]

    [set_variable]
    name=temp_loc_x
    add=2
    [/set_variable]

    {FREE_UNIT (Bone Shooter) (Undead Raider) ( _ "Undead Raider") 4 $temp_loc_x $mage_loc_y}


    #EASY: create 1 Skeleton, 1 Skeleton Archer
    #ifdef EASY

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=2
    [/set_variable]

    {FREE_UNIT (Skeleton) (Undead Raider) ( _ "Undead Raider") 4 $mage_loc_x $temp_loc_y}

    [set_variable]
    name=temp_loc_x
    value=$mage_loc_x
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

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

    [set_variable]
    name=temp_loc_y
    add=2
    [/set_variable]

    {FREE_UNIT (Skeleton Archer) (Undead Raider) ( _ "Undead Raider") 4 $temp_loc_x $temp_loc_y}

    #endif

    #MEDIUM: +1 Revenant, +1 Skeleton Archer

    #ifdef MEDIUM

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=2
    [/set_variable]

    {FREE_UNIT (Revenant) (Undead Raider) ( _ "Undead Raider") 4 $mage_loc_x $temp_loc_y}

    [set_variable]
    name=temp_loc_x
    value=$mage_loc_x
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

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

    [set_variable]
    name=temp_loc_y
    add=2
    [/set_variable]

    {FREE_UNIT (Skeleton Archer) (Undead Raider) ( _ "Undead Raider") 4 $temp_loc_x $temp_loc_y}

    #endif

    #HARD: create 1 Revenant, and 1 Bone Shooter
    #ifdef HARD

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=2
    [/set_variable]

    {FREE_UNIT (Revenant) (Undead Raider) ( _ "Undead Raider") 4 $mage_loc_x $temp_loc_y}

    [set_variable]
    name=temp_loc_x
    value=$mage_loc_x
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    value=$mage_loc_y
    [/set_variable]

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

    [set_variable]
    name=temp_loc_y
    add=2
    [/set_variable]

    {FREE_UNIT (Bone Shooter) (Undead Raider) ( _ "Undead Raider") 4 $temp_loc_x $temp_loc_y}

    #endif

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

    [message]
    description=Elyssa
    message= _ "Back, you fiends! Or I'll kill you a second time!"
    [/message]

    #ifdef HARD

    [message]
    description=Go'hag
    message= _ "You have defied our master for the last time. Now you shall die! And I shall personally make it slow and painful, to thank you for that scorching you gave me. "
    [/message]

    #else

    [message]
    description=Go'hag
    message= _ "You have defied our master for the last time. Now you shall die!"
    [/message]

    #endif

    [message]
    description=Elyssa
    message= _ "Stupid undead, they never listen. Then have a taste of my flame!"
    [/message]

    [message]
    speaker=unit
    message= _ "She looks like she's in trouble. We should help her."
    [/message]

    [/then]
[/if]

[/event]


#define ELYSSA_TALK

            [message]
            speaker=Nym
            message= _ "Whew! Looks like that's the last of them."
            [/message]

            [message]
            description=Elyssa
            message= _ "Thanks for the help! That was a little too close for comfort."
            [/message]

            [message]
            speaker=Kaleh
            message= _ "That was a lot of undead. Why were they coming after you?"
            [/message]

            [message]
            description=Elyssa
            message= _ "I accidentally managed to anger a powerful necromancer a while ago...it's a long story. But who are you? You almost look like elves."
            [/message]

            [message]
            speaker=Kaleh
            message= _ "We are, we're the Quenoth Elves and we are traveling north. You look like you're a mage, but I thought your kind were all gone."
            [/message]

            [message]
            description=Elyssa
            message= _ "I am, I'm a fire mage. I've been traveling for quite a while now, exploring and learning. But these sands seem particularly inhospitable! I've been meaning to check out the northern mountains; mind if I join you for a while in your travels?"
            [/message]

            [message]
            speaker=Zhul
            message= _ "We'd be glad to have the help of someone with the mastery of fire."
            [/message]

#enddef

#undead gang death counter, display messages when all undead gang are dead

#define UNDEAD_COUNTER

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

    [if]
        [variable]
        name=undead_gang_deaths
        numerical_equals=$number_undead_gang
        [/variable]

        [then]

        #if Elyssa died, don't print conversation
        [if]

            [have_unit]
            description=Elyssa
            [/have_unit]

            [then]
            {ELYSSA_TALK}
            [/then]

            [else]

            [message]
            speaker=second_unit
            message= _ "The undead are defeated, but we lost her in the fight as well. Darn, if only we could have saved her."
            [/message]
            [/else]
        [/if]
        [/then]
    [/if]

#enddef

[event]
name=die
first_time_only=no
    [filter]
    description=Undead Raider
    [/filter]

    {UNDEAD_COUNTER}
[/event]

[event]
name=die
first_time_only=no
    [filter]
    description=Go'hag
    [/filter]

    {UNDEAD_COUNTER}
[/event]


#Encounter #5 Castle/Orge Camp
#x coor: 25-27 to 40
#y coor: 22-23 to 31-33
#Encounter happens right after player moves near castle

#ogrecastle_appeared
#wraithcastle_appreared

[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]

#x coor: 25-27 to 40
#y coor: 22-23 to 31-33

{RANDOM 27..29}

[set_variable]
name=loc_x
value=$random
[/set_variable]

{RANDOM 22..23}

[set_variable]
name=loc_y_top
value=$random
[/set_variable]

{RANDOM 31..33}

[set_variable]
name=loc_y_bottom
value=$random
[/set_variable]

[if]
    [variable]
    name=ogrecastle_appeared
    numerical_equals=0
    [/variable]

    [variable]
    name=x1
    greater_than_equal_to=$loc_x
    [/variable]

    [variable]
    name=y1
    greater_than_equal_to=$loc_y_top
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=$loc_y_bottom
    [/variable]

    [then]

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

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

    #create ogres
    #Easy: 1 ogre, 3 young ogres
    #Medium: 2 ogres, 2 young ogres
    #Hard: 3 ogres, 1 young ogre

    [set_variable]
    name=number_ogres2
    value=4
    [/set_variable]

    #in all 3 difficulties, there are at least 1 ogre and 1 young ogre

    {FREE_UNIT (Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 34 26}
    {FREE_UNIT (Young Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 33 29}

    #ifdef EASY
    {FREE_UNIT (Young Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 33 25}
    {FREE_UNIT (Young Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 37 28}
    #endif

    #ifdef MEDIUM
    {FREE_UNIT (Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 33 25}
    {FREE_UNIT (Young Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 37 28}
    #endif

    #ifdef HARD
    {FREE_UNIT (Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 33 25}
    {FREE_UNIT (Ogre) (Ogre Nomad) ( _ "Ogre Nomad") 3 37 28}
    #endif

    [message]
    type=Ogre
    message= _ "Elves! Kill them all!"
    [/message]

    [message]
    speaker=unit
    message= _ "This ruined castle must be where the ogres make their home. Well, if it's a fight they want, it's a fight they'll get. "
    [/message]

    [/then]

[/if]
[/event]


#Problem: if ogres from encounter #2 aren't dead before this encounter is
#tripped, the ogres from one encounter will count for the other.

#Ogre Camp death counter

#ogre death counter
[event]
name=die
first_time_only=no

    [filter]
    description=Ogre Nomad
    [/filter]

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

    # test to make sure player killed ogre before displaying
    # victory message
    [store_unit]
        [filter]
        x=$x2
        y=$y2
        side=1
        [/filter]
    variable=temp
    [/store_unit]

    [if]
        [variable]
        name=ogre_deaths2
        numerical_equals=$number_ogres2
        [/variable]

        [then]

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

        [if]
            [variable]
            name=temp.length
            numerical_equals=1
            [/variable]

            [then]

            [message]
            speaker=second_unit
            message= _ "That's the last of those stinking beasts. They will trouble us no more."
            [/message]

            [/then]

            [else]

            [message]
            description=Kaleh
            message= _ "That's the last of those stinking beasts. They will trouble us no more."
            [/message]

            [/else]

        [/if]

        [message]
        description=Garak
        message= _ "Y'know, this ruin looks oddly familiar."
        [/message]

        [message]
        description=Nym
        message= _ "Yuck, there's still dried blood on the stones. It's kind of spooky."
        [/message]

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


# Encounter #5 Wraith appears

# if elves are within castle bounds and
# if dusk/dawn/night
# if castleogres_dead = 1 and
# if castlewraith_appeared = 0

[event]
name=new turn
first_time_only=no

[if]
    [have_unit]
    x=31-37
    y=24-29
    side=1
    [/have_unit]

    [then]

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

        [or]
        [variable]
        name=time_of_day
        equals=6
        [/variable]
        [/or]

        [or]
        [variable]
        name=time_of_day
        equals=-5
        [/variable]
        [/or]

        [or]
        [variable]
        name=time_of_day
        equals=-6
        [/variable]
        [/or]

        [or]
        [variable]
        name=time_of_day
        equals=-7
        [/variable]
        [/or]

        [or]
        [variable]
        name=time_of_day
        equals=-8
        [/variable]
        [/or]

        [or]
        [variable]
        name=time_of_day
        equals=-9
        [/variable]
        [/or]

        [then]

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

            [then]

            [if]


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

                [then]

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

                #ifdef EASY
                [modify_side]
                side=5
                income=10
                gold=75
                [/modify_side]
                #endif

                #ifdef MEDIUM
                [modify_side]
                side=5
                income=15
                gold=75
                [/modify_side]
                #endif

                #ifdef HARD
                [modify_side]
                side=5
                income=20
                gold=100
                [/modify_side]
                #endif

                #create wraith and 2 ghosts

                [unit]
                type=Wraith
                description=Vengeful Lord
                user_description= _ "Vengeful Lord"
                side=5
                x=34
                y=25
                canrecruit=1
                [/unit]

                #extra ghosts only on med and hard
                {UNIT_ (Ghost) (Honor Guard) ( _ "Honor Guard") 5 33 25}
                {UNIT_ (Ghost) (Honor Guard) ( _ "Honor Guard") 5 35 25}

                #ifdef EASY
                #else
                {UNIT_ (Ghost) (Honor Guard) ( _ "Honor Guard") 5 33 26}
                {UNIT_ (Ghost) (Honor Guard) ( _ "Honor Guard") 5 35 26}
                #endif

                [message]
                description=Vengeful Lord
                message= _ "No more shall infidels pollute my castle! Wait a minute, I remember you elves. You thought me defeated, but I am back even more powerful than before. Death reigns eternal, and soon your scorched bones and lifeless bodies shall follow a new master!"
                [/message]

                [message]
                description=Garak
                message= _ "Still singing the same tune. We defeated you once before, we can do so again!"
                [/message]

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

[/event]

#when wraith is killed, player gets bonus gold for his trouble
[event]
name=die

[filter]
description=Vengeful Lord
[/filter]

[message]
description=Vengeful Lord
message= _ "No!!!!"
[/message]

[kill]
description=Vengeful Lord
animate=yes
[/kill]

#ifdef EASY
[set_variable]
name=goldreward
value=250
[/set_variable]
#endif

#ifdef MEDIUM
[set_variable]
name=goldreward
value=200
[/set_variable]
#endif

#ifdef HARD
[set_variable]
name=goldreward
value=150
[/set_variable]
#endif

[sound]
name=gold.ogg
[/sound]

[message]
speaker=unit
message= _ "Searching his castle, we found a chest with $goldreward gold."
[/message]

[gold]
    side=1
    amount=$goldreward
[/gold]

[/event]


#Encounter #6 Outlaw Sign
#y coor: 1 to (20-21)
#Sign appears as soon as player moves to the location
#Outlaw leader is given money and units


[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]

# y variation 20-21

{RANDOM 20..21}

[set_variable]
name=loc_y
value=$random
[/set_variable]

[if]
    [variable]
    name=blackhandsign_appeared
    numerical_equals=0
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=$loc_y
    [/variable]

    [then]

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

    [set_variable]
    name=temp_loc_y
    value=$y1
    [/set_variable]

    [set_variable]
    name=temp_loc_y
    add=-1
    [/set_variable]

    [item]
    x=$x1
    y=$temp_loc_y
    image=items/signpost.png
    [/item]

    [message]
    speaker=unit
    message= _ "This sign reads: This land belongs to the Black Hand. Trespass and you will die."
    [/message]

    [if]
        [set_variable]
        name=oasis_ambush
        numerical_equals=1
        [/set_variable]

        [then]

        [message]
        speaker=unit
        message= _ "So they're posting signs now, are they? Whoever these guys are, if they get in our way, they're going to be sorry."
        [/message]

        [message]
        speaker=unit
        message= _ "Did you see that? I think I just saw someone disappear behind that dune over there. I think we're being watched. I suspect there are more of these bandits lurking in these dunes than we originally thought."
        [/message]

        [message]
	speaker=Kaleh
	message= _ "There's no way we can get all our people safely across the desert if these outlaws keep harassing us. We must defeat them before we can continue."
	[/message]

        [/then]

        [else]

        [message]
        speaker=unit
        message= _ "I'm not sure who these guys are, but they don't sound friendly. Nonetheless, if they get in our way, they're going to be sorry."
        [/message]

        [message]
        speaker=unit
        message= _ "Did you see that? I think I just saw someone disappear behind that dune over there. I think we're being watched. I suspect there are more enemies lurking in these dunes than we originally thought."
        [/message]

        [message]
	speaker=Kaleh
	message= _ "There's no way we can get all our people safely across the desert if we are under constant attack. Whoever they are, we must eliminate this threat before we can continue."
	[/message]

        [/else]
    [/if]

    # Set starting scenario objectives

[objectives]
    summary= _ "New Objectives:"
    show=yes
    [objective]
        description= _ "Kaleh Must Reach the Northern Edge of the Desert"
        condition=win
    [/objective]
    [objective]
        description= _ "Defeat Outlaw Leader"
        condition=win
    [/objective]
    [objective]
        description= _ "Death of Kaleh, Nym, Garak or Zhul"
        condition=lose
    [/objective]
[/objectives]

    #ifdef EASY
    [modify_side]
    side=2
    income=9
    gold=100
    [/modify_side]
    #endif

    #ifdef MEDIUM
    [modify_side]
    side=2
    income=11
    gold=125
    [/modify_side]
    #endif

    #ifdef HARD
    [modify_side]
    side=2
    income=13
    gold=150
    [/modify_side]
    #endif

    [capture_village]
            side=2
            x,y=17,7
    [/capture_village]
    [capture_village]
            side=2
            x,y=19,10
    [/capture_village]
    [capture_village]
            side=2
            x,y=24,10
    [/capture_village]
    [capture_village]
            side=2
            x,y=27,7
    [/capture_village]

    [/then]

[/if]

[/event]


#Encounter #7 Mirage
#Oasis disappears as soon as player moves to the location

[event]
name=moveto
first_time_only=no

[filter]
side=1
[/filter]

#x coor: 9 to 13
#y coor: 19 to 18

[if]
    [variable]
    name=mirage_appeared
    numerical_equals=0
    [/variable]

    [variable]
    name=x1
    greater_than_equal_to=9
    [/variable]

    [variable]
    name=x1
    less_than_equal_to=13
    [/variable]

    [variable]
    name=y1
    greater_than_equal_to=13
    [/variable]

    [variable]
    name=y1
    less_than_equal_to=18
    [/variable]

    [then]

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

    [terrain]
    letter=I
    x=10,10,11,11,11,12,12
    y=14,15,15,16,17,15,16
    [/terrain]

    [message]
    speaker=unit
    message= _ "Dang. I was sure I saw an oasis here. Must have been a mirage. I've been out in the sand for too long."
    [/message]

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

# Encounter 7.5 Pinnacle Rock
# first unit to see the rock comments on the outlaws there
# this event can be undone

[event]
name=moveto

[filter]
x=14-29
y=1-14
side=1
[/filter]

[allow_undo]
[/allow_undo]

    [message]
    speaker=unit
    message= _ "So, the outlaws have made a base around Pinnacle Rock. It's a good location, but we will drive them from it all the same"
    [/message]

[/event]

#Encounter 8: Death of outlaw leader

#changed so player gets holy water in easy and medium difficulty

[event]
name=die

[filter]
description=Thorn
[/filter]

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

[message]
speaker=unit
message= _ "I surrender! I mean we surrender. Just please don't kill me."
[/message]

#ifdef HARD

[message]
speaker=unit
message= _ "Please, have mercy on us. We're just trying to survive in this horrible land."
[/message]

[message]
speaker=Kaleh
message= _ "I will not kill you in cold blood. But leave these lands, and never darken our path again. Or I will show you no mercy."
[/message]

#else

[message]
speaker=unit
message= _ "Please, have mercy on us. We'm just trying to survive in this horrible land."
[/message]

[set_variable]
name=holy_water_x
value=$x1
[/set_variable]

[set_variable]
name=holy_water_y
value=$y1
[/set_variable]

[item]
    x=$holy_water_x
    y=$holy_water_y
    image=items/holy-water.png
[/item]

[message]
speaker=unit
message= _ "Here, take this vial of holy water. You'll need it with all the undead around."
[/message]

[message]
speaker=Kaleh
message= _ "I will take this vial, in exchange for your life. But leave these lands, and never darken our path again. Or I will show you no mercy."
[/message]

[message]
description=Zhul
message= _ "It's Holy Water. When anointed on a weapon it makes it deadly to the undead. Vials such as these are rare and valuable. We should choose carefully who will use it."
[/message]

#endif

#all surviving outlaws flee, so kill all units
[kill]
side=2
animate=no
fire_event=no
[/kill]

[/event]


#ifdef HARD
#else

# Holy Water item event
# If unit moves to hex after outlaw leader it dead, it gets the holy water
[event]
name=moveto
first_time_only=no

[filter]
x=$holy_water_x
y=$holy_water_y
side=1
[/filter]

[if]
    #only happens if outlaw leader is dead
    [variable]
    name=thorn_dead
    numerical_equals=1
    [/variable]

    [then]

    [object]
        id=PureWater
        name= _ "Pure Water"
        image=items/holy-water.png
        description= _ "This water will make your melee weapons holy, and thus especially powerful against the undead."

        [effect]
        apply_to=attack
        range=melee
        set_type=holy
        [/effect]

    [/object]

    [removeitem]
        x=$holy_water_x
        y=$holy_water_y
    [/removeitem]

    [/then]

[/if]

[/event]

#endif


#if Kaleh moves to north edge of map but outlaw leader isn't defeated
#then this warns the player that he must go back and kill outlaw leader
#first to complete the scenario

[event]
name=moveto
first_time_only=no

[filter]
y=1
side=1
description=Kaleh
[/filter]

[if]
    [variable]
    name=thorn_dead
    numerical_equals=0
    [/variable]

    [then]

    [message]
    description=Kaleh
    message= _ "The Black Hand outlaws still threaten the others. While their leader still fights we won't be able to get all our people across the sands safely. We must deal with the Black Hand before we can progress further."
    [/message]

    [/then]

[/if]
[/event]


#victory if Kaleh moves to north of map and outlaw is defeated
[event]
name=moveto
first_time_only=no

[filter]
y=1
side=1
description=Kaleh
[/filter]

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

    [then]

    [message]
    description=Kaleh
    message= _ "The outlaws are defeated and we've made it across these blasted sands. The hills are just a few miles to the north. We should be able to find water and rest there."
    [/message]

    [endlevel]
    result=victory
    bonus=yes
    [/endlevel]

    [/then]
[/if]

[/event]

[event]
name=victory

[if]
    [have_unit]
    description=Elyssa
    [/have_unit]

    [then]

        [message]
        description=Kaleh
        message= _ "Now that we have a moment of peace, I have to ask you, Elyssa, what were you really doing out in the middle of the desert? It's a rather barren place to be traveling."
        [/message]

        [message]
        description=Elyssa
        message= _ "I've been searching for secrets from the past. Did you know that this entire land used to be a huge empire? Apparently this used to all be great plains and farmland, before the sands came."
        [/message]

        [message]
        description=Nym
        message= _ "It's hard to imagine. There's barely enough rain here now to support these tiny cacti, let alone crops."
        [/message]

        [message]
        description=Garak
        message= _ "And yet the great ruins that I have seen scattered across these sands are a testament that something was here before us. Perhaps in a time long ago when the land was more forgiving."
        [/message]

        [message]
        description=Elyssa
        message= _ "Before the great fall, there were huge cities, with great schools of magery, libraries of books, vast repositories of knowledge. Most of it was destroyed in the ensuing chaos and years of decay, but I'm searching for the little fragments that are left. For example, have you ever heard of The Scepter of Fire?"
        [/message]

        [message]
        description=Kaleh
        message= _ "No, I haven't. What is it?"
        [/message]

        [message]
        description=Elyssa
        message= _ "I'm not sure. I've read various references to it, but nothing specific. I've been searching for it for a long time. All I know is that it was a very powerful magical wand and that it was some sort of symbol of royalty in the old empire, but I have no idea where it might be. So I scour the land, learning all I can about the olden days. I'm sure it must be somewhere."
        [/message]

        [message]
        description=Kaleh
        message= _ "Perhaps. But it has been so long, and so much has been lost. Who can say?"
        [/message]

    [/then]
[/if]


    #clear variables

    #prestart variables
    {CLEAR_VARIABLE first_night}
    {CLEAR_VARIABLE scorpions_appeared}
    {CLEAR_VARIABLE ring_appeared}
    {CLEAR_VARIABLE ogres_appeared}
    {CLEAR_VARIABLE oasis_ambush}
    {CLEAR_VARIABLE firemage_appeared}
    {CLEAR_VARIABLE ogrecastle_appeared}
    {CLEAR_VARIABLE castleogres_dead}
    {CLEAR_VARIABLE wraithcastle_appeared}
    {CLEAR_VARIABLE blackhandsign_appeared}
    {CLEAR_VARIABLE mirage_appeared}
    {CLEAR_VARIABLE thorn_dead}
    {CLEAR_VARIABLE time_of_day}
    {CLEAR_VARIABLE daytime}
    {CLEAR_VARIABLE desert_damage}

    #other temp variables
    {CLEAR_VARIABLE number_scorpions}
    {CLEAR_VARIABLE scorpion_deaths}
    {CLEAR_VARIABLE scorpy_x}
    {CLEAR_VARIABLE scorpy_y}
    {CLEAR_VARIABLE ring_x}
    {CLEAR_VARIABLE ring_y}
    {CLEAR_VARIABLE loc_x}
    {CLEAR_VARIABLE loc_y}
    {CLEAR_VARIABLE ogre_x}
    {CLEAR_VARIABLE ogre_y}
    {CLEAR_VARIABLE number_ogres}
    {CLEAR_VARIABLE ogre_deaths}
    {CLEAR_VARIABLE temp_loc_x}
    {CLEAR_VARIABLE temp_loc_y}
    {CLEAR_VARIABLE loc_y_top}
    {CLEAR_VARIABLE loc_y_bottom}
    {CLEAR_VARIABLE oasis_x}
    {CLEAR_VARIABLE oasis_y}
    {CLEAR_VARIABLE number_undead_gang}
    {CLEAR_VARIABLE undead_gang_deaths}
    {CLEAR_VARIABLE mage_loc_x}
    {CLEAR_VARIABLE mage_loc_y}
    {CLEAR_VARIABLE number_ogres2}
    {CLEAR_VARIABLE ogre_deaths2}
    {CLEAR_VARIABLE counter}
    {CLEAR_VARIABLE number_ghost}
    {CLEAR_VARIABLE holy_water_x}
    {CLEAR_VARIABLE holy_water_y}

    {CLEAR_VARIABLE locs}
    {CLEAR_VARIABLE temp}
    {CLEAR_VARIABLE goldreward}



[/event]

#time over defeat event
[event]
name=time over
    [message]
        description=Kaleh
        message= _ "We've run out of provisions and our people are exhausted. We've taken too long crossing the desert, I fear we shall never reach the other side. "
    [/message]
[/event]




# These events happen continually throughout the scenario

# All units (except unit carrying the traveler's ring) take 4/5/6 non-lethal
# damage (depending on difficulty) if they are standing in a desert, desert
# hills, or desert mountains hex during the day

[event]
name=side turn
first_time_only=no

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

    [variable]
	name=side_number
	numerical_equals=2
    [/variable]

    [then]

    [set_variable]
	name=damage_msg
	format=$desert_damage
    [/set_variable]

    [set_variable]
	name=damage_msg
	multiply=-1
    [/set_variable]

	[redraw]
	[/redraw]

    [store_locations]
    x=1-40
    y=1-80
    #although adding an extra radius shouldn't be necessary, it ensures
    #that i cover the entire map
    radius=1000
    terrain=JIRz
        [filter]
        side=1
		[not]
		role=immune
		[/not]
        [/filter]
	variable=locs
    [/store_locations]

    {FOREACH locs i}

    [set_variable]
        name=temp_x
        to_variable=locs[$i].x
    [/set_variable]

    [set_variable]
        name=temp_y
        to_variable=locs[$i].y
    [/set_variable]

    [store_unit]
        [filter]
        x,y=$temp_x,$temp_y
        [/filter]
    variable=unitstats
    [/store_unit]

    [set_variable]
	name=unitstats.hitpoints
		add=$desert_damage
    [/set_variable]

    #if unitstats.hitpoints is < 1 then set hitpoints to 1
	[if]
        [variable]
        name=unitstats.hitpoints
		less_than=1
        [/variable]

        [then]

        [set_variable]
        name=unitstats.hitpoints
        value=1
        [/set_variable]

        [/then]

    [/if]

	[unstore_unit]
		variable=unitstats
		text=$damage_msg
		{COLOR_HARM}
	[/unstore_unit]

    {CLEAR_VARIABLE unitstats}

    {NEXT i}

    {CLEAR_VARIABLE locs}
    {CLEAR_VARIABLE damage_msg}

    [/then]

[/if]

[/event]


# Create undead at dusk function

# At first dusk, Garak comments about the dangers of the night

# Create X ghosts, number based on difficulty
# Loop:
#	Pick a random hex
#	If hex is a desert, dune or road terrain hex
#		then place a ghost and increment counter
#	else don't increment counter
# repeat loop until counter equals X


[event]
name=new turn
first_time_only=no

[if]
    #time of day is 5 or -5

    [or]
    [variable]
    name=time_of_day
    numerical_equals=5
    [/variable]
    [/or]

    [or]
    [variable]
    name=time_of_day
    numerical_equals=-5
    [/variable]
    [/or]

    [then]

    [if]
        [variable]
        name=first_night
        numerical_equals=0
        [/variable]

        [then]

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

        [message]
        description=Garak
        message= _ "The sands are haunted with the spirits of tortured souls long since dead. At dusk they rise again, and during the Long Dark they can be particularly nasty. They disappear again at dawn, but personally I prefer the heat of the day to the horrors of the night."
        [/message]

        [message]
        description=Zhul
        message= _ "The combination of the heat of the day and the rising undead make dusk a particularly dangerous time of day."
        [/message]

        [/then]
    [/if]

    #reset undead killed counter

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

    #create ghosts based on numbers defined in prestart

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

    [while]

    [variable]
    name=counter
    less_than=$number_ghost
    [/variable]

    [do]

    {RANDOM 0..39}

    [set_variable]
        name=temp_x
        value=$random
    [/set_variable]

    {RANDOM 0..74}

    [set_variable]
        name=temp_y
        value=$random
    [/set_variable]

    [store_locations]
    x=$temp_x
    y=$temp_y
    terrain=JIR
    variable=locs
    [/store_locations]

    [if]

    [variable]
    name=locs.length
    numerical_equals=1
    [/variable]

    [then]

        {FREE_UNIT (Ghost) (Roaming Undead) ( _ "Roaming Undead") 4 $temp_x $temp_y}

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

    [/then]

    [/if]

    [/do]

    [/while]

    [/then]

    [/if]

[/event]

#define KILL_UNDEAD

    [store_locations]
    x=1-40
    y=1-80
    #although adding an extra radius shouldn't be necessary, it ensures
    #that I cover the entire map
    radius=1000
        [filter]
        description=Roaming Undead
        side=4
        [/filter]
    variable=locs
    [/store_locations]

    {FOREACH locs i}

    [set_variable]
        name=temp_x
        to_variable=locs[$i].x
    [/set_variable]

    [set_variable]
        name=temp_y
        to_variable=locs[$i].y
    [/set_variable]

    [kill]
    x,y=$temp_x,$temp_y

    #if animate=yes, will jump to each dying undead
    animate=no
    fire_event=yes
    [/kill]

    {NEXT i}

    {CLEAR_VARIABLE locs}

#enddef


# Destroy undead at dawn function

[event]
name=new turn
first_time_only=no

[if]
    #time of day is 1 or -1

    [or]
    [variable]
    name=time_of_day
    numerical_equals=-1
    [/variable]
    [/or]

    [or]
    [variable]
    name=time_of_day
    numerical_equals=1
    [/variable]
    [/or]

    [then]

    {KILL_UNDEAD}

    [/then]

    [/if]

[/event]

# If player kills more than 25-50% of the undead on the map, then the rest flee

[event]
name=die
first_time_only=no

[filter]
side=4
[/filter]

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

[if]
    [variable]
    name=undead_killed
    numerical_equals=$nightly_limit
    [/variable]

    [then]

    {KILL_UNDEAD}

    [kill]
    x=$x1
    y=$y1
    animate=no
    fire_event=no
    [/kill]

    [if]
        [variable]
        name=wandering_spirits_conversation
        numerical_equals=0
        [/variable]

        [then]

        [message]
        description=Kaleh
        message= _ "What happened? The undead spirits all just disappeared."
        [/message]

        [message]
        description=Garak
        message= _ "These spirits are weak. They seek to prey on the helpless, but when they encounter strong resistance they flee."
        [/message]

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

        [/then]

        [else]

        [message]
        description=Kaleh
        message= _ "Flee, you craven spirits, and leave us in peace!"
        [/message]

        [/else]
    [/if]

    [/then]

[/if]


[/event]

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

[/scenario]
