#textdomain wesnoth
#
# Macros for items and objects
#
# All images are GPL, many come from Worldforge.
# Worldforge images should be replaced with custom images.

#define ITM_BOOK1 X Y
    [item]
        x={X}
        y={Y}
        image=items/book1.png
    [/item]
#enddef

#define ITM_TREE1 X Y
    [item]
        x={X}
        y={Y}
        image=scenery/pine1.png
    [/item]
#enddef

#define ITM_WISHINGWELL X Y
    [item]
        x={X}
        y={Y}
        image=scenery/well.png
    [/item]
    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [message]
            speaker=narrator
            message= _ "You have come across a wishing well. What would you like to wish for?"
            image=scenery/well.png
            [option]
                message= _ "A swift victory"
                [command]
                    [gold]
                        amount=-1
                    [/gold]
                    [message]
                        speaker=unit
                        message= _ "With this golden coin, I wish that this battle end in a swift and safe victory."
                    [/message]
                [/command]
            [/option]

            [option]
                message= _ "Lots of gold"
                [command]
                    [gold]
                        amount=-1
                    [/gold]
                    [message]
                        speaker=unit
                        message= _ "I wish this single gold coin be returned ten-fold to me."
                    [/message]
                [/command]
            [/option]

            [option]
                message= _ "Peace throughout Wesnoth."
                [command]
                    [gold]
                        amount=-1
                    [/gold]
                    [message]
                        speaker=unit
                        message= _ "The only thing worth wishing for is peace throughout the land."
                    [/message]
                [/command]
            [/option]

            [option]
                message= _ "Don't make a wish."
            [/option]
        [/message]
    [/event]
#enddef

#define ITM_GLOWING_BRAZIER X Y
    [item]
        x={X}
        y={Y}
        image=items/brazier-lit1.png
        halo=halo/fire-aura.png
    [/item]
#enddef

#define PICKUPPABLE_ITEM ID X Y CAN_TAKE_FILTER_WML IMAGE TEXT CANNOT_TAKE_TEXT OBJECT_WML
    # This places an item on the map which can be picked up once, but allows the
    # player to choose whether the unit stepping on it should take it or not.
    # The "object" doesn't necessarily need to be an [object], any action works.
    #
    # An example which shows the:
    # ! {PICKUPPABLE_ITEM ring_of_hp 8 12 race=human items/ring-red.png
    # !     _"$unit.name finds a pretty ring. Should he pick it up?"
    # !     _"$unit.name finds a pretty ring. But only a human can take it!" (
    # !     [object]
    # !         name= _ "Ring of HP"
    # !         image=items/ring-red.png
    # !         description= _ "This ring grants the wearer +10 max hp!"
    # !
    # !         [effect]
    # !             apply_to=hitpoints
    # !             increase_total=10
    # !         [/effect]
    # !     [/object]
    # ! )}

    [item]
        x,y={X},{Y}
        image={IMAGE}
    [/item]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x,y={X},{Y}
        [/filter]

        [if]
            [have_unit]
                x,y={X},{Y}
                {CAN_TAKE_FILTER_WML}
            [/have_unit]

            [variable]
                name=item_{ID}_picked_up
                not_equals=yes
            [/variable]

            [then]
                [message]
                    speaker=narrator
                    message={TEXT}
                    image={IMAGE}

                    [option]
                        message= _ "Take it"

                        [command]
                            {OBJECT_WML}

                            [removeitem]
                                x,y={X},{Y}
                                image={IMAGE}
                            [/removeitem]

                            [set_variable]
                                name=item_{ID}_picked_up
                                value=yes
                            [/set_variable]
                        [/command]
                    [/option]

                    [option]
                        message= _ "Leave it"

                        [command]
                            [allow_undo]
                            [/allow_undo]
                        [/command]
                    [/option]
                [/message]
            [/then]

            [else]
                [if]
                    [variable]
                        name=item_{ID}_picked_up
                        not_equals=yes
                    [/variable]

                    [then]
                        [message]
                            speaker=narrator
                            message={CANNOT_TAKE_TEXT}
                            image={IMAGE}
                            side_for=$side_number
                            # the above is used to prevent an AI side from
                            # accidentally triggering this dialog
                        [/message]
                    [/then]
                [/if]

                [allow_undo]
                [/allow_undo]
            [/else]
        [/if]
    [/event]

    [event]
        name=victory

        [clear_variable]
            name=item_{ID}_picked_up
        [/clear_variable]
    [/event]
#enddef

#define OBJ_POTION_HEALING X Y ID
    [item]
        x={X}
        y={Y}
        image=items/potion-red.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Potion of Healing"
            image=items/potion-red.png
            duration=level
            description= _ "A feeling of well-being overwhelms the drinker."
            cannot_use_message= _ "You are not worthy of healing."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=hitpoints
                increase=10%
            [/effect]
        [/object]
    [/event]
#enddef

