#textdomain wesnoth-sof
[scenario]
    name= _ "The Dragon"
    id=8_The_Dragon
    turns=-1
    map_data="{@campaigns/Sceptre_of_Fire/maps/8_The_Dragon.map}"
    next_scenario=9_Caverns_of_Flame

    {DEFAULT_MUSIC_PLAYLIST}

    {DEFAULT_SCHEDULE}

    [time_area]
        x=4-32
        y=1-31
        {UNDERGROUND}
    [/time_area]

    [side]
        type=Dwarvish Fighter
        description=Rugnur
        save_id=Rugnur
        side=1
        canrecruit=yes
        controller=human
        recruit=Dwarvish Fighter,Dwarvish Thunderer,Dwarvish Guardsman,Gryphon Rider
        gold=200
        shroud=yes
    [/side]

    [side]
        type=Elvish Marshal
        description=Landar
        user_description= _ "Landar"
        side=2
        canrecruit=yes
        controller=ai
        recruit=Elvish Avenger,Elvish Marshal,Elvish Champion,Elvish Outrider,Dwarvish Thunderguard,Dwarvish Berserker,Dwarvish Steelclad
        gold=1000
        income=50
        [ai]
            turns=1-12
            aggression=0.8
            caution=0.2
            village_value=0.2
            recruitment_pattern=scout,fighter,fighter,archer,mixed fighter,archer
            recruitment_ignore_bad_movement=yes
            recruitment_ignore_bad_combat=yes
            #grouping causes the dwarves to wait for the elves, who move slower
            grouping=none

            [target]
                side=1
                value=2.0
            [/target]
        [/ai]
        [ai]
            turns=12-99
            aggression=1.0
            caution=0.0
            village_value=0.0
            recruitment_pattern=scout,fighter,fighter,archer,mixed fighter,archer
            recruitment_ignore_bad_movement=yes
            recruitment_ignore_bad_combat=yes
            grouping=none

            [target]
                side=1
                value=4.0
            [/target]
        [/ai]
        team_name=elves
    [/side]

    [side]
        type=Fire Dragon
        description=Khrakrahs
        user_description= _ "Khrakrahs"
        profile=portraits/khrakrahs.png
        side=3
        canrecruit=yes
        controller=ai
        {RECRUIT (Vampire Bat) (Vampire Bat) (Vampire Bat,Blood Bat)}
        {GOLD 200 300 400}
        [ai]
            recruitment_pattern=scout
            aggression=0.9
            caution=0.1
            grouping=offensive
        [/ai]
        team_name=khrakrahs
    [/side]

    [story]
        [part]
            story= _ "Thus Alanin escaped from his Elvish pursuers. But the dwarves were not so lucky. I would say that, perhaps, their betrayal of Durstorn was coming back to haunt them. For unknown to them, they had entered the caves of Khrakrahs... the dragon."
        [/part]
        [part]
            background=maps/wesnoth.png
            show_title=yes
            {DOT 322 157}
            {CROSS 335 141}
        [/part]
    [/story]

    {SOF_DEATHS}

    [event]
        name=prestart

        [objectives]
            side=1
            [objective]
                description= _ "Get all heroes to the end of the tunnel"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Rugnur"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Krawg"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Thursagan"
                condition=lose
            [/objective]
        [/objectives]
    [/event]

#define RANDOM_MERCENARY TYPE
    {RANDOM_TRAIT_UNIT (
    type={TYPE}
    x,y=2,14
    side=2)}
#enddef
    [event]
        name=start

        {MOVE_UNIT description=Rugnur 12 7}

        [redraw]
            side=1
        [/redraw]

        [recall]
            description=Baglur
        [/recall]
        [recall]
            description=Krawg
        [/recall]
        [recall]
            description=Thursagan
        [/recall]

        #the enemy gets mercenaries
        {RANDOM_MERCENARY (Dwarvish Berserker)}
        {RANDOM_MERCENARY (Dwarvish Berserker)}
        {RANDOM_MERCENARY (Dwarvish Berserker)}
