#textdomain wesnoth-l
[scenario]
    id=04_Unlawful_Orders
    name= _ "Unlawful Orders"
    next_scenario=05_Hide_and_Seek
    victory_when_enemies_defeated=yes
    map_file=04_Unlawful_Orders.map
    {TURNS 26 22 18}
    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC "transience.ogg" "the_king_is_dead.ogg"}
    {EXTRA_SCENARIO_MUSIC "vengeful.ogg"}
    {EXTRA_SCENARIO_MUSIC "knalgan_theme.ogg"}
    {EXTRA_SCENARIO_MUSIC "battle.ogg"}

    [label]
        x,y=16,15
        text= _ "Elensefar"
    [/label]

    [label]
        x,y=8,13
        text= _ "Port of Elensefar"
    [/label]

    {LIBERTY_BIGMAP {JOURNEY_04_NEW} }

    [side]
        type=Bandit
        id=Baldras
        side=1
        color=black
        canrecruit=yes
        controller=human
        recruit=Thug,Footpad,Poacher
        {GOLD 175 150 125}
        team_name=good_guys
        user_team_name=_"Rebels"
    [/side]

    # wmllint: directory spelling Maddock
    [side]
        type=General
        id=Lord Maddock
        name= _ "Lord Maddock"
        profile=portraits/maddock.png
        side=2
        color=teal
        canrecruit=yes
        controller=ai
        recruit=Spearman,Horseman,Cavalryman,Heavy Infantryman,Mage,Bowman
        [ai]
            recruitment_pattern=scout,mixed fighter,fighter,archer,fighter
            leader_value=3
            village_value=0.2
        [/ai]
        {GOLD 110 100 90}
        team_name=good_guys
        user_team_name=_"Rebels"
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 2 15}

    [side]
        type=General
        id=Kestrel
        name= _ "Kestrel"
        side=3
        color=darkred
        canrecruit=yes
        controller=ai
        recruit=Spearman,Horseman,Cavalryman,Heavy Infantryman,Bowman
        [ai]
            caution=0.0
            aggression=1.0
            recruitment_pattern=scout,fighter,fighter,archer,archer
            leader_value=20
        [/ai]
        {GOLD 160 200 240}
        user_team_name=_"Weldyn"
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES 3 5}

    #
    # Prestart events
    #
    [event]
        name=prestart

        {PLACE_IMAGE items/chest-plain-closed.png 6 4}
        {PLACE_IMAGE items/grain-sheaf.png 7 30}
        {PLACE_IMAGE items/straw-bale1.png 24 27}

        {PLACE_IMAGE scenery/tent-fancy-red.png 18 16}
        {PLACE_IMAGE scenery/temple1.png 14 9}
        {PLACE_IMAGE scenery/lighthouse.png 6 12}
        {PLACE_IMAGE scenery/lighthouse.png 7 16}
        {PLACE_IMAGE scenery/well.png 21 28}
        {PLACE_IMAGE scenery/rock4.png 21 3}
        {PLACE_IMAGE scenery/leanto.png 5 36}

        [objectives]
            side=1
            [objective]
                description= _ "Defeat the enemy general"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Baldras"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Harper"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Maddock"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=yes
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]

        [store_unit]
            [filter]
                id=Baldras
            [/filter]

            kill=yes
            variable=stored_Baldras
        [/store_unit]

        {VARIABLE stored_Baldras.facing sw}

        {NAMED_LOYAL_UNIT 3 Lieutenant 19 36 Rothel (_ "Rothel")}
        [+unit]
            [modifications]
                {TRAIT_QUICK}
            [/modifications]
        [/unit]
    [/event]

    #
    # Starting conversation and actions
    #
    [event]
        name=start

        [move_unit_fake]
            side=1
            type=Boat
            x=25,23
            y= 9,11
        [/move_unit_fake]

        [item]
            x,y=23,11
            image=units/transport/boat.png~FL(horiz)
        [/item]

        [move_unit_fake]
            side=1
            type=$stored_Baldras.type
            x=23,21
            y=11,11
        [/move_unit_fake]

        [unstore_unit]
            variable=stored_Baldras
        [/unstore_unit]

        [recall]
            id=Harper
        [/recall]
        [role]
            type=Huntsman,Ranger,Fugitive,Highwayman,Outlaw,Trapper,Bandit,Footpad,Poacher,Thug
            role=Advisor
            [auto_recall][/auto_recall]
            [not]
                id=Harper,Baldras
            [/not]
        [/role]

        [message]
            speaker=Baldras
            message= _ "Maddock, I be coming to report—"
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "I am already aware of your altercation in Dallben, Baldras. Your dissent was not wise."
        [/message]
        [message]
            speaker=Baldras
            # po: pigdirt is slang for bullshit or hogwash
            message= _ "Dissent? Maddock, I’m not trusting no strange riders who show up out of nowhere claimin’ to be from the Queen. Seems like a bunch of pigdirt to me."
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "That was partially my fault, since I was not able to send a messenger to you in time. I shall have to inform you now. Five weeks ago, at the Ford of Abez, Queen Asheviere’s men allied themselves with the northern orcs and betrayed King Garard II."
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "Since Prince Eldred died in the battle, the Queen took the throne and has been consolidating her power. Part of that has been bringing the elders from the local villages here, forcing them to swear allegiance to her. That was the purpose of that patrol."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Annuvin province be ruled by Elensefar! We has no duty to Weldyn."
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "You do now. I do not really need to tell you what will happen should you refuse Her Majesty’s offer."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Grow a spine, Maddock. If they come to ya and make you swear fealty to this Asheviere, would ya really give up that easy?"
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "Well, they do not come within the walls of my city. There is a large garrison south at the great fortress of Halstead, but even should they mobilize all their troops, I doubt they could take Elensefar. It is true that for now, the majority of my forces are still returning from the battle of Abez, but unless we are attacked within the next few days, I shall be able to hold the city."
        [/message]
        [message]
            speaker=Baldras
            message= _ "And what abouts us? Throw us like dogs to those Wesnothians?"
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "We have an uneasy peace to maintain. The treaty between Elensefar and Wesnoth is ancient, and I do not think Her Majesty means to break it. At the same time, I have some concessions that I shall have to make. I cannot afford a war with Weldyn, as you can surely understand."
        [/message]
        [message]
            speaker=Harper
            message= _ "But we can’t do nothing! The Queen even be sending them beast orcs against us, that’s how evil she is! Surely you can’t stand for this..."
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "Yes, I am aware of Queen Asheviere’s propensity for hiring orcs to supplement her forces. That does not mean I could do anything about it, even if I were so inclined. The best advice I can give you is to just apologize. Even if they may want your head, Baldras, you still have the chance to preserve your village. Think of the bigger picture."
        [/message]
        [message]
            speaker=Baldras
            message= _ "The bigger picture of you idly sittin’ here waiting till them Wesnothians come to take the city right from your hands."
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "I very much doubt they would be bold enough to attack us outright—"
        [/message]
        [message]
            speaker=Baldras
            message= _ "Head out of your behind, Maddock. Open your eyes! Look south and tell me that again!"
        [/message]

        [scroll_to_unit]
            id=Kestrel
        [/scroll_to_unit]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Lord Maddock
            message= _ "An invading army? No, something is not right with those soldiers... but I presume we have no time to ponder that. To arms!"
        [/message]

        # prevent Rothel from suiciding ahead of time
        [modify_unit]
            [filter]
                id=Rothel
            [/filter]
            moves=0
        [/modify_unit]

        {CLEAR_VARIABLE stored_Baldras}
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=6,4
        [/filter]

        [message]
            speaker=unit
            message= _ "Hey, look! Some buried treasure!"
        [/message]

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

        [gold]
            side=1
            amount=33
        [/gold]

        {REMOVE_IMAGE 6 4}
        {PLACE_IMAGE items/chest-plain-open.png 6 4}
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=5,36
        [/filter]

        [message]
            speaker=unit
            message= _ "Looks like someone left some supplies here."
        [/message]

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

        [gold]
            side=1
            amount=17
        [/gold]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=21,3
            [not]
                id=Baldras
            [/not]
        [/filter]

        [message]
            speaker=unit
            message= _ "It says, “Here lies Daneth, child of the Light, loyal defender of Lord and Land.” Whoever that was."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Maddock’s firstborn son."
        [/message]
        [message]
            speaker=unit
            message= _ "Oh."
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            id=Harper
            x,y=21,28
        [/filter]

        [message]
            speaker=Harper
            message= _ "That’s a deep well! Wonder how far down it goes. Guess I’ll chuck a rock down and find out."
        [/message]
        [message]
            speaker=Harper
            message= _ "...
