Modify unit traits

Discussion and development of scenarios and campaigns for the game.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
Blymurkla
Posts: 9
Joined: December 7th, 2015, 5:01 pm

Modify unit traits

Post by Blymurkla »

Well, I know the answers somewhere there - but so far the wiki has yielded nothing. I must be tiered or blind. Might as well ask for help.

I'm creating a unit (with the [unit] tag). I want to give that unit specific traits. Well, only one trait at the moment. The other one (this a normal peasant, it should only have 2) can be randomized or non-existent - it makes no matter.

Next I want to add (or replace) a trait with as a result of an event, or more precise the command of an option. I think I should use [modify_unit] but I'm not getting it to work. Any help would be much appreciated.

Code: Select all

    # The unit as it is created
    [unit]
	type=Peasant
	side=3
	x=13
	y=17
	id=Bran
	name=Bran
	unrenamable=yes
	animate=yes
	random_traits=no
	[trait]
	id=resilient
	[/trait]
    [/unit]

       # The option which should result in a new trait
        [option]
            message= _ "There are spoils for a compentend soldier!"
            [command]
		[modify_unit]
 		[filter]
	   	 id=Bran
 		[/filter]
	    	side=1
		[trait]
		id=loyal
		[/trait]		
		[/modify_unit]
            [/command]
        [/option]

User avatar
James_The_Invisible
Posts: 520
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: Modify unit traits

Post by James_The_Invisible »

Code: Select all

[trait]
  id=something
[/trait]
does nothing (noticeable) on its own. You need to add at least attribute name for it to be shown and one or more [effect] tags for the trait to do anything. Standard traits have defined their macros for simple use. But they cannot be placed directly in [unit] tag, you need to enclose them in [modifications] tag. Like this:

Code: Select all

[unit]
...
    [modifications]
        {TRAIT_RESILIENT}
    [/modifications]
[/unit]
Complete documentation for [trait] tag can be found on here.

User avatar
WhiteWolf
Forum Regular
Posts: 617
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Modify unit traits

Post by WhiteWolf »

Hi,

What James wrote before is all that's got to do with giving a trait to a unit upon creating it.

To modify an existing unit's traits is done by the modify_unit tag, as you guessed correctly.
Here's the syntax:

Code: Select all

# Here's your command inside your option:
[command]

[modify_unit]
[filter]
    id=Bran
[/filter]
{TRAIT_LOYAL}
[/modify_unit]

[/command]
Traits are not described by id's as you think, there are macros for them which are a lot more convenient. I suggest you learn them, they really come in handy. Here's their full list: http://www.wesnoth.org/macro-reference.xhtml
Search for the word "TRAIT" in your browser, and there you'll have the complete list of ingame traits available for units.

If I were you, after I modified my unit to have the loyal trait, I would also give it the loyal crown indicator. This is done by:

Code: Select all

[modify_unit]
[filter]
id=Bran
[/filter]
overlays="misc/loyal-icon.png"
[/modify_unit]
Hope this helps!
WhiteWolf
Author of the Underness Series, consisting of V parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Standalone works: The Ravagers - now for 1.14, with new bugs!

User avatar
Blymurkla
Posts: 9
Joined: December 7th, 2015, 5:01 pm

Re: Modify unit traits

Post by Blymurkla »

Thanks! That helped.

Post Reply