Add level to 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.
Add level to unit
Ive been wondering this for a while now and if it is possible it would make my scenario 1000000x more interesting. Is it possible to add a level to a unit that advances.? i see that you have the option to manualy add a level or more to a unit using the debug command but i actually want to make a event that increases the level of a unit.
EX:
mage steps on this tile, mage is now level 2
EX:
mage steps on this tile, mage is now level 2
Re: Add level to unit
Do you mean level up to custom unit, increase unit.level or level unit to existing unit/amla?
1. part of your post shows that only number needs to change, but I think debug command changes unit type as well.
Why not use {ADVANCE_UNIT}? For most likely thing you requested that works.
1. part of your post shows that only number needs to change, but I think debug command changes unit type as well.
Why not use {ADVANCE_UNIT}? For most likely thing you requested that works.
Re: Add level to unit
Ravana wrote:Do you mean level up to custom unit, increase unit.level or level unit to existing unit/amla?
1. part of your post shows that only number needs to change, but I think debug command changes unit type as well.
Why not use {ADVANCE_UNIT}? For most likely thing you requested that works.
something like this
apply to= unit level
add=1
without it advancing
Re: Add level to unit
Code: Select all
[store_unit]
[filter]
#yours
[/filter]
variable=to_adv
[/store_unit]
{FOREACH to_adv i}
{VARIABLE_OP to_adv[$i].level add 1}
{NEXT i}
[unstore_unit]
find_vacant=no
variable=to_adv
[/unstore_unit]
{CLEAR_VARIABLE to_adv}
Re: Add level to unit
Ravana wrote:Written in forum so untested and without indentation.Code: Select all
[store_unit] [filter] #yours [/filter] variable=to_adv [/store_unit] {FOREACH to_adv i} {VARIABLE_OP to_adv[$i].level add 1} {NEXT i} [unstore_unit] find_vacant=no variable=to_adv [/unstore_unit] {CLEAR_VARIABLE to_adv}
Wow it worked thanx a lot.! and also thanks on your timely response.
Re: Add level to unit
The store- /unstore mechanism is obsolete, use modify_unit instead.
Code: Select all
[modify_unit]
[filter]
id=$unit.id # whatever
[/filter]
level="$($this_unit.level+1)"
[/modify_unit]
Re: Add level to unit
http://wiki.wesnoth.org/InternalActions ... re_unit.5D does not say that this is obsolete.trewe wrote:The store- /unstore mechanism is obsolete, use modify_unit instead.
Code: Select all
[modify_unit] [filter] id=$unit.id # whatever [/filter] level="$($this_unit.level+1)" [/modify_unit]
I avoid [modify_unit] because http://wiki.wesnoth.org/DirectActionsWM ... fy_unit.5D
With variables I can clearly see what happens.note: The syntax allowed is somehow vague. Just try things and possibly correct/add/modify this documentation. (a forum thread discusses some related issues).
Re: Add level to unit
From my experience unstore_unit is not very multiplayer friendly (especially there). Although modify_unit internally just fires store/unstore too, it usually gives fewer problems. And it is faster.
For the syntax, it allows every attribute as [unit], except variation, without problems. type= should be avoided though since it can leave to unwanted results (use transform_unit to change an unit type).
For the syntax, it allows every attribute as [unit], except variation, without problems. type= should be avoided though since it can leave to unwanted results (use transform_unit to change an unit type).
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Add level to unit
Why do you think this ? Sorry, it's nonsense.trewe wrote:The store- /unstore mechanism is obsolete, use modify_unit instead.
Due to the way it is implemented I couldn't give a better description. The allowed syntax depends on a huge number of allowed or disallowed syntaxes of the C++ engine.Ravana wrote: I avoid [modify_unit] because http://wiki.wesnoth.org/DirectActionsWM ... fy_unit.5Dnote: The syntax allowed is somehow vague. Just try things and possibly correct/add/modify this documentation. (a forum thread discusses some related issues).
I doubt that.trewe wrote:And it is faster.
All it is is sort of a wrapper and syntactic sugar or syntax simplifying interface to functionalities which exist anyway. I think it was added in order to create a challenging test case for our lua interface. In case there are automatically stored variables ($unit etc) it's better to use direct variable modification.
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: Add level to unit
When I tried to use store and unstore_unit swap the position of two units at the start of combat to replace one with the other, the combat ended. modify_unit works for me.Anonymissimus wrote:I doubt that.
All it is is sort of a wrapper and syntactic sugar or syntax simplifying interface to functionalities which exist anyway. I think it was added in order to create a challenging test case for our lua interface. In case there are automatically stored variables ($unit etc) it's better to use direct variable modification.
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.
Re: Add level to unit
You probably did something wrong. [modify_unit] is implemented using [store_unit], [kill], and [unstore_unit] internally.A Guy wrote:When I tried to use store and unstore_unit swap the position of two units at the start of combat to replace one with the other, the combat ended. modify_unit works for me.
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm.
Re: Add level to unit
I tried storing both units and unstoring them on top of each other. They swapped places, but the combat ended before anyone attacked.shadowmaster wrote:You probably did something wrong. [modify_unit] is implemented using [store_unit], [kill], and [unstore_unit] internally.A Guy wrote:When I tried to use store and unstore_unit swap the position of two units at the start of combat to replace one with the other, the combat ended. modify_unit works for me.
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.
Re: Add level to unit
Sounds like you didnt have find_vacant=no for [unstore_unit].A Guy wrote: I tried storing both units and unstoring them on top of each other. They swapped places, but the combat ended before anyone attacked.
That is assuming you left units alive when storing them.Didnt notice you said start of combat before.
However topic seems to have changed from unit levels to [store_unit] vs [modify_unit] , you might want to create new thread for that.
Last edited by Ravana on July 10th, 2013, 8:30 pm, edited 1 time in total.
Re: Add level to unit
With obsolete I mean the archaic store - set variable - unstore, when all what one wants to do is some ad-hoc changes to an unit. Obviously, unstore does not dissapear completly, LikeAnonymissimus wrote:Why do you think this ? Sorry, it's nonsense.trewe wrote:The store- /unstore mechanism is obsolete, use modify_unit instead.
when one of the above functions is not required. One has to deliberately choose which serves the purpose better.Anonymissimus wrote:In case there are automatically stored variables ($unit etc) it's better to use direct variable modification.
Well, the results are not exactly the same. As it is now it mostly only simplifies the syntax (with some side effects).Anonymissimus wrote:All it is is sort of a wrapper and syntactic sugar or syntax simplifying interface to functionalities which exist anyway. I think it was added in order to create a challenging test case for our lua interface.
That is expected. How exactly does modify_unit help there?A Guy wrote:I tried storing both units and unstoring them on top of each other. They swapped places, but the combat ended before anyone attacked.
Re: Add level to unit
modify_unit let me change both units to a copy of the other without interrupting combat.trewe wrote:That is expected. How exactly does modify_unit help there?A Guy wrote:I tried storing both units and unstoring them on top of each other. They swapped places, but the combat ended before anyone attacked.
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.