#textdomain wesnoth-ei

[scenario]
    id=05_Northern_Outpost
    name= _ "Northern Outpost"
    map_data="{campaigns/Eastern_Invasion/maps/05_Northern_Outpost.map}"
    turns=20
    next_scenario=06_Two_Paths
    victory_when_enemies_defeated=no

    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC transience.ogg wanderer.ogg}
    {EXTRA_SCENARIO_MUSIC traveling_minstrels.ogg}
    {EXTRA_SCENARIO_MUSIC loyalists.ogg}

    {EI_TRACK {JOURNEY_05_NEW} }

    # wmllint: validate-off
    [side]
        side=1
        controller=human
        {GOLD 150 130 100}
        team_name=good
        user_team_name=_"Wesnothians"
        {FLAG_VARIANT loyalist}

        # wmllint: recognize Gweddry
        {CHARACTER_STATS_GWEDDRY}
    [/side]

    [side]
        side=2
        controller=ai
        recruit=Cavalryman,Mage,Heavy Infantryman
        {GOLD 90 70 50}
        team_name=good
        user_team_name= _ "Wesnothians"

        # wmllint: recognize Owaec
        {CHARACTER_STATS_OWAEC}

        # Manually canrecruit flag here is deliberate
        canrecruit=yes
        facing=sw

        [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]
    # wmllint: validate-on

    [side]
        side=3
        controller=ai
        recruit=Skeleton,Skeleton Archer,Skeleton Rider

        {GOLD 30 40 50}
        {INCOME 9 14 18}
        team_name=undead
        user_team_name= _ "Undead"
        {FLAG_VARIANT undead}

        type=Revenant
        id=Lanar-Skal
        name= _ "Lanar-Skal"
        canrecruit=yes

        facing=sw

        [ai]
            aggression=-0.1
            caution=0.25
            grouping=defensive
            recruitment_pattern=archer,archer,fighter,fighter,scout
            passive_leader=yes
        [/ai]
    [/side]

    [side]
        side=4
        no_leader=yes
        team_name=bad
        hidden=yes
        [ai]
            grouping=no
            aggression=0.7
            leader_aggression=0.7
            grouping=offensive
        [/ai]
    [/side]

    {AI_CONTROLLER () 1 2 ()}

    {PLACE_IMAGE scenery/rock1.png 15 28}
    {PLACE_IMAGE scenery/rock2.png 8 5}

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Find the outlaw leader"
                condition=win
                [show_if]
                    {VARIABLE_CONDITIONAL boss_found not_equals yes}
                [/show_if]
            [/objective]
            [objective]
                description= _ "Kill Shodrano"
                condition=win
                [show_if]
                    [have_unit]
                        side=4
                        # wmllint: recognize Shodrano
                        id=Shodrano
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Defeat the undead leader"
                condition=win
                [show_if]
                    [have_unit]
                        side=3
                        canrecruit=yes
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Gweddry"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Dacyn"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Owaec"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                bonus=no
                carryover_percentage=70
            [/gold_carryover]

            {AI_CONTROLLER_NOTE}
        [/objectives]

        {VARIABLE shodrano_killed no}

        [store_villages]
            y=1-22
        [/store_villages]

        [spread_bandit_villages]
            x=1-32
            y=1-22
            count=$($location.length / 2)
#ifdef EASY
            types="Footpad,Footpad,Poacher,Poacher,Thug,Thug,Thug,Thug,Thief,Thief,Thief,Thief"
#else
            types="Footpad,Footpad,Poacher,Poacher,Thug,Thug,Thug,Thug,Thief,Thief,Thief,Thief,Rogue,Bandit,Outlaw"
