#textdomain wesnoth-utbs

#! -- Inform the player about the possibility of challenge and adjust garak accordingly
#! -- Perform the challenge, set the death events where required
#! -- internal variables : $garak_duel, $garak_x, $garak_y, $challenged
#define CHALLENGE
    [event]
        name=turn 2
        [message]
            speaker=Garak
            message=_"These champions... I will challenge them. Zhul, bless my weapons with light of Eloh."
        [/message]
        [message]
            speaker=Zhul
            message=_"Garak, but the suns..."
        [/message]
        [message]
            speaker=Kaleh
            message=_"You will not do any such thing, anyone trying to fight these creeps singlehanded will surely die. We need you, we will not make it without you."
        [/message]
        [message]
            speaker=Garak
            message=_"I had dreams this night Kaleh, full of gloom and darkness, my journey will end here one way or another."
        [/message]
        [message]
            speaker=Kaleh
            message=_"No! That's not true, our future is what we make of it, stay behind for this fight and... "
        [/message]
        [message]
            speaker=Garak
            message=_"And what? You'll help me become a coward? I lived long, I'm not afraid of the end, just let me give it some meaning."
        [/message]
        [message]
            speaker=Zhul
            message=_"I bless you champion with the light that will come, I bless you with the memory and the promise. Break your bow champion, and let your sword shine in the dark."
        [/message]
        [object]
            id=Garak_vow
            silent=yes
            [filter]
                description=Garak
            [/filter]
            [effect]
                apply_to=remove_attacks
                range=ranged
            [/effect]
            [effect]
                apply_to=new_ability
                [abilities]
                    {ABILITY_STEADFAST}
                [/abilities]
            [/effect]
            [effect]
                #textdomain wesnoth
                apply_to=attack
                range=melee
                [set_specials]
                    [berserk]
                        id=berserk
                        name= _ "berserk"
                        description= _ "Berserk:
Whether used offensively or defensively, this attack presses the engagement until one of the combatants is slain, or 30 rounds of attacks have occurred."
                        value=30
                        [filter_opponent]
                            description=Zur
                            [or]
                                description=Grak
                            [/or]
                        [/filter_opponent]
                    [/berserk]
#ifdef HARD
#else
                    [chance_to_hit]
                        id=magical
                        name= _ "magical"
                        description= _ "Magical:
This attack always has a 70% chance to hit regardless of the defensive ability of the unit being attacked."
                        value=70
                        cumulative=no
                        [filter_opponent]
                            description=Zur
                            [or]
                                description=Grak
                            [/or]
                        [/filter_opponent]
                    [/chance_to_hit]
                    [firststrike]
                        id=firststrike
                        name= _ "firststrike"
                        description= _ "First Strike:
This unit always strikes first with this attack, even if they are defending."
                        [filter_opponent]
                            description=Zur
                            [or]
                                description=Grak
                            [/or]
                        [/filter_opponent]
                    [/firststrike]