...
..."
        [/message]
        [message]
            speaker=Harper
            message= _ "Plunk!"
        [/message]

        [store_unit]
            [filter]
                x,y=21,28
            [/filter]
            variable=stored_unit
        [/store_unit]

        {VARIABLE_OP stored_unit.experience add 2}

        [unstore_unit]
            variable=stored_unit
        [/unstore_unit]

        {CLEAR_VARIABLE stored_unit}
    [/event]

    [event]
        name=attack
        [filter]
            side=3
        [/filter]
        [filter_condition]
            [variable]
                name=turn_number
                less_than=4
            [/variable]
        [/filter_condition]

        [message]
            speaker=Lord Maddock
            message= _ "Hold there, soldier! Can we not come to terms without bloodshed?"
        [/message]
        [message]
            speaker=unit
            message= _ "..."
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "Hmm. Something is quite wrong indeed..."
        [/message]
    [/event]

    #
    # Special event - the human enemies become undead at night
    #

    [event]
        name=turn 4

        [message]
            speaker=narrator
            message= _ "<i>The sun sets...</i>"
        [/message]

        [message]
            speaker=narrator
            message= _ "Baldras and Harper watch, petrified, as the skin and flesh of their adversaries begin to rot away."
            image="wesnoth-icon.png"
        [/message]

        {INCIDENTAL_MUSIC the_city_falls.ogg}
    [/event]

    [event]
        name=prestart

        [set_variables]
            name=undead_transformation

            [value]
                human_type=Spearman
                undead_type=Skeleton
            [/value]
            [value]
                human_type=Swordsman
                undead_type=Deathblade
            [/value]
            [value]
                human_type=Pikeman
                undead_type=Revenant
            [/value]
            [value]
                human_type=Bowman
                undead_type=Skeleton Archer
            [/value]
            [value]
                human_type=Longbowman
                undead_type=Bone Shooter
            [/value]
            [value]
                human_type=Heavy Infantryman
                undead_type=Ghoul
            [/value]
            [value]
                human_type=Shock Trooper
                undead_type=Necrophage
            [/value]
            [value]
                human_type=Cavalryman
                undead_type=Skeleton Rider
            [/value]
            [value]
                human_type=Dragoon
                undead_type=Bone Knight
            [/value]
            [value]
                human_type=Lieutenant
                undead_type=Death Squire
            [/value]
            [value]
                human_type=General
                undead_type=Death Knight
            [/value]
            [value]
                human_type=Horseman
                undead_type=Skeleton Rider
            [/value]
            [value]
                human_type=Knight
                undead_type=Bone Knight
            [/value]
            [value]
                human_type=Lancer
                undead_type=Bone Knight
            [/value]
        [/set_variables]
    [/event]

#define FALLBACK
    [if]
        [variable]
            name=type_to_turn_into
            equals=$null
        [/variable]
        [then]
            [wml_message]
                logger=error
                message=_"Could not convert a $stored_changers[$i].type, please report!"
            [/wml_message]
            {VARIABLE type_to_turn_into $stored_changers[$i].type}
        [/then]
    [/if]
#enddef
    [event]
        name=new turn
        first_time_only=no

        {VARIABLE temp $turn_number}
        {VARIABLE_OP temp add 2}
        {VARIABLE_OP temp modulo 6}

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

            [variable]
                name=turn_number
                greater_than_equal_to=4
            [/variable]

            [then]
                [color_adjust]
                    red=255
                    green=100
                    blue=100
                [/color_adjust]
                [delay]
                    time=10
                [/delay]
                [color_adjust]
                    red=0
                    green=0
                    blue=0
                [/color_adjust]

                [terrain_mask]
                    x,y=16,33
                    mask="{campaigns/Liberty/masks/04_Unlawful_Orders_1.mask}"
                    alignment=even
                [/terrain_mask]

                [redraw]
                [/redraw]

                [disallow_recruit]
                    side=3
                    type=Spearman,Horseman,Cavalryman,Heavy Infantryman,Bowman
                [/disallow_recruit]
                [allow_recruit]
                    side=3
                    type=Skeleton,Skeleton Rider,Skeleton Archer
                [/allow_recruit]

                [store_unit]
                    [filter]
                        side=3
                    [/filter]

                    kill=yes
                    variable=stored_changers
                [/store_unit]

                [for]
                    array=stored_changers
                    variable=i
                    [do]
                        [for]
                            array=undead_transformation
                            variable=j
                            [do]
                                [if]
                                    [variable]
                                        name=stored_changers[$i].type
                                        equals=$undead_transformation[$j].human_type
                                    [/variable]

                                    [then]
                                        {VARIABLE type_to_turn_into $undead_transformation[$j].undead_type}
                                        {VARIABLE j 999}
                                    [/then]
                                [/if]
                            [/do]
                        [/for]

                        {FALLBACK}
                        [unit]
                            type=$type_to_turn_into
                            side=3
                            x,y=$stored_changers[$i].x,$stored_changers[$i].y
                            id=$stored_changers[$i].id
                            name=$stored_changers[$i].name
                            experience=$stored_changers[$i].experience
                            hitpoints=$stored_changers[$i].hitpoints
                            canrecruit=$stored_changers[$i].canrecruit
                            [variables]
                                [insert_tag]
                                    name=stored_trait
                                    variable=stored_changers[$i].modifications.trait
                                [/insert_tag]

                                turned_to_undead_at_least_once=yes
                            [/variables]
                            to_variable=changer
                        [/unit]
                        {CLEAR_VARIABLE type_to_turn_into}

                        [if]
                            [variable]
                                name=changer.hitpoints
                                greater_than=$changer.max_hitpoints
                            [/variable]

                            [then]
                                {VARIABLE changer.hitpoints $changer.max_hitpoints}
                            [/then]
                        [/if]

                        [unstore_unit]
                            variable=changer
                        [/unstore_unit]
                    [/do]
                [/for]

                {CLEAR_VARIABLE stored_changers,changer}
            [/then]
        [/if]
    [/event]

    [event]
        name=new turn
        first_time_only=no

        {VARIABLE temp $turn_number}
        {VARIABLE_OP temp modulo 6}

        [if]
            [variable]
                name=temp
                equals=1
            [/variable]

            [variable]
                name=turn_number
                greater_than_equal_to=4
            [/variable]

            [then]
                [color_adjust]
                    red=255
                    green=255
                    blue=100
                [/color_adjust]
                [delay]
                    time=10
                [/delay]
                [color_adjust]
                    red=0
                    green=0
                    blue=0
                [/color_adjust]

                [terrain_mask]
                    x,y=16,33
                    mask="{campaigns/Liberty/masks/04_Unlawful_Orders_2.mask}"
                    alignment=even
                [/terrain_mask]

                [redraw]
                [/redraw]

                [disallow_recruit]
                    side=3
                    type=Skeleton,Skeleton Rider,Skeleton Archer
                [/disallow_recruit]
                [allow_recruit]
                    side=3
                    type=Spearman,Horseman,Cavalryman,Heavy Infantryman,Bowman
                [/allow_recruit]

                [store_unit]
                    [filter]
                        side=3
                    [/filter]

                    kill=yes
                    variable=stored_changers
                [/store_unit]

                [for]
                    array=stored_changers
                    [do]
                        [for]
                            array=undead_transformation
                            variable=j
                            [do]
                                [if]
                                    [variable]
                                        name=stored_changers[$i].type
                                        equals=$undead_transformation[$j].undead_type
                                    [/variable]

                                    [then]
                                        {VARIABLE type_to_turn_into $undead_transformation[$j].human_type}
                                        [break][/break]
                                    [/then]
                                [/if]
                            [/do]
                        [/for]

                        {FALLBACK}
                        [if]
                            [variable]
                                name=stored_changers[$i].variables.turned_to_undead_at_least_once
                                equals=yes
                            [/variable]

                            [then]
                                [unit]
                                    type=$type_to_turn_into
                                    side=3
                                    x,y=$stored_changers[$i].x,$stored_changers[$i].y
                                    id=$stored_changers[$i].id
                                    name=$stored_changers[$i].name
                                    experience=$stored_changers[$i].experience
                                    hitpoints=$stored_changers[$i].hitpoints
                                    canrecruit=$stored_changers[$i].canrecruit
                                    [modifications]
                                        [insert_tag]
                                            name=trait
                                            variable=stored_changers[$i].variables.stored_trait
                                        [/insert_tag]
                                    [/modifications]
                                    [variables]
                                        turned_to_undead_at_least_once=yes
                                    [/variables]
                                    to_variable=changer
                                [/unit]
                            [/then]

                            [else]
                                [unit]
                                    type=$type_to_turn_into
                                    side=3
                                    x,y=$stored_changers[$i].x,$stored_changers[$i].y
                                    experience=$stored_changers[$i].experience
                                    hitpoints=$stored_changers[$i].hitpoints
                                    canrecruit=$stored_changers[$i].canrecruit
                                    random_traits=yes
                                    generate_name=yes
                                    to_variable=changer
                                [/unit]
                            [/else]
                        [/if]
                        {CLEAR_VARIABLE type_to_turn_into}

                        [if]
                            [variable]
                                name=changer.hitpoints
                                greater_than=$changer.max_hitpoints
                            [/variable]

                            [then]
                                {VARIABLE changer.hitpoints $changer.max_hitpoints}
                            [/then]
                        [/if]

                        [unstore_unit]
                            variable=changer
                        [/unstore_unit]
                    [/do]
                [/for]

                {CLEAR_VARIABLE stored_changers,changer}
            [/then]
        [/if]
    [/event]
