#textdomain wesnoth-thot

#define CONDITIONAL_MAGE_RECRUITING
    [event]
        name=die
        first_time_only=no
        [filter]
            side=1
            type_adv_tree=Mage
            trait=loyal
            [not]
                id=Ratheln
            [/not]
        [/filter]

        [if]
            [not]
                [have_unit]
                    search_recall_list=yes
                    side=1
                    type_adv_tree=Mage
                    trait=loyal
                    [not]
                        id=Ratheln
                    [/not]
                [/have_unit]
            [/not]
            [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]
                    side=1
                    type=Mage
                [/disallow_recruit]
            [/then]
        [/if]
    [/event]
#enddef

#define OBJ_STAFF_OF_RIGHTEOUS_FLAME X Y
    {PLACE_IMAGE "scenery/temple1.png" {X} {Y}}

    [event]
        name=moveto
        [filter]
            side=1
            x,y={X},{Y}
        [/filter]

        [message]
            speaker=unit
            message= _ "There an altar in this temple, and a staff lies upon it."
        [/message]
    [/event]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x,y={X},{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 a mage may wield this Staff."
            [filter]
                side=1
                type_adv_tree=Mage
                x,y=$x1,$y1
            [/filter]

            [then]
                [modify_unit]
                    [filter]
                        id=$unit.id
                    [/filter]

                    overlays=misc/righteous-flame-icon.png

                    [event]
                        id=death_of_sorf_holder
                        name=last breath
                        delayed_variable_substitution=no
                        [filter]
                            id=$unit.id
                        [/filter]

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

                        [animate_unit]
                            [filter]
                                id=$unit.id
                            [/filter]

                            flag=boo
                        [/animate_unit]

                        [kill]
                            [filter_adjacent]
                                id=$unit.id
                                is_enemy=yes
                            [/filter_adjacent]
                            animate=yes
                            fire_event=yes
                        [/kill]

                        [redraw][/redraw]
                    [/event]
                [/modify_unit]
            [/then]

            [effect]
                apply_to=new_ability
                [abilities]
                    {ABILITY_STEADFAST}
                [/abilities]
            [/effect]

            [effect]
                apply_to=new_animation
                [extra_anim]
                    flag=boo
                    start_time=0

                    [frame]
                        halo=halo/elven/faerie-fire-halo[1~7].png:100
                        blend_color=255,0,0
                        blend_ratio=0.5
                        sound=fire.wav
                    [/frame]
                [/extra_anim]
            [/effect]
        [/object]
    [/event]
#enddef

#define RECALL_VETERAN TYPE X Y
    [recall]
        type={TYPE}
        [or]
            race=dwarf
        [/or]
        [not]
            id=Aiglondur,Dulcatulos
        [/not]
        x,y={X},{Y}
    [/recall]
#enddef

#define RENAME_MASKED_DWARVES SIDE
    # The Masked Dwarves are nameless, it's a part of their charm...
    [event]
        name=recruit
        first_time_only=no
        [filter]
            side={SIDE}
        [/filter]

        {MODIFY_UNIT x,y=$x1,$y1 name ( _ "Masked Dwarf")}
    [/event]
#enddef
