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

Discussion in 'RGSSx Script Support' started by S.Court, Jan 16, 2018.

Thread Status:
Not open for further replies.
  1. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #1
  2. A-Moonless-Night

    A-Moonless-Night WINTER IS COMING Veteran

    Messages:
    509
    Likes Received:
    364
    Location:
    New Zealand
    First Language:
    English
    Primarily Uses:
    RMVXA
    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>
     
    #2
    S.Court likes this.
  3. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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
     
    #3
  4. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    800
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    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 :D) is what you should do here like mentioned above.

    Ohh, I should refresh the page before answering, right? :D
    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.
     
    #4
  5. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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...
     
    #5
  6. A-Moonless-Night

    A-Moonless-Night WINTER IS COMING Veteran

    Messages:
    509
    Likes Received:
    364
    Location:
    New Zealand
    First Language:
    English
    Primarily Uses:
    RMVXA
    #6
  7. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    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

    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
     
    #7
  8. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,976
    Likes Received:
    10,676
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #8
Thread Status:
Not open for further replies.

Share This Page