Disable opponent weapon during fight

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
Xardas666
Posts: 31
Joined: March 10th, 2021, 7:12 pm

Disable opponent weapon during fight

Post by Xardas666 »

Hello. Is there a simple way to disable opponent weapon during fight when he is hit by special attack?
I have the following piece of code but it disables attacks only after a fight.

Code: Select all

#define WEAPON_SPECIAL_WG5_FREEZE
    [damage]
        id=wg5_freeze
        name= _ "freeze"
        description= _ ""
    [/damage]
#enddef

#define WG5_FREEZE_EVENTS
    [event]
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special_id=wg5_freeze
        [/filter_attack]
        [filter_second]
            [not]
                [filter_wml]
                    [status]
                        unfreezeable=yes
                    [/status]
                [/filter_wml]
            [/not]
        [/filter_second]
    {VARIABLE second_unit.status.frozen yes}
    [unstore_unit]
        variable=second_unit
        find_vacant=no
        text=_ "frozen"
        red,green,blue=0,0,255
    [/unstore_unit]

    [modify_unit]
        [filter]
            id=$second_unit.id
        [/filter]
        [object]
            silent=yes
            duration=turn
            id=wg5_frozen_obj
            take_only_once=no
            [effect]
                apply_to=halo
                halo=halo/frozen/ice_block.png
            [/effect]
            [effect]
                apply_to=attack
                increase_attacks="-100%"
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_WG5_DISABLED}
                [/set_specials]
            [/effect]
            [effect]
                apply_to=max_attacks
                increase="-100%"
            [/effect]
            [effect]
                apply_to=movement
                set="0"
            [/effect]
        [/object]
    [/modify_unit]
    [/event]
    [event]
        name=defender hits
        first_time_only=no
        [filter_second_attack]
            special_id=wg5_freeze
        [/filter_second_attack]
        [filter]
            [not]
                [filter_wml]
                    [status]
                        unfreezeable=yes
                    [/status]
                [/filter_wml]
            [/not]
        [/filter]
    {VARIABLE unit.status.burning yes}
    [unstore_unit]
        variable=unit
        find_vacant=no
        text=_ "frozen"
        red,green,blue=0,0,255
    [/unstore_unit]

    [modify_unit]
        [filter]
            id=$unit.id
        [/filter]
        [object]
            silent=yes
            duration=turn
            id=wg5_frozen_obj
            take_only_once=no
            [effect]
                apply_to=halo
                halo=halo/frozen/ice_block.png
            [/effect]
            [effect]
                apply_to=attack
                increase_attacks="-100%"
                [set_specials]
                    mode=append
                    {WEAPON_SPECIAL_WG5_DISABLED}
                [/set_specials]
            [/effect]
            [effect]
                apply_to=max_attacks
                increase="-100%"
            [/effect]
            [effect]
                apply_to=movement
                set="0"
            [/effect]
        [/object]
    [/modify_unit]
    [/event]

[event]
    name=side turn
    id=wg5_stop_being_freezed_event
    first_time_only=no

    [filter]
        status=frozen
    [/filter]

    {VARIABLE unit.status.frozen no}

    [unstore_unit]
        variable=unit
        find_vacant=no
        advance=no
    [/unstore_unit]

    [remove_object]
        x,y=$unit.x,$unit.y
        object_id=wg5_frozen_obj
    [/remove_object]
[/event]
#enddef
white_haired_uncle
Posts: 1232
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: Disable opponent weapon during fight

Post by white_haired_uncle »

I don't know the answer to your question, but I did notice that when defender hits you set unit.status.burning, which looks odd.
User avatar
Toranks
Translator
Posts: 168
Joined: October 21st, 2022, 8:59 pm
Location: Sevilla
Contact:

Re: Disable opponent weapon during fight

Post by Toranks »

Just before the attack. For example, in pre attack event:

Code: Select all

    [modify_unit]
        [filter]
            id=$unit.id
        [/filter]
        [object]
            id=aww_disable_attacks
            [effect]
                apply_to=attack
                set_attacks=0
            [/effect]
        [/object]
    [/modify_unit]
After the attack, on attack end event:

Code: Select all

    [remove_object]
        id=$unit.id
        object_id=aww_disable_attacks
    [/remove_object]
I think it's much simpler than what you're trying
Last edited by Toranks on June 30th, 2023, 9:27 pm, edited 1 time in total.
User avatar
Ravana
Forum Moderator
Posts: 3028
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Disable opponent weapon during fight

Post by Ravana »

side_turn does not contain unit, so filter means it never activates.
Post Reply