Multiple Attacks

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
Wecth
Posts: 13
Joined: April 14th, 2023, 9:07 am

Multiple Attacks

Post by Wecth »

So I need help for a particular issue. Lets say a unit has two types of attacks: Attack A and Attack B. The unit has an attacks attribute of 3. I want the unit to attack with Attack A twice and Attack B once. Can I make it so that the unit cannot attack using Attack A more than twice and Attack B more than once?
User avatar
beetlenaut
Developer
Posts: 2814
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Multiple Attacks

Post by beetlenaut »

There is more than one way to do this, but this is probably what I would do:

Store a variable in the unit that records the number of attacks available for each weapon. You will want to do that in a unit_placed event so it happens when the unit is recruited, spawned, leveled into, or inserted with a debug command. In an attack_end event, subtract one from the variable that corresponds to the weapon that was just used. (It is automatically stored in the $weapon variable.) If the unit variable has dropped to zero, use modify_unit to remove that attack from the unit. Use a turn_end or turn_refresh event to reset the variables and attacks for all of those units. Which event to use depends on when you want the attacks to be reset. You can place these events in the unit_type tag so that they are automatically added to the scenario whenever this unit is being used.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply