Attacks in units

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
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Attacks in units

Post by pyrophorus »

Hi !
In unit_type, there is an 'attacks' key which specifies how much time the unit can attack per turn.
In an actual unit, this key is unknown (i.e. modifying 'unit.attacks' fails but reading it succeed).
I'm puzzled with this. How to change attacks number of a particular unit ? Which relationship exists within attacks in unit_type and max_attacks in unit data ?

Thanks in advance,
User avatar
Dugi
Posts: 4961
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: Attacks in units

Post by Dugi »

Use max_attacks=2 or something like that in the [unit_type] tag.
Kernigh
Posts: 107
Joined: February 13th, 2007, 10:21 pm
Location: United States
Contact:

Re: Attacks in units

Post by Kernigh »

I believe that [unit_type]attacks= becomes $unit.max_attacks. Then $unit.attacks_left goes from $unit.max_attacks down to zero. This is like how [unit_type]hitpoints= becomes $unit.max_hitpoints, and how $unit.hitpoints goes from $unit.max_hitpoints down to zero.

SingleUnitWML is missing documentation for $unit.attacks_left.
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Attacks in units

Post by Elvish_Hunter »

What Kernigh says is right. In [unit_type], you can put attacks=2, or even attacks=10, if you want.
Once that you create (not if you recruit or recall it, as usual) a unit of that kind, it'll have its variables $attacks_left and $max_attacks equal to 2 (or 10, or any other value that you choose). At the start of every turn, $attacks_left will be replenished to equal $max_attacks.
Kernigh wrote:I believe that [unit_type]attacks= becomes $unit.max_attacks. Then $unit.attacks_left goes from $unit.max_attacks down to zero. This is like how [unit_type]hitpoints= becomes $unit.max_hitpoints, and how $unit.hitpoints goes from $unit.max_hitpoints down to zero.SingleUnitWML is missing documentation for $unit.attacks_left.
Fixed.
At this point, it will be nice to have EffectWML supporting an apply_to=attacks key (as well as an apply_to=halo, but that's another story), with a structure like this:
attacks: modifies the unit's number of time that it can attack per turn.

increase: maximum attacks number is increased by this amount. It can be positive, negative, or specified as a percentage.
set: maximum attacks number is set to a specific value.
What's your opinion?
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
pyrophorus
Posts: 533
Joined: December 1st, 2010, 12:54 pm

Re: Attacks in units

Post by pyrophorus »

Hi,
Thanks for your replies !
My opinion is EffectWML should have the same features as [modify_unit]. I will not say if it should be done allowing [modify_unit] inside [effect], but something of the like would be handy. For now, it is not easy to modify an unit in custom advance, except of course, what is already available in 'apply_to'.
Friendly,
Post Reply