Item Hit Ratio Addition
By BigEd781
I did this as a request, so I thought i would share. This script allows you to give consumable items like potions and scrolls a hit ratio attribute. For example, you could create an item that revives a character, but is only effective 50% of the time.
Configuration / UseTo give an item a hit ratio, you will add a line to the "Notes" field of that item. It should look like this:
CODE
[hit ratio]50
Spaces and case are ignored. The "[hit ratio]" tag tells the script that this item has a specified hit ratio value, and "50" is the value. A value of 50 would mean that the item is successful 50% of the time. 25 would mean it was successful 25% of the time, 100 would mean 100% (which is the default) and so on. Here is an image:

ScriptCODE
module RPG
class Item
def get_consumable_hit_ratio
ratio = 100
self.note.each { |line|
line.downcase!
line.gsub!(' ', '')
ratio = line.gsub("[hitratio]", '') if line.include?("[hitratio]") }
return ratio.to_i
end
end
end
class Game_Battler
#--------------------------------------------------------------------------
# * Apply Item Effects
# user : Item user
# item : item
#--------------------------------------------------------------------------
alias :eds_old_pre_hit_ratio_item_effect :item_effect
def item_effect(user, item)
if item_effective?(user, item) && item.is_a?(RPG::Item)
clear_action_results
ratio = item.get_consumable_hit_ratio
if rand(100) >= ratio
@missed = true
return
end
end
eds_old_pre_hit_ratio_item_effect(user, item)
end
end
Compatibility / IssuesShould be fine as far as compatibility is concerned, let me know of any bugs.