#textdomain wesnoth-trow
[scenario]
    id=The_Dragon
    name= _ "The Dragon"
    map_data="{campaigns/The_Rise_Of_Wesnoth/maps/The_Dragon.map}"
    {TURNS 39 36 33}

    {DEFAULT_SCHEDULE}

    next_scenario=Elf_Lords
    victory_when_enemies_defeated=no
    bonus=yes

    [music]
        name="northerners.ogg"
    [/music]

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

    [story]
        [part]
            background=story/the_great_continent.png
            show_title=yes
            {DOT 315 180}
            {DOT 315 210}
            {DOT 315 240}
            {DOT 315 270}
            {CROSS 310 296}
        [/part]
    [/story]

    [side]
        type=Noble Commander
        description=Prince Haldric
        user_description= _ "Prince Haldric"
        unrenamable=yes
        side=1
        canrecruit=yes
        controller=human
        team_name=Haldric
    [/side]

    [side]
        type=Saurian Flanker
        description=Irix
        user_description= _ "Irix"
        side=2
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
#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]
            [protect_location]
                x=20
                y=23
                radius=12
                value=10
            [/protect_location]
        [/ai]
    [/side]

    {STARTING_VILLAGES 2 10}

    [side]
        type=Saurian Flanker
        description=Vriss
        user_description= _ "Vriss"
        side=3
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
#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]
            [protect_location]
                x=20
                y=23
                radius=12
                value=10
            [/protect_location]
        [/ai]
    [/side]

    {STARTING_VILLAGES 3 10}

    [side]
        type=Saurian Flanker
        description=Axiz
        user_description= _ "Axiz"
        side=4
        canrecruit=yes
        {GOLD 110 140 160}
        {INCOME 2 4 8}
        team_name=Liz
#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]
            [protect_location]
                x=20
                y=23
                radius=12
                value=10
            [/protect_location]
        [/ai]
    [/side]

    {STARTING_VILLAGES 4 10}

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

#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}

            [target]
                description=Prince Haldric
                value=15
            [/target]
        [/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]
            description=Lady Jessica
        [/recall]
        [recall]
            description=Burin the Lost
        [/recall]
        [recall]
            description=Sir Ruddry
        [/recall]

        [recall]
            description=Sir Ladoc
        [/recall]

        [recall]
            description=Minister Edmond
        [/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]
                description= _ "Heroic: Slay the Dragon and defeat all enemies"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Prince Haldric"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Lady Jessica"
                condition=lose
            [/objective]
            [objective]
                description= _ "Turns run out"
                condition=lose
            [/objective]
        [/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]

        [message]
            description=Burin the Lost
            message= _ "Flies, flies, everywhere! Ack!"
        [/message]

        [message]
            description=Prince Haldric
            message= _ "'Prince Haldric the Dragonbane' sounds rather nice."
        [/message]

        [message]
            description=Lady Jessica
            message= _ "We'll see..."
        [/message]
    [/event]

    [event]
        name=victory
        [message]
            description=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]
            description=Lady Jessica
            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]
            description=Prince Haldric
            message= _ "Watch for the big mudcrawlers. They divide when you kill them."
        [/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]
                {LOYAL_UNIT 5 (Fire Dragon) 20 27 ("Shek'kahan") ( _ "Shek'kahan")}
                # wmllint: recognize Shek'kahan

                [set_variable]
                    name=dragon_awake
                    value=1
                [/set_variable]
                [message]
                    description="Shek'kahan"
                    message= _ "It is unwise to trifle with dragons, boy!"
                [/message]
                [message]
                    description=Prince Haldric
                    message= _ "We shall see."
                [/message]
                {GOLD_TO_BADDIES}
            [/then]
        [/if]
    [/event]

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

                [set_variable]
                    name=dragon_awake
                    value=1
                [/set_variable]
                [message]
                    description="Shek'kahan"
                    message= _ "Who dares disturb Shek'kahan the Terrible?"
                [/message]
                [message]
                    description=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]
                    description=Lady Jessica
                    message= _ "We still have to slay the dragon!"
                [/message]
            [/then]
            [else]
                [if]
                    [variable]
                        name=got_treasure
                        numerical_equals=0
                    [/variable]
                    [then]
                        [message]
                            description=Prince Haldric
                            message= _ "The dragon's cave has yielded some treasure!"
                        [/message]
                        {LOOT 200 1}
                    [/then]
                [/if]
                [endlevel]
                    result=victory
                    bonus=yes
                [/endlevel]
            [/else]
        [/if]
        [set_variable]
            name=got_enemies
            value=1
        [/set_variable]
    [/event]

    [event]
        name=die
        [filter]
            description="Shek'kahan"
        [/filter]
        [message]
            description="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]
                    description=Prince Haldric
                    message= _ "We've slain the dragon: "

                    [option]
                        message= _ "Let's get out of here!"
                        [command]
                            [endlevel]
                                result=victory
                                bonus=no
                            [/endlevel]
                        [/command]
                    [/option]

                    [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]
                            description=Prince Haldric
                            message= _ "The dragon's cave has yielded some treasure!"
                        [/message]
                        {LOOT 200 1}
                    [/then]
                [/if]

                [endlevel]
                    result=victory
                    bonus=yes
                [/endlevel]
            [/else]
        [/if]
    [/event]

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