ForestDragon's WML questions

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
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

hi again! so, i want to make sure that units affected by my weapon special (which makes their mp 0) have their original mp stored, and then given back to them, here is my failed attempts at it:

Code: Select all

[event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special=paralyze
        [/filter_attack]
        [filter_second]
          [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
            [/not]
        [/filter_second]
            [modify_unit]
              [filter]
                 id=$second_unit.id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
		[if]
                  [variable]
                    name=second_unit.status.paralyzed
                    equals=no
                  [/variable]
			[then]
        [unstore_unit]
            variable=second_unit
	    text="paralyzed"
            {COLOR_HARM}
            find_vacant=no
        [/unstore_unit]
                       [/then]
		[/if]
    [set_variables]
        name=paralyze_unit_information
        mode=append
        [value]
            id=$second_unit.id
            side=$second_unit.side
            turn_of_unparalyze=$"($turn_number| + 1)"
        [/value]
    [/set_variables]
    [object]
            silent=yes
#            duration=turn
            sort=potion-like
            [filter]
                find_in=second_unit
            [/filter]
            [effect]
                apply_to=image_mod
                replace="CS(60,30,40)"
            [/effect]
        [/object]
        [object]
            silent=yes
#            duration=turn
            [filter]
                find_in=second_unit
            [/filter]
            [effect]
                apply_to=attack
                attack_weight=0
                defense_weight=0
            [/effect]
            [effect]
                apply_to=movement
                set=0
            [/effect]
        [/object]
    [/event]
    [event]
        name=defender_hits
        first_time_only=no
        [filter_second_attack]
            special=paralyze
        [/filter_second_attack]
        [filter]
          [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
            [/not]
        [/filter]
            [modify_unit]
              [filter]
                 id=$second_unit.id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
		[if]
                  [variable]
                    name=unit.status.paralyzed
                    equals=no
                  [/variable]
			[then]
        [unstore_unit]
            variable=unit
	    text="paralyzed"
            {COLOR_HARM}
            find_vacant=no
        [/unstore_unit]
                       [/then]
		[/if]
    [set_variables]
        name=paralyze_unit_information
        mode=append
        [value]
            id=$unit.id
            side=$unit.side
            turn_of_unparalyze=$"($turn_number| + 1)"
        [/value]
    [/set_variables]
        [object]
            silent=yes
            sort=potion-like
#            duration=turn
            [filter]
                find_in=unit
            [/filter]
            [effect]
                apply_to=image_mod
                replace="CS(60,30,40)"
            [/effect]
        [/object]
        [object]
            silent=yes
#            duration=turn
            [filter]
                find_in=unit
            [/filter]
            [effect]
                apply_to=attack
                attack_weight=0.0
                defense_weight=0.0
            [/effect]
            [effect]
                apply_to=movement
                set=0
            [/effect]
        [/object]
    [/event]
[event]
    name=side turn
    first_time_only=no

    {FOREACH paralyze_unit_information i}
        [if]
            [variable]
                name=paralyze_unit_information[$i].turn_of_unparalyze
                less_than_equal_to=$turn_number
            [/variable]
            [and]
                [variable]
                    name=paralyze_unit_information[$i].side
                    equals=$side_number
                [/variable]
            [/and]

            [then]
#                [unpetrify]
#                    id=$paralyze_unit_information[$i].id
#                [/unpetrify]

#            {CLEAR_VARIABLE $paralyze_unit_information[$i].status.paralyzed}
            [modify_unit]
              [filter]
id=$paralyze_unit_information[$i].id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
            [store_unit]
              [filter]
                id=$paralyze_unit_information[$i].id
              [/filter]
              variable=current_unit
              kill=no
            [/store_unit]
            [object]
                silent=yes
                sort=potion-like
                [filter]
                    id=$paralyze_unit_information[$i].id
                [/filter]
                [effect]
                    apply_to=image_mod
                    replace="CS(0,0,0)"
                [/effect]
            [effect]
                apply_to=attack
                attack_weight=1
                defense_weight=1
            [/effect]
            [effect]
                apply_to=movement
                increase=$current_unit.movement
            [/effect]
            [/object]
                [clear_variable]
                    name=paralyze_unit_information[$i]
                [/clear_variable]
                [clear_variable]
                    name=current_unit
                [/clear_variable]
            [/then]
        [/if]
    {NEXT i}
[/event]
what i would like to know is: how would i put make a [/store_unit] in the attack event, which saves the mp values of each individual attacked unit
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut »

You already store some information with a set_variables for paralyze_unit_information, so can't you just store the movement points too? (You don't need to if it's just the same as max_moves because that's already stored in the unit whose id you have.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

beetlenaut wrote:You already store some information with a set_variables for paralyze_unit_information, so can't you just store the movement points too? (You don't need to if it's just the same as max_moves because that's already stored in the unit whose id you have.)
oh, thanks :D i almost forgot about that part of the code, thanks!
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

hmmm... i did a few edits, but i still doesn't work:

Code: Select all

[event]
        name=attacker_hits
        first_time_only=no
        [filter_attack]
            special=paralyze
        [/filter_attack]
        [filter_second]
          [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
            [/not]
        [/filter_second]
            [modify_unit]
              [filter]
                 id=$second_unit.id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
		[if]
                  [variable]
                    name=second_unit.status.paralyzed
                    equals=no
                  [/variable]
			[then]
        [unstore_unit]
            variable=second_unit
	    text="paralyzed"
            {COLOR_HARM}
            find_vacant=no
        [/unstore_unit]
                       [/then]
		[/if]
    [set_variables]
        name=paralyze_unit_information
        mode=append
        [value]
            id=$second_unit.id
            side=$second_unit.side
            turn_of_unparalyze=$"($turn_number| + 1)"
            movement=$second_unit.movement
        [/value]
    [/set_variables]
    [object]
            silent=yes
#            duration=turn
            sort=potion-like
            [filter]
                find_in=second_unit
            [/filter]
            [effect]
                apply_to=image_mod
                replace="CS(60,30,40)"
            [/effect]
        [/object]
        [object]
            silent=yes
#            duration=turn
            [filter]
                find_in=second_unit
            [/filter]
            [effect]
                apply_to=attack
                attack_weight=0
                defense_weight=0
            [/effect]
            [effect]
                apply_to=movement
                set=0
            [/effect]
        [/object]
    [/event]
    [event]
        name=defender_hits
        first_time_only=no
        [filter_second_attack]
            special=paralyze
        [/filter_second_attack]
        [filter]
          [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
            [/not]
        [/filter]
            [modify_unit]
              [filter]
                 id=$second_unit.id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
		[if]
                  [variable]
                    name=unit.status.paralyzed
                    equals=no
                  [/variable]
			[then]
        [unstore_unit]
            variable=unit
	    text="paralyzed"
            {COLOR_HARM}
            find_vacant=no
        [/unstore_unit]
                       [/then]
		[/if]
    [set_variables]
        name=paralyze_unit_information
        mode=append
        [value]
            id=$unit.id
            side=$unit.side
            turn_of_unparalyze=$"($turn_number| + 1)"
            movement=$unit.movement
        [/value]
    [/set_variables]
        [object]
            silent=yes
            sort=potion-like
#            duration=turn
            [filter]
                find_in=unit
            [/filter]
            [effect]
                apply_to=image_mod
                replace="CS(60,30,40)"
            [/effect]
        [/object]
        [object]
            silent=yes
#            duration=turn
            [filter]
                find_in=unit
            [/filter]
            [effect]
                apply_to=attack
                attack_weight=0.0
                defense_weight=0.0
            [/effect]
            [effect]
                apply_to=movement
                set=0
            [/effect]
        [/object]
    [/event]
[event]
    name=side turn
    first_time_only=no

    {FOREACH paralyze_unit_information i}
        [if]
            [variable]
                name=paralyze_unit_information[$i].turn_of_unparalyze
                less_than_equal_to=$turn_number
            [/variable]
            [and]
                [variable]
                    name=paralyze_unit_information[$i].side
                    equals=$side_number
                [/variable]
            [/and]

            [then]
#                [unpetrify]
#                    id=$paralyze_unit_information[$i].id
#                [/unpetrify]

#            {CLEAR_VARIABLE $paralyze_unit_information[$i].status.paralyzed}
            [modify_unit]
              [filter]
                 id=$paralyze_unit_information[$i].id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
            [object]
                silent=yes
                sort=potion-like
                [filter]
                    id=$paralyze_unit_information[$i].id
                [/filter]
                [effect]
                    apply_to=image_mod
                    replace="CS(0,0,0)"
                [/effect]
            [effect]
                apply_to=attack
                attack_weight=1
                defense_weight=1
            [/effect]
            [effect]
                apply_to=movement
                increase=$paralyze_unit_information[$i].movement
            [/effect]
            [/object]
                [clear_variable]
                    name=paralyze_unit_information[$i]
                [/clear_variable]
            [/then]
        [/if]
    {NEXT i}
[/event]
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut »

There is no "movement" in a unit variable. You probably want "moves" or "max_moves".
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

getting closer, but, i noticed a weird bug, only one paralyzed unit restores his max moves correctly, while the rest only have 1 mp:

Code: Select all

[event]
    name=side turn
    first_time_only=no

    {FOREACH paralyze_unit_information i}
        [if]
            [variable]
                name=paralyze_unit_information[$i].turn_of_unparalyze
                less_than_equal_to=$turn_number
            [/variable]
            [and]
                [variable]
                    name=paralyze_unit_information[$i].side
                    equals=$side_number
                [/variable]
            [/and]

            [then]
#                [unpetrify]
#                    id=$paralyze_unit_information[$i].id
#                [/unpetrify]

#            {CLEAR_VARIABLE $paralyze_unit_information[$i].status.paralyzed}
            [modify_unit]
              [filter]
                 id=$paralyze_unit_information[$i].id
              [/filter]
              [status]
                paralyzed=no
              [/status]
            [/modify_unit]
            [object]
                silent=yes
                sort=potion-like
                [filter]
                    id=$paralyze_unit_information[$i].id
                [/filter]
                [effect]
                    apply_to=image_mod
                    replace="CS(0,0,0)"
                [/effect]
            [effect]
                apply_to=attack
                attack_weight=1
                defense_weight=1
            [/effect]
            [effect]
                apply_to=movement
                increase=$paralyze_unit_information[$i].movement
            [/effect]
            [/object]
                [clear_variable]
                    name=paralyze_unit_information[$i]
                [/clear_variable]
            [/then]
        [/if]
    {NEXT i}
[/event]
EDIT: fun fact, one unit gained his old max moves+1
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: ForestDragon's WML questions

Post by The_Gnat »

That is odd, it sounds like you are having a variable problem. What I sometimes do is go along my events and print out all my variables every time something happens using messages. That way I can see where a variable goes wrong.

(Edit: also instead of modifying this units movement back to his original using the object. it might work to instead edit his max_moves)
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

The_Gnat wrote:That is odd, it sounds like you are having a variable problem. What I sometimes do is go along my events and print out all my variables every time something happens using messages. That way I can see where a variable goes wrong.

(Edit: also instead of modifying this units movement back to his original using the object. it might work to instead edit his max_moves)
thanks, will try, btw, how do you print the messages?

EDIT: solved the problem by changing the 'increase' part in the object to 'set'
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

hi, so, i am trying to make an ability like feeding, but which gives a unit 50% of the enemy's hp after killing him, here is what i've been trying, but it doesn't work:

Code: Select all

# wmllint: unbalanced-on
#define ABILITY_FEEDING2
    # Canned definition of the Feeding ability to be included in an
    # [abilities] clause.  Note: this is deliberately unbalanced WML,
    # in order to close the abilities clause then insert the event
    # then reopen the abilities clause.
    [dummy]
        id=feeding2
        name= _ "feeding2"
        female_name= _ "female^feeding2"
        description=_ "This unit gains 50% of enemy hitpoints added to its maximum whenever it kills a unit, except units that are immune to plague."
    [/dummy]
    # wmlxgettext: [abilities]
[/abilities]
[event]
    id=ability_feeding2_die
    name=last breath
    first_time_only=no

    [filter]
        [not]
            [filter_wml]
                [status]
                    unplagueable="yes"
                [/status]
            [/filter_wml]
        [/not]
    [/filter]

    [filter_second]
        ability=feeding
    [/filter_second]
[set_variable]
 name=enemyhp
 value=$unit.hitpoints
 [/set_variable]
[set_variable]
 name=enemyhp
 divide=2
 [/set_variable]
    [unstore_unit]
        variable=second_unit
        {COLOR_HEAL}
        text= _ "+ $enemyhp| max HP"
        find_vacant=no
    [/unstore_unit]

    [object]
        silent=yes
        duration=forever

        [filter]
            x,y=$x2,$y2
        [/filter]

        [effect]
            apply_to=hitpoints
            increase_total=$enemyhp|
            increase=$enemyhp|
        [/effect]
    [/object]
[clear_variable]
 name=enemyhp
 [/clear_variable]
[/event]
[+abilities]
    # wmlxgettext: [/abilities]
#enddef
# wmllint: unbalanced-off
 
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper »

ForestDragon wrote:

Code: Select all

[set_variable]
 name=enemyhp
 value=$unit.hitpoints
 [/set_variable]
Well, a dying unit isn't going to have a lot of hitpoints left..?
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

zookeeper wrote:
ForestDragon wrote:

Code: Select all

[set_variable]
 name=enemyhp
 value=$unit.hitpoints
 [/set_variable]
Well, a dying unit isn't going to have a lot of hitpoints left..?
so, how is the max hitpoints variable named?
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut »

Go into a game, and type :inspect. Look at a unit, and you can see the name of every variable it has.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ForestDragon
Posts: 1770
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

beetlenaut wrote:Go into a game, and type :inspect. Look at a unit, and you can see the name of every variable it has.
thanks! i actually never used it before, will try it out

EDIT: couldn't find the max hp
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ForestDragon's WML questions

Post by Ravana »

I suggest you look again, and make sure you look unit data not normal variables.

Other than that, this ability has been done in mercenaries era as graverobber.
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: ForestDragon's WML questions

Post by The_Gnat »

Hi in your feeding macro you have written filter second ability feeding. But your ability is called feeding 2 so I think that may be your problem.

As for messages i just write them like normal from the narrator and put $ variables in them:

Code: Select all

[message]
      speaker=narrator
      message=_"var 1 : $var1"
[/message]
Then if you put in that $unit.hitpoints, $unit.max_hp and any others you want you can check what they are.
Post Reply