#undef FALLBACK

    [event]
        name=turn 4
        [message]
            speaker=Harper
            message= _ "By the Light! Them things look like evil spirits! Are they those undead you told me about, Uncle?"
        [/message]
        [message]
            speaker=Baldras
            message= _ "They bears some likeness, but these men almost seem half alive. This be some kind of truly dreadful sorcery."
        [/message]
    [/event]

    [event]
        name=turn 7
        {INCIDENTAL_MUSIC nunc_dimittis.ogg}
        [message]
            speaker=Lord Maddock
            message= _ "So, their human aspect returns. Whatever these creatures are, we shall crush them all under the light of the sun."
        [/message]
    [/event]

    #
    # Victory
    #
    [event]
        name=last breath
        [filter]
            id=Kestrel
        [/filter]
        [message]
            speaker=second_unit
            message= _ "Who are you? What are you?"
        [/message]
        [message]
            speaker=Kestrel
            message= _ "We... are accursed. We were the soldiers of Prince Eldred, the King’s son and betrayer... when the Prince was slain at the hands of the mage Delfador, those of us who bore witness to it were warped into these twisted forms. Now, our mortal bodies pass... into another plane of hellish existence..."
        [/message]

        [kill]
            id=Kestrel
            animate=yes
            fire_event=no
        [/kill]

        [message]
            speaker=Lord Maddock
            message= _ "Such is the price for treachery."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Maddock, we helped you defend your city. Will you help us now?"
        [/message]
        # he really doesn't want to help, but...
        [message]
            speaker=Lord Maddock
            message= _ "..."
        [/message]
        # guess he still has a little bit of a conscience
        [message]
            speaker=Lord Maddock
            message= _ "<i>Listen carefully. I shall not openly speak against Asheviere seeing as some of her spies are in the city... however, rest assured, I certainly do not trust the Queen and her questionable tactics.</i>"
        [/message]
        [message]
            speaker=Baldras
            message= _ "<i>What can ya offer us then?</i>"
        [/message]
        [message]
            speaker=Lord Maddock
            message= _ "<i>Well, I do not normally make my relationship with them known, but I can make an exception. Southeast of here, in Carcyn, you may find assistance from one of my... contacts. Their methods should be better suited to your needs. As for your homes, I cannot offer you protection against Weldyn, but I can arrange for some roads to be closed to delay their patrols. That is the most I can do for you.</i>"
        [/message]
        [message]
            speaker=Baldras
            message= _ "<i>Hmph. Clear that you won’t help us fight, but I gots no more time to be stayin’ here. If we is going to resist the Crown a second time, we needs ourselves a good plan. Hope that you’re not sending us to our deaths, Maddock.</i>"
        [/message]

        {CLEAR_VARIABLE undead_transformation}
        {CLEAR_VARIABLE temp}

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    #
    # Loss conditions - turns run out
    #
    [event]
        name=time over
        [message]
            speaker=Baldras
            message= _ "More troops be coming from the south! With all them reinforcements, we gots no chance to defend Elensefar!"
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=defeat

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message=_ "Asheviere’s armies assembled and struck before the nascent rebellion could even be planned. Without the necessary forces, Annuvin soon fell under Weldyn’s absolute control."
        [/message]
    [/event]

    {LIBERTY_DEATHS}
[/scenario]


#textdomain wesnoth-l
[scenario]
    id=05_Hide_and_Seek
    next_scenario=06_The_Hunters
    victory_when_enemies_defeated=no
    name= _ "Hide and Seek"
    map_file=05_Hide_and_Seek.map
    turns=28

    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {DAWN}

    {INTRO_AND_SCENARIO_MUSIC knolls.ogg underground.ogg}
    {EXTRA_SCENARIO_MUSIC the_deep_path.ogg}
    {EXTRA_SCENARIO_MUSIC nunc_dimittis.ogg}

    [story]
        [part]
            story= _ "22 Deeproot, 501 YW

Been a tough few days since we left Elensefar with all them patrols running around. Going by boat along the Great River, we has been managing to avoid them Wesnothians, but being constantly on the lookout be real taxing. I truly be starting to feel that tiredness in my bones... old men like me should be sitting back at home, resting our grey bodies and watchin’ over them younger folk growing up. I don’t got no business here, running around as some outlaw. Maybe if I was ten years younger..."
            background=story/frontier.jpg
        [/part]
        [part]
            story= _ "Anyway, the messenger I sent back to Relana should be in Delwyn already. We should be arriving to Carcyn soon too, to where that coward Maddock said his ‘contact’ be. Truths be told, I don’t know how this’ll be turning out, especially since I don’t be no social butterfly like sis were. Don’t like me no city folk really. But I’ll deal with them if I gots to."
            background=story/frontier.jpg
        [/part]
    [/story]

    {LIBERTY_BIGMAP {JOURNEY_05_NEW} }

    [side]
        type=Bandit
        id=Baldras
        side=1
        color=black
        canrecruit=yes
        controller=human
        recruit=Thug,Footpad,Poacher
        gold=0
        income=-2
        village_gold=0
        team_name=good_guys
        user_team_name=_"Rebels"
        shroud=no
        fog=yes
        share_vision=none
    [/side]

    [side]
        type=Master Bowman
        id=Quentin
        name= _ "Quentin"
        side=2
        color=red
        canrecruit=yes
        controller=ai
        user_team_name=_"Weldyn"
        team_name=bad_guys
        [ai]
            ai_algorithm=idle_ai
            passive_leader=yes
        [/ai]
        shroud=no
        fog=yes
    [/side]

    [side]
        no_leader=yes
        side=3
        color=red
        controller=ai
        team_name=bad_guys
        user_team_name=_"Weldyn"
        [ai]
            aggression=1.0
            caution=0.0
            grouping=no
            simple_targeting=yes
        [/ai]
        shroud=no
        fog=yes
        {FLAG_VARIANT loyalist}
    [/side]

    {STARTING_VILLAGES_ALL 2}

    [side]
        type=Rogue
        id=Hans
        name= _ "Hans"
        side=4
        color=purple
        canrecruit=yes
        controller=ai
        facing=sw
        [ai]
            passive_leader=yes
        [/ai]
        team_name=good_guys
        user_team_name=_"Rebels"
        shroud=no
        fog=yes
        share_vision=none
        {FLAG_VARIANT6 ragged}
    [/side]

    #
    # Prestart events
    #
    [event]
        name=prestart

        {PLACE_IMAGE "scenery/oak-leaning.png~FL(horiz)" 12 37}

        [store_side]
            side=1
            variable=stored_side_1
        [/store_side]

        [objectives]
            side=1
            [objective]
                description= _ "Enter the Grey Woods"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Baldras"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Harper"
                condition=lose
            [/objective]

            [note]
                description= _ "In fog, units always see one hex further than they can move."
            [/note]

            {TURNS_RUN_OUT}
        [/objectives]

        #some various city props
        {PLACE_IMAGE scenery/well.png 10 36}

        {PLACE_IMAGE items/scarecrow.png 15 22}

        {PLACE_IMAGE items/straw-bale1.png 3 23}
        {PLACE_IMAGE "items/straw-bale2.png~FL(horiz)" 4 23}
        {PLACE_IMAGE "items/straw-bale1.png~FL(horiz)" 4 22}
        {PLACE_IMAGE items/straw-bale1.png 32 27}

        {PLACE_IMAGE "items/archery-target-right.png~FL(horiz)" 4 44}
        {PLACE_IMAGE "items/archery-target-right.png~FL(horiz)" 6 45}
        {PLACE_IMAGE "items/archery-target-right.png~FL(horiz)" 5 47}

        # Here we preplace a few guards