#define OBJ_POTION_POISON X Y ID
    [item]
        x={X}
        y={Y}
        image=items/potion-yellow.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Poison"
            image=items/potion-yellow.png
            duration=level
            description= _ "Poison is seeping through the veins of this unit at this very moment."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=status
                add=poisoned
            [/effect]
        [/object]
    [/event]
#enddef

#define OBJ_POTION_HOLY X Y ID
    {PICKUPPABLE_ITEM {ID} {X} {Y} side=1 items/holy-water.png
    _"Sprinkling this water on melee weapons grants them the 'arcane' damage type until the end of the current scenario. Should $unit.name use it?"
    _"I am not suited to the use of this item! Let another take it." (
        [object]
            name= _ "Holy Water"
            image=items/holy-water.png
            duration=level
            description= _ "This water will make melee weapons have the 'arcane' damage type until the end of the current scenario."
            [effect]
                apply_to=attack
                range=melee
                set_type=arcane
            [/effect]
        [/object]
        [sound]
            name={SOUND_LIST:HOLY}
        [/sound]
    )}
#enddef

#define OBJ_POTION_STRONG X Y ID
    [item]
        x={X}
        y={Y}
        image=items/potion-red.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Potion of Strength"
            image=items/potion-red.png
            duration=level
            description= _ "Strength is given to the drinker."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=attack
                range=melee
                increase_damage=1
            [/effect]
            [effect]
                apply_to=hitpoints
                increase_total=2
                heal_full=yes
            [/effect]
        [/object]
    [/event]
#enddef

#define OBJ_POTION_DECAY X Y ID
    [item]
        x={X}
        y={Y}
        image=items/potion-blue.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Potion of Decay"
            image=items/potion-blue.png
            duration=level
            description= _ "This poor unit drank something really bad."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=hitpoints
                increase=-10%
            [/effect]
        [/object]
    [/event]
#enddef

#define OBJ_RING_REGENERATION X Y ID
    [item]
        x={X}
        y={Y}
        image=items/ring-red.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Ring of Regeneration"
            image=items/ring-red.png
            duration=forever
            description= _ "This ring will heal the bearer a little each turn."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=new_ability
                [abilities]
                    {ABILITY_REGENERATES}
                [/abilities]
            [/effect]
        [/object]
    [/event]
#enddef

#define OBJ_RING_SLOW X Y ID
    [item]
        x={X}
        y={Y}
        image=items/ring-brown.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Ring of Slowness"
            image=items/ring-brown.png
            duration=forever
            description= _ "The bearer of this ring is slowed."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=status
                add=slowed
            [/effect]
        [/object]
    [/event]
#enddef

#define OBJ_STAFF_SPEED X Y ID
    [item]
        x={X}
        y={Y}
        image=items/staff.png
    [/item]

    [event]
        name=moveto
        first_time_only=no
        [filter]
            x={X}
            y={Y}
        [/filter]
        [object]
            id={ID}
            name= _ "Staff of Swiftness"
            image=items/staff.png
            duration=forever
            description= _ "This staff will grant the bearer swift movement."
            cannot_use_message= _ "Only magical beings can wield such an object."
            [filter]
                x={X}
                y={Y}
            [/filter]
            [then]
                [removeitem]
                    x,y={X},{Y}
                [/removeitem]
            [/then]
            [effect]
                apply_to=movement
                increase=2
            [/effect]
        [/object]
    [/event]
#enddef

#wmllint: markcheck off
#define LIGHTNING_ANIMATION NAME_STRING DIRECTION_NUMBER
    #"Effect generating a new animation that throws lightning in a specified direction."
    [effect]
        apply_to=new_animation
        name={NAME_STRING}
        [attack_anim]
            [filter_attack]
                name={NAME_STRING}
            [/filter_attack]
            {LIGHTNING_BOLT {DIRECTION_NUMBER}}
            [if]
                hits=no
                [frame]
                    begin=-200
                    end=0
                    sound=lightning-miss.ogg
                [/frame]
            [/if]
            [else]
                hits=yes
                [frame]
                    begin=-200
                    end=0
                    sound=lightning.ogg
                [/frame]
            [/else]
        [/attack_anim]
    [/effect]
#enddef

#define OBJ_TRIDENT_STORM X Y ID
    {PICKUPPABLE_ITEM {ID} {X} {Y} race=merman items/storm-trident.png _"Should $unit.name pick up the trident?" _"Only the mermen can use this item!" (
        [object]
            name= _ "Storm Trident"
            image=items/storm-trident.png
            duration=forever
            description= _ "This trident allows a merman to shoot electric bolts at his enemies!"
            [effect]
                apply_to=new_attack
                name="storm trident"
                description= _ "storm trident"
                icon=attacks/lightning.png
                type=fire
                range=ranged
                [specials]
                    {WEAPON_SPECIAL_MAGICAL}
                [/specials]
                damage=14
                number=2
            [/effect]

            {LIGHTNING_ANIMATION "storm trident" 1}
            {LIGHTNING_ANIMATION "storm trident" 2}
            {LIGHTNING_ANIMATION "storm trident" 3}
        [/object]
    )}
#enddef
#wmllint: markcheck on
