Thanks, but this isn't actually what I wanted... That's for if I want Accuracy and Evasion to increase on level up. I don't. What I DO want is to change how the chance-to-hit is determined. If Accuracy and Evasion must be a percentage, then it'd be something like this
chance to hit = (100%-b.evasion+a.accuracy), then have it be a minimum of 5% and a maximum of 95%
rather than the default which is (something like)
chance to hit = a.accuracy*(100%-b.evasion)
Hit or miss is calculated in the item_apply method of Game_Battler, specifically the line that starts with "@result.missed =". By default, it gets the value of the skill to hit out of 100 (as a decimal), then compares this to a random of 0 up to but not including one to determine if it hits (if the random value is greater, the attack missed). You just need to replace this calculation with the one you have described.
Basically, what you would need to do is just rand(20), if the result is 0 or 19, skip all further calculation and set @result.missed appropriately, otherwise, return the skill's chance to hit instead as an integer, then add that value to your previous random and compare to target's evasion to determine if it is missed. Since you are incorporating evasion into your to-hit formula, @result.evaded should always be false (the default state after being cleared) so we won't do any calculation for this.
I'll go ahead and elaborate on this, but in the future, if you need in-depth instruction on how to set something up, it is probably best to make a separate thread.
End result, you'd end up with something like this:
Code:
class Game_Battler def item_hit(user, item) to_hit = item.success_rate - 50 # Get success rate adjustment of item as base to_hit, adjust by -50 to allow positive and negative adjustments to to_hit based on skill real_hit = user.hit * 100 # get user's real hit rate scaled to while numbers to_hit += real_hit if item.physical? # add user's to hit adjustment if physical attack return to_hit # Return calculated to_hit adjustment end def item_eva(user, item) return eva * 100 if item.physical? # Return evasion if physical attack (as whole num) return mev * 100 if item.magical? # Return magic evasion if magic attack (as whole num) return 0 # if not physical or magical end def item_apply(user, item) @result.clear @result.used = item_test(user, item) # this is the part of the formula we are altering from the norm v = rand(20) + 1 # your 'roll' of 1-20 if v == 1 @result.missed = true # fumble elsif v == 20 @result.missed = false # auto-hit else # values 2-18 @result.missed = item_eva(user, item) >= item_hit(user, item) + v # miss if evasion of target is greater than or equal to hit of user plus roll end # end part of the formula we are altering from the norm if @result.hit? unless item.damage.none? @result.critical = (rand < item_cri(user, item)) make_damage_value(user, item) execute_damage(user) end item.effects.each {|effect| item_effect_apply(user, item, effect) } item_user_effect(user, item) end endend
Note that the above would make the "success rate" field of your items/skills into a "to hit adjustment" with the zero point at 50 (eg., 50 is +0, 51 is +1, 49 is -1) which would also accomplish your other goal of having hit adjustments for skills. Since the field is restricted from 0 to 100, this was the easiest way to get it done, just remember you have to change skills success rate values to 50 (as well as remove all default +hit% bonuses, including from classes and enemies) or the system falls apart right away (each 1% difference in hit is calculated as 1 accuracy for the purposes of the formula, and since both negative and positive inputs are allowed for hit% adjustments, zero is actually zero for this).