#textdomain wesnoth-nr

# This scenario takes only place if Eryssa is with the player.
# However, the scenario has code to handle the case that Eryssa died.

# If the player wins this scenario without Sisal dying, he will have more gold in the final one.
# But if he doesn't succeed, he may have less money, because the carryover gold is 40%,
# compared to 100% if not playing this scenario. He get's more XP though.

[scenario]
    id=12a_Get_the_Gold
    name= _ "Get the Gold"
    map_file=12a_Get_the_Gold.map
    {TURNS 35 30 25}
    next_scenario=13a_Showdown

    {DEFAULT_SCHEDULE}

    {INTRO_AND_SCENARIO_MUSIC "revelation.ogg" "breaking_the_chains.ogg"}
    {EXTRA_SCENARIO_MUSIC     "elvish-theme.ogg"}
    {EXTRA_SCENARIO_MUSIC     "the_king_is_dead.ogg"}

    [story]
        [part]
            # wmllint: local spelling Angthurim
            story= _ "After conquering Castle Angthurim, the party set off after Rakshas, hoping that Hidel’s elves had been able to hold him."
            music=sad.ogg
        [/part]
        [part]
            story= _ "Orcs are heavy-footed creatures; Rakshas’s trail was readily followed. But an ominous silence, broken only by the cawing of ravens, brooded over the road he had taken."
        [/part]
        [part]
            story= _ "Soon they encountered the wrack of a great battle. Bodies of elves and orcs lay everywhere. Broken weapons and smashed armor were strewn about and elvish arrows and orcish bolts bristled from the nearby trees. The ground was red with blood."
        [/part]
        [part]
            story= _ "There were some survivors. Father Morvin oversaw their healing, while Tallin followed Eryssa as she anxiously walked among the dead."
        [/part]
        [part]
            story= _ "Suddenly, Eryssa cried out. In front of her lay Hidel."
        [/part]
        [part]
            story= _ "Scattered around him were the bodies of at least three orcish warlords, and nearly a score of grunts, warriors and crossbowmen. His weapons were notched and broken; his armor dented and smashed. It was clear that his fall had been a battle of valor and glory, worthy to be remembered in the songs of all the kindred races until the end of days."
            music=heroes_rite.ogg
        [/part]
        [part]
            story= _ "With tears streaming down her face, Eryssa knelt and cradled his head in her lap. As she stroked his face, his eyes fluttered open."
        [/part]

        {STORY_PART_HIDEL (_ "I am sorry, my lady... We held him for... as long as we could... but his bodyguards... were... just too many and powerful... And then... the orcish... reinforcements arrived...")}

        [part]
            story= _ "Her face streaked with tears, Eryssa gazed imploringly at Father Morvin and Sister Thera. They sighed and shook their heads. In a broken voice Eryssa addressed him:"
        [/part]

        {STORY_PART_ERYSSA (_ "Hidel, I am sorry. I have sent you to your death.")}

        {STORY_PART_HIDEL (_ "... Don’t tax yourself... Eryssa... I have died... a warrior’s death... You should be proud...")}

        {STORY_PART_HIDEL (_ "... But... there is... one thing... we... could do. We... managed to... recover the gold... Sisal... took it and... retreated south...")}

        {STORY_PART_HIDEL (_ "I held out as... long as... I could... but they... defeated us... Rakshas went... east and the... rest... went... after... Sisal...")}

        {STORY_PART_HIDEL (_ "Now... uphold the honor... of the Northern... Elves... Recover... the gold... slay this monster... and bring peace... to the... Northlands... Tallin?")}

        [part]
            story= _ "At Hidel’s call Tallin approached. He knelt beside, bowing his head in respect."
        [/part]

        {STORY_PART_TALLIN (_ "At your service, sir.")}

        {STORY_PART_HIDEL (_ "Eryssa has been... my charge ever... since she was born... I now return... to the earth... from which... I sprang... Please take care... of her.")}

        {STORY_PART_TALLIN (_ "I will.")}

        {STORY_PART_HIDEL (_ "Thank you... Tallin... Now I may rest... in... peace... May you... be victorious...")}

        [part]
            story= _ "Then Hidel closed his eyes and took one last breath."
        [/part]

        [part]
            story= _ "Slowly Tallin approached her. He hesitated before wrapping her gently in his arms."
            music=love_theme.ogg
        [/part]
        [part]
            story= _ "Sobbing against Tallin’s chest, Eryssa told him of the many ways Hidel had cherished and warded her and her sister. How he had comforted their childhood hurts; how in later years, he had guided them in the green paths of the forest, and taught them the deep mysteries of elven-kind."
        [/part]
        [part]
            story= _ "The torrent of childhood memories and the depth of her grief left her unable to speak. She and Tallin sat together silently holding each-other for some time."
        [/part]
        [part]
            story= _ "As Tallin comforted Eryssa, the surviving elves gathered all of the fallen warriors, and with the humans’ help, laid them to rest. For Hidel, the dwarves raised a monument so that his heroic death would long be remembered. Then, they came before Tallin and Eryssa."
        [/part]

        {STORY_PART_FATHER_MORVIN (_ "My lady... it is a hard thing, I know, but you must put your grief behind you. Or at least, put it aside for a little while. We must go quickly to the aid of Sisal and recover our gold.")}

        {STORY_PART_ARTHIAN (_ "Forge your sorrow into rage, girl, and visit it on the slayers of your kinsmen. Teach them what happens to those who make an enemy of an elf.")}

        [part]
            story= _ "At these words, Eryssa arose and wiped away her tears. She took command of the surviving elvish forces, for all knew she was a princess of high rank and looked to Hidel’s ward as their leader. Scarcely a face among them was less grim than her own as they took arms and started down Rakshas’s trail."
            music=vengeful.ogg
        [/part]
        [part]
            # po: "espied" is correct here, it's a deliberate archaism
            story= _ "Moments later a gryphon swooped down from overhead and reported battle in a forest just a few leagues south of their position. The remainder of the elvish forces had been espied fighting a desperate battle with the orcs."
        [/part]
        [part]
            story= _ "It seemed to the gryphon that the elves were sore beset. The party quickly turned south and plunged into the forest."
        [/part]
    [/story]

    {NR_TRACK ({RECOVERY_COMPLETE} {ELVES_STAGE1}) }

    # Players side - Tallin
    # wmllint: validate-off
    [side]
        side=1
        controller=human
        recruit=Thug,Poacher,Spearman,Bowman,Dwarvish Fighter,Dwarvish Thunderer,Dwarvish Ulfserker,Dwarvish Scout,Gryphon,Footpad
        team_name=knalgans
        user_team_name= _ "Alliance"

        # wmllint: recognize Tallin
        {CHARACTER_STATS_TALLIN}
    [/side]
    # wmllint: validate-on

    # Allied AI - Sisal, set to play cautiously
    [side]
        side=2
        controller=ai
        recruit=Elvish Fighter,Elvish Archer,Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman
        {GOLD 350 300 250}
        team_name=knalgans
        user_team_name= _ "Alliance"
        {FLAG_VARIANT wood-elvish}

        type=Elvish Avenger
        gender=female
        id=Sisal
        name= _ "Sisal"
        profile=portraits/Sisal.webp
        canrecruit=yes

        [ai]
            aggression=0.3
            caution=0.7
            leader_value=10
            [avoid]
                terrain=D*,W*
            [/avoid]
        [/ai]

        # Place Sisal troops
        {GENERIC_UNIT 2 "Elvish Archer" 9 20}
        [+unit]
            hitpoints=18
        [/unit]

        {GENERIC_UNIT 2 "Elvish Fighter" 10 20}
        [+unit]
            hitpoints=24
        [/unit]

        {GENERIC_UNIT 2 "Elvish Shaman" 9 21}
        {GENERIC_UNIT 2 "Elvish Captain" 11 21}
        [+unit]
            hitpoints=39
        [/unit]

        {GENERIC_UNIT 2 "Elvish Shaman" 20 21}
        {GENERIC_UNIT 2 "Elvish Fighter" 21 21}
    [/side]

    # Enemy AI - set to be aggressive
    [side]
        side=3
        controller=ai
        recruit=Orcish Warrior,Orcish Slayer,Troll,Troll Rocklobber,Orcish Crossbowman
        {GOLD 800 1200 1600}
        team_name=orcs
        user_team_name= _ "Orcs"
        {FLAG_VARIANT6 ragged}

        type=Orcish Warlord
        id="Ha'Tuil"
        name= _ "Ha’Tuil"
        canrecruit=yes

        [ai]
            aggression=1.0
            caution=-1.0
            leader_value=50
        [/ai]

        # Place enemy troops
        {GENERIC_UNIT 3 "Orcish Crossbowman" 10 19}
        [+unit]
            hitpoints=30
        [/unit]

        {GENERIC_UNIT 3 "Orcish Slayer" 11 20}
        [+unit]
            hitpoints=25
        [/unit]

        {GENERIC_UNIT 3 "Orcish Crossbowman" 14 17}
        [+unit]
            hitpoints=3
        [/unit]

        {GENERIC_UNIT 3 "Orcish Crossbowman" 23 19}
        [+unit]
            hitpoints=30
        [/unit]

        {GENERIC_UNIT 3 "Orcish Warrior" 17 17}
        {GENERIC_UNIT 3 "Orcish Warrior" 15 15}
        {GENERIC_UNIT 3 "Orcish Warrior" 14 14}
        {GENERIC_UNIT 3 "Orcish Warrior" 17 15}
        {GENERIC_UNIT 3 "Orcish Warrior" 18 14}
        {GENERIC_UNIT 3 "Orcish Warrior" 18 14}
        {GENERIC_UNIT 3 "Orcish Warrior" 16 14}
        {GENERIC_UNIT 3 "Orcish Warrior" 18 13}
        {GENERIC_UNIT 3 "Orcish Warrior" 18 13}
        {GENERIC_UNIT 3 "Orcish Warrior" 18 13}
        {GENERIC_UNIT 3 "Orcish Warrior" 18 13}
        {GENERIC_UNIT 3 "Orcish Warrior" 15 17}
        {GENERIC_UNIT 3 "Orcish Warrior" 20 18}
        {GENERIC_UNIT 3 "Orcish Warrior" 19 18}

        {GENERIC_UNIT 3 "Orcish Slayer" 17 17}
        {GENERIC_UNIT 3 "Orcish Slayer" 17 17}
        {GENERIC_UNIT 3 "Orcish Slayer" 15 15}
        {GENERIC_UNIT 3 "Orcish Slayer" 15 14}
        {GENERIC_UNIT 3 "Orcish Slayer" 17 15}
        {GENERIC_UNIT 3 "Orcish Slayer" 18 14}
        {GENERIC_UNIT 3 "Orcish Slayer" 16 14}
        {GENERIC_UNIT 3 "Orcish Slayer" 18 13}
        {GENERIC_UNIT 3 "Orcish Slayer" 18 13}
        {GENERIC_UNIT 3 "Orcish Slayer" 21 17}

        {GENERIC_UNIT 3 "Orcish Crossbowman" 18 13}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 18 13}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 18 13}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 17 17}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 15 15}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 15 14}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 17 15}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 18 14}
        {GENERIC_UNIT 3 "Orcish Crossbowman" 16 14}
    [/side]

    # Krash may not actually still be alive at this point, but setting up
    # his side this way is the only way to reliably pick up his recall
    # list if he is.
    [side]
        side=4
        controller=human
        save_id=Krash
        side_name= _ "Krash"
        recruit=Drake Fighter,Drake Glider,Drake Burner,Drake Clasher
        {GOLD 250 200 150}
        team_name=knalgans
        user_team_name= _ "Alliance"
        no_leader=yes
        # Krash's color
        color=orange
        {FLAG_VARIANT long}
    [/side]

    # Empty side - player will assume control of it if Eryssa is alive
    [side]
        side=5
        controller=human
        save_id=Elves
        persistent=yes
        no_leader=yes
        recruit=Elvish Fighter,Elvish Archer,Elvish Shaman,Elvish Scout,Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Rider,Elvish Druid,Elvish Sorceress
        {GOLD 400 350 300}
        team_name=knalgans
        user_team_name= _ "Alliance"
        color=teal
        {FLAG_VARIANT wood-elvish}
    [/side]

    [event]
        name=prestart

        # Remember we went this way.
        # FIXME: this variable is currently used nowhere!
        {VARIABLE path_get_the_gold yes}

        # Here’s where we edit out Krash's side if he's dead.
        {RECALL_KRASH 4}
        [if]
            [not]
                [have_unit]
                    #wmllint: recognize Krash
                    id=Krash
                [/have_unit]
            [/not]
            [then]
                [kill]
                    side=4
                [/kill]

                [terrain]
                    x=4,4,4,5,5,5,6,6,6
                    y=3,4,5,3,4,5,3,4,5
                    terrain=Gs^Fp
                [/terrain]

                [modify_side]
                    side=4
                    hidden=yes
                [/modify_side]

                # give gold if no krash
                [gold]
                    side=1,5
                    amount={ON_DIFFICULTY 300 275 250}
                [/gold]
            [/then]
        [/if]

        # If Eryssa is alive change her to recruiting leader of side 5 and
        # place on that keep. This method works because, unlike Krash, she
        # has no recall list of followers to preserve.
        [if]
            [have_unit]
                #wmllint: recognize Eryssa
                id=Eryssa
                search_recall_list=yes
            [/have_unit]
            [then]
                [store_starting_location]
                    side=5
                    variable=eryssa_starts_at
                [/store_starting_location]

                [recall]
                    id=Eryssa
                    x=$eryssa_starts_at.x
                    y=$eryssa_starts_at.y
                [/recall]

                # Remove loyalty overlay
                [remove_unit_overlay]
                    id=Eryssa
                    image=misc/loyal-icon.png
                [/remove_unit_overlay]

                # Give expendable overlay
                [unit_overlay]
                    id=Eryssa
                    image=misc/leader-expendable.png
                [/unit_overlay]

                [store_unit]
                    [filter]
                        id=Eryssa
                    [/filter]
                    variable=place_eryssa_at
                    kill=yes
                [/store_unit]

                {VARIABLE place_eryssa_at.side 5}
                {VARIABLE place_eryssa_at.x    $eryssa_starts_at.x}
                {VARIABLE place_eryssa_at.y    $eryssa_starts_at.y}
                {VARIABLE place_eryssa_at.canrecruit yes}

                [unstore_unit]
                    variable=place_eryssa_at
                [/unstore_unit]

                [modify_side]
                    side=5
                    side_name= _ "Eryssa"
                [/modify_side]

                {CLEAR_VARIABLE place_eryssa_at}
                {CLEAR_VARIABLE eryssa_starts_at}
            [/then]
            [else]
                [modify_side]
                    side=5
                    hidden=yes
                [/modify_side]
            [/else]
        [/if]

        # Recall heroes
        {RECALL_SUPPORTER}

        {RECALL_OR_REPLACE id=Camerin}

        [recall]
            id=Father Morvin
        [/recall]

        [recall]
            id=Sister Thera
        [/recall]

        {RECALL_OR_REPLACE id=Elenia}

        {RECALL_OR_REPLACE id=Stalrag}

        [recall]
            id="Ro'Sothian"
        [/recall]

        [recall]
            id="Ro'Arthian"
        [/recall]

        {RECALL_OR_REPLACE id=Abhai}

        # Set the objectives
        [objectives]
            side=0
            [objective]
                description= _ "Defeat the orcs"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Tallin"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Ro’Arthian"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Ro’Sothian"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

            [note]
                description= _ "You will not receive any gold if Sisal dies."
            [/note]

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

    [event]
        name=start

        [message]
            speaker=narrator
            image=wesnoth-icon.png
            message= _ "After several hours of hard travel the party arrived at the battle scene."
        [/message]

        [message]
            id=Eryssa
            message= _ "Sisal, how do you fare?"
        [/message]

        [message]
            id=Sisal
            message= _ "Your Highness! You are here! How fares Hidel?"
        [/message]

        [message]
            id=Eryssa
            message= _ "(<i>Sheds a tear</i>)"
        [/message]

        [message]
            id=Tallin
            message= _ "Hidel... died a hero’s death, one worthy to be sung forever."
        [/message]

        [message]
            id=Sisal
            message= _ "The dung-spawned bastards! Verily, had it not been for Hidel we would all be dead and Rakshas would be gleefully counting his gold."
        [/message]

        [message]
            id=Sisal
            message= _ "Hidel and a handful of elves held off the orcs for more than an hour. That was enough time for us to make off with the gold and rally here at these ruins."
        [/message]

        [message]
            id=Tallin
            message= _ "So you have the gold?"
        [/message]

        [message]
            id=Sisal
            message= _ "We have the gold, and now we shall have the blood of these orcs! IN HIDEL’S NAME!"
        [/message]

        [message]
            id="Ha'Tuil"
            # wmllint: local spelling Grrr
            message= _ "Grrr, Ha’Tuil has never failed in his mission. I will soon lay your severed heads at the feet of the Master!"
        [/message]

        [message]
            id=Sisal
            message= _ "You will eat cold steel and whimper your way to hell, foul wretch of an orc!"
        [/message]
    [/event]

    # Bad guy die event
    [event]
        name=last breath
        [filter]
            id="Ha'Tuil"
        [/filter]

        [message]
            id="Ha'Tuil"
            message= _ "Argh! I have failed!"
        [/message]

        [message]
            id=Sisal
            message= _ "Cheer up — you won’t have to live with your failure for long... (<i>Snicker</i>)"
        [/message]
    [/event]

    # Sisal die event
    [event]
        name=last breath
        [filter]
            id=Sisal
        [/filter]

        {INCIDENTAL_MUSIC "sad.ogg"}

        [message]
            id=Sisal
            message= _ "Ahhhh! Farewell, friends. I now go to join Hidel."
        [/message]

        [message]
            id=Eryssa
            message= _ "Sisal! Noooo!"
        [/message]

        [message]
            speaker=second_unit
            message= _ "Haha! We got the gold now!"
        [/message]

        [message]
            id="Ha'Tuil"
            message= _ "Hahaha! Mission accomplished! I’ll send a wolf to the Master to deliver the gold. Now let’s crush the rest of this scum!"
        [/message]

        [move_unit_fake]
            type=Goblin Knight
            x=19,25
            y=13,12
            side=3
        [/move_unit_fake]

        [message]
            id=Eryssa
            message= _ "I don’t think so, you bastard orcs! That gold belongs to us. Besides, we now have a few scores to settle with you. Take them, troops! I want no orc left alive!"
        [/message]
    [/event]

    [event]
        name=enemies defeated

        [if]
            [have_unit]
                id=Sisal
            [/have_unit]
            [then]
                [message]
                    id=Tallin
                    message= _ "Thanks to Hidel and the elves, we have recovered our gold. Now let’s run down Rakshas and end this once and for all."
                [/message]
            [/then]
            [else]
                [message]
                    id=Tallin
                    message= _ "Hidel’s death was a grievous loss; our thirst for vengeance must do what the stolen gold cannot. Now let’s run down Rakshas and settle this once and for all."
                [/message]
            [/else]
        [/if]

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

    # Victory
    [event]
        name=victory

        [if]
            [have_unit]
                id=Sisal
            [/have_unit]
            [then]
                [modify_unit]
                    [filter]
                        id=Sisal
                    [/filter]
                    canrecruit=no
                    {TRAIT_LOYAL}
                [/modify_unit]
            [/then]
        [/if]

        # Make veteran elves available for the Elf side in Showdown.
        {MODIFY_UNIT (side=2) side 5}

        # Sisal and Eryssa need to be recallable.
        [modify_unit]
            [filter]
                id=Sisal,Eryssa
            [/filter]
            side=1
        [/modify_unit]
    [/event]

    # Load death events
    {HERODEATH_EVERYONE}
[/scenario]