#endif
                    mode=append
                [/set_specials]
            [/effect]
            #textdomain wesnoth-utbs
            [effect]
                apply_to=attack
                range=melee
                set_type=fire
            [/effect]
        [/object]
    [/event]

    [event]
        name=attack
        first_time_only=no
        [filter]
            description=Garak
            [or]
                description=Grak
            [/or]
            [or]
                description=Zur
            [/or]
        [/filter]
        [filter_second]
            description=Garak
            [or]
                description=Grak
            [/or]
            [or]
                description=Zur
            [/or]
        [/filter_second]
        [if]
            [and]
                [variable]
                    name=second_unit.description
                    equals=Grak
                [/variable]
                [or]
                    [variable]
                        name=second_unit.description
                        equals=Zur
                    [/variable]
                [/or]
            [/and]
            [and]
                [variable]
                    name=unit.description
                    equals=Garak
                [/variable]
            [/and]
            [then]
                {VARIABLE challenged $second_unit.description}
                [if]
                    [variable]
                        name=challenged
                        equals=Grak
                    [/variable]
                    [then]
                        [message]
                            description=Garak
                            message=_"You there! Creep! Stand an face me shade! I challenge you!"
                        [/message]
                        [if]
                            [variable]
                                name=zur_challenged
                                equals=0
                            [/variable]
                            [then]
                                [message]
                                    description=Grak
                                    message=_"Foolish mortal... For crossing my path I'll devour your soul and torment it for all eternity..."
                                [/message]
                            [/then]
                            [else]
                                [message]
                                    description=Grak
                                    message=_"So you destroyed Zur... Come mortal, lets cross our blades... It's time for you to take his place..."
                                [/message]
                            [/else]
                        [/if]
                    [/then]
                    [else]
                        [message]
                            description=Garak
                            message=_"You there! Pile of bones! I challenge you, stand and face me!"
                        [/message]
                        [if]
                            [variable]
                                name=grak_challenged
                                equals=0
                            [/variable]
                            [then]
                                [message]
                                    description=Zur
                                    message=_"Puny elf... Time to die..."
                                [/message]
                            [/then]
                            [else]
                                [message]
                                    description=Zur
                                    message=_"Grak was weak... But still you deserve respect... Meet my axe and take his place..."
                                [/message]
                            [/else]
                        [/if]
                    [/else]
                [/if]
                [event]
                    name=die
                    [filter]
                        description=Garak
                    [/filter]
                    [filter_second]
                        description=Zur
                        [or]
                            description=Grak
                        [/or]
                    [/filter_second]
                    [message]
                        description=$challenged
                        message=_"And so it ends... Your champion is dead elves... Come join him..."
                    [/message]
                [/event]
                [event]
                    name=die
                    [filter]
                        description=$challenged
                    [/filter]
                    [if]
                        [variable]
                            name=second_unit.description
                            equals=Grak
                        [/variable]
                        [then]
                            {VARIABLE grak_challenged 1}
                        [/then]
                        [else]
                            {VARIABLE zur_challenged 1}
                        [/else]
                    [/if]
                    {CLEAR_VARIABLE challenged}
                [/event]
            [/then]
        [/if]
        [if]
            [and]
                [variable]
                    name=unit.description
                    equals=Grak
                [/variable]
                [or]
                    [variable]
                        name=unit.description
                        equals=Zur
                    [/variable]
                [/or]
            [/and]
            [and]
                [variable]
                    name=second_unit.description
                    equals=Garak
                [/variable]
            [/and]
            [then]
                {VARIABLE challenged $unit.description}
                [if]
                    [variable]
                        name=challenged
                        equals=Grak
                    [/variable]
                    [then]
                        [message]
                            description=Garak
                            message=_"You there! Creep! Stand an face me shade! I challenge you!"
                        [/message]
                        [if]
                            [variable]
                                name=zur_challenged
                                equals=0
                            [/variable]
                            [then]
                                [message]
                                    description=Grak
                                    message=_"Foolish mortal... For crossing my path I'll devour your soul and torment it for all eternity..."
                                [/message]
                            [/then]
                            [else]
                                [message]
                                    description=Grak
                                    message=_"So you destroyed Zur... Come mortal, lets cross our blades... It's time for you to take his place..."
                                [/message]
                            [/else]
                        [/if]
                    [/then]
                    [else]
                        [message]
                            description=Garak
                            message=_"You there! Pile of bones! I challenge you, stand and face me!"
                        [/message]
                        [if]
                            [variable]
                                name=grak_challenged
                                equals=0
                            [/variable]
                            [then]
                                [message]
                                    description=Zur
                                    message=_"Puny elf... Time to die..."
                                [/message]
                            [/then]
                            [else]
                                [message]
                                    description=Zur
                                    message=_"Grak was weak... But still you deserve respect... Meet my axe and take his place..."
                                [/message]
                            [/else]
                        [/if]
                    [/else]
                [/if]
                [event]
                    name=die
                    [filter]
                        description=Garak
                    [/filter]
                    [filter_second]
                        description=Zur
                        [or]
                            description=Grak
                        [/or]
                    [/filter_second]
                    [message]
                        description=$challenged
                        message=_"And so it ends... Your champion is dead elves... Come join him..."
                    [/message]
                [/event]
                [event]
                    name=die
                    [filter]
                        description=$challenged
                    [/filter]
                    [if]
                        [variable]
                            name=second_unit.description
                            equals=Grak
                        [/variable]
                        [then]
                            {VARIABLE grak_challenged 1}
                        [/then]
                        [else]
                            {VARIABLE zur_challenged 1}
                        [/else]
                    [/if]
                    {CLEAR_VARIABLE challenged}
                [/event]
            [/then]
        [/if]
    [/event]

    [event]
        name=die
        [filter]
            description=Garak
        [/filter]
        [filter_second]
            [not]
                description=Grak
            [/not]
            [not]
                description=Zur
            [/not]
        [/filter_second]
        [message]
            description=Kaleh
            message=_"Where is Garak? Has anybody seen him?"
        [/message]
        [message]
            description=Zhul
            message=_"I saw him jumping into deep darkness pursuing a group of enemies. Let's hope nothing happened to him."
        [/message]
    [/event]

#enddef
