An item that increase xp
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.
An item that increase xp
Hello,
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... I saw in the wiki, that I can only modify the unit max experience not add xp.
There is a way to create this type of function???
...sorry for the bad english...
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... I saw in the wiki, that I can only modify the unit max experience not add xp.
There is a way to create this type of function???
...sorry for the bad english...
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
- Flameslash
- Posts: 633
- Joined: December 21st, 2008, 12:29 pm
Re: An item that increase xp
If it lets you edit the max experience, you could reduce it to simulate adding XP?
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: An item that increase xp
This piece of code taken from the test scenario should give you an idea about how to proceed:Since unit is automatically stored, there is no need in this case to use [store_unit]. If you want to do this for multiple units, you'll have also to iterate the variable using {FOREACH} and {NEXT}. A similar effect can be obtained by using [modify_unit] and [floating_text].
Code: Select all
[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]
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: An item that increase xp
thanks Elvish_Hunter!
And if I want that the experience will add only to one unit I need to write "first_time_only=yes"?
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?
And if I want that the experience will add only to one unit I need to write "first_time_only=yes"?
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?
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: An item that increase xp
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?
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: An item that increase xp
Ok, now I've created the macro, to recall it, but it doesn't work...
I have modified a bit the structure to recall on the macro the x y and value, but when I try to start the campaign it says that macro/file "ITEM" is missing..
This is the macro...
I tried to use this on the scenario file to recall it
Do I need to use a tag? If yes, which??
I have modified a bit the structure to recall on the macro the x y and value, but when I try to start the campaign it says that macro/file "ITEM" is missing..
This is the macro...
Code: Select all
#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
Code: Select all
{ITEM 12 6 EARN 100 XP}
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: An item that increase xp
You should write #define ITEM X Y EARN VALUE XP instead of #define ITEM_X_Y_EARN_VALUE_XP. What you wrote, that is only a long macro name with no arguments, spaces separate the macro name from its arguments. Btw, the argument EARN is not used in the macro definition.
Re: An item that increase xp
Thanks dugi! Now it works, but now there is another problem...
A unit level up only one time.
Example:
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?
I tell you that I use a custom AMLA advancement that normally works
A unit level up only one time.
Example:
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?
I tell you that I use a custom AMLA advancement that normally works
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: An item that increase xp
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.
Instead of
use this:
and define a few harmer_dummies with levels equal to the amounts of exp you want to give.
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.
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.
Instead of
Code: Select all
{VARIABLE_OP unit.experience add {VALUE}
Code: Select all
[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]
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.
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: An item that increase xp
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.
Code: Select all
[unstore_unit]
variable=unit
text="{VALUE} XP"
red,green,blue=232,232,103
advance=yes
fire_event=yes
[/unstore_unit]
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
Re: An item that increase xp
I fear it doesn't work
If it's a bug, I've tried to report it to gna.org, but I don't know how to do it... I don't see a button to add a report
If it's a bug, I've tried to report it to gna.org, but I don't know how to do it... I don't see a button to add a report
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: An item that increase xp
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.
Re: An item that increase xp
Oopsdugi 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.
Something like that?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.
Code: Select all
#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]
#enddef
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
Re: An item that increase xp
Well, it says when I place the unit on the tile:dugi wrote:Yeah, try to give it a try.
Code: Select all
<invalid WML found> [store_unit] missing required [filter] tag
DeviantArt Profile
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--
My project: Stickmen Era
Coming soon project: The Chaos Lord- a campaign with the Stickmen Era
--The measure of a man is what he does with power--