#textdomain wesnoth-tsg
[scenario]
    id=06a_Tidings_Good_and_Ill

    name= _ "Tidings, Good and Ill"
    next_scenario=07a_Into_the_Depths

    {SCENARIO_MUSIC loyalists.ogg}
    {EXTRA_SCENARIO_MUSIC wanderer.ogg}

    map_data="{campaigns/The_South_Guard/maps/06a_Tidings_Good_and_Ill.map}"

#define SG_DEATHS_JAREK_ALTERNATIVE
#enddef
    {campaigns/The_South_Guard/utils/sg_deaths.cfg}
    {campaigns/The_South_Guard/utils/sg_help.cfg}

    {DEFAULT_SCHEDULE_DUSK}

    turns=18
    victory_when_enemies_defeated=no

    {TSG_BIGMAP {JOURNEY_06A_NEW} }

    # Deoran will be removed and Gerrick instated as the leader in a prestart
    # event.

    [side]
        side=1
        type=Horseman Commander
        id=Deoran
        name= _ "Deoran"
        profile=portraits/deoran.png
        unrenamable=yes

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

        gold=0
        income=0

        shroud=yes
        fog=yes

        canrecruit=yes
    [/side]

    # Miscellaneous Enemy Combatants

    [side]
        side=2

        team_name=Various_Baddies
        user_team_name=_"Enemies"
        no_leader=yes
        hidden=yes

        controller=ai

        {NAMED_GENERIC_UNIT 2 (Saurian Skirmisher) 8 21 (Ssesseth) (_"Ssesseth")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Saurian Skirmisher) 17 16 (Zasz) (_"Zasz")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Saurian Skirmisher) 8 16 (Zerix) (_"Zerix")} {GUARDIAN}

        {NAMED_GENERIC_UNIT 2 (Giant Scorpion) 14 16 (Scorpion) (_"Scorpion")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Ogre) 4 10 (Kramak) (_"Kramak")} {GUARDIAN}

        {NAMED_GENERIC_UNIT 2 (Naga Fighter) 13 9 (Issorai) (_"Issorai")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Naga Fighter) 14 9 (Zarr) (_"Zarr")} {GUARDIAN}

        {NAMED_GENERIC_UNIT 2 (Dark Adept) 8 1 (Abdur) (_"Abdur")} {GUARDIAN}

        #wmllint: local spelling Xeila
#ifdef EASY
        {NAMED_GENERIC_UNIT 2 (Naga Fighter) 12 8 (Queen Xeila) (_"Queen Xeila")} {GUARDIAN}
        [+unit]
            gender=female
            ellipse=misc/ellipse-hero
        [/unit]
#endif

#ifdef NORMAL
        {NAMED_GENERIC_UNIT 2 (Saurian Skirmisher) 9 14 (Ssanur) (_"Ssanur")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Naga Fighter) 13 7 (Lesssh) (_"Lesssh")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Naga Warrior) 12 8 (Queen Xeila) (_"Queen Xeila")} {GUARDIAN}
        [+unit]
            gender=female
            ellipse=misc/ellipse-hero
        [/unit]
#endif

#ifdef HARD
        {NAMED_GENERIC_UNIT 2 (Saurian Ambusher) 9 14 (Ssanur) (_"Ssanur")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Dark Adept) 7 1 (Kallen) (_"Kallen")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Naga Warrior) 13 7 (Lesssh) (_"Lesssh")} {GUARDIAN}
        {NAMED_GENERIC_UNIT 2 (Naga Myrmidon) 12 8 (Queen Xeila) (_"Queen Xeila")} {GUARDIAN}
        [+unit]
            gender=female
            ellipse=misc/ellipse-hero
        [/unit]
#endif
    [/side]

    #prestart

    [event]
        name=prestart

        # Store away Deoran, Ethiliel and her bodyguards, so
        # that only Gerrick, human troops and the rest of the elves remain.
        # wmllint: recognize Ethiliel
        # wmllint: recognize Minister Hylas
        # wmllint: recognize Elvish Bodyguard
        # wmllint: recognize Sir Gerrick

        [store_unit]
            [filter]
                id=Deoran
            [/filter]

            kill=yes
            variable=stored_Deoran
        [/store_unit]

        [store_unit]
            [filter]
                id=Ethiliel
            [/filter]

            kill=yes
            variable=stored_Ethiliel
        [/store_unit]

        [store_unit]
            [filter]
                id=Minister Hylas
            [/filter]

            kill=yes
            variable=stored_Hylas
        [/store_unit]

        [store_unit]
            [filter]
                side=1
                role=Elvish Bodyguard
            [/filter]

            kill=yes
            variable=stored_elvish_bodyguards
        [/store_unit]

        # Store Deoran’s gold so it can be restored in Into the Depths and set
        # Gerrick’s gold to 75.

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

        [modify_side]
            side=1
            gold=75
        [/modify_side]

        # Recall Gerrick and set him as the leader.

        [recall]
            id=Sir Gerrick
            x,y=16,23
        [/recall]

        {MODIFY_UNIT (id=Sir Gerrick) overlays ""}
        {MODIFY_UNIT (id=Sir Gerrick) canrecruit yes}
        {MODIFY_UNIT (id=Sir Gerrick) ellipse ""}

        [set_recruit]
            side=1
            recruit=Elvish Fighter,Elvish Shaman
        [/set_recruit]

        [if]
            [variable]
                name=has_merfolk
                equals="yes"
            [/variable]
            [then]
                [allow_recruit]
                    side=1
                    type=Merman Hunter
                [/allow_recruit]
            [/then]
        [/if]

        [unit]
            type=Elvish Ranger
            id=Eliomir
            name= _ "Eliomir"
            x,y=17,22
            facing=sw
            side=1
            [modifications]
                {TRAIT_LOYAL}
                {TRAIT_DEXTROUS}
            [/modifications]
            {IS_LOYAL}
        [/unit]
    [/event]

    #start

    [event]
        name=start

        [message]
            speaker=Eliomir
            message= _ "Sir Gerrick, you must return to Westin and warn your people of the danger from the south. We will lead you through the forest and clear the foes from your path. You may choose some of your veterans to accompany your journey. Any troops you leave behind will still have time to join Ethiliel and Deoran."
        [/message]

        [remove_shroud]
            side=1
            x=8-10,9
            y=0-1,2
        [/remove_shroud]

        {HIGHLIGHT_IMAGE 9 1 items/gohere.png ()}

        [message]
            speaker=Sir Gerrick
            message= _ "With many of the bandits and undead vanquished already, few foes should remain before us. Let us hope this is a speedy journey, for the specter of winter looms closer."
        [/message]

        [objectives]
            side=1
            [objective]
                description= _ "Move Sir Gerrick to the north end of the woods"
                condition=win
            [/objective]
            [objective]
                description= _ "Defeat Queen Xeila"
                condition=win
                [show_if]
                    [variable]
                        name=naga_queen_sighted
                        boolean_equals=yes
                    [/variable]
                    [have_unit]
                        id=Queen Xeila
                    [/have_unit]
                [/show_if]
            [/objective]
            [objective]
                description= _ "Death of Sir Gerrick"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [gold_carryover]
                carryover_percentage=0
            [/gold_carryover]

            [note]
                description= _ "Recalled units will be unavailable to Deoran."
            [/note]
        [/objectives]
    [/event]

    # The naga are sighted, and move to defend their home.
    # They are enraged if you allied with the mermen in "Born to the Banner"

    [event]
        name=sighted
        [filter]
            id=Queen Xeila
        [/filter]

        [if]
            [variable]
                name=has_merfolk
                equals="yes"
            [/variable]
            [then]
                [message]
                    # wmllint: local spelling Hss
                    # po: Hss is a hissing sound made by the naga
                    speaker=Queen Xeila
                    message= _ "Hss... Here come the humans who have made a pact with the cursed mermen!"
                [/message]
                [message]
                    speaker=Eliomir
                    message= _ "We have stumbled upon a den of naga!"
                [/message]
                [message]
                    speaker=Queen Xeila
                    message= _ "Hss... Elves too! We will kill them all, my brood. Hss..."
                [/message]
                [message]
                    speaker=Sir Gerrick
                    message= _ "If we leave these naga here, they will ambush Deoran and Ethiliel! We must destroy them!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Queen Xeila
                    message= _ "Hss... elves! Are they friends or enemies? Hss..."
                [/message]
                [message]
                    speaker=Sir Gerrick
                    message= _ "We are weary travelers, seeking our homes. If you but let us pass..."
                [/message]
                [message]
                    speaker=Queen Xeila
                    message= _ "Hss... And humans! Humans drained our swamps and destroyed our homes! Now they have found my winter nest and seek to destroy me. The Land-Walkers must die! Hss..."
                [/message]
                [message]
                    speaker=Sir Gerrick
                    message= _ "She refuses to listen! If we leave these naga here, they will ambush Deoran and Ethiliel! We must destroy them!"
                [/message]
            [/else]
        [/if]

        {VARIABLE naga_queen_sighted yes}

        [show_objectives][/show_objectives]
    [/event]

    [event]
        name=sighted
        [filter]
            type_adv_tree=Naga Fighter

            [not]
                id=Queen Xeila
            [/not]
        [/filter]

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

            [then]
                [message]
                    speaker=second_unit
                    message= _ "There are a group of naga occupying this area. They don’t look very friendly."
                [/message]

                [message]
                    speaker=Sir Gerrick
                    message= _ "If they are hostile to us, they could endanger Deoran and Ethiliel as well, but perhaps we can reason with their leader."
                [/message]
            [/then]
        [/if]
    [/event]

    # Queen Xeila dies...

    [event]
        name=last breath
        [filter]
            id=Queen Xeila
        [/filter]
        [message]
            speaker=Queen Xeila
            message= _ "Who will watch over my brood now? Hss..."
        [/message]
    [/event]

    # Kramak, the wild ogre

    [event]
        name=sighted
        [filter]
            id=Kramak
        [/filter]
        [message]
            speaker=Kramak
            #po: The ogre purposely has very bad grammar, because he is very stupid.
            message= _ "Oh! Me see elves. Elves tasty food?"
        [/message]
        [message]
            speaker=second_unit
            # wmllint: local spelling Mr.
            message= _ "Err, Mr. Ogre, we are not very tasty."
        [/message]
        [message]
            speaker=Kramak
            message= _ "Oh. Me like only tasty meat. You go away."
        [/message]
        [message]
            speaker=Kramak
            message= _ "..."
        [/message]
        [message]
            speaker=Kramak
            message= _ "Wait! Me no believe! Me eat you!"
        [/message]
    [/event]

    [event]
        name=last breath
        [filter]
            id=Kramak
        [/filter]
        [message]
            speaker=Kramak
            message= _ "Bad food! It hurt me. Me no like. Me pain..."
        [/message]
    [/event]

    # The Dark Adept's Story
    [event]
        name=sighted
        [filter]
            id=Abdur
        [/filter]
        [message]
            speaker=Abdur
            message= _ "Hail, travelers! I seek the dark sage who is rumored to dwell in these lands. Surely you have come from him?"
        [/message]
        [message]
            speaker=Sir Gerrick
            message= _ "Indeed! I just left my comrades, who were preparing to kill the vile necromancer."
        [/message]
        [message]
            speaker=Abdur
            message= _ "Unworthy fools! How dare you attack the hallowed one?! You must be slain for this sacrilege!"
        [/message]
    [/event]

    # Sir Gerrick moves to the head of the road
    [event]
        name=moveto
        first_time_only=no
        [filter]
            id=Sir Gerrick
            x,y=9,1
        [/filter]

        [if]
            [have_unit]
                id=Queen Xeila
            [/have_unit]

            [then]
                [message]
                    speaker=Sir Gerrick
                    message= _ "These naga are still in control of the road. We must clear the way for Deoran and Ethiliel!"
                [/message]

                [allow_undo][/allow_undo]
            [/then]

            [else]
                [remove_item]
                    x,y=9,1
                [/remove_item]

                [message]
                    speaker=Sir Gerrick
                    message= _ "I must hasten back to Kerlath Province and seek the advice of the Council of Westin. I pray that Deoran and Ethiliel find the strength to defeat the undead on their own."
                [/message]
                [message]
                    speaker=Eliomir
                    message= _ "We will return to our council as well. There is much we have to tell them... much indeed."
                [/message]

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

    [event]
        name=victory

        # The next scenario is again led by Deoran, so store away Gerrick and
        # his troops, except those remaining on the recall list.

        [heal_unit]
            [filter]
                side=1
            [/filter]
            amount=full
            animate=no
            moves=full
            restore_attacks=yes
            restore_statuses=yes
        [/heal_unit]

        [store_unit]
            [filter]
                id=Sir Gerrick
            [/filter]

            kill=yes
            variable=stored_Sir_Gerrick
        [/store_unit]

        {VARIABLE stored_Sir_Gerrick.canrecruit no}
        {VARIABLE stored_Sir_Gerrick.overlays misc/loyal-icon.png}
        {CLEAR_VARIABLE stored_Sir_Gerrick.ellipse}

        [store_unit]
            variable=stored_Sir_Gerrick_army
            [filter]
                side=1
                {NOT_ON_RECALL_LIST}
                [not]
                    race=mermen
                [/not]
            [/filter]
            kill=yes
        [/store_unit]

        # Mermen return to their homes now, as mentioned in S5.
        # They would not be of any use in later scenarios.
        [kill]
            race=mermen
        [/kill]

        # Reinstate Deoran as the leader and unstore Hylas, Ethiliel and
        # troops so they're all again recallable in the next scenario.

        [unstore_unit]
            variable=stored_Deoran
            x,y=recall,recall
        [/unstore_unit]

        [unstore_unit]
            variable=stored_Ethiliel
        [/unstore_unit]

        # He may die from now on
        {VARIABLE stored_Hylas.overlays misc/loyal-icon.png}
        {CLEAR_VARIABLE stored_Hylas.ellipse}

        [unstore_unit]
            variable=stored_Hylas
        [/unstore_unit]

        [foreach]
            array=stored_elvish_bodyguards
            [do]
                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]

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

        {CLEAR_VARIABLE stored_Deoran_side}
        {CLEAR_VARIABLE stored_Deoran}
        {CLEAR_VARIABLE stored_Ethiliel}
        {CLEAR_VARIABLE stored_Hylas}
        {CLEAR_VARIABLE stored_elvish_bodyguards}
        {CLEAR_VARIABLE has_merfolk,naga_queen_sighted}
    [/event]
[/scenario]