#define SEEKER X Y TYPE
    [unit]
        type={TYPE}
        generate_name=yes
        x,y={X},{Y}
        side=2
        random_traits=yes
    [/unit]
#enddef

        {SEEKER 2 45 (Bowman)}
        {SEEKER 3 47 (Bowman)}

        {RANDOM "a,b,c"}
        [switch]
            variable=random

            [case]
                value=a

                [store_locations]
                    x= 7,19,24,30,17,25, 2, 6,18, 2,24,13,16, 3,15,17,30,19, 3,27, 9
                    y=13, 9,10,13,18,21,22,23,27,28,30,32,32,37,37,38,38,41,42,43,47
                    variable=guard_locs
                [/store_locations]
            [/case]

            [case]
                value=b

                [store_locations]
                    x= 2,25,14,30, 5,16,25, 6, 2,33,16,22,13, 3,15,17,28, 3, 7,21
                    y=10,10,13,13,19,20,21,23,28,28,31,31,32,37,37,38,39,42,48,48
                    variable=guard_locs
                [/store_locations]
            [/case]

            [case]
                value=c

                [store_locations]
                    x=22, 7,16,26,15, 4,31,19,15,30, 5, 4, 8,15,17,27,19, 3,20
                    y=12,13,13,15,18,22,23,26,27,29,32,35,35,37,38,39,41,42,46
                    variable=guard_locs
                [/store_locations]
            [/case]
        [/switch]

        [for]
            array=guard_locs
            # The guard positions are designed to work with 4MP guards only, so
            # we need to make sure the guards cannot get the quick trait, and we
            # do this by randomizing their traits manually.
            [do]
                [set_variables]
                    name=traits_without_quick

                    [value]
                        {TRAIT_STRONG}
                    [/value]
                    [value]
                        {TRAIT_RESILIENT}
                    [/value]
                    [value]
                        {TRAIT_FEARLESS}
                    [/value]
                    [value]
                        {TRAIT_INTELLIGENT}
                    [/value]
                [/set_variables]

                {VARIABLE_OP first_trait rand "0..3"}
                [set_variables]
                    name=this_guard_traits
                    to_variable=traits_without_quick[$first_trait].trait
                [/set_variables]

                # To prevent the same trait from being picked twice, we need to find
                # and remove the first picked trait from the array.
                [for]
                    array=traits_without_quick
                    variable=j
                    [do]
                        [if]
                            [variable]
                                name=traits_without_quick[$j].trait.id
                                equals=$traits_without_quick[$first_trait].trait.id
                            [/variable]

                            [then]
                                {CLEAR_VARIABLE traits_without_quick[$first_trait]}
                            [/then]
                        [/if]
                    [/do]
                [/for]

                {VARIABLE_OP second_trait rand "0..2"}
                [set_variables]
                    name=this_guard_traits
                    mode=append
                    to_variable=traits_without_quick[$second_trait].trait
                [/set_variables]

                {RANDOM "Shock Trooper,Iron Mauler"}

                [unit]
                    type=$random
                    side=2
                    x,y=$guard_locs[$i].x,$guard_locs[$i].y
                    generate_name=yes
                    random_traits=no
                    [modifications]
                        [insert_tag]
                            name=trait
                            variable=this_guard_traits
                        [/insert_tag]
                    [/modifications]
                [/unit]

                {CLEAR_VARIABLE this_guard_traits}
            [/do]
        [/for]

        {CLEAR_VARIABLE guard_locs,traits_without_quick,first_trait,second_trait,random}

        [store_unit]
            [filter]
                id=Baldras
            [/filter]

            kill=yes
            variable=stored_Baldras
        [/store_unit]

        [unit]
            side=1
            type=Boat
            id=Boat
            x,y=1,4
        [/unit]

        [hide_unit]
            x,y=1,4
        [/hide_unit]

        [item]
            x,y=1,4
            image=units/transport/boat.png
        [/item]
    [/event]

    #
    # Starting conversation and actions
    #
    [event]
        name=start

        [message]
            speaker=narrator
            message= _ "Relentlessly pursued by riders patrolling the road to Elensefar, Baldras and his men traveled unseen along the swampy banks of the Great River to the city of Carcyn. They hid until nightfall, then crept out to find the help Lord Maddock hinted was here."
            image="wesnoth-icon.png"
        [/message]

        [kill]
            x,y=1,4
            animate=no
            fire_event=no
        [/kill]

        [remove_item]
            x,y=1,4
        [/remove_item]

        [move_unit_fake]
            side=1
            type=Boat
            x=1,7
            y=4,5
        [/move_unit_fake]

        [item]
            x,y=7,5
            image=units/transport/boat.png
        [/item]

        [move_unit_fake]
            side=1
            type=$stored_Baldras.type
            x=7,7
            y=5,6
        [/move_unit_fake]

        [unstore_unit]
            variable=stored_Baldras
        [/unstore_unit]

        [redraw]
            side=1
        [/redraw]

        [recall]
            id=Harper
            x,y=8,5
        [/recall]

        [message]
            speaker=Harper
            message= _ "Wow, is that Carcyn in the distance? Look at how grand some of them spires be!"
        [/message]

        [message]
            speaker=Baldras
            message= _ "Not since I were a young lad did I come this far south. Maybe it looks impressive now, but city life weren’t never something real nice. Them city folk be real impatient and mean. Always wantin’ some price for their help, too."
        [/message]

        [message]
            speaker=Harper
            message= _ "Well, we need their help now, don’t we? So we got to figure out a way to get to Lord Maddock’s friend. But he didn’t say anything about who that was."
        [/message]

        [message]
            speaker=Baldras
            message= _ "Harper, when a noble lord says he don’t want some kind of relationship known, it means some kind o’ connection with the black market. We be looking for criminals, probably some thieves’ den. Or, maybe they be looking for us."
        [/message]

        [move_unit_fake]
            type=Thief
            side=4
            x=7,6
            y=9,6
        [/move_unit_fake]

        [unit]
            type=Thief
            side=4
            x,y=6,6
            random_traits=yes
            id=Link
            name= _ "Link"
        [/unit]

        [message]
            speaker=Baldras
            message= _ "Right on time."
        [/message]

        [message]
            speaker=Harper
            message= _ "How do we know we can trust him?"
        [/message]

        [message]
            speaker=Link
            message= _ "If you were one of my quarries, your throat would be slit by now, boy. As it is, you two are still in imminent danger. Just a week ago, the Crown sent a contingent of heavy infantry here to supervise the city. They’re patrolling the streets and forests for us."
        [/message]

        [message]
            speaker=Baldras
            message= _ "I be assuming they’ll also try to stop us if they see us."
        [/message]

        [message]
            speaker=Link
            message= _ "Very likely. Now hurry, you must make it past the city into the Grey Woods. There is a small path in the southeast that leads into the forest. Look for the signpost. My brother Hans will guide you from there. Avoid the soldiers if you can."
        [/message]

        {HIGHLIGHT_IMAGE 26 48 scenery/signpost.png ()}

        [scroll_to_unit]
            id=Baldras
        [/scroll_to_unit]

        {MOVE_UNIT id=Link 5 8}

        [kill]
            id=Link
            animate=no
            fire_event=no
        [/kill]

        [redraw]
        [/redraw]

        {CLEAR_VARIABLE stored_Baldras}
    [/event]

    [event]
        name=sighted
        [filter]
            side=2
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        [redraw]
            side=1
        [/redraw]

        [message]
            speaker=second_unit
            message= _ "Looks like these guards be holding stationary posts. If we’re careful, we can get ourselves around them unnoticed."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Harper, you younger and faster folks needs to be our eyes. Scout ahead and find a way past them guards, but make sure ya don’t get yourselves spotted..."
        [/message]
    [/event]

    [event]
        name=side 2 turn
        first_time_only=no

        [if]
            [have_unit]
                side=1

                [filter_vision]
                    visible=yes
                    side=2
                [/filter_vision]

                [or]
                    side=1

                    [filter_vision]
                        visible=yes
                        side=3
                    [/filter_vision]
                [/or]
            [/have_unit]

            [then]
                # if player is visible to enemies, flip all nearby enemies to side 3,
                # which is the aggressive side and thus the nearby enemies will begin
                # to pursue the player

                [modify_unit]
                    [filter]
                        side=2

                        [filter_location]
                            [filter]
                                side=1
                            [/filter]

                            {QUANTITY radius 8 11 13}
                        [/filter_location]
                    [/filter]

                    side=3
                [/modify_unit]
            [/then]

            [else]
                # if player isn't seen by enemies anymore, make all enemies idle again

                [modify_unit]
                    [filter]
                        side=3
                    [/filter]

                    side=2
                [/modify_unit]
            [/else]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            side=3
        [/filter]

        [message]
            speaker=unit
            message= _ "Who goes there? Halt!"
        [/message]
        [message]
            speaker=Harper
            message= _ "They’ve seen us! <i>Run</i>!"
        [/message]
    [/event]

    [event]
        name=attack_end
        [filter]
            side=2
        [/filter]
        [filter_second]
            side=1
        [/filter_second]

        {IF_VAR $second_unit.hitpoints greater_than 0 (
            [then]
                [message]
                    speaker=Baldras
                    message= _ "Quick, back into the shadows! Maybe we can still lose them!"
                [/message]
            [/then]
        )}
    [/event]

    [event]
        name=sighted
        [filter]
            id=Hans
        [/filter]
        [filter_second]
            side=1
        [/filter_second]
        [message]
            speaker=unit
            message= _ "This way, into the forest! We’ll be able to lose them in the Grey Woods."
        [/message]
    [/event]

    #
    # Special event - if someone besides Baldras goes to the end, you get a
    # message
    #
    [event]
        name=moveto

        [filter]
            side=1

            [filter_adjacent]
                id=Hans
            [/filter_adjacent]

            [not]
                id=Baldras
            [/not]
        [/filter]

        [message]
            speaker=Hans
            message= _ "You can come if you wish, but we are mostly interested in speaking to Baldras."
        [/message]

        [allow_undo][/allow_undo]
    [/event]

    #
    # Victory
    #
    [event]
        name=moveto

        [filter]
            x=26
            y=48
            id=Baldras
        [/filter]

        [message]
            speaker=Baldras
            message= _ "I haven’t run so much in years. Feels like I be a real outlaw now, infiltrating a heavily guarded city relyin’ on nothing but the cover of darkness and my wits."
        [/message]

        [message]
            speaker=Harper
            message= _ "It was fun, wasn’t it?"
        [/message]

        [message]
            speaker=Baldras
            message= _ "Perhaps a little."
        [/message]

        [message]
            speaker=Hans
            message= _ "Enough chatter, you still have some guards on your tail. We need to head deeper into the Grey Woods to lose them."
        [/message]

        [message]
            speaker=Baldras
            message= _ "Lead the way."
        [/message]

        [modify_side]
            side=1
            gold=$stored_side_1.gold
        [/modify_side]

        {CLEAR_VARIABLE stored_side_1}

        [endlevel]
            result=victory
            bonus=no
            {NEW_GOLD_CARRYOVER 100}
        [/endlevel]
    [/event]

    #
    # Loss conditions - turns run out
    #
    [event]
        name=time over
        [message]
            speaker=Baldras
            message= _ "Blast it, we was too slow! With the sun rising already, them guards will have no trouble spotting us now..."
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    {LIBERTY_DEATHS}
[/scenario]

