maximum attack index

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
CookieLord
Posts: 19
Joined: June 22nd, 2022, 8:57 pm

maximum attack index

Post by CookieLord »

How can you figure out the highest attack index of a given unit?

I want to modify a random weapon of a unit and was going to us a {VARIABLE_OP rand_index rand(0..[highest index])}, but cant figure out how to find that value.
User avatar
Celtic_Minstrel
Developer
Posts: 2166
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: maximum attack index

Post by Celtic_Minstrel »

If you have the unit in a variable, then $unit.attack.length is the number of weapons it possesses. So the highest index would be "$($unit.attack.length - 1)".
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
CookieLord
Posts: 19
Joined: June 22nd, 2022, 8:57 pm

Re: maximum attack index

Post by CookieLord »

thanks
Post Reply