=begin #=============================================================================== Title: Target Hit Rate Into Author: Hime Date: Mar 7, 2013 -------------------------------------------------------------------------------- ** Change log Mar 7, 2013 - Initial release -------------------------------------------------------------------------------- ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Credit Tsukihime * Preserve this header -------------------------------------------------------------------------------- ** Required Enemy Target Info (http://yanflychannel.com/rmvxa/battle-scripts/ace-battle-engine/enemy-target-info/) -------------------------------------------------------------------------------- ** Description This script adds a a "hit rate" to the target info window, which is the chance to hit the selected enemy using your selected skill. Note that this cuts off the name if the name is too long. -------------------------------------------------------------------------------- ** Usage Plug and play. -------------------------------------------------------------------------------- ** Compatibility #=============================================================================== =end $imported = {} if $imported.nil? $imported["TH_TargetHitRateInfo"] = true #=============================================================================== # ** Rest of Script #=============================================================================== class Window_Comparison < Window_Base alias :th_hit_rate_info_draw_parameters :draw_parameters def draw_parameters th_hit_rate_info_draw_parameters # don't draw it for the user. return if @battler == actor dx = contents.width / 2 draw_hit_rate(dx, 0) end #----------------------------------------------------------------------------- # New #----------------------------------------------------------------------------- def draw_hit_rate(dx, dy) # draw rectangle dw = contents.width / 2 colour = Color.new(0, 0, 0, translucent_alpha/2) rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2) contents.fill_rect(rect, colour) # draw text change_color(system_color) draw_text(dx+4, dy, dw - 8, line_height, "Hit Rate") change_color(normal_color) text = "%d%%" %(get_hit_rate * 100) draw_text(dx+4, dy, dw-8, line_height, text, 2) end #----------------------------------------------------------------------------- # New #----------------------------------------------------------------------------- def get_hit_rate # chance of hitting the target hit_rate = @battler.item_hit(actor, actor.current_action.item) p hit_rate # chance of target evading evade_rate = @battler.item_eva(actor, actor.current_action.item) # Probability of not missing and probability of not evading return (hit_rate) * (1 - evade_rate) end end