#textdomain wesnoth-ei
[scenario]
    id=Northern_Outpost
    name= _ "Northern Outpost"
    map_data="{campaigns/Eastern_Invasion/maps/Northern_Outpost.map}"
    turns=20
    next_scenario=Two_Paths
    victory_when_enemies_defeated=no
    {DEFAULT_MUSIC_PLAYLIST}
    {VICTORY_AND_DEFEAT_MUSIC}
    

    {DEFAULT_SCHEDULE}

    {campaigns/Eastern_Invasion/utils/deaths.cfg}

    [side]
        type=Lieutenant
        description=Gweddry
        user_description= _ "Gweddry"
        side=1
        canrecruit=yes
        recruit=Spearman,Cavalryman,Mage,Horseman,Heavy Infantryman
        controller=human
        team_name=good
    [/side]

    [side]
        type=Mounted Fighter
        description=Owaec
        user_description= _ "Owaec"
        side=2
        canrecruit=yes
        facing=sw
        recruit=Cavalryman,Mage,Heavy Infantryman
        team_name=good
        profile=portraits/owaec.png
        {GOLD 90 70 50}
        [ai]
            passive_leader=yes
            recruitment_pattern=mixed fighter,fighter,scout,mixed fighter,fighter
            {NO_SCOUTS}
            [avoid]
                x=1-32
                y=1-18
            [/avoid]
        [/ai]
    [/side]

    [side]
        type=Revenant
        description=Lanar-Skal
        user_description= _ "Lanar-Skal"
        side=3
        canrecruit=yes
        facing=sw
        recruit=Skeleton,Skeleton Archer
        team_name=evil
        {INCOME 5 10 15}
        {GOLD 30 40 50}
        [ai]
            aggression=-0.1
            recruitment_pattern=archer,fighter
        [/ai]
    [/side]

    [side]
        side=4
        no_leader=yes
        [ai]
            grouping=no
        [/ai]
    [/side]

#define TRAPMAN TYPE
    [unit]
        type={TYPE}
        side=4
        x=$x1
        y=$y1
        generate_description=yes
        random_traits=yes
    [/unit]
#enddef

    [event]
        name=prestart

        # {SCATTER_IMAGE (terrain=Gg) 20 scenery/pine1.png}
        # {SCATTER_IMAGE (terrain=Gs^Fp) 12 scenery/oak-leaning.png}
        {PLACE_IMAGE scenery/rock1.png 15 28}
        {PLACE_IMAGE scenery/rock2.png 8 5}

        [objectives]
            side=1
            [objective]
                description= _ "Find the outlaw leader in the villages and kill him"
                condition=win
            [/objective]
            [objective]
                description= _ "Defeat the undead leader"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Owaec"
                condition=lose
            [/objective]
        [/objectives]
    [/event]

    [event]
        name=start
        [set_variable]
            name=trapdiff
            value=1
        [/set_variable]
        [recall]
            description=Dacyn
        [/recall]
        [message]
            description=Owaec
            message= _ "Hail, Gweddry!"
        [/message]
        [message]
            description=Gweddry
            message= _ "Greetings, Owaec! We have been forced from our positions by undead invaders. They follow us even now."
        [/message]
        [message]
            description=Dacyn
            message= _ "Indeed, they do. And do not think you will be able to defeat them. They are too powerful. We are heading for the Northlands, where we may be able to outrun them. Will you join us?"
        [/message]
        [message]
            description=Owaec
            message= _ "I am not sure. There are bandits in this country, and I have been told that it is my duty to defeat them, and protect the local villages. However, I cannot find a way to defeat them. The outlaws hide in the villages when we are close, and come out when we are far away."
        [/message]
        [message]
            description=Dacyn
            message= _ "Hoping to protect these villages is foolish; all who stay here will die. However, if we can drive these bandits out, we will be able to have all the villagers follow us into the northlands. There they may survive. But Wesnoth is no longer safe."
        [/message]
        [message]
            description=Owaec
            message= _ "Well, you appear to know what you're talking about... but, I have no way to remove these bandits."
        [/message]
        [message]
            description=Dacyn
            message= _ "I think I may be able to help you. I am a mage; I believe I will be able to cast a spell that will reveal them if you enter the villages. However, I won't be able to help you in battle."
        [/message]
        [message]
            description=Gweddry
            message= _ "That sounds good; it is time to drive out some bandits. Dacyn, go cast your spell!"
        [/message]
        [message]
            description=Owaec
            message= _ "I believe there is a leader behind these outlaws; kill him, and we will have defeated these bandits."
        [/message]
        [message]
            description=Lanar-Skal
            message= _ "Go, go far from here! But me and my kind will chase you, and kill you!"
        [/message]
        [message]
            description=Dacyn
            message= _ "It seems the undead have caught up with us! We will have to kill them, too, if we want these villages to be safe. Well, I will see you when you defeat the outlaws and undead!"
        [/message]
        [store_unit]
            [filter]
                description=Dacyn
            [/filter]
            variable=dacyn
            kill=yes
        [/store_unit]
        [set_variable]
            name=shodranoshown
            value=no
        [/set_variable]
    [/event]

    [event]
        name=capture
        first_time_only=no
        #creates random enemies when you flag a village
        [filter]
            side=1
        [/filter]

        [if]
            [variable]
                name=shodrano_killed
                not_equals=yes
            [/variable]

            [then]
                {RANDOM 0..10}
                [if]
                    [variable]
                        name=random
                        less_than=$trapdiff
                    [/variable]
                    [then]
                        [set_variable]
                            name=numban
#ifdef EASY
                            random=0..3
#endif
#ifdef NORMAL
                            random=1..4
#endif
#ifdef HARD
                            random=2..5
