#textdomain wesnoth-sota

# There is one complicated event, but it is described in the code.

[scenario]
    name= _ "Bandits"
    map_data="{campaigns/Secrets_of_the_Ancients/maps/03_Bandits.map}"

    id=03_Bandits
    next_scenario=04_Becalmed

    [story]
        [part]
            [background_layer]
                image=story/trackless-wilds.jpg
                scale=no
            [/background_layer]
            story= _ "17 III, 23 YW:

Even with the delay at the graveyard, I reached the outskirts of Llorvin at first light, and it was far behind me when the sun rose above the mountain peaks. I doubt the Academy will be looking for me in the trackless wilds inhabited only by woodcutters, and with my new companions, I feel safe enough to travel during the day. I am heading east and then north towards the docks. A ship should be leaving for Blackwater Port in a few days, and I mean to be on it."
        [/part]
        {JOURNEY_PART 3}
    [/story]

    {DEFAULT_SCHEDULE}
    {DEFAULT_MUSIC_PLAYLIST}
    {TURNS 35 35 35}

    [side]
        {SIDE_1_ARDONNA_EARLY}
        {GOLD 150 150 140}
    [/side]

    [side]
        side=2
        controller=ai
        user_team_name= _ "Bandits"
        type=Bandit
        id=Garcyn
        name= _ "Garcyn"
        recruit=Thug, Footpad, Ruffian, Poacher
        {GOLD 150 200 250}
        [unit]
            type=Outlaw
            gender=female
            id=Mossa
            name= _ "Mossa"
            x,y=9,16
            [modifications]
                {TRAIT_QUICK}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]
        {FLAG_VARIANT knalgan}
    [/side]

    {STARTING_VILLAGES 2 7}

    # *************************** PRESTART ***************************
    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Defeat the enemy leader"
                condition=win
            [/objective]

            {HOW_TO_LOSE_WITH_ARDONNA}

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

        [set_variable]
            name=undead_seen
            value=no
        [/set_variable]
    [/event]

    [event]
        name=side 1 turn 1 refresh
        [modify_unit]
            [filter]
                id=Mossa
            [/filter]
            moves=0
            attacks_left=0
        [/modify_unit]
    [/event]

    # *************************** PLAY ***************************

#define THEY_ARE_UNDEAD ID
    [message]
        speaker={ID}
        message= _ "They are not underfed, they’re dead! How can they be dead? They’re horrible!"
    [/message]
    [message]
        speaker=Garcyn
        message= _ "Huh. Well, they’re not the first ugly things we’ve seen in the wilds. Your club crushes bone just fine, so crush them."
    [/message]
    [message]
        speaker={ID}
        message= _ "And there is a white-haired girl."
    [/message]
    [message]
        speaker=Garcyn
        message= _ "She must be in league with the dead, so crush her too."
    [/message]
    [set_variable]
        name=undead_seen
        value=yes
    [/set_variable]
#enddef

    # The first time a unit from side 2 gets close to an undead unit, the conversation
    # above is triggered. This happens no matter which unit is the one that moved.
    # The next two events control this behavior. The variable undead_seen is to make
    # sure only one of the events triggers the conversation. It's a lot of work for a
    # small effect, but it's important to the plot that the average person hasn't ever
    # seen the undead.
    [event]
        name=moveto
        first_time_only=no

        # An outlaw gets close to an undead unit:
        [filter]
            side=2
        [/filter]
        [filter_condition]
            [variable]
                name=undead_seen
                equals=no
            [/variable]
            [and]
                [have_location]
                    [and]
                        x,y=$x1,$y1
                        radius=3
                    [/and]
                    [and]
                        [filter]
                            race=undead
                        [/filter]
                    [/and]
                [/have_location]
            [/and]
        [/filter_condition]

        {THEY_ARE_UNDEAD $unit.id}
    [/event]

    [event]
        name=moveto
        first_time_only=no

        # An undead unit gets close to an outlaw:
        [filter]
            race=undead
        [/filter]
        [filter_condition]
            [variable]
                name=undead_seen
                equals=no
            [/variable]
        [/filter_condition]

        [store_unit]
            variable=seen_by
            [filter]
                side=2
                [filter_location]
                    x,y=$x1,$y1
                    radius=3
                [/filter_location]
            [/filter]
        [/store_unit]

        [if]
            [variable]
                name=seen_by.length
                greater_than=0
            [/variable]
            [then]
                {THEY_ARE_UNDEAD $seen_by.id}
            [/then]
        [/if]
        [allow_undo]
        [/allow_undo]
    [/event]

    [event]
        name=die
        [filter]
            id=Mossa
        [/filter]
        [message]
            speaker=Garcyn
            message= _ "No!"
        [/message]
        [message]
            speaker=Garcyn
            message= _ "You have earned my wrath, wench. Death will be too good for you!"
        [/message]
    [/event]

    # *************************** OPENING / ENDING ***************************
    [event]
        name=start
        [message]
            speaker=Mossa
            message= _ "What have we here?"
        [/message]
        [move_unit]
            id=Mossa
            to_x=5
            to_y=7
        [/move_unit]
        [message]
            speaker=Mossa
            message= _ "Prey approaches, dearest. It’s an unusual band, but the ones with weapons look underfed."
        [/message]
        [message]
            speaker=Garcyn
            message= _ "Easy pickings then."
        [/message]
        [message]
            speaker=Ardonna
            message= _ "I think we were just spotted from that hill. Weapons up, my friends. We may be walking into an ambush."
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Garcyn
        [/filter]
        [message]
            speaker=Garcyn
            message= _ "Please! Don’t kill me."
        [/message]
        [message]
            speaker=Ardonna
            message= _ "No? Fine then. I have an idea for another experiment."
        [/message]
        [clear_variable]
            name=undead_seen,seen_by
        [/clear_variable]
    [/event]

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

    [event]
        name=time over
        [message]
            speaker=Ardonna
            message= _ "The ship will surely leave before we can reach it!"
        [/message]
    [/event]

    {HERO_DEATHS}
    {MANAGE_PROFILE}

#undef THEY_ARE_UNDEAD
[/scenario]
