HOW to heal in village more than 8 with WML

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
Sauron
Posts: 221
Joined: January 11th, 2006, 8:51 am
Location: Barad-Dur, Mordor
Contact:

HOW to heal in village more than 8 with WML

Post by Sauron »

Hi!

Could you please give me a hint, why it does not work? I am fiddling with this about 4 hours now...

Code: Select all

	[event]
		name=side turn
		first_time_only=no
		[store_locations]
			variable=locs
			terrain=aAbBDeLptUVvYZP
			[filter]
				side=$side_number
			[/filter]
		[/store_locations]

		{FOREACH locs i}
			{VARIABLE_OP tempx to_variable locs[$i].x}
			{VARIABLE_OP tempy to_variable locs[$i].y}
			[object]
				[filter]
					x=$tempx
					y=$tempy
				[/filter]
				[effect]
					apply_to=hitpoints
					increase=24
					violate_max=no
				[/effect]
			[/object]
		{NEXT i}
		{CLEAR_VARIABLE tempx}
		{CLEAR_VARIABLE tempy}
		{CLEAR_VARIABLE locs}
		{CLEAR_VARIABLE i}
	[/event]
HELP NEEDED
Sauron
Customize yourself random factor in game:
GET my mod [available as C++ sourcecode and compiled Windows executable] for wesnoth 1.6.4
at http://saurons-mod.zor.org/
Mod thread
http://www.wesnoth.org/forum/viewtopic.php?t=26803
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Try changing this:

Code: Select all

{VARIABLE_OP tempx to_variable locs[$i].x}
{VARIABLE_OP tempy to_variable locs[$i].y} 
to:

Code: Select all

{VARIABLE_OP tempx format $locs[$i].x}
{VARIABLE_OP tempy format $locs[$i].y} 
I'd say your version should work, but I'd also never use to_variable unless I really needed to. I find it somehow confusing, although it is simple.

You probably also want to add silent=yes to the [object].

Another hint: use debug [message]s or savefiles to find out which variables get their values set correctly, etc. It really speeds up this kind of debugging.
Sauron
Posts: 221
Joined: January 11th, 2006, 8:51 am
Location: Barad-Dur, Mordor
Contact:

Post by Sauron »

zookeeper wrote:

Code: Select all

{VARIABLE_OP tempx format $locs[$i].x}
{VARIABLE_OP tempy format $locs[$i].y} 
Still - the problem seems to be connected with the filter (?) - the locs variable seems empty ...


