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

Re: ForestDragon's WML questions

Post by Ravana »

Code: Select all

dependencies=Ageless_Era,XP_Modification,Plan_Your_Advancements_Mod,Switch_Leader,Color_Modification,Ally_Village_Modification
User avatar
ForestDragon
Posts: 1771
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

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

Re: ForestDragon's WML questions

Post by ForestDragon »

hi everyone again, and sorry for bothering you with somewhat stupid questions, but here it is:

i would like something to randomly select a unit in a radius around a unit. i need it for a boss fight, where the boss casts random spells on random units.
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
Astoria
Inactive Developer
Posts: 1007
Joined: March 20th, 2008, 5:54 pm
Location: Netherlands

Re: ForestDragon's WML questions

Post by Astoria »

Code: Select all

[store_unit]
    [filter]
        side=whatever
        [filter_location]
             x,y=whatever
             radius=whatever
        [/filter_location]
    [/filter]
    kill=no
    variable=target_selection
[/store_unit]

{VARIABLE_OP target_idx rand "0..$($target_selection.length - 1)"}
The targeted unit should then be target_selection[$target_idx].
Last edited by Astoria on July 19th, 2016, 7:20 pm, edited 1 time in total.
Reason: Fixed
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper »

bumbadadabum wrote:{VARIABLE_OP target_idx rand "0..$target_selection.length"}
Except target_idx can end up out-of-bounds by one. What you want is:

{VARIABLE_OP target_idx rand "0..$($target_selection.length - 1)"}
User avatar
ForestDragon
Posts: 1771
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

so, if i understand you two correctly, the stored unit is the one whom the random selects around?
and, if i want, say, to so something to the selected unit, i should use this?:

Code: Select all

x,y=target_idx.x,target_idx.y
well, thanks for the help ^_^
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
Astoria
Inactive Developer
Posts: 1007
Joined: March 20th, 2008, 5:54 pm
Location: Netherlands

Re: ForestDragon's WML questions

Post by Astoria »

zookeeper wrote:
bumbadadabum wrote:{VARIABLE_OP target_idx rand "0..$target_selection.length"}
Except target_idx can end up out-of-bounds by one. What you want is:

{VARIABLE_OP target_idx rand "0..$($target_selection.length - 1)"}
:doh:
ForestDragon wrote:so, if i understand you two correctly, the stored unit is the one whom the random selects around?
and, if i want, say, to so something to the selected unit, i should use this?:

Code: Select all

x,y=target_idx.x,target_idx.y
No, you need to do x,y=$target_selection[$target_idx].x,$target_selection[$target_idx].y
Formerly known as the creator of Era of Chaos and maintainer of The Aragwaithi and the Era of Myths.
User avatar
ForestDragon
Posts: 1771
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

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

Re: ForestDragon's WML questions

Post by ForestDragon »

hi, once again, i apologise if the sheer amount of wml questions of mine is getting on your nerves, but oh well, here it is:

i am trying to have a filter for a movement type, but it isn't working, i think i messed up with the [filter_wml] part

Code: Select all

        [filter]
           side=1,2
       [and]
            [filter_wml]
               [unit_type]
                 movement_type=mounted
               [/unit_type]
            [/filter_wml]
       [/and]
       [and]
        [not]
            [filter_wml]
                [status]
                    not_living="yes"
                [/status]
            [/filter_wml]
        [/not]
       [/and]
        [/filter]
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: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ForestDragon's WML questions

Post by Ravana »

I doubt you can access it, but try just without [unit_type].
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper »

When you look at a unit via :inspect (or in a savefile), do you see a [unit_type] tag inside it and then a movement_type= key inside that? You don't, so your [filter_wml] cannot match.

So, you can't filter by movetype directly, but you can of course filter by individual movement/defense/resistance values and probably get effectively the same result that way.
User avatar
ForestDragon
Posts: 1771
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

zookeeper wrote:When you look at a unit via :inspect (or in a savefile), do you see a [unit_type] tag inside it and then a movement_type= key inside that? You don't, so your [filter_wml] cannot match.

So, you can't filter by movetype directly, but you can of course filter by individual movement/defense/resistance values and probably get effectively the same result that way.
ok, i did it like this, and it worked:

Code: Select all

            [filter_wml]
               [unit]
                  undead_variation=mounted
               [/unit]
            [/filter_wml]
it's much simpler than your solution, and it works not only on those with 'mounted' movement_type, but also wolves, and elvish riders, ect.
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 »

That was a good idea, but just be careful of counting on it. If a zombie wolf gets created, for example, that could change.
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 »

That cannot work. There's no [unit] tag to filter for in a unit any more than there is a [unit_type] tag.
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 »

Well, I mean using undead_variation is a good idea at least.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply