#textdomain wesnoth-trow
[scenario]
    id=17a_The_Dragon
    name= _ "The Dragon"
    next_scenario=16_The_Kalian
    victory_when_enemies_defeated=no
    bonus=yes
    map_data="{campaigns/The_Rise_Of_Wesnoth/maps/17a_The_Dragon.map}"

    {TURNS 39 36 33}
    {DEFAULT_SCHEDULE}

    {SCENARIO_MUSIC wanderer.ogg}
    {EXTRA_SCENARIO_MUSIC knalgan_theme.ogg}
    {EXTRA_SCENARIO_MUSIC suspense.ogg}

    # No story
    {BIGMAP_17A}

    {TROW_DEATHS}

    [side]
        type=Noble Commander
        id=Prince Haldric
        name= _ "Prince Haldric"
        unrenamable=yes
        side=1
        canrecruit=yes
        gold=200
        controller=human
        team_name=Haldric
        user_team_name=_"Refugees"
        {FLAG_VARIANT loyalist}
    [/side]

    [side]
        type=Saurian Flanker
        id=Irix
        name= _ "Irix"
        side=2
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
        user_team_name=_"Saurians"
#ifdef EASY
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif
        [ai]
            #{NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,archer,scout,scout,healer
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            [goal]
                name=protect_location
                [criteria]
                    x,y=20,23
                [/criteria]
                protect_radius=12
                value=10
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 2 10}

    [side]
        type=Saurian Flanker
        id=Vriss
        name= _ "Vriss"
        side=3
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
        user_team_name=_"Saurians"
#ifdef EASY
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif
        [ai]
            #{NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,archer,scout,scout,healer
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            [goal]
                name=protect_location
                [criteria]
                    x,y=20,23
                [/criteria]
                protect_radius=12
                value=10
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 3 10}

    [side]
        type=Saurian Flanker
        id=Axiz
        name= _ "Axiz"
        side=4
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
        user_team_name=_"Saurians"
#ifdef EASY
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif

        [ai]
            #{NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,archer,scout,scout,healer
            {ATTACK_DEPTH 4 5 5}
        [/ai]
        [ai]
            [goal]
                name=protect_location
                [criteria]
                    x,y=20,23
                [/criteria]
                protect_radius=12
                value=10
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 4 10}

    [side]
        type=Saurian Flanker
        id=Satras
        name= _ "Satras"
        side=5
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
        user_team_name=_"Saurians"

#ifdef EASY
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Vampire Bat,Saurian Augur
#else
        recruit=Saurian Skirmisher, Mudcrawler, Giant Mudcrawler, Saurian Ambusher, Vampire Bat,Saurian Augur,Saurian Oracle,Saurian Soothsayer
#endif
        [ai]
            #{NO_SCOUTS}
            recruitment_ignore_bad_movement=yes
            recruitment_pattern=scout,archer,scout,scout,healer
            {ATTACK_DEPTH 4 5 5}
            [goal]
                name=target
                [criteria]
                    id=Prince Haldric
                [/criteria]
                value=15
            [/goal]
        [/ai]
    [/side]

    {STARTING_VILLAGES 5 10}

    {campaigns/The_Rise_Of_Wesnoth/utils/trow-nlmsg.cfg}

    [event]
        name=prestart

        {PLACE_IMAGE (scenery/mine-abandoned.png) 20 27}

        [recall]
            id=Lady Jessene
        [/recall]
        [recall]
            id=Burin the Lost
        [/recall]
        [recall]
            id=Sir Ruddry
        [/recall]

        [recall]
            id=Sir Ladoc
        [/recall]

        [recall]
            id=Minister Edren
        [/recall]
        [set_variable]
            name=dragon_awake
            value=0
        [/set_variable]
        [set_variable]
            name=got_treasure
            value=0
        [/set_variable]
        [set_variable]
            name=got_enemies
            value=0
        [/set_variable]
        [set_variable]
            name=dragon_dead
            value=0
        [/set_variable]

        [objectives]
            side=1
            [objective]
                description= _ "Slay the Dragon"
                condition=win
            [/objective]
            [objective]
                {BONUS_OBJECTIVE_CAPTION}
                description= _ "Slay the Dragon and defeat all enemy leaders"+{EARLY_FINISH_BONUS_FOOTNOTE}
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Prince Haldric"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Lady Jessene"
                condition=lose
            [/objective]

            {TURNS_RUN_OUT}

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

    [event]
        name=start
        [message]
            speaker=narrator
            message= _ "After some days of travel Haldric finds himself confronted by a vast expanse of swamp. A small island with a mountain dominates the view. That can only be the home of the dragon."
            image=wesnoth-icon.png
        [/message]

        [scroll_to]
            x,y=20,27
        [/scroll_to]

        [delay]
            time=1000
        [/delay]

        [message]
            speaker=Burin the Lost
            message= _ "Flies, flies, everywhere! Ack!"
            image=portraits/burin-annoyed.png
        [/message]

        [message]
            speaker=Prince Haldric
            # wmllint: local spelling Dragonbane
            message= _ "‘Prince Haldric the Dragonbane’ sounds rather nice."
        [/message]

        [message]
            speaker=Lady Jessene
            message= _ "We’ll see..."
        [/message]
    [/event]

    [event]
        name=victory
        [message]
            speaker=Prince Haldric
            message= _ "I’m glad that’s over. The elves certainly aren’t taking it easy on us. It’s a miracle any of us are alive at all."
        [/message]

        [message]
            speaker=Lady Jessene
            message= _ "I’m still not calling you ‘the Dragonbane’."
        [/message]

        {VARIABLE_OP num_done add 1}

        [set_variable]
            name=the_dragon
            value=1
        [/set_variable]

        [set_variable]
            name=last_done
            value="Dragon"
        [/set_variable]
        {CLEAR_VARIABLE dragon_awake}
        {CLEAR_VARIABLE got_treasure}
        {CLEAR_VARIABLE got_enemies}
        {CLEAR_VARIABLE dragon_dead}
    [/event]

    [event]
        name=die
        first_time_only=no

        [filter]
            type=Giant Mudcrawler
        [/filter]

        {LOYAL_UNIT 2 (Mudcrawler) ($x1) ($y1)}
        {LOYAL_UNIT 3 (Mudcrawler) ($x1) ($y1)}
    [/event]

    [event]
        name=die
        [filter]
            type=Giant Mudcrawler
        [/filter]
        [message]
            speaker=Prince Haldric
            message= _ "Watch for the big mudcrawlers. They divide when you kill them."
            image=portraits/haldric-mad.png
        [/message]
    [/event]

