Unit stats/attributes

The place to post your WML questions and answers.

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.
Post Reply
User avatar
Arozay
Posts: 2
Joined: July 22nd, 2020, 8:28 pm

Unit stats/attributes

Post by Arozay »

Hey everyone,

I want to implement a mechanic where each unit can have a total of six stats (STR, DEX, AGI...), which will later influence other things like unit health, damage, avoid, etc. - is there a way to have each unit have its own set of such "stats", and have them assigned on recruitment, or should it be done through traits in some way?

Thanks for your help in advance.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Unit stats/attributes

Post by WhiteWolf »

Anything that is able to apply an [effect] to units should be up for this task. This could indeed be done with a trait, or if you don't want to interfere with the existing trait system, then an [object] will do just the same.
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
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Unit stats/attributes

Post by Pilauli »

I think you can assign variables to units.

I don't have much experience with that, but you could look at the SyntaxWML page on the wiki.
https://wiki.wesnoth.org/SyntaxWML

Not sure how whether you could use those to affect stats or not, though. Probably, but it might take ugly hacky stuff.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Unit stats/attributes

Post by WhiteWolf »

Pilauli wrote: September 1st, 2020, 4:29 pm I think you can assign variables to units.
I'm not sure what you mean. You can store a unit into a variable, and every unit contains an array of its own [variables] which can store practically anything, but those won't affect the actual stats by themselves. For that you need an [effect] applied by something, could be a trait, an object, or through [modify_unit] (not directly though, an object or an effect call is still needed inside [modify_unit], except for the list of attributes that are never reset by the game).
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
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Unit stats/attributes

Post by Pilauli »

WhiteWolf wrote: September 1st, 2020, 9:29 pmevery unit contains an array of its own [variables] which can store practically anything, but those won't affect the actual stats by themselves. For that you need an [effect] applied by something [...]
That's basically what I meant.

The reason I mentioned each unit's array of [variables] (by "assign variables to units" I meant "put variables into units' arrays of variables") was that, if Arozay wants to store STR, DEX, and the rest of the values, and use them to calculate things like max movement points, max health, and damage per swing, then putting each unit's variables into its own array is probably the most organized way to do it.

If Arozay just wants to set max movement points, max health, and damage per swing to random values when a unit is recruited, then they probably just need the stuff you said.
User avatar
Arozay
Posts: 2
Joined: July 22nd, 2020, 8:28 pm

Re: Unit stats/attributes

Post by Arozay »

Thank you to you both for your accurate replies.

I'll go with Pilauli's method, as I want to put variables into arrays for further use. We'll see how it goes.
Post Reply