[SOLVED] Trying to modify multiple units, only 1 is modified
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.
[SOLVED] Trying to modify multiple units, only 1 is modified
I try to modify the hp of all Drake Burners at the same time. It seems though that only out of four units is modified. I probably have messed something up with the foreach or the unstoring. Any help is appreciated. This is the code used:
Code: Select all
#ifdef EASY
{VARIABLE hp_add 20}
#endif
#ifdef NORMAL
{VARIABLE hp_add 10}
#endif
#ifdef HARD
{VARIABLE hp_add 0}
#endif
[store_unit]
[filter]
type=Drake Burner
[/filter]
variable=burners
[/store_unit]
[foreach]
array=burners
[do]
[set_variable]
name=this_item.max_hitpoints
add=$hp_add
[/set_variable]
[set_variable]
name=this_item.hitpoints
add=$hp_add
[/set_variable]
[/do]
[/foreach]
[unstore_unit]
variable=burners
[/unstore_unit]
Last edited by Anagkai on September 18th, 2018, 5:43 pm, edited 1 time in total.
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
Re: Trying to modify multiple units, only 1 is modified
Unstoring is only implemented for one unit, so put it in loop too.
Or you can use [modify_unit] which is wrapper for this kind of unit modification.
Or you can use [modify_unit] which is wrapper for this kind of unit modification.