ForestDragon's WML questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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

Re: ForestDragon's WML questions

Post by Ravana » July 13th, 2016, 12:21 pm

Code: Select all

dependencies=Ageless_Era,XP_Modification,Plan_Your_Advancements_Mod,Switch_Leader,Color_Modification,Ally_Village_Modification

User avatar
ForestDragon
Forum Regular
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » July 13th, 2016, 12:26 pm

thanks :)
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Forum Regular
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » July 19th, 2016, 5:51 pm

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.
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
bumbadadabum
Developer
Posts: 1005
Joined: March 20th, 2008, 5:54 pm
Location: Netherlands
Contact:

Re: ForestDragon's WML questions

Post by bumbadadabum » July 19th, 2016, 5:56 pm

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 bumbadadabum on July 19th, 2016, 7:20 pm, edited 1 time in total.
Reason: Fixed

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

Re: ForestDragon's WML questions

Post by zookeeper » July 19th, 2016, 6:00 pm

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
Forum Regular
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » July 19th, 2016, 6:04 pm

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 ^_^
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
bumbadadabum
Developer
Posts: 1005
Joined: March 20th, 2008, 5:54 pm
Location: Netherlands
Contact:

Re: ForestDragon's WML questions

Post by bumbadadabum » July 19th, 2016, 7:19 pm

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

User avatar
ForestDragon
Forum Regular
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » July 19th, 2016, 7:43 pm

ok, thanks!
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Forum Regular
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » August 1st, 2016, 3:20 pm

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]
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
Ravana
Moderator
Posts: 1874
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ForestDragon's WML questions

Post by Ravana » August 1st, 2016, 3:39 pm

I doubt you can access it, but try just without [unit_type].

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

Re: ForestDragon's WML questions

Post by zookeeper » August 1st, 2016, 3:43 pm

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
Forum Regular
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » August 1st, 2016, 4:34 pm

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.
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
beetlenaut
Developer
Posts: 2239
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut » August 1st, 2016, 4:39 pm

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: 9739
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper » August 1st, 2016, 4:46 pm

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: 2239
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut » August 1st, 2016, 4:53 pm

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