[VX Ace] Help with Hime's Cover condition script

Discussion in 'RGSSx Script Support' started by S.Court, Mar 3, 2018.

  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 Cover condition script and I'd like to add some cover conditions to certain character. I'd like some help to set them.

    1) This character will cover all allies who are under 20% of Max HP
    2) This character will cover allies only from physical attacks
    3) This character will have a chance to cover healthy allies, this chance will be (user's luck / 192) (That means the higher this character's luck, he'll have a bigger chance to cover healthy allies)
    4) This character won't be able to cover allies if he has the states 20 and 21

    I know this is a quite complicated condition set, but the first two are quite easy to create (I think) based in Hime's instructions in this script, I think I can replicate the first 2 conditions

    Code:
    <cover condition>
    b.hp < b.mhp / 5 && (i || i.physical?)
    </cover condition>
    Another thing is this script doesn't allow to check the target will be covering allies' stats (at least not using a - the battler that is currently executing its action conditions in this script) but this can be "easily" solved because this cover ability will only be usable by the actor with the ID 2, so I think this can be solved using p - game party tags.

    So here is it. Again, I know it's a bit complicated request, but does someone know how to fit all those conditions? Thank you
     
    #1
  2. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    BUMP
     
    #2
  3. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    800
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    No idea what that bracket part should check, but here is what it actually does:
    If the i variable (the used item/skill from what I read) is NOT nil, it automatically returns true.
    If the i variable is nil, it will try to run the physical? method on it, but because it is nil, that will either crash your game, or it will simply break your whole condition and automatically turns into a true or false depending on the rescue method used on it.

    You probably wanted to use (!i || i.physical?) there instead, which would be the correct check to make.

    Here is what I would try to use:
    Code:
    <cover condition>
    b.hp_rate < 0.2 && (!i || i.physical?)
    </cover condition>
    Your two other conditions must be performed on the battler which would be the substitute (the one covering the others).
    You can get the battler which will cover for the others with this code:
    Code:
    b.friends_unit.substitute_battler
    Knowing this, we can expand the condition...
    Code:
    <cover condition>
    sbt = b.friends_unit.substitute_battler;
    return false unless sbt;
    (!i || i.physical?) &&;
    [20,21].none? {|sid| sbt.state?(sid) } &&;
    sbt.hp_rate > 0.2 &&;
    (b.hp_rate < 0.2 || sbt.luk.to_f / 192 > rand)
    </cover condition>
    This condition should work, but as always, I did not check it myself.
    Note the ; signs at the end of every line, those are there for a reason (necessary forced line-breaks in the "code's eye"), so don't forget them.

    Your luck based cover thing is quite... interesting... I mean, why would a near death party member cover a fully healed one, for example? Wouldn't that be a bit counter-productive at the end?

    And note that if this particular cover maniac would reach 192 or higher luck, it would cover everyone without exception all the time (unless in the mentioned states, of course). I could tell that you wanted to base this chance on luck and 192, but no idea how, so I just mashed up a condition which include these, but I can't know if this is what you actually wanted or not.
     
    Last edited: Mar 7, 2018
    #3
    S.Court likes this.
  4. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    Well, according to Hime's script's instructions b should be the character you want to be covered

    Under that logic, what I'm looking is the one with the substitute flag covers his allies if they're under 20% of their Max HP and also being able to cover healthy allies if the character with the substitute flag's luck check occurs

    EDIT: Also, what does sid mean in this formula?

    EDIT 2:
    192 of Luck is a impossible stat scenary for this character (he'll hardly be able to arrive to more than 100 of Luck) so he should not be able to cover from physical attacks 100% of times
     
    Last edited: Mar 7, 2018
    #4
  5. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    800
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    That's exactly what I talked about.

    The character who will cover the others may have very low HP too, yet the way you described means that this character may cover healthy allies too if "lucky" enough regardless of his own HP (at least you didn't mention anything about this situation yet). This could result in the death of the brave (or stupid :D) knight who tried to protect a perfectly healthy ally, which I consider a counter-productive effect.

    There are 3 sides here:
    1. The currently acting battler. This will be the attacker. This is a in the formula.
    2. The targeted battler. The attacker targets this one. This is b in the formula. It's not who you want to cover, it's simply the target(s) of the attacker.
    3. The substitute battler. This one will cover the targeted battler(s). This is sbt in the final formula I wrote.
    From what I understood, you wanted that luck check on the substitute battler, and if that's true, the counter-productive effect I mentioned can indeed happen, unless you put in some other conditions to prevent the substitute battler from going suicide just because he got "lucky" to cover an ally.
    I suggest you put in some HP rate conditions for this too, so that the shining knight won't cover anyone if he's actually near death himself, or if he has less HP than the attacked battler, for example. As it stands now, you only check the HP rate of the attacked battlers, and don't care about the substitute's HP rate at all.

    The sid means a simple "state ID" in the formula. It will be the numbers from that state ID array you see at the start of that line.
    The shorter, the better, since it's just a local/inside variable which is not used outside of that specific iteration.
     
    #5
  6. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    Ohhh, I do get it now! That's true, I hadn't thought in that lol

    Would you add a check when the substitute flag character doesn't try to covery anyone if he's under 20% of HP as well, please? :)
     
    #6
  7. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    800
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    I edited the formula above and added it in.
    You can also try to use sbt.hp_rate > b.hp_rate , which would make the substitute battler cover the target only if he has more HP rate than the target (this would be based on their maximum HP), or if you want to base it on direct HP values, you can also use sbt.hp > b.hp , which would make the substitute battler cover the target only if he has more HP than the target of the attack.
     
    #7
    S.Court likes this.
  8. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    Mmm I tried this tag and this happened

    [​IMG]
     
    #8
  9. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    800
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    Try to loose the ; signs from the end where you see && .
    Now that I think about it, there is no need for a line break there (although I still don't know why it triggers that error, it should still count as a regular line break, and that shouldn't bother the code).
     
    #9
  10. S.Court

    S.Court Veteran Veteran

    Messages:
    394
    Likes Received:
    97
    Location:
    Colombia
    First Language:
    Español
    Primarily Uses:
    RMVXA
    There is something wrong with this formula. I put the character luck to 192 but the character is not covering healthy allies.

    Seeing the code, I think this is the problem

    Code:
    (!i || i.physical?)
    Why? Well, seeing the code Hime has as default in the script

    Code:
        # The global condition to check.
        Global_Condition = "
           b.hp < b.mhp / 4 && (!i || !i.certain?)
        "
    That means the character you want to be covered should be under 25% of Max HP and the attack should NOT be of the "certain hit" category

    Seeing your tag, I think it means the attack should NOT be a physical attack, and that's exactly the opposite I want, that is what maybe is causing the conflict?
     
    #10
  11. Sixth

    Sixth Veteran Veteran

    Messages:
    2,130
    Likes Received:
    800
    First Language:
    Hungarian
    Primarily Uses:
    RMVXA
    Note the exclamation marks before the i. That is the NOT sign in Ruby. I didn't use it before the physical? check.
    The formula should cover exactly what you asked for, so no idea why it isn't working for you, sorry.
     
    #11

Share This Page