#ifdef EASY
#else
        {RANDOM_MERCENARY (Dwarvish Berserker)}
#endif
#ifdef HARD
        {RANDOM_MERCENARY (Dwarvish Berserker)}
        {RANDOM_MERCENARY (Dwarvish Berserker)}
#endif
        {RANDOM_MERCENARY (Dwarvish Lord)}
        {RANDOM_MERCENARY (Dwarvish Lord)}
        {RANDOM_MERCENARY (Dwarvish Lord)}
        {RANDOM_MERCENARY (Dwarvish Dragonguard)}
        {RANDOM_MERCENARY (Dwarvish Dragonguard)}

        [message]
            description=Rugnur
            message= _ "Well, Thursagan, we've reached the caves, but the elves are hot on our trail. What do we do now?"
        [/message]
        [message]
            description=Thursagan
            message= _ "Well, we have two choices. We may either stand and fight, and assuredly die, or run as quickly as possible down this path into the depths of the cave, where we may find something that will help us. Also, remember, the elves can't run as fast in caves as we can, so we may be able to get ahead of them and perhaps lay a trap."
        [/message]
        [message]
            description=Krawg
            message= _ "Wyy yoo no urrendrr? Alddey woont iz za wagic doun!"
            # "Why don't we just surrender? All they want is that magic stone!"
        [/message]
        [message]
            description=Rugnur
            message= _ "If we give them the ruby, then what? They'll probably kill us anyway. And, that ruby has the power to do great things, evil things. We can't let it fall into the wrong hands."
        [/message]
        [message]
            description=Thursagan
            message= _ "Then we shall run. I suggest calling to arms every last dwarf we possibly can here. This might be the last chance we'll get to do so."
        [/message]
        [if]
            [have_unit]
                description=Baglur
            [/have_unit]
            [then]
                [message]
                    description=Baglur
                    message= _ "So we're running away, eh? I don't like that, but it seems it's our only option."
                [/message]
                [message]
                    description=Rugnur
                    message= _ "If it makes you feel any better, we'll probably die this way, too."
                [/message]
            [/then]
        [/if]
    [/event]

    [event]
        name=sighted
        [filter]
            type=Fire Dragon
        [/filter]
        [redraw]
            side=1
        [/redraw]
        [scroll_to]
            x,y=$x1,$y1
        [/scroll_to]
        [message]
            speaker=Rugnur
            message= _ "Look, there's a dragon in these caves!"
        [/message]
        [message]
            description=Khrakrahs
            message= _ "Ah, fresh meat!"
        [/message]
        [message]
            description=Thursagan
            message= _ "And which of the great dragons are you?"
        [/message]
        [message]
            description=Khrakrahs
            message= _ "I am Khrakrahs, greatest dragon of all time! Haldric killed Shek'kahan my brother, but he was weaker than me, and you will not find me so easy to defeat. Now get out of my volcano!"
        [/message]
        [message]
            description=Rugnur
            message= _ "I'd rather face one powerful dragon than hundreds of mighty elves. Continue!"
        [/message]
    [/event]

    [event]
        name=sighted
        [filter]
            race=dwarf
            side=2
        [/filter]
        [redraw]
            side=1
        [/redraw]
        [scroll_to]
            x,y=$x1,$y1
        [/scroll_to]
        [message]
            description=Thursagan
            message= _ "What's this? A dwarf fighting against us with the elves?!"
        [/message]
        [message]
            description=Baglur
            message= _ "It must be one of those Surghan mercenaries. I'll bet those elves have hired more of them. That's bad news for us, for they'll go as fast in caves as we do."
        [/message]
    [/event]

    [item]
        x,y=16,25
        image=items/altar.png
    [/item]

    [event]
        name=moveto
        [filter]
            x,y=16,25
            side=1
        [/filter]
        [message]
            speaker=unit
            message= _ "Look, I've found something here. It looks like a forge, heated by the lava. It looks magic, and it looks hot enough to make the Sceptre."
        [/message]
        [message]
            description=Khrakrahs
            message= _ "That pretty metal rock is mine! Get away from it!"
        [/message]
        [objectives]
            side=1
            [objective]
                description= _ "Move Thursagan to the forge"
                condition=win
            [/objective]
            [objective]
                description= _ "Defend Thursagan until the sceptre is complete"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Rugnur"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Krawg"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Thursagan"
                condition=lose
            [/objective]
        [/objectives]
    [/event]

    [event]
        name=moveto
        [filter]
            x,y=16,25
            description=Thursagan
        [/filter]
        [message]
            description=Thursagan
            message= _ "This forge will work perfectly. Give me a few days here, and I can reforge the sceptre to fulfill its purpose."
        [/message]
        [set_variable]
            name=turnsleft
            value=10
        [/set_variable]
        [objectives]
            side=1
            [objective]
                description= _ "Survive for 9 turns"
                condition=win
            [/objective]
            [objective]
                description= _ "Death of Rugnur"
                condition=lose
            [/objective]
            [objective]
                description= _ "Death of Krawg"
                condition=lose
            [/objective]
            [objective]
                description= _ "An enemy moves onto the forge"
                condition=lose
            [/objective]
        [/objectives]
        [store_unit]
            [filter]
                description=Thursagan
            [/filter]
            variable=thur
            kill=yes
        [/store_unit]
        [event]
            name=moveto
            [filter]
                x,y=16,25
                side=2,3
            [/filter]
            [message]
                speaker=narrator
                caption= _ "Thursagan"
                image=portraits/thursagan.png
                message= _ "You fool, you let the enemy get at me as I was unarmed!"
            [/message]
            [message]
                speaker=narrator
                caption= _ "Thursagan"
                image=portraits/thursagan.png
                message= _ "Ayahahh..."
                sound=dwarf-die-1.ogg
            [/message]
            [endlevel]
                result=defeat
            [/endlevel]
        [/event]
        [event]
            name=new turn
            first_time_only=no
            [set_variable]
                name=turnsleft
                add=-1
            [/set_variable]
            [if]
                [variable]
                    name=turnsleft
                    numerical_equals=0
                [/variable]
                [then]
                    [unstore_unit]
                        variable=thur
                        find_vacant=yes
                    [/unstore_unit]

                    [object]
                        id=scepter of fire
                        silent=yes
                        duration=forever

                        [filter]
                            description=Thursagan
                        [/filter]

                        [effect]
                            apply_to=new_attack
                            name=scepter of fire
                            description= _ "scepter of fire"
                            icon=attacks/fireball.png
                            type=fire
                            range=ranged
                            [specials]
                                {WEAPON_SPECIAL_MAGICAL}
                            [/specials]
                            damage=14
                            number=4
                        [/effect]

                        [effect]
                            apply_to=new_animation

                            [attack_anim]
                                [attack_filter]
                                    name=scepter of fire
                                [/attack_filter]

                                {MISSILE_FRAME_FIREBALL}

                                [frame]
                                    begin=-200
                                    end=0
                                    sound=fire.wav
                                [/frame]
                            [/attack_anim]
                        [/effect]
                    [/object]
                    [message]
                        description=Thursagan
                        message= _ "I have completed my work. Now it is truly the Sceptre of Fire, a powerful magical artifact."
                    [/message]
                    [message]
                        description=Rugnur
                        message= _ "Good. Now, let's get out of this cave, before the elves, dwarves or bats kill us!"
                    [/message]
                    [clear_variable]
                        name=turnsleft
                    [/clear_variable]
                    [endlevel]
                        result=victory
                        bonus=no
                    [/endlevel]
                [/then]
                [else]
                    [message]
                        speaker=narrator
                        caption= _ "Thursagan"
                        image=portraits/thursagan.png
                        message= _ "In $turnsleft more turns I will have completed the sceptre."
                    [/message]
                [/else]
            [/if]
        [/event]
    [/event]
[/scenario]
