HOW to heal in village more than 8 with WML
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.
HOW to heal in village more than 8 with WML
Hi!
Could you please give me a hint, why it does not work? I am fiddling with this about 4 hours now...
HELP NEEDED
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]
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
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
Try changing this:
to:
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.
Code: Select all
{VARIABLE_OP tempx to_variable locs[$i].x}
{VARIABLE_OP tempy to_variable locs[$i].y}
Code: Select all
{VARIABLE_OP tempx format $locs[$i].x}
{VARIABLE_OP tempy format $locs[$i].y}
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.
Still - the problem seems to be connected with the filter (?) - the locs variable seems empty ...zookeeper wrote:Code: Select all
{VARIABLE_OP tempx format $locs[$i].x} {VARIABLE_OP tempy format $locs[$i].y}
Changed code, did not help at all

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
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
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.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.
Thanx, it helped:
but still
does not heal any unit 
Code: Select all
[store_locations]
x=1-100
y=1-100
variable=locs
terrain=aAbBDeLptUVvYZP
[filter]
side=$side_number
[/filter]
[/store_locations]
Code: Select all
[object]
silent=yes
[filter]
x=$tempx
y=$tempy
[/filter]
[effect]
apply_to=hitpoints
increase=24
violate_max=no
[/effect]
[/object]

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
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
That's odd...have you tried it without violate_max=no? That's about the only thing I can think of.Sauron wrote:does not heal any unitCode: Select all
[object] silent=yes [filter] x=$tempx y=$tempy [/filter] [effect] apply_to=hitpoints increase=24 violate_max=no [/effect] [/object]
Well:
heals 10 hp (TOTAL)
while
heals 8 points (TOTAL)

Well:
HEALS 10 hp ! WTF?!?
Code: Select all
[object]
silent=yes
[filter]
x=$tempx
y=$tempy
[/filter]
[effect]
apply_to=hitpoints
increase=24
[/effect]
[/object]
while
Code: Select all
[object]
silent=yes
[filter]
x=$tempx
y=$tempy
[/filter]
[effect]
apply_to=hitpoints
increase=8
[/effect]
[/object]

Well:
Code: Select all
[object]
silent=yes
[filter]
x=$tempx
y=$tempy
[/filter]
[effect]
apply_to=hitpoints
#increase=90
heal_full=yes
[/effect]
[/object]
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
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
- Kestenvarn
- Inactive Developer
- Posts: 1307
- Joined: August 19th, 2005, 7:30 pm
- Contact:
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.
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."
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.
edit: fixed typo
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]
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."
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:

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
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