change unit statistics at the beginning of a scenario
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.
change unit statistics at the beginning of a scenario
I am beginning to develop my first test campaign, although I know programming, I get lost sometimes in the examples by the theme of the different versions of Wesnoth ...
Bluntly, I need to change some statistics of my initial units, including the leader. step fragment of my code, thank you very much
In this case I managed to place the loyal trait in modification but when I wanted to assign to 8 the movements of this unit and that of the leader, it does not allow me
Bluntly, I need to change some statistics of my initial units, including the leader. step fragment of my code, thank you very much
In this case I managed to place the loyal trait in modification but when I wanted to assign to 8 the movements of this unit and that of the leader, it does not allow me
Code: Select all
[side]
side=1
controller=human
team_name="good"
user_team_name= _ "My Team"
id=MyLeader
name= _ "My Leader's Name"
type="Elvish Ranger"
unrenameable=yes
movement=8
canrecruit=yes
recruit="Elvish Fighter, Elvish Archer, Elvish Shaman,Lancero Orco"
gold=100
{NAMED_LOYAL_UNIT 1 (Wolf) 2 20 (Blacky) (_ "Blacky")}
[unit]
type="Lancero Orco"
side=1
x,y=4,21
name="Chiporchi"
canrecruit=yes
[modifications]
movement=8
{TRAIT_LOYAL}
[/modifications]
overlays="misc/loyal-icon.png"
[/unit]
- Pentarctagon
- Project Manager
- Posts: 5565
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: change unit statistics at the beginning of a scenario
Moved to the WML Workshop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
Re: change unit statistics at the beginning of a scenario
[modifications]
has a little bit different meaning, it's not where you can "modify" a unit, it's the group where [traits], [objects], and possibly some other stuff I don't recall, go to. For example the {TRAIT_LOYAL} is correctly there. However, please note that canrecruit=yes
in a unit will automatically assume 0 upkeep, so the loyal trait on Chiporchi won't have any actual effect, it'll just be there.Similarly,
movement
is not an accepted key inside [side] or [unit] to set a unit current moves, see the unit wiki.The way you can modify an initial unit's moves is to actualy modify the unit. One way to go is the
[modify_unit]
tag.
Code: Select all
[event]
name=start # or wherever you want it done
[modify_unit]
[filter]
id=MyLeader
[/filter]
max_moves=8 # it's important to set the maximumum moves to 8, otherwise it would just reset on the next turn.
moves=8
[/modify_unit]
[/event]
Code: Select all
[side]
... your side stuff, leader stuff
id=MyLeader
[modifications]
[object]
id=leader_has_8_mp
[effect]
apply_to=movement # this means max moves here
set=8
[/effect]
[/object]
[/modifications]
{NAMED_LOYAL_UNIT 1 (Wolf) 2 20 (Blacky) (_ "Blacky")}
[unit]
# tip: you might want to give this unit an id if he's important
type="Lancero Orco"
side=1
x,y=4,21
name="Chiporchi"
canrecruit=yes #*
[modifications]
[object]
id=this_unit_has_8_mp
[effect]
apply_to=movement # this means max moves here
set=8
[/effect]
[/object]
#{TRAIT_LOYAL} as said, this is unecessary because of previous canrecruit=yes
[/modifications]
overlays="misc/loyal-icon.png" # tip: check out the {IS_LOYAL} macro
[/unit]
[/side]
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: change unit statistics at the beginning of a scenario
thank you very much, the second code worked for me, the first one on the other hand didn't work
- Celtic_Minstrel
- Developer
- Posts: 2222
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: change unit statistics at the beginning of a scenario
The only actual issue with your initial code is that
movement=8
was placed inside the [modifications]
tag. Move it up one line and your original code should be fine. There's no need to use [modify_unit]
here. That said, Whitewolf is correct that the change could be lost on level-up, so use of an [object]
is preferable. But, note that that would force the unit to always have 8 MP, even if it would have otherwise gained more MP from a level-up. If that's a problem (obviously not in the Elvish Range case, but I have no clue about the other), you can add a [filter]
tag in the [effect]
tag that limits the effect to level 2 units.