[VX Ace] Help with Hime's conditional states script

Hello, I'm using Hime's conditional states script and I'm trying to create an attack adds a differente state depending of user's speed, the condition would be this (not sure if it's relevant, but it's a skill does damage as well):

if user's AGI/10 = to 1, it'd add the state id 11
if AGI/10 = 2, it'd add the state id 12
if AGI/10 = 3, it'd add the state id 13
if AGI/10 = 4, it'd add the state id 14
if AGI/10 = 5 or superior, it'd add the state id 15

I tried to implement it this way

Code:
<conditional state>
if (a.agi / 10) == 1
11
else
if (a.agi / 10) == 2
12
else
if (a.agi / 10) == 3
13
else
if (a.agi / 10) == 4
14
else
15
end
</conditional state>

However, when I use the attack, it's not applying any state at all, so I'm sure I'm making something wrong with this formula, could please someone help me to make a proper formula to apply those states? Thank you
A couple of things:
  1. Try adding .to_i at the end of each parentheses? E.g. (a.agi / 10).to_i. This turns the number into an integer.
  2. Do elsif rather than else then if:
Code:
<conditional state>
if (a.agi / 10).to_i == 1
11
elsif (a.agi / 10).to_i == 2
12
elsif (a.agi / 10).to_i == 3
13
elsif (a.agi / 10).to_i == 4
14
else
15
end
</conditional state>
I tested and it didn't work either, and now I checked, a. referes to target's conditions and I need it for user's condition checks, so that script won't help me at all, thanks anyways, but I'll ask for this script to be closed
An integer divided by another integer results in an integer by default, so no need to call to_i here.

I am surprised that you didn't get any crashes with that note-tag you tried, it has syntax errors (missing end lines).
Using elsif or case (I prefer case statements in these... cases 😀) is what you should do here like mentioned above.

Ohh, I should refresh the page before answering, right? 😀
But the provided code from above should work. But if it's not what you need (you want to check the user's stats, right?), no point in investigating further, I guess.
An integer divided by another integer results in an integer by default, so no need to call to_i here.

I am surprised that you didn't get any crashes with that note-tag you tried, it has syntax errors (missing end lines).
Using elsif or case (I prefer case statements in these... cases 😀) is what you should do here like mentioned above.

Ohh, I should refresh the page before answering, right? 😀
But the provided code from above should work. But if it's not what you need (you want to check the user's stats, right?), no point in investigating further, I guess.

Well, now you mention it, I'm surprised as well hahaha

But I made a mistake about this thread, I thought a refered to caster's conditions (which is what I need to check) but actually it means target's conditions, so trying to solve it this way won't help at all...
You could try Hime's Formula Effects script? http://himeworks.com/2014/02/formula-effects/
After I checked the damage formula I put as script to create a base formula, I decided to test adding some checks, with satisfactory results

Spoiler: I can't believe it actually worked!
Code:
#-------------------------------------------------------------------------------
#Conditional state magical attack (Defense check)
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class Game_Battler < Game_BattlerBase
  def state_magic(a, b, base, state_chance, state)
#---------------------------------------------------- 
#Damage Formula
#---------------------------------------------------- 
    x0 = base * 4
    dmg = x0 + ((a.level * a.mat * base) / 32)
    dmg *= ((100 - b.mdf) / 101.0)
    dmg += 1
#---------------------------------------------------- 
#Check user's AGI to increase state's ID
#---------------------------------------------------- 
    if (a.agi / 10) == 2 then state += 1 end
    if (a.agi / 10) == 3 then state += 2 end
    if (a.agi / 10) == 4 then state += 3 end
    if (a.agi / 10) >= 5 then state += 4 end
#---------------------------------------------------- 
#Adding the state (checking LUK's effect and state rate
#----------------------------------------------------
    chance = state_chance
    chance *= b.state_rate(state)
    chance *= b.luk_effect_rate(a)
    b.add_state(state) if rand(100) <= chance
    return dmg.round.to_i
  end
end

Basically I put all the necessary stats together in database as you can see in next picture, and I chose as base state id the first one (14 in this case)

Database.png
After that, I added the agility checks and I made each one increase base state id depending of the result. This formula could be optimized I guess but for now is a satisfactory result
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-help-with-himes-conditional-states-script.89977/