#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}
            [wml_filter]
                [variables]
                    has_sorf=yes
                [/variables]
            [/wml_filter]
        [/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]

        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x1,$y1
                    is_enemy=yes
                [/filter_adjacent]
            [/filter]
            kill=no
            variable=finalstriketargets
        [/store_unit]

        {FOREACH finalstriketargets i}
        [kill]
            x,y=$finalstriketargets[$i].x,$finalstriketargets[$i].y
            animate=yes
            fire_event=yes
        [/kill]
        {NEXT i}

        {CLEAR_VARIABLE finalstriketargets}
        [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]
            description=Aiglondur
        [/not]
        [not]
            description=Dulcatulos
        [/not]
        role=veteran
    [/role]

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

#define GIANT_SPIDER X Y
    [unit]
        type=Giant Spider
        x={X}
        y={Y}
        side=2
        ai_special=guardian
        description=Giant Spider
    [/unit]
#enddef

#define MASKED_GUARD X Y
    [unit]
        type=Dwarvish Masked Steelclad
        x={X}
        y={Y}
        side=2
        ai_special=guardian
        random_traits=yes
        generate_description=yes
        user_description= _ "Masked Dwarf"
    [/unit]
#enddef

#define MASKED_SNIPER X Y
    [unit]
        type=Dwarvish Masked Thunderguard
        x={X}
        y={Y}
        side=2
        ai_special=guardian
        random_traits=yes
        generate_description=yes
        user_description= _ "Masked Dwarf"
    [/unit]
#enddef

#define MASKED_STALWART X Y
    [unit]
        type=Dwarvish Stalwart
        x={X}
        y={Y}
        side=2
        ai_special=guardian
        random_traits=yes
        generate_description=yes
        user_description= _ "Masked Dwarf"
    [/unit]
#enddef

#define DRAUG_GUARD X Y
    [unit]
        type=Draug
        x={X}
        y={Y}
        side=2
        ai_special=guardian
    [/unit]
#enddef

#define JAIL_SAGA DESCRIPTION

    [set_variable]
        name=saga_told
        value=1
    [/set_variable]

    [message]
        description={DESCRIPTION}
        message= _ "Finally! I see someone managed to see through the web of deception thrown up by that vile Karrag!"
    [/message]

    [message]
        description=Aiglondur
        message= _ "I thought Karrag's fight was against the so called 'dirtgrubbers'. Why would he keep you, a dwarf captive?"
    [/message]

    [message]
        description={DESCRIPTION}
        message= _ "I guess Karrag thought I knew too much. When his masked henchmen started raiding, plundering and taking all sorts of prisoners - which were sent to these underlevels and never seen again - I began to inquire. I discovered many unsettling things indeed, but before I could capitalize on them I was arrested and thrown down here."
    [/message]

    [message]
        description={DESCRIPTION}
        message= _ "I gather that he is involved in some sick ritual which requires the blood of living creatures. These cells seem to be the holding place where he keeps his victims. The 'dirtgrubbers' he seems to prefer sacrificing have long since been taken away. Now it is just us few dwarves that remain..."
    [/message]

    [message]
        description="Angarthing"
        message= _ "Freeing these prisoners is more of a blow to Karrag then we thought, for now he is unable to continue in his dirty sorcery."
    [/message]

#enddef
#define INITIALIZE_LICHES
    [set_variable]
        name=liches_active
        value=no
    [/set_variable]
#enddef

#define ACTIVATE_LICHES 
    [if]
        [set_variable]
            name=liches_active
            value=no
        [/set_variable]
        [then]
            [message]
                speaker="Angarthing"
                message=_"I sense wrongness.  Some greater evil awakens before us."
            [/message]

            [allow_recruit]
                side=2
                type="Blood Bat,Ghost,Wraith,Shadow,Skeleton,Skeleton Archer,Ghoul,Necrophage,Revenant,Deathblade,Bone Shooter"
            [/allow_recruit]

            [allow_recruit]
                side=6
                type="Blood Bat,Ghost,Wraith,Shadow,Skeleton,Skeleton Archer,Ghoul,Necrophage,Revenant,Deathblade,Bone Shooter"
            [/allow_recruit]

            [allow_recruit]
                side=7
            type="Blood Bat,Ghost,Wraith,Shadow,Skeleton,Skeleton Archer,Ghoul,Necrophage,Revenant,Deathblade,Bone Shooter"
            [/allow_recruit]

            [set_variable]
                name=liches_active
                value=yes
            [/set_variable]
        [/then]
    [/if]
#enddef