Changed code, did not help at all :-( THanx 4 advise anyway
Sauron
Customize yourself random factor in game:
GET my mod [available as C++ sourcecode and compiled Windows executable] for wesnoth 1.6.4
at http://saurons-mod.zor.org/
Mod thread
http://www.wesnoth.org/forum/viewtopic.php?t=26803
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

the wiki wrote:[store_locations] Stores a series of locations that pass certain criteria into an array. Each member of the array has members 'x' and 'y'.

* standard location filter- a location or location range which specifies the locations to store. You must specify this or no locations will be stored.
I'd suggest you try giving the [store_locations] the location ranges x=1-30 (or whatever is the width of the map) and y=1-20 (or whatever is the height of the map) and see if that helps. Now that I think of it, I think that's the most probable cause of the bug.
Sauron
Posts: 221
Joined: January 11th, 2006, 8:51 am
Location: Barad-Dur, Mordor
Contact:

Post by Sauron »

Thanx, it helped:

Code: Select all

		[store_locations]
			x=1-100
			y=1-100
			variable=locs
			terrain=aAbBDeLptUVvYZP
			[filter]
				side=$side_number
			[/filter]
		[/store_locations]
but still

Code: Select all

			[object]
				silent=yes
				[filter]
					x=$tempx
					y=$tempy
				[/filter]
				[effect]
					apply_to=hitpoints
					increase=24
					violate_max=no
				[/effect]
			[/object]
does not heal any unit :(
Sauron
Customize yourself random factor in game:
GET my mod [available as C++ sourcecode and compiled Windows executable] for wesnoth 1.6.4
at http://saurons-mod.zor.org/
Mod thread
http://www.wesnoth.org/forum/viewtopic.php?t=26803
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Sauron wrote:

Code: Select all

			[object]
				silent=yes
				[filter]
					x=$tempx
					y=$tempy
				[/filter]
				[effect]
					apply_to=hitpoints
					increase=24
					violate_max=no
				[/effect]
			[/object]
does not heal any unit :(
That's odd...have you tried it without violate_max=no? That's about the only thing I can think of.
Sauron
Posts: 221
Joined: January 11th, 2006, 8:51 am
Location: Barad-Dur, Mordor
Contact:

Post by Sauron »

Well:

Code: Select all

	[object]
				silent=yes
				[filter]
					x=$tempx
					y=$tempy
				[/filter]
				[effect]
					apply_to=hitpoints
					increase=24
				[/effect]
			[/object]
heals 10 hp (TOTAL)
while

Code: Select all

			[object]
				silent=yes
				[filter]
					x=$tempx
					y=$tempy
				[/filter]
				[effect]
					apply_to=hitpoints
					increase=8
				[/effect]
			[/object]
heals 8 points (TOTAL)

:shock:

Well:

Code: Select all

			[object]
				silent=yes
				[filter]
					x=$tempx
					y=$tempy
				[/filter]
				[effect]
					apply_to=hitpoints
					#increase=90
					heal_full=yes
				[/effect]
			[/object]
HEALS 10 hp ! WTF?!?
Sauron
Customize yourself random factor in game:
GET my mod [available as C++ sourcecode and compiled Windows executable] for wesnoth 1.6.4
at http://saurons-mod.zor.org/
Mod thread
http://www.wesnoth.org/forum/viewtopic.php?t=26803
User avatar
Kestenvarn
Inactive Developer
Posts: 1307
Joined: August 19th, 2005, 7:30 pm
Contact:

Post by Kestenvarn »

:|
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

You shouldn't be doing this with an object. Objects are typically for move-to events and permantent changes.

Use [store_unit] and [unstore_unit] instead.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I think this is inspired by my suggestion, isn´t it?

I´m sorry because it doesn´t work. The thing I added and I advice you to add is the stuff with the side turns and only units of the active side are healed. :wink:
First read, then think. Read again, think again. And then post!
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient »

This should work for 1.1.2 (in some other versions it might exceed max hp).

Also, it would be more thorough to check that they are not poisoned, but my code is just an illustration.

Code: Select all


[event] 
 name=side turn 
 first_time_only=no 

#define IF_TERRAIN X Y TYPES CONTENTS
    [store_locations]
        x={X}
        y={Y}
        terrain={TYPES}
        variable=IF_TERRAIN_temp
    [/store_locations] 
    [if]
        [variable]
            name=IF_TERRAIN_temp.length
            not_equals=0
        [/variable] 
        {CONTENTS}
    [/if] 
    {CLEAR_VARIABLE IF_TERRAIN_temp}
#enddef

 [store_unit]
  [filter]
   side=$side_number
  [/filter]
  variable=side_units_store
  kill=yes
 [/store_unit]
 {FOREACH side_units_store sus_i}
  {IF_TERRAIN $side_units_store[$sus_i].x $side_units_store[$sus_i].y aAbBDeLptUVvYZP (
   [then]
    [set_variable]
      name=side_units_store[$sus_i].hitpoints
      add=2
    [/set_variable]
   [/then]
  )}
  [unstore_unit]
   variable=side_units_store[$sus_i]
   find_vacant=no
  [/unstore_unit]
 {NEXT sus_i}
 {CLEAR_VARIABLE side_units_store}
[/event]
edit: fixed typo
Last edited by Sapient on April 1st, 2006, 7:21 pm, edited 1 time in total.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Sauron
Posts: 221
Joined: January 11th, 2006, 8:51 am
Location: Barad-Dur, Mordor
Contact:

Post by Sauron »

I DID IT :-)

THX 4 all help. Still - if unit has more than max HP and enters village - HP drops down to max ... in some scenarios exceeding max might be possible - what then?

My code 2 heal 32 HP in villages:

Code: Select all

#define HealPatch

	[event]
		name=side turn
		first_time_only=no
		[store_locations]
			x=1-100
			y=1-100 
			variable=locs
			terrain=aAbBDeLptUVvYZP
			[filter]
				side=$side_number
			[/filter]
		[/store_locations]
		[set_variable]
			name=i
			value=0
		[/set_variable]
		[while]
			[variable]
				less_than=$locs.length
				name=i
			[/variable]
			[do]
				[set_variable]
					name=tx
					format=$locs[$i].x
				[/set_variable]	
				[set_variable]
					name=ty
					format=$locs[$i].y
				[/set_variable]					
				[store_unit]
					[filter]
						x=$tx
						y=$ty
					[/filter]
					variable=unit
					kill=no
				[/store_unit]
				[set_variable]
					name=unit.hitpoints
					add=24
				[/set_variable]

				[unstore_unit]
					variable=unit
				[/unstore_unit]
				[clear_variable]
					name=unit
				[/clear_variable]
				[clear_variable]
					name=tx
				[/clear_variable]
				[clear_variable]
					name=ty
				[/clear_variable]
				[set_variable]
					name=i
					add=1
				[/set_variable]
			[/do]
		[/while]
		[clear_variable]
					name=locs
		[/clear_variable]
		[clear_variable]
					name=i
		[/clear_variable]
	[/event]

#enddef
Sauron
Customize yourself random factor in game:
GET my mod [available as C++ sourcecode and compiled Windows executable] for wesnoth 1.6.4
at http://saurons-mod.zor.org/
Mod thread
http://www.wesnoth.org/forum/viewtopic.php?t=26803
Post Reply