#textdomain wesnoth-tsg
[scenario]
    id=1_Born_To_The_Banner

    name= _ "Born to the Banner"
    next_scenario=2_Proven_By_The_Sword

    {SCENARIO_MUSIC breaking_the_chains.ogg}
    {EXTRA_SCENARIO_MUSIC knolls.ogg}

    map_data="{campaigns/The_South_Guard/maps/1_Born_To_The_Banner.map}"

    {campaigns/The_South_Guard/utils/sg_deaths.cfg}
    {campaigns/The_South_Guard/utils/sg_help.cfg}

    {DEFAULT_SCHEDULE}

    {TURNS 40 32 24}

    # Scenario Introduction - Summer

    {SG_BORN_TO_THE_BANNER}

    # The South Guard

    [side]	# wmllint: validate-off
        side=1
        {QUANTITY type (Horseman Commander) (Junior Commander) (Junior Commander)}
        id=Deoran
        name= _ "Deoran"
        unrenamable=yes
        facing=sw

        team_name=South_Guard
        user_team_name=_"South Guard"
        controller=human
        {CUSTOM_SG_FLAG}

        {GOLD 120 100 80}
        {INCOME 4 1 0}

        canrecruit=yes
        recruit=Peasant
    [/side]	# wmllint: validate-on

    {STARTING_VILLAGES 1 4}

    # The Bandit Armies

    [side]
        side=2
        type=Bandit
        id=Urza Mathin
        name= _ "Urza Mathin"
        profile=portraits/urza-mathin.png

        team_name=bandits
        user_team_name=_"Bandits"
        controller=ai

        {GOLD 40 70 90}

        canrecruit=yes
#ifdef EASY
        recruit=Ruffian,Thug
#endif

#ifdef NORMAL
        recruit=Ruffian,Thug,Poacher
#endif

#ifdef HARD
        recruit=Footpad,Thief,Poacher,Thug
#endif
        [ai]
            {ATTACK_DEPTH 1 2 3}
#ifdef EASY
            recruitment_pattern=fighter
#endif
#ifdef NORMAL
            recruitment_pattern=fighter,fighter,archer
#endif
#ifdef HARD
            recruitment_pattern=scout,fighter,archer,archer
#endif
        [/ai]
    [/side]

    {STARTING_VILLAGES 2 14}

    [label]
        x,y=13,10
        text= _ "The River Fort"
    [/label]

    # Scenario Pre-start

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Investigate the river fort"
                condition=win
            [/objective]
            [objective]
                description= _ "Defeat Urza Mathin"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                condition=lose
            [/objective]
            [objective]
                description= _ "Time runs out"
                condition=lose
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]

#ifdef EASY
        [set_variable]
            name=leader_attacked
            value=false
        [/set_variable]
#endif

        # Add a useful village on 'trivial' difficulty'.
#ifdef EASY
        {MODIFY_TERRAIN Gg^Vh 13 23}
#endif

        # Modify the size of the keep of the enemy on 'simple' and 'easy' difficulties.
#ifdef NORMAL
        {MODIFY_TERRAIN Ce 20 22}
#endif
#ifdef HARD
        {MODIFY_TERRAIN Ce 20 22}
        {MODIFY_TERRAIN Ce 19 24}
#endif
    [/event]

    # Scenario Start

    [event]
        name=start
        [message]
            speaker=narrator
            message= _ "Deoran found himself put to the test early in his command. Loris, the previous commander, had squandered his time in games and diversions and bandits had overrun the land..."
            image=wesnoth-icon.png
        [/message]

        [move_unit_fake]
            {QUANTITY type Pikeman Spearman Peasant}
            side=1
            x=18,18,18,19
            y=7,6,5,5
        [/move_unit_fake]

        [unit]
            {QUANTITY type Pikeman Spearman Peasant}
            id=Moreth
            name= _ "Moreth"
            side=1
            x,y=19,5
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [message]
            speaker=Moreth
            message= _ "You'll never take this village! I've seen your kind kill too many townsmen, and I'll defend them to the death!"
        [/message]

        [message]
            speaker=Deoran
            image=portraits/deoran-mad.png
            message= _ "My kind? I am a soldier of Wesnoth, a messenger of King Haldric, and the new commander of the South Guard! What do you mean, 'my kind'?"
        [/message]

        [message]
            speaker=Moreth
            message= _ "Sorry, sir! I thought you were one of the bandits who have been ransacking the towns and killing the villagers. What are you doing here? Sir Gerrick and I were the last of the South Guard..."
        [/message]

        [message]
            speaker=Deoran
            message= _ "I have been sent to take command of the South Guard and set things right. We must arm the villagers and drive off the bandits before they can do any more harm!"
        [/message]

        [message]
            speaker=Moreth
            message= _ "You should head to the river fort! Sir Gerrick will want to know that reinforcements have arrived!"
        [/message]

        {HIGHLIGHT_IMAGE 13 10 items/gohere.png ()}

#ifdef EASY
        [message]
            speaker=narrator
            image=items/gohere.png
            message= _ "Whenever you see a target that looks like this, you should move your leader (or whatever unit the dialogue just suggested) onto the hex that contains it."
        [/message]
#endif

        [message]
            speaker=Urza Mathin
            message= _ "Ha! This new commander is a mere boy. He will soon share the fate of that swine Loris!"
        [/message]
    [/event]

    # The River Fort - You find Sir Gerrick defending the citadel.

    [event]
        name=moveto

        [filter]
            side=1
            x,y=13,10
        [/filter]

        [removeitem]
            x,y=13,10
        [/removeitem]

        [unit]
            side=1
            type=South Guard Captain
            id=Sir Gerrick
            name= _ "Sir Gerrick"
            profile=portraits/sir-gerrick.png
            {IS_HERO}
            x,y=14,9
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_RESILIENT}
            [/modifications]
        [/unit]

        [message]
            speaker=Sir Gerrick
            message= _ "My lord, it is good that King Haldric has sent you to our lands! Bandits have overrun the whole countryside, and are killing and pillaging without pity. You must raise the South Guard again and drive off the bandits!"
        [/message]

        [message]
            speaker=Deoran
            message= _ "No doubt I am needed here. Unfortunately I have seen only farm tools to arm our men with. They are valorous, but cannot fight bandits with pitchforks!"
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "I will open the citadel's armory. We have a supply of spears and bows, and lacked only a leader to bring us to battle with them!"
        [/message]

#ifdef EASY
        [message]
            speaker=narrator
            image="units/commander.png~RC(magenta>red)"
            message= _ "Sir Gerrick is an infantry commander. He is a strong warrior in his own right, but when he is near less experienced troops, he makes their attack better too!"
        [/message]

        [message]
            speaker=narrator
            image="misc/hero-icon.png"
            message= _ "Units that have a hero marker are vital to your campaign. If any of them die, you will lose the scenario, so guard them carefully!"
        [/message]
#endif

        [objectives]
            side=1
            [objective]
                description= _ "Defeat Urza Mathin"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Deoran"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Sir Gerrick"
                condition=lose
            [/objective]
            [objective]
                description= _ "Time runs out"
                condition=lose
            [/objective]

            note={EARLY_FINISH_BONUS_NOTE}+{NEW_GOLD_CARRYOVER_NOTE_40}
        [/objectives]

#ifdef EASY
        [message]
            speaker=narrator
            image=items/gohere.png
            message= _ "Head back to the encampment where you started and recruit some troops!"
        [/message]

        {HIGHLIGHT_IMAGE 20 4 items/gohere.png ()}
#endif

        [allow_recruit]
            side=1
            type=Spearman, Bowman
        [/allow_recruit]
    [/event]

    # You return to the encampment and recruit troops.

#ifdef EASY
    [event]
        name=moveto
        [filter]
            x,y=20,4
        [/filter]

        [message]
            speaker=narrator
            message= _ "While you're in your camp, you can recruit more troops. Build up a small force to use against the bandits that Urza Mathin recruits."
            image=wesnoth-icon.png
        [/message]
        [message]
            speaker=narrator
            image="units/human-loyalists/bowman.png~RC(magenta>red)"
            message= _ "Bowmen have a strong ranged attack, and are very effective against units that lack a ranged attack, like Thieves and Thugs. They also carry a sword and can defend themselves against melee attacks."
        [/message]
        [message]
            speaker=narrator
            image="units/human-loyalists/spearman.png~RC(magenta>red)"
            message= _ "Spearmen have a strong melee attack, and are effective against most units. They also have a weak ranged attack. They form the backbone of the South Guard."
        [/message]
        [message]
            speaker=narrator
            message= _ "The best army will have a mix of units to deal with the different enemies that you will encounter. For now, concentrate on creating a small corps of experienced Bowmen."
            image=wesnoth-icon.png
        [/message]

        [removeitem]
            x,y=20,4
        [/removeitem]
    [/event]
