#textdomain wesnoth-thot

#define LOOT AMOUNT SIDE
    [sound]
        name=gold.ogg
    [/sound]

    {VARIABLE amount_gold {AMOUNT}}

    [message]
        speaker=narrator
        message= _ "You retrieve $amount_gold pieces of gold."
        image=wesnoth-icon.png
    [/message]

    {CLEAR_VARIABLE amount_gold}

    [gold]
        side={SIDE}
        amount={AMOUNT}
    [/gold]
#enddef

#define MAGES
Mage,Red Mage,White Mage,Arch Mage,Great Mage,Mage of Light,Silver Mage #enddef

#define CONDITIONAL_MAGE_RECRUITING
    [store_unit]
        [filter]
            side=1
            type={MAGES}
        [/filter]
        variable=mage_test
    [/store_unit]
    [if]
        [variable]
            name=mage_disallow
            boolean_equals=false
        [/variable]
        [variable]
            name=mage_test.length
            numerical_equals=0
        [/variable]
        [then]
            [message]
                speaker=narrator
                message= _ "Without magic users from Master Perrin's academy in your party, you can no longer recruit new ones."
                image=wesnoth-icon.png
            [/message]
            [disallow_recruit]
                type=Mage
            [/disallow_recruit]
            {VARIABLE mage_disallow true}
        [/then]
    [/if]
    {CLEAR_VARIABLE mage_test}
#enddef

#define OBJ_STAFF_OF_RIGHTEOUS_FLAME X Y
    {PLACE_IMAGE "scenery/temple1.png" {X} {Y}}
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id=sorf	# Prevent it from being picked up more than once.
            name= _ "Staff of Righteous Flame"
            image=items/staff-magic.png
            duration=forever
            description= _ "This staff gives a dying mage a final strike that will destroy all nearby enemies."
            cannot_use_message= _ "Only mages can wield the Staff."
            [filter]
                side=1
                type={MAGES}
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
                {PLACE_IMAGE "scenery/temple1.png" {X} {Y}}
                {MODIFY_UNIT x,y={X},{Y} variables.has_sorf yes}
            [/then]
            [effect]
                apply_to=new_ability
                [abilities]
                    {ABILITY_STEADFAST}
                [/abilities]
            [/effect]
        [/object]
    [/event]
#enddef

#define SET_RIGHTEOUS_FLAME_EVENT
    # Set up a final-strike ability contingent on having the Staff of
    # Righteous Flame -- gives a gaudy kill on all neighboring enemies.
    [event]
        name=die
        first_time_only=no

        [filter]
            type={MAGES}
            [filter_wml]
                [variables]
                    has_sorf=yes
                [/variables]
            [/filter_wml]
        [/filter]

        [message]
            speaker=unit
            message=_"Aaarrgh! Though I die, the flame of righteousness shall send you down to darkness!"
        [/message]

        [object]
            id=finalstrike_halo
            silent=yes

            [filter]
                x,y=$x1,$y1
            [/filter]

            [effect]
                apply_to=new_animation

                [extra_anim]
                    flag=boo
                    start_time=0

                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo1.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                        sound=fire.wav
                    [/frame]
                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo2.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                    [/frame]
                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo3.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                    [/frame]
                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo4.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                    [/frame]
                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo5.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                    [/frame]
                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo6.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                    [/frame]
                    [frame]
                        duration=100
                        halo=halo/elven/faerie-fire-halo7.png
                        blend_color=255,0,0
                        blend_ratio=0.5
                    [/frame]
                [/extra_anim]
            [/effect]
        [/object]

        [animate_unit]
            [filter]
                x,y=$x1,$y1
            [/filter]

            flag=boo
        [/animate_unit]

        [kill]
            [filter_adjacent]
                x,y=$x1,$y1
                is_enemy=yes
            [/filter_adjacent]
            animate=yes
            fire_event=yes
        [/kill]

        [redraw]	# Needed in case fog is active;
        [/redraw]	# the deaths might change some hex visibilities.
    [/event]
#enddef

#define RECALL_VETERAN TYPE X Y
    [role]
        type={TYPE}
        [not]
            id=Aiglondur
        [/not]
        [not]
            id=Dulcatulos
        [/not]
        role=veteran
    [/role]

    [recall]
        role=veteran
        x,y={X},{Y}
    [/recall]
#enddef
