How do I add abilities to individual units?
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.
How do I add abilities to individual units?
I'd like to create an object that gives units the 'teleport' ability. I've looked through the Wiki, the utils.cfg file, and a saved game file, but I'm still at a loss. It's worth noting that the Wiki page on the [unit] tag (for unit types) doesn't include the [abilities] tag that I see being used, only an 'abilities' key.
I know how I can change some variable of a unit defined with a key, like its hitpoints, movement, or side. But how do I change something defined in a tag?
I know how I can change some variable of a unit defined with a key, like its hitpoints, movement, or side. But how do I change something defined in a tag?
This is a young gryphon. She likes cheese. She will steal all your cheese.
Re: How do I add abilities to individual units?
You might be able to store the unit and do it manually.Ringcaat wrote:I'd like to create an object that gives units the 'teleport' ability. I've looked through the Wiki, the utils.cfg file, and a saved game file, but I'm still at a loss. It's worth noting that the Wiki page on the [unit] tag (for unit types) doesn't include the [abilities] tag that I see being used, only an 'abilities' key.
I know how I can change some variable of a unit defined with a key, like its hitpoints, movement, or side. But how do I change something defined in a tag?
1. In a normal scenario, store a Silver Mage and save the game
2. Examine the save file to find the variable of the stored unit. Note how the ability is stored.
3. Look at the Random Campaign on the 1.0 server for an example of how to add tags with keys to a stored variable (in this case he added traits instead of abilities).
4. Attempt to modify the stored-unit-tag-adding-technique you learned in step 3 to add the ability data structure you found in step 2. The result should be a series of {VARIABLE} macros that build up the tag and its keys one-by-one.
5. Apply the technique to some unit in-game. Don't forget to unstore the unit.
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
dont forget...
6. Update the wiki
(nice tip though)
6. Update the wiki

(nice tip though)
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
I used to simply store the unit, and then clone a new one, adding any tags that I needed, in your case something like:
Now this didn't work at all.
Don't really know why...
But then I tried setting a variable directly, like this:
... and it worked! The teleport ability isn't displayed, I guess you need extra WML to do that, but the unit ends up being able to teleport.
Now, if only one could specify the terrain type used for teleporting, that would be really neat!
So my guess is that the teleport tag just gets created automatically when you set a key within it as a variable.
Code: Select all
[store_unit]
variable=leader
kill=yes
[filter]
side=1
[/filter]
[/store_unit]
[unit]
description=$leader.description
type=$leader.type
x=$leader.x
y=$leader.y
side=$leader.side
canrecruit=1
[abilities]
[teleport]
any_old_key=1
[/teleport]
[/abilities]
[/unit]

But then I tried setting a variable directly, like this:
Code: Select all
[store_unit]
variable=leader
kill=yes
[filter]
side=1
[/filter]
[/store_unit]
[set_variable]
name=leader.abilities.teleport.any_old_key
value=1
[/set_variable]
[unstore_unit]
variable=leader
[/unstore_unit]
Now, if only one could specify the terrain type used for teleporting, that would be really neat!
So my guess is that the teleport tag just gets created automatically when you set a key within it as a variable.
Try some Multiplayer Scenarios / Campaigns
That is correct. As was said earlier, you can (and probably need to) build the teleport tag key by key (and in this case, all you need are the name and description keys, and even those are just so that the ability name and description are visible to the player).Rhuvaen wrote:So my guess is that the teleport tag just gets created automatically when you set a key within it as a variable.
If the ability however isn't displayed on the unit (in the right panel, etc) correctly, as someone mentioned, even when you add the right name and description keys to the [teleport] tag, then that should be considered a bug.
Well when I use those magic keys (which I had no clue aboutzookeeper wrote:If the ability however isn't displayed on the unit (in the right panel, etc) correctly, as someone mentioned, even when you add the right name and description keys to the [teleport] tag, then that should be considered a bug.

Try some Multiplayer Scenarios / Campaigns
You'd need to put in the descriptions manually 
Which also means you can put in your own description
But what I really like is the customizable 'ambush' ability... you can make a unit hide in villages (for example), instead of forests 

Which also means you can put in your own description

Code: Select all
[store_unit]
variable=teleport_store
[filter]
side=1
[/filter]
[/store_unit]
{VARIABLE teleport_store.abilities[0].teleport[0].name ( _ "teleport")}
{VARIABLE teleport_store.abilities[0].teleport[0].description ( _ "Teleport:
This unit may teleport between any two friendly villages using one of its moves.")}
[unstore_unit]
variable=teleport_store
[/unstore_unit]

i wanted to make a white mage become steadfast in a MP Quest
(see http://www.wesnoth.org/forum/viewtopic.php?t=11974).
this did not work:
i tried something like this, cause a white mage has allready a special ability:
various modification of this did not work either.
giving the mage the ability ambush seems to work.
question: is steadfast no ability?
(see http://www.wesnoth.org/forum/viewtopic.php?t=11974).
this did not work:
Code: Select all
[set_variable]
name=leader.abilities.steadfast.any_old_key
value=1
[/set_variable]
i tried something like this, cause a white mage has allready a special ability:
Code: Select all
[set_variable]
name=leader.abilities[1].steadfast[1].any_old_key
value=1
[/set_variable]
giving the mage the ability ambush seems to work.
question: is steadfast no ability?
no borders, no nation
Yes, steadfast is a variation of the resistance effect. Check out the macro in abilities.cfg:wulf wrote:i wanted to make a white mage become steadfast in a MP Quest
(see http://www.wesnoth.org/forum/viewtopic.php?t=11974).
question: is steadfast no ability?
Code: Select all
#define ABILITY_STEADFAST
[resistance]
id=steadfast
multiply=2
max_value=50
apply_to=blade,pierce,impact,fire,cold,holy
[filter_base_value]
greater_than=0
[/filter_base_value]
name= _ "steadfast"
description= _ "Steadfast:
This unit's resistances are doubled, up to a maximum of 50%, when defending. Vulnerabilities are not affected."
affect_self=yes
active_on=defense
[/resistance]
#enddef

Try some Multiplayer Scenarios / Campaigns