[SOLVED] Trying to modify multiple units, only 1 is modified

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
Anagkai
Posts: 54
Joined: February 12th, 2012, 10:05 am

[SOLVED] Trying to modify multiple units, only 1 is modified

Post by Anagkai » September 18th, 2018, 3:45 pm

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) & Relocate (in dev)

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

Re: Trying to modify multiple units, only 1 is modified

Post by Ravana » September 18th, 2018, 3:49 pm

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.

Post Reply