#define GOLD_TO_BADDIES
    [gold]
        side=2
        amount=40
    [/gold]
    [gold]
        side=3
        amount=40
    [/gold]
    [gold]
        side=4
        amount=40
    [/gold]
    [gold]
        side=5
        amount=60
    [/gold]
#enddef

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x=12-26
            y=24-30
        [/filter]

        [if]
            [variable]
                name=dragon_awake
                numerical_equals=0
            [/variable]
            [then]
                {NAMED_LOYAL_UNIT 5 (Fire Dragon) 20 27 ("Shek'kahan") ( _ "Shek’kahan")}
                [+unit]
                    profile=portraits/shekkahan.png
                [/unit]

                [set_variable]
                    name=dragon_awake
                    value=1
                [/set_variable]
                [message]
                    speaker="Shek'kahan"
                    message= _ "It is unwise to trifle with dragons, boy!"
                [/message]
                [message]
                    speaker=Prince Haldric
                    message= _ "We shall see."
                    image=portraits/haldric-mad.png
                [/message]
                {GOLD_TO_BADDIES}
            [/then]
            [else]
                [allow_undo]
                [/allow_undo]
            [/else]
        [/if]
    [/event]

    [event]
        name=turn 15
        [if]
            [variable]
                name=dragon_awake
                numerical_equals=0
            [/variable]
            [then]
                {NAMED_LOYAL_UNIT 5 (Fire Dragon) 20 27 ("Shek'kahan") ( _ "Shek’kahan")}

                [set_variable]
                    name=dragon_awake
                    value=1
                [/set_variable]
                [message]
                    speaker="Shek'kahan"
                    message= _ "Who dares disturb Shek’kahan the Terrible?"
                [/message]
                [message]
                    speaker=Prince Haldric
                    message= _ "I do, you fiend!"
                    image=portraits/haldric-mad.png
                [/message]
                {GOLD_TO_BADDIES}
            [/then]
        [/if]
    [/event]

    [event]
        name=moveto
        [filter]
            side=1
            x=20
            y=27
        [/filter]

        {LOOT 200 1}

        [set_variable]
            name=got_treasure
            value=1
        [/set_variable]
    [/event]

    [event]
        name=enemies defeated
        [if]
            [variable]
                name=dragon_dead
                numerical_equals=0
            [/variable]
            [then]
                [message]
                    speaker=Lady Jessene
                    message= _ "We still have to slay the dragon!"
                [/message]
            [/then]
            [else]
                [if]
                    [variable]
                        name=got_treasure
                        numerical_equals=0
                    [/variable]
                    [then]
                        [message]
                            speaker=Prince Haldric
                            message= _ "The dragon’s cave has yielded some treasure!"
                        [/message]
                        {LOOT 200 1}
                    [/then]
                [/if]
                [endlevel]
                    result=victory
                    bonus=yes
                    {NEW_GOLD_CARRYOVER 40}
                [/endlevel]
            [/else]
        [/if]
        [set_variable]
            name=got_enemies
            value=1
        [/set_variable]
    [/event]

    [event]
        name=last breath
        [filter]
            id="Shek'kahan"
        [/filter]
        [message]
            speaker="Shek'kahan"
            message= _ "No!"
        [/message]
        [set_variable]
            name=dragon_dead
            value=1
        [/set_variable]
        [if]
            [variable]
                name=got_enemies
                numerical_equals=0
            [/variable]
            [then]
                [message]
                    speaker=Prince Haldric
                    message= _ "We’ve slain the dragon: "
                    image=portraits/haldric-mad.png

                    [option]
                        message= _ "Let’s get out of here!"
                        [command]
                            [endlevel]
                                result=victory
                                bonus=no
                                {NEW_GOLD_CARRYOVER 40}
                            [/endlevel]
                        [/command]
                    [/option]

                    # TODO: prevent the time over defeat if this is chosen...
                    [option]
                        message= _ "Let’s finish off the rest of these monsters!"
                    [/option]
                [/message]
            [/then]
            [else]
                [if]
                    [variable]
                        name=got_treasure
                        numerical_equals=0
                    [/variable]
                    [then]
                        [message]
                            speaker=Prince Haldric
                            message= _ "The dragon’s cave has yielded some treasure!"
                        [/message]
                        {LOOT 200 1}
                    [/then]
                [/if]

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

    [event]
        name=time over
        [message]
            speaker=Prince Haldric
            message= _ "More saurians are arriving. They’ve surrounded us! We’re doomed."
            image=portraits/haldric-surprised.png
        [/message]
    [/event]
[/scenario]
