class Game_Battler
attr_accessor :invoke_magic
alias mf240406ini initialize
def initialize
mf240406ini
@invoke_magic = false
end
def item_apply(user, item)
@result.clear
@result.used = item_test(user, item)
@result.missed = (@result.used && rand >= item_hit(user, item))
@result.evaded = (!@result.missed && rand < item_eva(user, item))
if @result.hit?
return $invoke_magic = true if @invoke_magic
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
end
end
class Scene_Battle
alias mf240406start start
def start
mf240406start
$invoke_magic = false
end
def invoke_item(target, item)
if rand < target.item_cnt(@subject, item)
invoke_counter_attack(target, item)
elsif rand < target.item_mrf(@subject, item)
target.invoke_magic = true
apply_item_effects(apply_substitute(target, item), item)
else
apply_item_effects(apply_substitute(target, item), item)
end
invoke_magic_reflection(target, item) if $invoke_magic
$invoke_magic = false
target.invoke_magic = false
@subject.last_target_index = target.index
end
end