#textdomain wesnoth-sota

# If the bird bones were not found on the beach, then you get the ability to recruit
# chocobones when a unit inspects the bones of a flightless bird half-buried in the snow.
# There is one long event for this. If the bones *were* found earlier, this event is
# removed in the prestart event.

[scenario]
    name= _ "Mountain Pass"
    map_file=15_Mountain_Pass.map

    id=15_Mountain_Pass
    next_scenario=16_The_Mage
    victory_when_enemies_defeated=no

    [story]
        [part]
            [background_layer]
                image=story/mountain-pass.webp
                scale=no
            [/background_layer]
            #po: "consumption" is an old word for tuberculosis
            story= _ "6 V, 23 YW

We have reached a pass through the mountains that Ras-Tabahn knew of. The air is cool in these upper reaches. Mist rises from the snow in the afternoon, and the icicles drip the purest water from rock overhangs. I find it all refreshing, but Ras-Tabahn’s coughing fits are frequent. Sometimes he is reduced to speaking in short phrases due to lack of breath. Of course, he is quite old — at least fifty — but I am also certain that he is ill. His thinness leads me to believe it is consumption, but he refuses to discuss it, preferring to deny the severity of his problem."
        [/part]
        {JOURNEY_PART 15}
    [/story]

    {DEFAULT_SCHEDULE}
    {DEFAULT_MUSIC_PLAYLIST}
    {TURNS 26 25 24}

    # wmllint: validate-off
    [side]
        {SIDE_1_BOTH}
        {GOLD 200 170 140}
        fog=yes
    [/side]
    # wmllint: validate-on

    [side]
        side=2
        type=Gryphon
        controller=ai
        user_team_name= _ "Gryphons"
        team_name=bad
        recruit=Gryphon
        {GOLD 70 80 90}
        {INCOME 15 18 21}
    [/side]

    [side]
        side=3
        type=Gryphon
        controller=ai
        user_team_name= _ "Gryphons"
        team_name=bad
        recruit=Gryphon
        {GOLD 80 100 120}
        {INCOME 9 12 15}
    [/side]

    {STARTING_VILLAGES  1 6}

    # *************************** PRESTART ***************************
    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Move Ardryn-Na and Ras-Tabahn to level ground in the northeast corner"
                condition=win
            [/objective]

            {HOW_TO_LOSE_WITH_BOTH}

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

        [if]
            [variable]
                name=bird_bones_found
                not_equals=yes
            [/variable]
            [then]
                [item]
                    x,y=25,9
                    image=items/bird-bones.png
                [/item]
            [/then]
            [else]
                # If chocobones can already be recruited, you lose one unit.
                # Even though that unit tended to die fairly quickly, you still
                # should be compensated, so here's a little gold.
                [gold]
                    side=1
                    amount=18
                [/gold]
                [remove_event]
                    id=bird_bones
                [/remove_event]
            [/else]
        [/if]

        [clear_variable]
            name=bird_bones_found
        [/clear_variable]

        {RECALL_LOYAL_UNITS}
    [/event]
    # *************************** PLAY ***************************

    # This long event creates a chocobone when a unit moves to where bird bones are
    # buried in the snow. The event is removed if chocobones were discovered on the
    # beach with the Merfolk.
    # There is a short conversation, but there are many possibilities for which units
    # are involved, so there are a lot of ifs. There is also a lot of animation around
    # the appearance of the chocobone involving a skeleton and a flightless-bird unit.
    [event]
        name=moveto
        id=bird_bones

        [filter]
            x,y=25,9
            side=1
        [/filter]
        [if]
            [variable]
                name=unit.race
                equals=bats
            [/variable]
            [or]
                [variable]
                    name=unit.variation
                    equals=bat
                [/variable]
            [/or]
            [then]
                # Bones examined by a bat or undead bat
                [message]
                    speaker=Ras-Tabahn
                    message= _ "There are some... large bones there. Claws and wings... I think."
                [/message]
            [/then]
            [else]
                [if]
                    [variable]
                        name=unit.race
                        equals=undead
                    [/variable]
                    [then]
                        # Bones examined by a ghost, skeleton, or ghoul.
                        [message]
                            speaker=$unit.id
                            message= _ "Bones. Claws and wings."
                        [/message]
                    [/then]
                    [else]
                        # Bones examined by a human or Vendraxis.
                        [message]
                            speaker=$unit.id
                            message= _ "There are some large bones here. I can see claws and wings."
                        [/message]
                    [/else]
                [/if]
            [/else]
        [/if]

        [message]
            speaker=Ardonna
            message= _ "I wonder what they are from. A gryphon perhaps?"
        [/message]
        [message]
            speaker=Ras-Tabahn
            message= _ "A large (<i>cough, cough</i>) flightless bird... would be my guess."
        [/message]
        [message]
            speaker=Ardonna
            message= _ "Well, there is an easy way to discover the truth."
        [/message]

        # Remove the bones and show a resurrected bird:
        [if]
            [have_unit]
                id=Ardonna
                x,y=25,9
            [/have_unit]
            [then]
                # Since Ardonna is standing on the bones, face her toward the most likely hex for the bird to appear
                [animate_unit]
                    # Fire the recruitment animation (actually an extra_anim):
                    [filter]
                        id=Ardonna
                    [/filter]
                    flag=recruit2
                    [facing]
                        x,y=24,8
                    [/facing]
                [/animate_unit]
            [/then]
            [else]
                [animate_unit]
                    # Fire the recruitment animation (actually an extra_anim):
                    [filter]
                        id=Ardonna
                    [/filter]
                    flag=recruit2
                    [facing]
                        x,y=25,9
                    [/facing]
                [/animate_unit]
            [/else]
        [/if]
        [remove_item]
            # Remove the bones:
            x,y=25,9
        [/remove_item]
        [unit]
            # Show the bird fading in. The engine will automatically find an empty
            # location for it.
            x,y=25,9
            id=bird
            type=Bone Bird
            side=1
            facing=se
            animate=yes
        [/unit]
        [store_unit]
            # Store the bird so we can get its location later:
            [filter]
                id=bird
            [/filter]
            variable=bird
        [/store_unit]

        [message]
            speaker=Ardonna
            message= _ "Oh, you were right!"
        [/message]

        [if]
            [have_unit]
                id=Vendraxis
            [/have_unit]
            [then]
                [message]
                    speaker=Ras-Tabahn
                    message= _ "I wonder... if it could carry... someone light. Vendraxis perhaps."
                [/message]
                [message]
                    speaker=Vendraxis
                    message= _ "I will not climb on that ridiculous thing!"
                [/message]
            [/then]
            [else]
                [message]
                    speaker=Ras-Tabahn
                    message= _ "I wonder... if it could carry... someone light."
                [/message]
            [/else]
        [/if]

        [message]
            speaker=Ardonna
            message= _ "A skeleton could ride it I think."
        [/message]

        # Replace the bird with a Chocobone:
        [modify_unit]
            # We're about to animate a recruit which will most likely appear to
            # Ardonna's upper left, so we'll face her that direction:
            [filter]
                id=Ardonna
            [/filter]
            facing=nw
        [/modify_unit]
        [animate_unit]
            # Fire the recruitment animation (actually an extra_anim):
            [filter]
                id=Ardonna
            [/filter]
            flag=recruit2
        [/animate_unit]
        [unit]
            # Animate a skeleton getting recruited:
            side=1
            animate=yes
            type=Skeleton
            id=rider
            placement=leader
        [/unit]
        [store_unit]
            # Remove the skeleton, but store it so we can get its location:
            [filter]
                id=rider
            [/filter]
            variable=rider
            kill=yes
        [/store_unit]
        [move_unit_fake]
            # Show a skeleton moving from where the skeleton appeared to wherever
            # the bird is:
            type=Skeleton
            side=1
            x=$rider.x, $bird.x
            y=$rider.y, $bird.y
        [/move_unit_fake]
        [kill]
            id=bird
            animate=no
        [/kill]
        [unit]
            # Now we show a joined skeleton and bird:
            x,y=$bird.x, $bird.y
            type=Chocobone
            side=1
            animate=no
            facing=se
        [/unit]
        [clear_variable]
            name=bird, rider
        [/clear_variable]

        [message]
            speaker=Ardonna
            message= _ "That’s fantastic! These birds could be quite useful."
        [/message]
        [allow_recruit]
            side=1
            type=Chocobone
        [/allow_recruit]
        [message]
            speaker=narrator
            image=units/undead-skeletal/chocobone.png~SCALE(93,93)
            message= _ "You can now recruit chocobones!"
        [/message]
    [/event]

    # *************************** ENDING / OPENING ***************************

    [event]
        name=start
        [message]
            speaker=Ardonna
            message= _ "What dangers may lurk in this fog?"
        [/message]
        [message]
            speaker=Ras-Tabahn
            message= _ "Gryphons... live at this height. We should be cautious."
        [/message]
        [if]
            [have_unit]
                id=Vendraxis
            [/have_unit]
            [then]
                [message]
                    speaker=Vendraxis
                    message= _ "Yesss. The danger I sssensed is here." # no spellcheck
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            id=Ardonna
            [or]
                id=Ras-Tabahn
            [/or]
        [/filter]

        [store_unit]
            # Stores whichever leaders are the grassland in the NE corner.
            [filter]
                x=21-29
                y=1-3
                [filter_location]
                    terrain=G*^*
                [/filter_location]
                [and]
                    id=Ardonna
                    [or]
                        id=Ras-Tabahn
                    [/or]
                [/and]
            [/filter]
            variable=leaders_at_end
        [/store_unit]

        # If both leaders got stored, the player wins.
        [if]
            [variable]
                name=leaders_at_end.length
                equals=2
            [/variable]
            [then]
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/then]
            [else]
                [allow_undo]
                [/allow_undo]
            [/else]
        [/if]
        [clear_variable]
            name=leaders_at_end
        [/clear_variable]
    [/event]

    {HERO_DEATHS}
    {MAKE_BATS_NORMAL}
    {ZOMBIES}
    {KIDS_ADVANCE}
[/scenario]