#endif

    # Dusk - Sir Gerrick suggests that you should hold the north banks of the river.

#ifdef EASY
    [event]
        name=turn 4

        [if]
            [have_unit]
                id=Sir Gerrick
            [/have_unit]
            [then]
                [message]
                    speaker=Sir Gerrick
                    message= _ "Sir, bandits are most dangerous at night. Let us hold the north bank of the river until dawn and press our attack in the morning!"
                [/message]

                [message]
                    speaker=narrator
                    image=misc/schedule-firstwatch.png
                    message= _ "All of your units are 'lawful'. This means that they receive a combat bonus during the day, and a penalty at night. Urza Mathin's units are all 'chaotic', which means that they receive a bonus at night and a penalty during the day. You will be much more effective fighting during the day."
                [/message]
            [/then]
        [/if]
    [/event]
#endif

    # Dawn - Sir Gerrick suggests that you should attack now!

#ifdef EASY
    [event]
        name=turn 7

        [if]
            [have_unit]
                id=Sir Gerrick
            [/have_unit]
            [then]
                [message]
                    speaker=Sir Gerrick
                    message= _ "My lord! The dawn is breaking - now is the time for us to attack and drive these bandits from our lands. To me men of the South Guard!"
                [/message]

                [message]
                    speaker=narrator
                    image=misc/schedule-dawn.png
                    message= _ "During the day your units will deal more damage, and Urza Mathin's less. The more of his troops you can defeat during the day, the better!"
                [/message]
            [/then]
        [/if]
    [/event]
#endif

    # Mermen - You find mermen who will become allies and protect your waterways.

    [event]
        name=moveto
        [filter]
            side=1
            x,y=6,10
        [/filter]
        [unit]
            side=1
#ifdef EASY
            type=Merman Warrior
#endif
#ifdef NORMAL
            type=Merman Warrior
#endif
#ifdef HARD
            type=Merman Fighter
#endif
            id=Myssh
            name= _ "Myssh"
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_INTELLIGENT}
            [/modifications]
            x,y=7,11
        [/unit]
        [unit]
            side=1
#ifdef EASY
            type=Merman Spearman
#endif
#ifdef NORMAL
            type=Merman Hunter
#endif
#ifdef HARD
            type=Merman Hunter
#endif
            id=Ylla
            name= _ "Ylla"
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
            x,y=5,10
        [/unit]

        [message]
            speaker=Myssh
            message= _ "Your people have been allies of our lord, King Typhon. We will help you drive these bandits from your land if you allow us to live here in peace."
        [/message]

        [message]
            speaker=Deoran
            message= _ "We welcome your aid in the fight against these criminals! The rivers of this land are yours if you will aid us in our battles."
        [/message]

#ifdef EASY
        [message]
            speaker=narrator
            image="units/merfolk/hunter.png~RC(magenta>red)"
            message= _ "You may now recruit Merman Hunters. Mermen are aquatic creatures. Keep them in rivers and swamps and they will fight well! Put them on dry land and they're in trouble!"
        [/message]
#endif

        [allow_recruit]
            side=1
            type=Merman Hunter
        [/allow_recruit]
        {VARIABLE has_mermen "yes"}
    [/event]

    # Village Ambush - You find something unexpected in one of the villages.

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

#ifdef EASY
        [unit]
            side=1
            type=Longbowman
            id=Aleron
            name= _ "Aleron"
            x,y=16,12
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_QUICK}
            [/modifications]
        [/unit]

        [message]
            speaker=unit
            message= _ "Who goes there! Come out of the house now!"
        [/message]
        [message]
            speaker=Aleron
            message= _ "Stay! It's me, Aleron! The villagers hid me from the bandits when the town was overrun. They have kept me safe, though I was gravely wounded..."
        [/message]
        [message]
            speaker=Sir Gerrick
            message= _ "I am glad to find you alive Aleron, we feared the worst when you did not return after the battle!"
        [/message]
        [message]
            speaker=Aleron
            message= _ "Let us punish these bandits for their crimes and murders! My wounds are healed and I am ready for battle!"
        [/message]
        [message]
            speaker=narrator
            message= _ "Aleron is a longbowman, stronger and better trained than regular bowmen. His arrows are deadly to enemies without a ranged attack."
            image="units/human-loyalists/longbowman.png~RC(magenta>red)"
        [/message]
