Giving xp to leader for every killed 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.
Giving xp to leader for every killed unit
The following code should give xp to my leader, whenever I kill a unit, that is with any of my units. It doesn't work though, there's probably a problem with the variables or the filters.
Any tips are appreciated.
Code: Select all
[event]
name=die
[filter]
level=2,3
[/filter]
[filter_second]
side=1
[/filter_second]
[modify_unit]
[filter]
id=Henry
[/filter]
{VARIABLE_OP ($this_unit.experience) add ($unit.level)}
[/modify_unit]
[/event]
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)
Re: Giving xp to leader for every killed unit
You change at the end a variable, but… that variable is never going to have any effect, and also only exists inside the modify_unit tag, and will be cleared afterwards.
You could add a line like experience=$this_unit.experience afterwards to use it.
You can also use the Wesnoth Formula Language: experience=$($this_unit.experience+$unit.level)
In other places where one manipulates unit variables (e.g. $unit), one could use [unstore_unit] to change the actual unit afterwards.
You could add a line like experience=$this_unit.experience afterwards to use it.
You can also use the Wesnoth Formula Language: experience=$($this_unit.experience+$unit.level)
In other places where one manipulates unit variables (e.g. $unit), one could use [unstore_unit] to change the actual unit afterwards.
Try out the dark board theme.
Re: Giving xp to leader for every killed unit
I doubt you can actually use actionWML inside modify_unit, which means VARIABLE_OP does nothing.
- beetlenaut
- Developer
- Posts: 2825
- Joined: December 8th, 2007, 3:21 am
- Location: Washington State
- Contact:
Re: Giving xp to leader for every killed unit
You can use Wesnoth Formula Language, but I recommend doing it this way: store Henry, do the variable operation on stored_Henry.experience, then unstore Henry. It's very powerful technique that you should know. (Actually, this is exactly what [modify_unit] does, but that tag only handles simple cases.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide