maximum attack index
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.
-
- Posts: 19
- Joined: June 22nd, 2022, 8:57 pm
maximum attack index
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.
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.
- Celtic_Minstrel
- Developer
- Posts: 2214
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: maximum attack index
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)"
.