#undef SEEKER


#textdomain wesnoth-l
[scenario]
    id=06_The_Hunters
    name= _ "The Hunters"
    victory_when_enemies_defeated=no
    next_scenario=07_Glory
    map_file=06_The_Hunters.map
    turns=27
    {FIRST_WATCH}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}
    {MORNING}
    {MORNING}
    {AFTERNOON}
    {AFTERNOON}
    {AFTERNOON}
    {DUSK}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {DAWN}
    {MORNING}

    {INTRO_AND_SCENARIO_MUSIC "transience.ogg" "the_king_is_dead.ogg"}
    {EXTRA_SCENARIO_MUSIC siege_of_laurelmor.ogg}
    {EXTRA_SCENARIO_MUSIC "casualties_of_war.ogg"}
    {EXTRA_SCENARIO_MUSIC underground.ogg}

    [story]
        [part]
            story= _ "24 Deeproot, 501 YW

The sun don’t really shine at all in these Grey Woods, but truth be told, I has been getting used to it more and more. Lounging out in the warm daylight, talkin’ with Erwen while watching them kids play out in the fields... those times were so long ago. Our lives weren’t never real peaceful, but back then, we had our homes and our friends and our family... now we be creatures of the dark."
            background=story/frontier.jpg
        [/part]
        [part]
            story= _ "It be real lonesome like this. I still has me Harper, and I be grateful for the boy, but he don’t really understand an old man like me. I know the past be the past, but I just can’t help but think of sis in times like these. How she used to be dragging me out on some silly little romp, a little job here and there for some gold or lil trinket, or sometimes just for fun... I never wanted to go, of course. I were always real lazy. Still am, even now."
            background=story/frontier.jpg
        [/part]
        [part]
            story= _ "Then, Harper tells me, “Come on Uncle, we’re on an adventure! Don’t be so mopey, live a little!” I know he be trying to be cheery, but he really don’t know how much he be reminding me of her sometimes..."
            background=story/frontier.jpg
        [/part]
        [part]
            story= _ "I must be strong. That’s what I tells myself. I should be strong, but... I don’t know what be keeping me going, if it be this misguided sense of pride, or my duties to the village, or Harper, or even just remembering the past, making some futile attempts to go back to better times."
            background=story/frontier.jpg
        [/part]
        [part]
            story= _ "Either way, I be here now, on this adventure."
            background=story/frontier.jpg
        [/part]
    [/story]

    {LIBERTY_BIGMAP {JOURNEY_06_NEW} }

    [side]
        side=1
        color=black
        type=Highwayman
        id=Baldras
        canrecruit=yes
        controller=human
        fog=yes
        recruit=Thug,Footpad,Poacher
        {GOLD 150 125 100}
        village_gold=1
        team_name=good_guys
        user_team_name=_"Rebels"
    [/side]

    {STARTING_VILLAGES 1 10}

    [side]
        type=Shadow Lord
        id=Helicrom
        name= _ "Helicrom"
        profile=portraits/helicrom.png
        facing=sw
        side=2
        color=purple
        canrecruit=yes
        recruit=Rogue Mage,Shadow Mage,Thief,Rogue
        {GOLD 120 90 60}
        village_gold=1
        controller=human
        fog=yes
        share_vision=all
        team_name=good_guys
        user_team_name=_"Rebels"
    [/side]

    [side]
        side=3
        color=red
        type=Shock Trooper
        id=Linneus
        name= _ "Linneus"
        facing=sw
        canrecruit=yes
        recruit=
        gold=100
        controller=ai
        shroud=yes
        fog=yes
        share_vision=none
        team_name=bad_guys
        user_team_name=_"Weldyn"
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        side=4
        color=red
        type=Lieutenant
        id=Archarel
        name= _ "Archarel"
        canrecruit=yes
        recruit=
        gold=0
        income=-2
        controller=ai
        shroud=yes
        fog=yes
        share_vision=none
        team_name=bad_guys
        user_team_name=_"Weldyn"
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        side=5
        controller=ai
        no_leader=yes
        hidden=yes
        team_name=monsters
        color=brown
    [/side]

    {STARTING_VILLAGES 4 10}

    [event]
        name=prestart

        [micro_ai]
            side=3
            ai_type=messenger_escort
            action=add

            [filter]
                side=3
                canrecruit=yes
            [/filter]
            waypoint_x,waypoint_y=7,4
        [/micro_ai]

        {PLACE_IMAGE scenery/signpost.png 11 7}
        {PLACE_IMAGE scenery/leanto.png 23 3}
        {PLACE_IMAGE scenery/whirlpool.png 3 26}
        {PLACE_IMAGE items/sword.png 38 2}
        {PLACE_IMAGE items/coffin-closed.png 23 26}
        {PLACE_IMAGE items/key.png 10 12}

        {VARIABLE has_key 0}

        [objectives]
            side=1,2
            [objective]
                description= _ "Kill all enemy patrols before they reach the outpost"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Baldras"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Harper"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Helicrom"
                condition=lose
            [/objective]
            [objective]
                description= _ "Any patrol units survive when turns run out"
                condition=lose
            [/objective]
            [objective]
                description= _ "Any allied unit is sighted by the outpost guards"
                condition=lose
            [/objective]

            [gold_carryover]
                bonus=no
                carryover_percentage=40
            [/gold_carryover]
        [/objectives]

        [store_unit]
            variable=stored_Linneus
            kill=yes
            [filter]
                id=Linneus
            [/filter]
        [/store_unit]
        #set up units

        {GENERIC_UNIT 2 (Rogue Mage) 18 21}
        {GENERIC_UNIT 2 (Shadow Mage) 18 22}
        {GENERIC_UNIT 4 (Heavy Infantryman) 7 2} {GUARDIAN}
        {GENERIC_UNIT 4 (Heavy Infantryman) 7 6} {GUARDIAN}
    [/event]

    #
    # Starting conversation and actions
    #

