CODE
#--------------------------------------------------------------------------
# * Calculate Critical Rate of Skill/Item
#--------------------------------------------------------------------------
def item_cri(user, item)
item.damage.critical ? user.luk.to_f / (self.luk+ user.luk).to_f : 0
end
The code will generate a random number between 0 - 1, and if the number returned by item_cri is greater than that random number, then the item will be a critical.
What I've done is taken the percentage of the item user's luck compared to the defender's luck.
So if the user's luck is double the defender's luck, you have double the chance of getting a critical (compared to the chance of not getting a critical)
Keep in mind the item has to be able to do critical damage, otherwise it's kinda pointless...
Technically you're supposed to use the
luk_effect_rate function when using the luck variable, but it didn't seem appropriate for this... I'll let you play around with it