I want to implement something akin to Pillars of Eternity's hit formula. Random number 1-100, add a hit parameter, then subtract an evasion parameter. Final result determines whether the attack misses, does half damage, full damage, or crit damage based on thresholds. How would I do this?
Custom accuracy formula
RGSS3 Script RequestsYou'll need a script to do this
I've moved this thread to Script Request. Please be sure to post your threads in the correct forum next time. Thank you.
I've moved this thread to Script Request. Please be sure to post your threads in the correct forum next time. Thank you.
Can you give more detailed info?
Numbers, how it should work etc.?
Numbers, how it should work etc.?
Mostly I want to see where the game does these calculations so I can get better at scripting myself. Right now, I suppose, I want physical accuracy to be (character accuracy + weapon accuracy + ATK + AGI + LUK), magical accuracy to be (character accuracy + spell accuracy + MAG + AGI + LUK), physical evasion to be (character evasion + equipment physical evasion + (AGI * 2) + LUK) and then magical evasion to be (character evasion + equipment magical evasion + (MDEF * 2) + LUK). Then, (random number + attacker's hit - defender's evasion) for hit calculation. If the result is less than 16, miss; more than 15 but less than 51, graze (attack deals half damage); more than 50 but less than 86, hit, and more than 85, crit (damage * 1.5).
Eventually I also want to fiddle with status ailment infliction, but I'm not sure how at this point.
Eventually I also want to fiddle with status ailment infliction, but I'm not sure how at this point.
So yeah, Andar is right, you definitely need a script for that.
And I'm afraid I cannot help you at this point.
Extra Param Formulas in this script you would be able to determine how accuracy is calculated. (as well as other parameters like evasion etc.)
Then trying to setup that somehow in damage formula... To be honest I don't know.
I think somebody else will help you better than me.
Sorry.
And I'm afraid I cannot help you at this point.
Extra Param Formulas in this script you would be able to determine how accuracy is calculated. (as well as other parameters like evasion etc.)
Then trying to setup that somehow in damage formula... To be honest I don't know.
I think somebody else will help you better than me.
Sorry.
Well, it looks like setting the Graze and Crit multipliers is fairly easy, just creating an apply_graze method with syntax similar to the existing apply_critical method in Game_Battler, and it looks like modifying item_apply could let me do the main hit calculation.
Still, I'm unsure how to set that up as a script to plug and play.
Still, I'm unsure how to set that up as a script to plug and play.
You'll have to tweak the Game_Battler item_apply def to implement something like that. However, the system initially determines if you hit, then it determines if you evade. I was able to overwrite it in my game to make it so that you hit provided (random number) is > (item's to hit - target's evade), and the random number was between 0 and 1. Since to hit and evade are in decimals that are between 0 and 1, you will want your random number to be a decimal between 0 and 1 instead (easily done by the rand command).
Just one additional info about this:
The default engine doesn't calculate HIT - it's calculating MISS. If you do not keep that in mind, your formulae will call the functions at the wrong numbers (unless you rewrite the entire battlesequence).
The default engine doesn't calculate HIT - it's calculating MISS. If you do not keep that in mind, your formulae will call the functions at the wrong numbers (unless you rewrite the entire battlesequence).
Andar is correct on that. I had to set it so that it missed when the random number was above the number for hit - evade in my game. Also, unless you overwrite it, it will also calculate a 2nd time to see if you evade an attack, so you will need to be sure to disable that calculation.
Hrmm, every time I think I get this right I go further down the rabbit hole. Right now I'm trying to figure out how to guarantee healing spells work right (that is, they don't miss).
Flag healing spells as certain hit. When you do that, as far as I know the engine doesn't do a hit/miss calculation (unless you add it in).
Original thread: https://forums.rpgmakerweb.com/threads/custom-accuracy-formula.42719/