#endif
                        [/set_variable]
                        [set_variable]
                            name=numban
                            add=$trapdiff
                        [/set_variable]
                        [while]
                            [variable]
                                name=numban
                                greater_than=0
                            [/variable]
                            [do]
                                {RANDOM Footpad,Thug,Thief,Poacher,Thug,Thief,Footpad,Thug,Thief,Poacher,Thug,Thief,Rogue,Bandit}
                                {TRAPMAN $random}
                                [set_variable]
                                    name=numban
                                    add=-2
                                [/set_variable]
                            [/do]
                        [/while]
                        {CLEAR_VARIABLE numban}
                        [message]
                            speaker=unit
                            message= _ "They're here!"
                        [/message]
                        #decides if the badguy leader appears
                        #badguy leader has less chance of appearing early on. (as in 0% chance for first 5 villages. :P)
                        {RANDOM 4..10}
                        [if]
                            [variable]
                                name=random
                                greater_than_equal_to=$trapdiff
                            [/variable]
                            [or]
                                [variable]
                                    name=shodranoshown
                                    equals=yes
                                [/variable]
                            [/or]
                            [else]
                                [unit]
                                    type=Assassin
                                    side=4
                                    x=$x1
                                    y=$y1
                                    description=Shodrano
                                    user_description= _ "Shodrano"
                                [/unit]
                                [set_variable]
                                    name=shodranoshown
                                    value=yes
                                [/set_variable]
                                [message]
                                    description=Shodrano
                                    message= _ "So, you have found my hiding place. Very well, I guess I will have to kill you!"
                                [/message]
                                [message]
                                    description=Owaec
                                    message= _ "That's the bandit leader! Kill him, and we will have fulfilled our duty!"
                                [/message]
                            [/else]
                        [/if]
                    [/then]
                    [else]
                        [message]
                            speaker=unit
                            message= _ "No outlaws in this village."
                        [/message]
                    [/else]
                [/if]
                [set_variable]
                    name=trapdiff
                    add=1
                [/set_variable]
            [/then]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            description=Shodrano
        [/filter]
        [message]
            description=Shodrano
            message= _ "You have defeated me! I can terrorize the villagers no more..."
        [/message]
        [if]
            [have_unit]
                description=Lanar-Skal
            [/have_unit]
            [then]
                [message]
                    description=Owaec
                    message= _ "We still need to defeat these undead for the villagers to be safe."
                [/message]

                {VARIABLE shodrano_killed yes}
            [/then]
            [else]
                [message]
                    description=Owaec
                    message= _ "I have fulfilled my duty to the villages. Now I suppose I can join you in your quest."
                [/message]
                [unstore_unit]
                    variable=dacyn
                    find_vacant=yes
                [/unstore_unit]
                [message]
                    description=Dacyn
                    message= _ "Good job! Now, we should move onward, north. Tell the villagers to pack their belongings and follow us."
                [/message]

                {MODIFY_UNIT description=Owaec canrecruit no}
                {MODIFY_UNIT side=2 side 1}
                [store_unit]
                    [filter]
                        description=Owaec
                    [/filter]
                    variable=Owaec_store
                    kill=no
                [/store_unit]
                [unit_overlay]
                    x=$Owaec_store.x
                    y=$Owaec_store.y
                    image=misc/hero-icon.png
                [/unit_overlay]

                {CLEAR_VARIABLE Owaec_store}

                [endlevel]
                    bonus=yes
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            description=Lanar-Skal
        [/filter]
        [if]
            [have_unit]
                description=Shodrano
            [/have_unit]
            [or]
                [variable]
                    name=shodranoshown
                    equals=no
                [/variable]
            [/or]
            [then]
                [message]
                    description=Owaec
                    message= _ "There are still these outlaws to take care of - we must continue fighting here."
                [/message]
            [/then]
            [else]
                [message]
                    description=Owaec
                    message= _ "Well, both the outlaws and undead are defeated. We have some time to spare now before more undead arrive."
                [/message]
                [unstore_unit]
                    variable=dacyn
                    find_vacant=yes
                [/unstore_unit]
                [message]
                    description=Dacyn
                    message= _ "Good work! Now, we should move onward, north. Tell the villagers to pack their belongings and follow us."
                [/message]

                {MODIFY_UNIT description=Owaec canrecruit no}
                {MODIFY_UNIT side=2 side 1}
                [store_unit]
                    [filter]
                        description=Owaec
                    [/filter]
                    variable=Owaec_store
                    kill=no
                [/store_unit]
                [unit_overlay]
                    x=$Owaec_store.x
                    y=$Owaec_store.y
                    image=misc/hero-icon.png
                [/unit_overlay]

                {CLEAR_VARIABLE Owaec_store}

                [endlevel]
                    bonus=yes
                [/endlevel]
            [/else]
        [/if]
    [/event]

    #eternal holy water!
    [item]
        x=2
        y=25
        image=items/ankh-necklace.png
    [/item]

    [event]
        name=moveto
        [filter]
            side=1
            x=2
            y=25
        [/filter]
        [object]
            id=holyamulet
            name= _ "Holy Amulet"
            image=items/ankh-necklace.png
            duration=forever
            description= _ "Wearing this amulet will cause every blow you deal to inflict arcane damage!"
            cannot_use_message= _ "I am not suited to using this item! Let another take it."
            [then]
                [removeitem]
                    x=2
                    y=25
                [/removeitem]
            [/then]
            [effect]
                apply_to=attack
                range=melee
                set_type=arcane
            [/effect]
            [effect]
                apply_to=attack
                range=ranged
                set_type=arcane
            [/effect]
        [/object]
    [/event]
[/scenario]
