[store_unit] Get ability values

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
Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

[store_unit] Get ability values

Post by Enderlook » January 22nd, 2018, 11:44 pm

I have this store unit

Code: Select all

[store_unit]
	[filter]
		x,y=$x1,$y1
		[filter_adjacent]
			side=$side_number
			ability=healer
		[/filter_adjacent]
	[/filter]
	variable=healers
[/store_unit]
In the variable "healers" I store all the adjacent unit who have the "healer" ability. But now I want to get the value of the healer ability of each unit. I mean, the "healer" ability has a value (like: "healer +4", "healer +8", etc). I want to get that value. How can I do that?

Code: Select all

#define ABILITY_HEALER HP
	[dummy]
		value={HP}
		id=healer
		name= _ "medic +{HP}"
		female_name= _ "female^medic + {HP}"
		description= _ "This unit is able to use it own turn in order to heal an specific wounded target."
	[/dummy]
#enddef
I tried with something like this:

Code: Select all

$healers[{number}].abilities.healer.value
But didn't work, also I tried with "ability" instead of "abilities"... but again it didn't work :( . Any ideas?

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

Re: [store_unit] Get ability values

Post by zookeeper » January 23rd, 2018, 9:31 am

Enderlook wrote:I tried with something like this:

Code: Select all

$healers[{number}].abilities.healer.value
But didn't work, also I tried with "ability" instead of "abilities"... but again it didn't work :( . Any ideas?
There's no [healer] tag, there's a [dummy] tag, so $healers[{number}].abilities.dummy.value would be correct. But of course that means you should choose a disambiguous tag name (because it can be anything), just in case the unit has other [dummy] abilities.

Enderlook
Posts: 38
Joined: January 22nd, 2018, 12:23 am

Re: [store_unit] Get ability values

Post by Enderlook » January 23rd, 2018, 2:26 pm

Thanks! I didn't know that I had to write the tag name instead of id. Also I didn't know that I could make my own dummies!

Post Reply