[heal_unit]
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.
[heal_unit]
code:
Re: [heal_unit]
No, you're just making the same mistake I pointed out in the previous thread.
Re: [heal_unit]
all of the code works, sans for this:
[heal_unit]
[filter]
variable=survivor
[/filter]
amount=2
[/heal_unit]
I removed the [filter] tags once and it still did nothing.
[heal_unit]
[filter]
variable=survivor
[/filter]
amount=2
[/heal_unit]
I removed the [filter] tags once and it still did nothing.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: [heal_unit]
[if][filter] and [filter]variable= don't work
should work about this way (untested)
should work about this way (untested)
Code: Select all
#define ABILITY_SURVIVOR
# Canned definition of the survivor ability to be included in a
# [specials] clause.
# dummy weapon special used to describe the effect to the user
# and filter on special's id
[dummy]
id=unit_survivor
name= _ "survivor"
name_inactive= _ "survivor"
description= _ "survivor :
If this unit successfully survives an attack, they gain 2 HP."
description_inactive= _ "survivor :
If this unit successfully survives an attack, they gain 2 HP."
[/dummy]
[/abilities]
[event]
name=attack_end
first_time_only=no
[filter_second]
ability=unit_survivor
[/filter_second]
[if]
[variable]
name=second_unit.hitpoints
greater_than=0
[/variable]
[then]
[set_variable]
name=second_unit.hitpoints
add=2
[/set_variable]
[unstore_unit]
variable=second_unit
text="2"
{COLOR_HEAL}
[/unstore_unit]
[/then]
[/if]
[/event]
[+abilities]
#enddef
Last edited by Anonymissimus on October 8th, 2009, 8:40 pm, edited 1 time in total.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: [heal_unit]
Your [then] is either always or never entered, because you haven't specified any valid condition in your [if].
Nevertheless, any healing your [heal_unit] does to the unit is probably negated by the fact that you immediately overwrite the unit by replacing the now healed unit with the one you stored before it got healed.
And in standard unit filters there's no such key as a variable=. If you want to filter for the unit at $x1,$y1 then use x,y=$x1,$y1 as the filter.
Nevertheless, any healing your [heal_unit] does to the unit is probably negated by the fact that you immediately overwrite the unit by replacing the now healed unit with the one you stored before it got healed.
And in standard unit filters there's no such key as a variable=. If you want to filter for the unit at $x1,$y1 then use x,y=$x1,$y1 as the filter.
Re: [heal_unit]
I looked over the code I posted in my first post. It WAS wrong, but when I "fixed" it, it still doesn't function as I would like it to.
It doesn't seem to work when the unit is defending.. only when they are attacking.
I'm still learning this stuff, and the wiki is awful vague on a LOT of these things.
Code: Select all
#define ABILITY_SURVIVOR
# Canned definition of the survivor ability to be included in a
# [specials] clause.
# dummy weapon special used to describe the effect to the user
# and filter on special's id
[dummy]
id=unit_survivor
name= _ "survivor"
name_inactive= _ "survivor"
description= _ "survivor :
If this unit successfully survives an attack, they gain 2 HP."
description_inactive= _ "survivor :
If this unit successfully survives an attack, they gain 2 HP."
[/dummy]
[/abilities]
[event]
name=attack_end
first_time_only=no
[filter]
ability=unit_survivor
[/filter]
[filter_wml]
not_living=no
[/filter_wml]
[heal_unit]
amount=2
[/heal_unit]
[unstore_unit]
variable=unit
text="2"
{COLOR_HEAL}
[/unstore_unit]
{CLEAR_VARIABLE survivor}
[/event]
[+abilities]
#enddef
I'm still learning this stuff, and the wiki is awful vague on a LOT of these things.
Re: [heal_unit]
You didn't tell the engine which unit to heal, so it decided to heal the attacker.meowreka wrote:It doesn't seem to work when the unit is defending.. only when they are attacking.
Re: [heal_unit]
Not really, you just have to learn to not guess.meowreka wrote:I'm still learning this stuff, and the wiki is awful vague on a LOT of these things.
For example, what does the wiki say you can put in an [event]? It sure doesn't say anything about a [filter_wml]: instead, it says you can put in a [filter] with a standard unit filter inside it to make the event only trigger when a unit matching that filter is associated with an event of that type.
So if you want something to happen when an attack ends, and only if the attacker matches some criteria, then you make an attack_end event and put in a [filter] which contains a standard unit filter describing your criteria. Then you just go look what can go in a standard unit filter and figure out how to write a standard unit filter which describes the criteria you want. If you start to guess whether you can put this tag or that tag somewhere, it most likely won't work.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: [heal_unit]
not_living is a key describing the form of the unit, not its status (whether it is an undead unit i think)
to check whether the unit has survived you need to look after its hitpoints
(my above code is only for defense btw, but the other version is anlogous)
@zookeeper
It is really kind of you how you teach everyone, ever and ever, that wml stuff!
to check whether the unit has survived you need to look after its hitpoints
(my above code is only for defense btw, but the other version is anlogous)
@zookeeper
It is really kind of you how you teach everyone, ever and ever, that wml stuff!
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: [heal_unit]
Well I've learned a lot more now thanks to this than anything I've read on the wiki. It doesn't explicitly state anything like this on any of the pages I read.zookeeper wrote:Not really, you just have to learn to not guess.meowreka wrote:I'm still learning this stuff, and the wiki is awful vague on a LOT of these things.
For example, what does the wiki say you can put in an [event]? It sure doesn't say anything about a [filter_wml]: instead, it says you can put in a [filter] with a standard unit filter inside it to make the event only trigger when a unit matching that filter is associated with an event of that type.
So if you want something to happen when an attack ends, and only if the attacker matches some criteria, then you make an attack_end event and put in a [filter] which contains a standard unit filter describing your criteria. Then you just go look what can go in a standard unit filter and figure out how to write a standard unit filter which describes the criteria you want. If you start to guess whether you can put this tag or that tag somewhere, it most likely won't work.
Re: [heal_unit]
You put [filter_wml] inside the [filter] tag.
I'm just... a guy...
I'm back for now, I might get started on some work again.
I'm back for now, I might get started on some work again.
- solsword
- Code Contributor
- Posts: 291
- Joined: January 12th, 2009, 10:21 pm
- Location: Santa Cruz, CA
- Contact:
Re: [heal_unit]
Well, it does say on the wiki that [filter] inside an [event] applies to the first unit. In this case, the attacker. So your event only fires if the attacker has the ability. You need a separate event with a [filter_second] tag that heals the defender (as pointed out, just saying heal_unit without a filter isn't a good idea). Frankly, I'm surprised that it didn't heal every unit on the map. Use id=$unit.id to filter for the primary unit in an event.
The Knights of the Silver Spire campaign.
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?
http://www.cs.hmc.edu/~pmawhorter - my website.
Teamcolors for everyone! PM me for a teamcolored version of your sprite, or you can do it yourself. If you just happen to like magenta, no hard feelings?