I'm working on a scenario where I want to put an item, that can give some experience points to the unit who take it.
But there is a problem...
There is a way to create this type of function???
...sorry for the bad english...
Moderators: Forum Moderators, Developers
[label]
x,y=7,10
text="Earn 100 XP!"
[/label]
[event]
name=moveto
first_time_only=no
[filter]
x=7
y=10
[/filter]
{VARIABLE_OP unit.experience add 100}
[unstore_unit]
variable=unit
text="100 XP"
red,green,blue=200,200,50
[/unstore_unit]
[/event]Dorimen wrote:thanks Elvish_Hunter!
Just delete first_time_only=no. The default behaviour is to fire events just once.Dorimen wrote:And if I want that the experience will add only to one unit I need to write "first_time_only=yes"?
Yes. You'll also need a variable to check if the item was already taken, and such a check can be performed either with an [if] [then] [else] structure, or with [filter_condition] (especially if the [else] tag is supposed to contain only [allow_undo]).Dorimen wrote:But if I place two option, to choose if you want to take it or no, I need to write "first_time_only=no", right?
#define ITEM_X_Y_EARN_VALUE_XP
[label]
x,y={X},{Y}
text="Earn {VALUE} XP!"
[/label]
[event]
name=moveto
first_time_only=no
[filter]
x={X}
y={Y}
[/filter]
{VARIABLE_OP unit.experience add {VALUE}}
[unstore_unit]
variable=unit
text="{VALUE} XP"
red,green,blue=232,232,103
[/unstore_unit]
[/event]
#enddef {ITEM 12 6 EARN 100 XP}{VARIABLE_OP unit.experience add {VALUE}[unit]
type=harmer_dummy_60
id=exp_harmer
x,y={X},{Y}
side=1
[unit]
[harm_unit]
[filter]
x,y={X},{Y}
[/filter]
[filter_second]
id=exp_harmer
[/filter_second]
amount=0
experience=yes
animate=no
fire_event=no
[/harm_unit]
[kill]
id=exp_harmer
fire_event=no
animate=no
[/kill]
Dorimen wrote:A unit can level up with 20 xp, after taken the item he level up one time and have 80/25 xp...How can I solve this problem?
No need for a workaround. That clashes with what's written on the wiki at http://wiki.wesnoth.org/DirectActionsWM ... re_unit.5D :dugi wrote:If you modify a unit's exp or hp to weird values, they will remain like that until they enter combat. If you set a unit's hp to -20, it will not cause it to die. If you set an unit's exp to 999, it will not level-up. When you enter a combat, these things will be calculated.In your case, it is quite a problem, because there is no real way to make it level-up, especially if you have a specific advancement.Well, there might be a way, but I don't know about any.I suggest you to make a workaround.
This means that modifying the [unstore_unit] tag like this should work, and if it doesn't then it's a bug and should be reported:[unstore_unit]
...
advance: (default=true) if true the unit is advanced if it has enough XP. When modifying XP make sure to do it from inside a synchronized event or it may lead to OOS errors especially when several advancement paths exist. Note that advance and post advance events are called, so infinite loops can happen.
fire_event: (boolean yes|no, default no) Whether any advance/post advance events shall be fired if an advancement takes place, no effect otherwise.
[unstore_unit]
variable=unit
text="{VALUE} XP"
red,green,blue=232,232,103
advance=yes
fire_event=yes
[/unstore_unit]
dugi wrote:Btw, the map you have on DeviantArt has an error, the mountains at the north are named 'Mistery Mountains' instead of 'Mystery Mountains', and I don't think it was intended to be related to a mist of some kind.
dugi wrote:Well, maybe I was not right with my previous statement, all I remember is that this kind of thing could cause some maximum stat violations. If he encountered a bug, he apparently needs a workaround. But a workaround storing and unstoring him twice after unstoring him the first time should be an easier way.
#define ITEM X Y VALUE XP
[label]
x,y={X},{Y}
text="Earn {VALUE} XP!"
[/label]
[event]
name=moveto
first_time_only=no
[filter]
x={X}
y={Y}
[/filter]
{VARIABLE_OP unit.experience add {VALUE}}
[unstore_unit]
variable=unit
text="{VALUE} XP"
red,green,blue=232,232,103
advance=yes
fire_event=yes
[/unstore_unit]
[store_unit]
variable=unit
advances=yes
fire_event=yes
[/store_unit]
[unstore_unit]
variable=unit
advances=yes
fire_event=yes
[/unstore_unit]
[store_unit]
variable=unit
advances=yes
fire_event=yes
[/store_unit]
[unstore_unit]
variable=unit
advances=yes
fire_event=yes
[/unstore_unit]
[/event]
#enddefdugi wrote:Yeah, try to give it a try.
<invalid WML found> [store_unit] missing required [filter] tagUsers browsing this forum: No registered users and 2 guests