#define TROOPER TYPE TO_X TO_Y
    [move_unit_fake]
        type={TYPE}
        side=3
        x=39,{TO_X}
        y=23,{TO_Y}
    [/move_unit_fake]
    {GENERIC_UNIT 3 {TYPE} {TO_X} {TO_Y}}
    [+unit]
        facing=sw
    [/unit]
#enddef

    [event]
        name=start

        [recall]
            id=Harper
        [/recall]

        [message]
            speaker=Baldras
            message= _ "The leader, I presumes."
        [/message]
        [message]
            speaker=Helicrom
            message= _ "Indeed, I am Lord Helicrom, the Crow of the Grey Woods. We are acquaintances of Lord Maddock, who sent word to us of your predicament. I believe we can work something out for your situation."
        [/message]
        [message]
            speaker=Baldras
            message= _ "What be your pursuits?"
        [/message]
        [message]
            speaker=Helicrom
            message= _ "The former king’s magic ministry kept a tight control on the training and employment of mages in Wesnoth. Those of us who dared to... depart from the curriculum were dealt with harshly. Many of us were forced to escape here to continue our study of our brand of magic. Our security and secrecy are not cheap."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Then you be fellow outlaws. But why do you wants to help us?"
        [/message]
        [message]
            speaker=Helicrom
            message= _ "<i>Quid pro quo.</i> Our aid is never given freely. You have something that may be useful to us."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Manpower. Mages be no good at fighting, I knows. But what for?"
        [/message]
        [message]
            speaker=Helicrom
            message= _ "Understand this. Any weakening of the Throne of Wesnoth, whether it be occupied by king or queen, aids us. To accomplish that, we must destabilize their forces in this region. The key is Halstead."
        [/message]
        [message]
            speaker=Harper
            message= _ "The great fort standing between Aldril and Elensefar?"
        [/message]
        [message]
            speaker=Baldras
            message= _ "Aye, Harper. What the mage says be no surprise. It be a bastion of central importance, rivalin’ Elensefar even. Maddock said the Queen’s troops were gathering there. But we gots no way to fight a war with them, not since Maddock won’t send his soldiers to battle."
        [/message]
        [message]
            speaker=Helicrom
            message= _ "Know this, Baldras. During the past week, several patrols have again ventured across the Great River into Annuvin. A woman named Relana opposed them with a small militia and was victorious, but with heavy losses. The Crown, however, has begun to take notice of this rebellion and is massing forces within Halstead. When its armies are raised, none of your little villages will be able to resist them. Your only choice would be to flee farther north into orcish territory."
        [/message]
        [message]
            speaker=Harper
            message= _ "We’d never survive there. But would it be so bad if we just swore fealty to the Queen?"
        [/message]
        [message]
            speaker=Baldras
            message= _ "Only if we gots no other choice. Let’s hear the mage’s plan first."
        [/message]
        [message]
            speaker=Helicrom
            message= _ "I’m not asking you to fight a war. A direct fight against Weldyn’s armies would be undoubtedly foolish. However, we have other means within our grasp. From Dan Tonk to Halstead, the fastest path lies through the pass between the Brown Hills and the Gryphon Mountains followed by the trek through these Grey Woods. We are in prime position to gnaw away at their troops, crippling their forces before they ever arrive at their destination."
        [/message]
        [message]
            speaker=Baldras
            message= _ "Then what?"
        [/message]
        [message]
            speaker=Helicrom
            message= _ "I am sure you can guess, magistrate."
        [/message]
        [message]
            speaker=Baldras
            message= _ "You means to sack Halstead itself."
        [/message]
        [message]
            speaker=Harper
            message= _ "There’s no way we can fight them all... can we?"
        [/message]
        [message]
            speaker=Baldras
            message= _ "I don’t know. But, for now, ambushing them patrols be easy enough. That’ll slow them Wesnothians down enough for us to figure out the next step."
        [/message]
        [message]
            speaker=Helicrom
            message= _ "In the last day, my scouts have counted five platoons of troops marching towards the garrison. We must eliminate them all before they reach the outpost at the end of the woods. The outpost also must not be alerted to our presence, or we will have the bulk of their forces upon us."
        [/message]

        {SCROLL_TO 7 4}

        [delay]
            time=1500
        [/delay]

        [message]
            speaker=Harper
            message= _ "The first platoon approaches..."
        [/message]

        {SCROLL_TO 39 23}
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=37,22
            radius=3
        [/lift_fog]

        {TROOPER "Heavy Infantryman" 38 22}
        {TROOPER "Heavy Infantryman" 38 21}

#ifdef EASY
        {TROOPER "Heavy Infantryman" 37 23}
#else
        {TROOPER "Shock Trooper"     37 23}
#endif

#ifdef HARD
        {TROOPER "Shock Trooper"     38 23}
#else
        {TROOPER "Heavy Infantryman" 38 23}
#endif

        [move_unit_fake]
            type=$stored_Linneus.type
            side=$stored_Linneus.side
            x=39,37
            y=23,22
        [/move_unit_fake]
        [unstore_unit]
            variable=stored_Linneus
        [/unstore_unit]
        {CLEAR_VARIABLE stored_Linneus}

        [delay]
            time=750
        [/delay]

        [message]
            speaker=Helicrom
            message= _ "My men and I shall pincer them from the other side of this path. When we are done, no one shall fear the open roads and night sky more than the armies of Weldyn. Strike quickly, strike silently... and leave no one alive."
        [/message]

        [store_unit]
            [filter]
                id=Helicrom
            [/filter]
            variable=Helicrom
            kill=yes
        [/store_unit]
        [move_unit_fake]
            type=Shadow Lord
            side=2
            x=17,20
            y=22,18
        [/move_unit_fake]
        [kill]
            x,y=18,21
        [/kill]
        [move_unit_fake]
            type=Rogue Mage
            side=2
            x=18,20
            y=21,18
        [/move_unit_fake]
        [kill]
            x,y=18,22
        [/kill]
        [move_unit_fake]
            type=Shadow Mage
            side=2
            x=18,20
            y=22,18
        [/move_unit_fake]

        [terrain]
            x=16
            y=21
            terrain=Rb
        [/terrain]
        [terrain]
            x=17,18
            y=22,22
            terrain=Gll^Em
        [/terrain]
        [terrain]
            x=18
            y=21
            terrain=Re
        [/terrain]
        [redraw][/redraw]

        {SCROLL_TO 32 8}

        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=32,8
            radius=4
        [/lift_fog]

        [move_unit_fake]
            type=Shadow Lord
            side=2
            x=28,32
            y=11,8
        [/move_unit_fake]
        [unstore_unit]
            variable=Helicrom
            x,y=32,8
        [/unstore_unit]
        [move_unit_fake]
            type=Rogue Mage
            side=2
            x=28,31
            y=11,9
        [/move_unit_fake]
        {GENERIC_UNIT 2 (Rogue Mage) 31 9}
        [move_unit_fake]
            type=Shadow Mage
            side=2
            x=28,31
            y=11,9
        [/move_unit_fake]
        {GENERIC_UNIT 2 (Shadow Mage) 32 9}

        [capture_village]
            [filter_side]
                side=2
            [/filter_side]
            x=26-39
            y=4-12
        [/capture_village]

        [redraw]
            side=2
            clear_shroud=yes
        [/redraw]
        {CLEAR_VARIABLE Helicrom}
    [/event]

    #
    # Special Event - when you attack the bad guys for the first time they react
    #
    [event]
        name=attack
        [filter_second]
            side=3
        [/filter_second]
        [message]
            speaker=Linneus
            message= _ "It’s an ambush! Run!"
        [/message]
    [/event]

    # more special events

    [event]
        name=moveto
        [filter]
            id=Helicrom
            x,y=38,2
        [/filter]

        [message]
            speaker=Helicrom
            message= _ "Ah, here it is. I was wondering where I had misplaced my favorite blade."
        [/message]

        [sound]
            name=sword-1.ogg
        [/sound]

        [object]
            id=helicrom_buff
            take_only_once=yes
            silent=yes
            duration=forever
            [filter]
                x,y=38,2
            [/filter]
            [effect]
                apply_to=attack
                range=melee
                increase_damage=1
            [/effect]
        [/object]

        {REMOVE_IMAGE 38 2}
    [/event]

    [event]
        name=moveto
        [filter]
            side=1,2
            x,y=23,3
        [/filter]

        [message]
            speaker=unit
            message= _ "Hey, I found some old coins in this shack."
        [/message]

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

        [gold]
            side=1,2
            amount=16
        [/gold]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x,y=3,26
        [/filter]

        [sound]
            name=water-blast.wav
        [/sound]

        [unit]
            type=Tentacle of the Deep
            side=5
            x,y=2,26
            max_hitpoints=60
            hitpoints=60
            level=3
            animate=yes
        [/unit]

        [message]
            speaker=unit
            message= _ "Bleagh, a slimy tentacle. Why’s it so big?"
        [/message]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1,2
            x,y=10,12
        [/filter]

        [message]
            speaker=unit
            message= _ "There’s a rusty key here. I wonder if it could be useful?"
        [/message]

        {VARIABLE has_key 1}

        {REMOVE_IMAGE 10 12}
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1,2
            x,y=23,26
            [not]
                id=Baldras,Helicrom
            [/not]
        [/filter]

        [if]
            [variable]
                name=has_key
                numerical_equals=0
            [/variable]
            [then]
                [message]
                    speaker=unit
                    message= _ "There is a waterlogged coffin here."
                [/message]
            [/then]
        [/if]

        [if]
            [variable]
                name=has_key
                numerical_equals=1
            [/variable]
            [then]
                [message]
                    speaker=unit
                    message= _ "Hey, that key fits in this coffin. Should I open it?"
                [/message]
                [message]
                    speaker=Baldras
                    [option]
                        label= _ "No, that be a terrible idea."
                        [command]
                            [allow_undo]
                            [/allow_undo]
                        [/command]
                    [/option]
                    [option]
                        label= _ "Fine, do it."
                        [command]
                            [sound]
                                name=zombie-hit-4.ogg
                            [/sound]

                            [unit]
                                type=Ghoul
                                side=5
                                x,y=23,26
                                animate=yes
                            [/unit]

                            [message]
                                speaker=unit
                                message= _ "What is this disgusting monster?"
                            [/message]

                            [message]
                                speaker=Helicrom
                                message= _ "A ghoul, a creature of disease and pestilence. Kill the putrid thing. Its stench is making me sick."
                            [/message]

                            {REMOVE_IMAGE 23 26}

                            {PLACE_IMAGE items/coffin-open.png 23 26}

                            {VARIABLE has_key 2}
                        [/command]
                    [/option]
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            type=Ghoul
        [/filter]

        {PLACE_IMAGE items/potion-poison.png $x1 $y1}

        [message]
            speaker=Helicrom
            message= _ "Disgusting though it may be, perhaps that creature’s corpse could be useful."
        [/message]

        [event]
            name=moveto
            id=take_potion
            delayed_variable_substitution=no
            first_time_only=no
            [filter]
                x=$x1
                y=$y1
                side=1,2
            [/filter]
            [message]
                speaker=unit
                message= _ "Should I use this potion?"
                [option]
                    label= _ "Yes, I’ll use it."
                    [command]
                        [sound]
                            name=poison.ogg
                        [/sound]

                        [object]
                            id=poison_weapon
                            name= _ "Vile Concoction"
                            image=items/potion-poison.png
                            description= _ "This unit’s melee weapons gain the poison special and this unit gains a small number of hitpoints."
                            [filter]
                                x=$x1
                                y=$y1
                            [/filter]

                            [effect]
                                apply_to=hitpoints
                                increase_total=5
                                increase=5
                            [/effect]

                            [effect]
                                apply_to=attack
                                range=melee
                                [set_specials]
                                    {WEAPON_SPECIAL_POISON}
                                    mode=append
                                [/set_specials]
                            [/effect]
                        [/object]

                        [remove_item]
                            x=$x1
                            y=$y1
                        [/remove_item]

                        [remove_event]
                            id=take_potion
                        [/remove_event]
                    [/command]
                [/option]

                [option]
                    label= _ "No, I’ll leave it for someone else."
                    [command]
                        [allow_undo]
                        [/allow_undo]
                    [/command]
                [/option]
            [/message]
        [/event]
    [/event]

    #
    # Special Event - after 5 turns, send the second patrol
    #
    [event]
        name=turn 5

        {SCROLL_TO 39 23}
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=37,22
            radius=3
        [/lift_fog]

        {TROOPER "Spearman" 38 22}
        {TROOPER "Heavy Infantryman" 38 21}

#ifdef EASY
        {TROOPER "Spearman" 37 23}
#else
        {TROOPER "Javelineer"     37 23}
#endif

#ifdef EASY
        {TROOPER "Bowman" 39 23}
#else
        {TROOPER "Longbowman"     39 23}
#endif

#ifdef HARD
        {TROOPER "Shock Trooper"     38 23}
#else
        {TROOPER "Heavy Infantryman" 38 23}
#endif

        [move_unit_fake]
            type=Swordsman
            side=3
            x=39,37
            y=23,22
        [/move_unit_fake]
        [unit]
            side=3
            type=Swordsman
            facing=sw
            canrecruit=yes
            x,y=37,22
        [/unit]
    [/event]

    #
    # Special Event - after 11 turns, send the third patrol
    #
    [event]
        name=turn 11

        {SCROLL_TO 39 23}
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=37,22
            radius=3
        [/lift_fog]

        {TROOPER "Spearman" 38 22}
        {TROOPER "Heavy Infantryman" 38 21}

#ifdef EASY
        {TROOPER "Spearman" 37 23}
#else
        {TROOPER "Javelineer"     37 23}
#endif

#ifdef EASY
        {TROOPER "Heavy Infantryman" 39 23}
#else
        {TROOPER "Shock Trooper"     39 23}
#endif

#ifdef HARD
        {TROOPER "Longbowman"     38 23}
#else
        {TROOPER "Bowman" 38 23}
#endif

        [move_unit_fake]
            type=Pikeman
            side=3
            x=39,37
            y=23,22
        [/move_unit_fake]
        [unit]
            side=3
            type=Pikeman
            facing=sw
            canrecruit=yes
            x,y=37,22
        [/unit]

        [message]
            type=Spearman
            message= _ "Doesn’t something about these woods feel weird to you, sir?"
        [/message]
        [message]
            type=Pikeman
            message= _ "Afraid of ghosts, soldier?"
        [/message]
        [message]
            type=Spearman
            message= _ "..."
        [/message]
    [/event]

    #
    # Special Event - after 17 turns, send the fourth patrol
    #
    [event]
        name=turn 17

        {SCROLL_TO 39 23}
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=37,22
            radius=3
        [/lift_fog]

        {TROOPER "Shock Trooper" 38 22}
        {TROOPER "Heavy Infantryman" 38 21}
        {TROOPER "Swordsman" 37 23}

#ifdef EASY
        {TROOPER "Bowman" 39 23}
#else
        {TROOPER "Longbowman"     39 23}
#endif

#ifdef HARD
        {TROOPER "Shock Trooper"     38 23}
#else
        {TROOPER "Heavy Infantryman" 38 23}
#endif
        {TROOPER "Spearman" 39 22}

        [move_unit_fake]
            type=Lieutenant
            side=3
            x=39,37
            y=23,22
        [/move_unit_fake]
        [unit]
            side=3
            type=Lieutenant
            facing=sw
            canrecruit=yes
            x,y=37,22
        [/unit]
    [/event]

    #
    # Special Event - after 21 turns, send the fifth patrol
    # this one is a bit faster than the other patrols, so it'll be a bit more challenging
    #
    [event]
        name=turn 21

        {SCROLL_TO 39 23}
        [lift_fog]
            [filter_side]
                side=1
            [/filter_side]
            x,y=37,22
            radius=3
        [/lift_fog]

        {TROOPER "Duelist" 38 22}
        {TROOPER "Swordsman" 38 21}

#ifdef EASY
        {TROOPER "Fencer" 37 23}
#else
        {TROOPER "Duelist"     37 23}
#endif

#ifdef EASY
        {TROOPER "Spearman" 39 23}
#else
        {TROOPER "Javelineer"     39 23}
#endif

#ifdef HARD
        {TROOPER "Longbowman"     38 23}
#else
        {TROOPER "Bowman" 38 23}
#endif

        {TROOPER "Duelist" 39 22}

        [move_unit_fake]
            type=Master at Arms
            side=3
            x=39,37
            y=23,22
        [/move_unit_fake]
        [unit]
            side=3
            type=Master at Arms
            facing=sw
            canrecruit=yes
            x,y=37,22
        [/unit]

        [message]
            type=Master at Arms
            message= _ "Woods, woods, woods and more woods! Bah, that general had better have a good reason for dragging me out to Halstead with all these oafs."
        [/message]
        [message]
            type=Duelist
            message= _ "But cap’n, we’re your loyal troops..."
        [/message]
        [message]
            type=Master at Arms
            message= _ "Shut it and keep moving."
        [/message]
    [/event]

    #
    # Special Event - Archarel says some stuff
    #
    [event]
        name=turn 10

        {SCROLL_TO 7 4}
        [lift_fog]
            [filter_side]
                side=1,2
            [/filter_side]
            x,y=7,4
            radius=5
        [/lift_fog]

        [message]
            speaker=Archarel
            message= _ "Several platoons of troops were supposed to arrive today. I wonder if something happened to them."
        [/message]
    [/event]
    [event]
        name=turn 18

        {SCROLL_TO 7 4}
        [lift_fog]
            [filter_side]
                side=1,2
            [/filter_side]
            x,y=7,4
            radius=5
        [/lift_fog]

        [message]
            speaker=Archarel
            message= _ "Something about these woods seems quite unnatural. Perhaps we should stop sending our soldiers this way."
        [/message]
    [/event]

#define DEFEAT_TEXT
    {SCROLL_TO 7 4}
    [lift_fog]
        [filter_side]
            side=1,2
        [/filter_side]
        x,y=7,4
        radius=5
    [/lift_fog]

    [message]
        speaker=Archarel
        message= _ "Troops, to arms! Show these fugitive scum the meaning of the Queen’s law!"
    [/message]
    [message]
        speaker=Helicrom
        message= _ "With the outpost aware of our presence, we can no longer harry their reinforcements. Their forces will soon grow too powerful for us to resist."
    [/message]
#enddef

    #
    # End condition: turns run out
    #
    [event]
        name=time over
        [if]
            [have_unit]
                side=3
            [/have_unit]
            [then]
                [message]
                    speaker=narrator
                    message= _ "The next morning, the local night patrol returned to the nearby outpost. They were surprised to see their fellow soldiers engaged in combat with the band of thugs of which they had heard so much."
                    image="wesnoth-icon.png"
                [/message]

                {DEFEAT_TEXT}

                [endlevel]
                    result=defeat
                [/endlevel]
            [/then]
            [else]
                [fire_event]
                    name=win event
                [/fire_event]
            [/else]
        [/if]
    [/event]

    #
    # End condition: last patrol defeated
    #
    [event]
        name=die

        [filter_condition]
            [have_unit]
                side=3
                count=0
            [/have_unit]
            [and]
                [variable]
                    name=turn_number
                    greater_than=20
                [/variable]
            [/and]
        [/filter_condition]

        [fire_event]
            name=win event
        [/fire_event]
    [/event]

    #
    # Victory event
    #
    [event]
        name=win event
        [message]
            speaker=Baldras
            message= _ "It be done. Their patrols be shattered and broken."
        [/message]

        [message]
            speaker=Helicrom
            message= _ "Well done, but the fight is far from over. We will not be able to employ these tactics when more platoons arrive. You must make your choice. Will you fight? Or will you return to your village and beg for amnesty?"
        [/message]

        [message]
            speaker=Baldras
            message= _ "Amnesty? Knowing these Wesnothians, they’ll have my head. Then again, if I could gives my life to save my whole village, I would."
        [/message]

        [message]
            speaker=Harper
            message= _ "We need you! Uncle..."
        [/message]

        [message]
            speaker=Baldras
            message= _ "I know what you is going to say, Harper. That we should be fighting for our homes, just like we do against them orcs. But we be risking everything on this, lad."
        [/message]

        [message]
            speaker=Harper
            message= _ "If we go back like this, that means we’ll surrender to them Wesnothians and live our whole lives in oppression. You saw how they were sending so many soldiers and even orcs against us."
        [/message]

        [message]
            speaker=Helicrom
            message= _ "The boy is naive, but his spirit is in the right place. You risk your homes and the lives of your people, yes, but what good will they be if you live in tyranny? Believe me, I have been there. I would rather die than go back."
        [/message]

        [message]
            speaker=Baldras
            message= _ "Yes... Erwen would’ve said the same. If we march on Halstead, we gots to burn it to the ground before the Queen’s forces rally. If we does that, Weldyn won’t have no foothold in Annuvin no more."
        [/message]

        [message]
            speaker=Helicrom
            message= _ "It would be months before they could reassemble their forces here. Enough time for you to secure your homes, or relocate."
        [/message]

        [message]
            speaker=Baldras
            message= _ "Then it be decided. We’ll attack the fort together. Luck be with us."
        [/message]

        [modify_unit]
            [filter]
                side=2
            [/filter]
            side=1
        [/modify_unit]

        {CLEAR_VARIABLE has_key}

        [endlevel]
            result=victory
            bonus=yes
            {NEW_GOLD_CARRYOVER 40}
        [/endlevel]
    [/event]

    #
    # Loss conditions
    #
    [event]
        name=moveto
        [filter]
            side=3
            x=1-10
            y=1-6
        [/filter]

        [lift_fog]
            [filter_side]
                side=1,2
            [/filter_side]
            x,y=7,4
            radius=5
        [/lift_fog]

        [message]
            speaker=unit
            message= _ "Lieutenant, we were assaulted by a band of outlaws en route to the outpost. We were barely able to evade them and make it here!"
        [/message]

        {DEFEAT_TEXT}

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]
    [event]
        name=sighted
        [filter]
            side=1,2
        [/filter]
        [filter_second]
            side=4
        [/filter_second]

        [message]
            speaker=second_unit
            message= _ "Look there! Outlaws and bandits roam these woods, harrying our patrols!"
        [/message]

        {DEFEAT_TEXT}

        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Helicrom
        [/filter]
        [message]
            speaker=Helicrom
            message= _ "This is the end for me..."
        [/message]
        [endlevel]
            result=defeat
        [/endlevel]
    [/event]

    {LIBERTY_DEATHS}
[/scenario]

#undef TROOPER
#undef DEFEAT_TEXT