STATE COUNT IN DAMAGE FORMULA

Posts

Pages: 1
Adon237
if i had an allowance, i would give it to rmn
1743
I am having an issue with a battle damage formula that involves counting the amount of a states the target has that are also found in a pre-defined array.

  
def determine_states(y)
$good_states = [1, 2, 3, 4, 5]
if y == 0 # look for good states
for $good_states.each in self.states
statecount += 1
end
elsif y == 1 # look for bad states

elsif y == 2 # look for all states
end
end

I am not formally trained in programming, so I really am just making guesses from what I've experienced over the years of using VX/VXA. This formula does not determine the damage, statecount is just appended to the actual damage formula for its effect.

Pretty much, I'm trying to increase statecount by 1 for each state in the good states array that the target has been affected by in that use. How would I (better) go about this? Thank you!

states & $good_states
should give the intersection of the two arrays, see the array documentation and just ctrl+f intersection to see the intersect operator example. Once you have the intersection you can just get its length to get the # of elements in the intersection.
Adon237
if i had an allowance, i would give it to rmn
1743
Thank you very much GRS! I got it all to work using the information you linked me to.
Pages: 1