#endif

#ifdef NORMAL
        [unit]
            side=1
            type=Peasant
            id=Aleron
            name= _ "Aleron"
            x,y=16,12
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_STRONG}
            [/modifications]
        [/unit]

        [message]
            speaker=Aleron
            message= _ "Not more bandits... We have nothing left. Begone!"
        [/message]
        [message]
            speaker=unit
            message= _ "We are no bandits. The banner of the South Guard flies again! Help us drive these criminals from your land."
        [/message]
        [message]
            speaker=Aleron
            message= _ "However I can, I will help you!"
        [/message]
        [message]
            speaker=Sir Gerrick
            message= _ "Garrison the villages behind our lines and keep the enemy from slipping around us at night."
        [/message]
#endif

#ifdef HARD
        [unit]
            side=2
            type=Footpad
            random_traits=yes
            id=Glasar
            name= _ "Glasar"
            x,y=16,12
        [/unit]

        [message]
            speaker=Glasar
            message= _ "This village is ours to plunder! Begone or I will kill you all!"
        [/message]
        [message]
            speaker=unit
            message= _ "Do you not see the banners flying in the wind? The South Guard fights again. Flee while you can, or you will meet swift death on our spears!"
        [/message]
#endif
    [/event]

    # If the player doesn't find Sir Gerrick in five turns, prompt him again.

#ifdef EASY

    [event]
        name=turn 5
        [if]
            [have_unit]
                id=Sir Gerrick
            [/have_unit]
            [then]
            [/then]
            [else]
                {HIGHLIGHT_IMAGE 13 10 items/gohere.png ()}

                [message]
                    speaker=narrator
                    image=items/gohere.png
                    message= _ "Remember, Moreth told you that you should go meet Sir Gerrick at the river fort. Move Deoran there and find out what Sir Gerrick has to say!"
                [/message]
            [/else]
        [/if]
    [/event]

    # Nothing happens for a while: remind the player of the objective.

    [event]
        name=attack
        [filter_second]
            id=Urza Mathin
        [/filter_second]
        [set_variable]
            name=leader_attacked
            value=true
        [/set_variable]
    [/event]

    [event]
        name=turn 18
        [if]
            [variable]
                name=leader_attacked
                boolean_not_equals=true
            [/variable]
            [then]
                [scroll_to_unit]
                    id=Urza Mathin
                [/scroll_to_unit]
                [message]
                    speaker=narrator
                    image="units/human-outlaws/bandit.png~RC(magenta>red)"
                    message= _ "Remember, your job is to defeat Urza Mathin. He should be your main target. Archers will be especially effective against him, because he has no ranged attack. Surround him, and kill him!"
                [/message]
            [/then]
        [/if]
    [/event]

#endif

    # Victory - The bandits are defeated.

    [event]
        name=last breath
        [filter]
            id=Urza Mathin
        [/filter]

        [message]
            speaker=Urza Mathin
            message= _ "My days of pillage and plunder are over! My brothers will avenge me..."
        [/message]

        [kill]
            x,y=$x1,$y1
            animate=yes
        [/kill]

        [message]
            speaker=Sir Gerrick
            message= _ "He is dead! Congratulations, commander. We thought we would never see reinforcements - Did Sir Loris send you from Westin?"
        [/message]

        [message]
            speaker=Deoran
            message= _ "No. I have been sent by King Haldric to take command of the South Guard. The King has heard no news in weeks. How long have you and your men been shut up in the citadel?"
        [/message]

        [message]
            speaker=Sir Gerrick
            message= _ "Almost two months. Sir Loris took one of our patrols along the Westin road and never returned; and the next night, bandits struck and killed eight of my men. We held the citadel, and held out vain hope for reinforcement from Westin. We never thought we would see men sent from the King!"
        [/message]

        [message]
            speaker=Deoran
            image=portraits/deoran-sad.png
            message= _ "This is worse than even my darkest fears. We must ride to Westin at once, and hope that Sir Loris is there and well! Come men! Ride for Westin!"
        [/message]

        {CLEAR_VARIABLE leader_attacked}

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