#textdomain wesnoth-dw

# This copy of OBJ_TRIDENT_STORM adds the new merman types to the allowed units, and is only the object. It doesn't include the event for picking it up. The trident in wolf_coast uses a more complicated event for picking it up.

#define STORM_TRIDENT X Y ID
    [object]
        id={ID}
        name= _ "Storm Trident"
        image=items/storm-trident.png
        duration=forever
        description= _ "This weapon shoots powerful lightning bolts at your enemies."
        silent=yes
        cannot_use_message= _ "Only a merman can use this item."
        [filter]
            type=Merman Citizen,Merman Brawler,Merman Child King,Merman Young King,Merman Soldier King,Merman Warrior King,Mermaid Diviner,Mermaid Enchantress,Mermaid Initiate,Mermaid Priestess,Mermaid Siren,Merman Entangler,Merman Fighter,Merman Hoplite,Merman Hunter,Merman Javelineer,Merman Netcaster,Merman Spearman,Merman Triton,Merman Warrior
            x={X}
            y={Y}
        [/filter]
        [then]
            [unit_overlay]
                x={X}
                y={Y}
                image=overlays/storm-trident-icon.png
            [/unit_overlay]
            [remove_item]
                x={X}
                y={Y}
            [/remove_item]
        [/then]
        [effect]
            apply_to=new_attack
            name="storm trident"
            description= _ "storm trident"
            # need a better attack image, but this will do for now, replaced fireball with lightingbolt
            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

#define FLAMING_SWORD X Y ID
    [object]
        id={ID}
        name= _ "Flaming Sword"
        image=items/flame-sword.png
        duration=forever
        silent=yes
        [filter]
            x={X}
            y={Y}
        [/filter]
        [then]
            [unit_overlay]
                x={X}
                y={Y}
                image=overlays/flame-sword-icon.png
            [/unit_overlay]
            [remove_item]
                x={X}
                y={Y}
            [/remove_item]
        [/then]
        [effect]
            apply_to=new_attack
            name="flaming sword"
            description= _ "flaming sword"
            icon=attacks/sword-flaming.png
            type=fire
            range=melee
            [specials]
                {WEAPON_SPECIAL_MAGICAL}
            [/specials]
            damage=8
            number=4
        [/effect]
    [/object]
#enddef

#define ANKH_NECKLACE X Y ID
    [object]
        id={ID}
        name= _ "Ankh Necklace"
        image=items/ankh-necklace.png
        duration=forever
        silent=yes
        [filter]
            x={X}
            y={Y}
        [/filter]
        [then]
            [unit_overlay]
                x={X}
                y={Y}
                image=overlays/arcane-icon.png
            [/unit_overlay]
            [remove_item]
                x={X}
                y={Y}
                image=items/ankh-necklace.png
            [/remove_item]
        [/then]
        [effect]
            apply_to=resistance
            replace=true
            [resistance]
                arcane=30
            [/resistance]
        [/effect]
    [/object]
#enddef

# The ring of strength belongs to Mal-Kevek who appears in the second
# scenario. If he lives through that scenario, he appears again in the
# last. All the associated events need to be in both scenarios, so a
# macro is called for.