#endif
        [/spread_bandit_villages]

        {CLEAR_VARIABLE location}

        [recall]
            id=Dacyn
        [/recall]

        [recall]
            id=Terraent
        [/recall]
    [/event]

    [event]
        name=start

        [message]
            speaker=Owaec
            message= _ "Hail, Gweddry!"
        [/message]

        [message]
            speaker=Gweddry
            message= _ "Greetings, Owaec! We have been forced from our positions by undead invaders. They follow us even now."
        [/message]

        [message]
            speaker=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 I hope to find a means to stop this invasion. Will you join us?"
        [/message]

        [message]
            speaker=Owaec
            message= _ "I cannot. My orders were to protect these villages. If I leave, the villagers will be at the mercy of a gang of bandits. I cannot find a way to defeat them; the outlaws hide in the villages whenever I send in my troops."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "Hoping to protect these villages is foolish; all who stay here will die. However, if we can drive these bandits out, will you organize the villagers to flee to the west? There they may survive for a time. But soon nowhere in Wesnoth will be safe."
        [/message]

        [message]
            speaker=Owaec
            message= _ "If the situation is as dire as you’ve described, I must... but we have no way to remove these bandits."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "I think I may be able to help. Gweddry, I believe I can cast a spell that will reveal the bandits when our troops enter a village. However, this magic will require my full attention; I won’t be able to help you in battle."
        [/message]

        [message]
            speaker=Gweddry
            message= _ "That sounds good; it is time to drive out some bandits. Dacyn, cast your spell!"
        [/message]

        [message]
            speaker=Owaec
            message= _ "I believe there is a leader behind these outlaws; kill him and we will face no further resistance. I will place my clansmen at your service."
        [/message]

        [allow_recruit]
            side=1
            type=Horseman
        [/allow_recruit]

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "You may now recruit horsemen!"
        [/message]

        [message]
            speaker=Lanar-Skal
            message= _ "Go, go far from here! But me and my kind will chase you, and kill you!"
        [/message]

        [message]
            speaker=Dacyn
            message= _ "It seems the undead have caught up with us! We will have to kill them too if we want the villagers to be safe. Well, I will begin casting the spell."
        [/message]

        {MOVE_UNIT id=Dacyn 13 14}

        {DACYN_CASTING_SPELL_ANIMATION_OBJECT}

        {MODIFY_UNIT id=Dacyn variables.casting_the_spell yes}
    [/event]

    # Dacyn remains busy until the bandits are defeated
    [event]
        name=side 1 turn refresh
        first_time_only=no
        [filter_condition]
            [have_unit]
                id=Dacyn
                [filter_wml]
                    [variables]
                        casting_the_spell="yes"
                    [/variables]
                [/filter_wml]
            [/have_unit]
        [/filter_condition]

        [modify_unit]
            [filter]
                id=Dacyn
            [/filter]

            moves=0
            attacks_left=0
        [/modify_unit]
    [/event]

    [event]
        name=capture
        first_time_only=no
        [filter]
            side=1
        [/filter]
        [filter_condition]
            {VARIABLE_CONDITIONAL shodrano_killed not_equals yes}
        [/filter_condition]

        [bandit_village_capture]
            x,y=$x1,$y1
        [/bandit_village_capture]
    [/event]

    [event]
        name=boss_found

        [move_unit_fake]
            x=$x1,$x2
            y=$y1,$y2
            type=Assassin
            side=4
        [/move_unit_fake]

        [unit]
            x,y=$x2,$y2
            type=Assassin
            side=4
            id=Shodrano
            name= _ "Shodrano"
            canrecruit=yes
        [/unit]

        {INCIDENTAL_MUSIC battle-epic.ogg}

        [message]
            speaker=Shodrano
            message= _ "So, you have found my hiding place. Very well, I guess I will have to kill you!"
        [/message]

        [message]
            speaker=Owaec
            message= _ "That’s the bandit leader! Kill him!"
        [/message]

        [show_objectives][/show_objectives]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Shodrano
        [/filter]

        [message]
            speaker=Shodrano
            message= _ "You have defeated me! I can terrorize the villagers no more..."
        [/message]
    [/event]

    [event]
        name=die
        [filter]
            id=Shodrano
        [/filter]

        {VARIABLE shodrano_killed yes}

        {MODIFY_UNIT id=Dacyn variables.casting_the_spell no}

        [if]
            [have_unit]
                id=Lanar-Skal
            [/have_unit]
            [then]
                [message]
                    speaker=Owaec
                    message= _ "We still need to defeat these undead for the villagers to be safe."
                [/message]

                [show_objectives][/show_objectives]
            [/then]
            [else]
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 70}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            id=Lanar-Skal
        [/filter]

        [if]
            {VARIABLE_CONDITIONAL shodrano_killed not_equals yes}
            [then]
                [message]
                    speaker=Owaec
                    message= _ "There are still these outlaws to take care of — we must continue fighting here."
                [/message]

                [show_objectives][/show_objectives]
            [/then]
            [else]
                [endlevel]
                    result=victory
                    bonus=no
                    {NEW_GOLD_CARRYOVER 70}
                [/endlevel]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory

        {MODIFY_UNIT id=Dacyn variables.casting_the_spell no}

        [message]
            speaker=Owaec
            message= _ "Well, both the outlaws and undead are defeated. We have some time to spare now before more undead arrive."
        [/message]

        [message]
            speaker=Dacyn
            message= _ "Good! Now, we must move onward, north. Tell the villagers to pack their belongings and head west."
        [/message]

        [store_unit]
            [filter]
                id=Owaec
            [/filter]

            kill=yes
            variable=stored_Owaec
        [/store_unit]

        [unit]
            side=1
            id=Owaec
            name= _ "Owaec"
            unrenamable=yes
            x,y=$stored_Owaec.x,$stored_Owaec.y
            type=$stored_Owaec.type
            experience=$stored_Owaec.experience
            profile=portraits/owaec.png
            {IS_HERO}
            random_traits=no
            [modifications]
                {TRAIT_LOYAL}
            [/modifications]
        [/unit]

        {CLEAR_VARIABLE stored_Owaec,bandit_villages,bandit_types,villages_visited,boss_found,shodrano_killed}
    [/event]

    {HOLY_AMULET 2 25}

    {WESNOTH_DEFEAT}

    {HERODEATH_GWEDDRY}
    {HERODEATH_DACYN}
    {HERODEATH_OWAEC}
[/scenario]
