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

Re: ForestDragon's WML questions

Post by ForestDragon »

Ravana wrote:I noticed you call for variable name you do not assign.
please be specific about what exact variable it is
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: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ForestDragon's WML questions

Post by Ravana »

this_leader
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper »

You have a [store_unit] in your [set_menu_item].
User avatar
ForestDragon
Posts: 1769
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

oh, 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
Ravana
Forum Moderator
Posts: 2953
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ForestDragon's WML questions

Post by Ravana »

I guess I cant expect more from you.

formula= is part of standard unit filter not filter_wml.
User avatar
ForestDragon
Posts: 1769
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

well, slightly better, but, the ability triggers no matter how much hp the unit has

Code: Select all

#define ABILITY_DESPERATE VALUE
    # Canned definition of the Desperate ability to be included in an
    # [abilities] clause.
    [leadership]
        id=desperate
        value={VALUE}
        cumulative=no
        name= _ "desperate ({VALUE}%)"
        female_name= _ "female^desperate ({VALUE}%)"
        description= _ "This unit's attacks do {VALUE}% more damage when it's health is below 50%."
        affect_self=yes
        affect_allies=no
        affect_enemies=no
        [filter_self]
           [filter]
               formula="(($this_unit.max_hitpoints -1+1) / ($this_unit.hitpoints -1+1)) > 2"
	   [/filter]
        [/filter_self]
    [/leadership]
#enddef
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 »

You have stuff in your [filter_self] that shouldn't be there. When you have a problem with one single tag then you could first check whether you're using it right.
User avatar
ForestDragon
Posts: 1769
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

zookeeper wrote:You have stuff in your [filter_self] that shouldn't be there. When you have a problem with one single tag then you could first check whether you're using it right.
can you please be more specific?
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:can you please be more specific?
The extra [filter] tag. When the wiki says that you can put a StandardUnitFilter somewhere, then it means you can put the stuff listed on the StandardUnitFilter page there. If you need to wrap said StandardUnitFilter stuff in a [filter] tag, then the wiki will say so.
User avatar
ForestDragon
Posts: 1769
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

zookeeper wrote:
ForestDragon wrote:can you please be more specific?
The extra [filter] tag. When the wiki says that you can put a StandardUnitFilter somewhere, then it means you can put the stuff listed on the StandardUnitFilter page there. If you need to wrap said StandardUnitFilter stuff in a [filter] tag, then the wiki will say so.
well, the thing is, when i put the additional [filter], the ability triggers no matter how much hp the unit has, but if i remove the filter, the ability doesn't trigger at all
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: 1769
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

hello everyone! well, i got another filter issue: i want the [store_unit]'s filter not store units who have at least 2 enemies adjacent to them, but I have done something wrong with the filter, not quite sure what though

Code: Select all

                  [option]
               message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "Deposit All"}
               [command]
                  [store_unit]
                     [filter]
                        side=$side_number
             [not]
             [filter_adjacent]	
                [filter_side]
                    [enemy_of]
                        side=$side_number
                    [/enemy_of]
                [/filter_side]
                count=2-6
             [/filter_adjacent]
             [/not]
                     [/filter]
                     variable=exp_drained_unit
                  [/store_unit]
                  {FOREACH exp_drained_unit i}
                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]
                  {VARIABLE exp_drained_unit[$i].experience 0}
                  [unstore_unit]
                     variable=exp_drained_unit[$i]
                     find_vacant=no
                  [/unstore_unit]
                  {NEXT i}
                  {CLEAR_VARIABLE exp_drained_unit}
               [/command]
            [/option]
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 »

Looks correct to me.
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut »

ForestDragon wrote:well, the thing is, when i put the additional [filter], the ability triggers no matter how much hp the unit has, but if i remove the filter, the ability doesn't trigger at all
Since [filter] is not allowed here, everything inside it is ignored when you use it. When you take it out, the formula is evaluated, but it must not equal what you think it does. I have never used formula, but from the wiki, it looks like you should be using the variable "self" instead of "$this_unit".
ForestDragon wrote:I have done something wrong with the filter, not quite sure what though
Maybe the filter is not the problem. You should always try your code without CLEAR_VARIABLE the first time so you can use :inspect to see what your variables actually equal--in this case, what units did get stored, if any. You may have a problem because you are treating your variable as an array, but it might not be one.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper »

Oh, yeah, this is definitely a case where you're trying to treat a container as a variable:

Code: Select all

                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]
User avatar
ForestDragon
Posts: 1769
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

zookeeper wrote:Oh, yeah, this is definitely a case where you're trying to treat a container as a variable:

Code: Select all

                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]
well, sorry for not understanding, but what exactly should i fix?
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
Post Reply