#define RING_OF_STRENGTH_EVENTS
    [event]
        name=prestart

        [if]
            [variable]
                name=MD_dead
                not_equals=yes
            [/variable]

            [then]
                [object]
                    id=power_ring1
                    silent=yes

                    [effect]
                        apply_to=attack
                        increase_damage=1
                    [/effect]

                    [effect]
                        apply_to=hitpoints
                        increase=3
                        increase_total=3
                    [/effect]

                    [filter]
                        id=Mel Daveth
                    [/filter]
                [/object]
            [/then]
        [/if]

        [set_variable]
            name=ring_x
            value=999
        [/set_variable]
    [/event]

    [event]
        name=moveto
        first_time_only=no

        [filter]
            x=$ring_x
            y=$ring_y
            side=1
        [/filter]

        [if]
            [variable]
                name=unit.id
                contains=Bat
            [/variable]
            [then]
                [if]
                    [variable]
                        name=seen_ring_description
                        not_equals=yes
                    [/variable]
                    [then]
                        [message]
                            speaker=narrator
                            message= _ "The bat slips the ring over a claw, and flies straight up, flapping powerfully."
                            image=wesnoth-icon.png
                        [/message]

                        [message]
                            speaker=narrator
                            message= _ "The ring of power increases the damage of all its owner’s attacks by one, and adds three hitpoints."
                            image=wesnoth-icon.png
                        [/message]

                        [set_variable]
                            name=seen_ring_description
                            value=yes
                        [/set_variable]
                    [/then]
                [/if]

                [message]
                    speaker=Kai Krellis
                    [option]
                        message= _ "We will let the bat have the ring. It will make him more helpful."
                        [command]
                            [set_variable]
                                name=get_ring
                                value=yes
                            [/set_variable]
                        [/command]
                    [/option]
                    [option]
                        message= _ "Someone take that off of him before he hurts himself."
                    [/option]
                [/message]
            [/then]

            [else]
                [if]
                    [variable]
                        name=seen_ring_description
                        not_equals=yes
                    [/variable]
                    [then]
                        [message]
                            speaker=unit
                            message= _ "I’ll try on the ring."
                        [/message]

                        [message]
                            speaker=unit
                            message= _ "I feel different, and all my weapons are lighter!"
                        [/message]

                        [message]
                            speaker=narrator
                            message= _ "The ring of power increases the damage of all its owner’s attacks by one, and adds three hitpoints."
                            image=wesnoth-icon.png
                        [/message]
                        [set_variable]
                            name=seen_ring_description
                            value=yes
                        [/set_variable]
                    [/then]
                [/if]

                [message]
                    speaker=unit
                    [option]
                        message= _ "I’ll take this ring, and you can rely on my strength."
                        [command]
                            [set_variable]
                                name=get_ring
                                value=yes
                            [/set_variable]
                        [/command]
                    [/option]
                    [option]
                        message= _ "This thing makes me dizzy. Someone else can have it."
                    [/option]
                [/message]
            [/else]
        [/if]

        [if]
            [variable]
                name=get_ring
                not_equals=yes
            [/variable]

            [then]
                [allow_undo][/allow_undo]
            [/then]

            [else]  # Get the ring
                [object]
                    id=power_ring2
                    name= _ "Ring of Power"
                    image=items/ring-silver.png
                    duration=forever
                    silent=yes
                    [filter]
                        x=$ring_x
                        y=$ring_y
                    [/filter]
                    [then]
                        [unit_overlay]
                            x=$ring_x
                            y=$ring_y
                            image=overlays/silver-ring-icon.png
                        [/unit_overlay]
                        [remove_item]
                            x=$ring_x
                            y=$ring_y
                        [/remove_item]
                    [/then]
                    [effect]
                        apply_to=attack
                        increase_damage=1
                    [/effect]
                    [effect]
                        apply_to=hitpoints
                        increase_total=3
                        increase=3
                    [/effect]
                [/object]
                {CLEAR_VARIABLE get_ring}
                {CLEAR_VARIABLE seen_ring_description}

                # This keeps it from being picked up a second time.
                [set_variable]
                    name=ring_x
                    value=999
                [/set_variable]

                # This [if] only applies to the second scenario. That is where this variable might be set to "yes".
                [if]
                    [variable]
                        name=end_level_when_ring_picked_up
                        equals=yes
                    [/variable]

                    [then]
                        # End level:
                        [message]
                            speaker=Cylanna
                            message= _ "Killing these enemies was good, but there were many more on the way. I’m sure it is still unsafe here."
                        [/message]

                        [message]
                            speaker=Kai Krellis
                            message= _ "I agree. I hate to leave our home, but we will return."
                        [/message]

                        [clear_variable]
                            name=ring_x
                        [/clear_variable]
                        [clear_variable]
                            name=ring_y
                        [/clear_variable]
                        [clear_variable]
                            name=KK
                        [/clear_variable]
                        [clear_variable]
                            name=get_ring
                        [/clear_variable]

                        [endlevel]
                            result=victory
                            bonus=yes
                            {NEW_GOLD_CARRYOVER 40}
                        [/endlevel]

                        [clear_variable]
                            name=end_level_when_ring_picked_up
                        [/clear_variable]
                    [/then]
                [/if]
            [/else]
        [/if]
    [/event]
#enddef

#define RING_OF_STRENGTH_APPEARS
    [if]
        [variable]
            name=MD_dead
            not_equals=yes
        [/variable]

        [then]
            [set_variable]
                name=ring_x
                value=$x1
            [/set_variable]
            [set_variable]
                name=ring_y
                value=$y1
            [/set_variable]

            {PLACE_IMAGE items/ring-silver.png $ring_x $ring_y}
            [delay]
                time=600
                # Gives you half a second to see the ring before the message (possibly) covers it up.
            [/delay]

            [message]
                speaker=$second_unit.id
                message= _ "The human wizard was wearing a ring! Maybe it is magic. Someone should try it on to see what it does."
            [/message]
        [/then]
    [/if]
#enddef
