Another bug fix for Multi-Hit (replace Scene_Battle within the script):
class Scene_Battle
def rand_hits(value)
return value if value.is_a?(Integer)
return (rand(value.max - value.min + 1) + value.min)
end
def repeating_action?
return (@repeat[1] - @repeat[0] > 0)
end
alias update_phase4_step1_multi_hit_later update_phase4_step1
def update_phase4_step1(battler = nil)
if battler != nil
update_phase4_step1_multi_hit_later(battler)
return
end
update_phase4_step1_multi_hit_later
@repeat = [1, 1, 0]
return if @active_battler == nil || !$game_system.MULTI_HIT
if @active_battler.current_action.kind == 0
if @active_battler.current_action.basic == 0
if @active_battler.is_a?(Game_Actor)
hits = rand_hits(BlizzCFG.weapon_hits(@active_battler.weapon_id))
elsif @active_battler.is_a?(Game_Enemy)
hits = rand_hits(BlizzCFG.enemy_hits(@active_battler.id))
end
@repeat = [hits, hits, 2]
end
elsif @active_battler.current_action.kind == 1
@repeat[2] = 3
elsif @active_battler.current_action.kind == 2
@repeat[2] = 4
end
end
alias update_phase4_step2_multi_hit_later update_phase4_step2
def update_phase4_step2(battler = nil)
if battler != nil
update_phase4_step2_multi_hit_later(battler)
return
end
update_phase4_step2_multi_hit_later
return if !$game_system.MULTI_HIT
if @phase4_step != 1
if @repeat[2] == 3
hits = rand_hits(BlizzCFG.skill_hits(@skill.id))
@repeat = [hits, hits, 5]
elsif @repeat[2] == 4
hits = rand_hits(BlizzCFG.item_hits(@item.id))
@repeat = [hits, hits, 5]
end
end
if repeating_action?
unless BlizzCFG::SHOW_ANIMATION_PER_HIT
@animation1_id = 0
@animation2_id = 0
end
@help_window.visible = false
end
end
alias update_phase4_step3_multi_hit_later update_phase4_step3
def update_phase4_step3
update_phase4_step3_multi_hit_later
@active_battler.white_flash = false if repeating_action?
end
alias update_phase4_step4_multi_hit_later update_phase4_step4
def update_phase4_step4
update_phase4_step4_multi_hit_later
@wait_count = 0 if repeating_action? && !BlizzCFG::SHOW_ANIMATION_PER_HIT
end
alias update_phase4_step5_multi_hit_later update_phase4_step5
def update_phase4_step5(battler = nil)
if battler != nil
update_phase4_step5_multi_hit_later(battler)
return
end
update_phase4_step5_multi_hit_later
return if !$game_system.MULTI_HIT
if @active_battler.current_action.kind == 1
if BlizzCFG::SKILL_RANDOM.include?(@skill.id)
if @active_battler.is_a?(Game_Actor)
@active_battler.current_action.decide_random_target_for_actor
elsif @active_battler.is_a?(Game_Enemy)
@active_battler.current_action.decide_random_target_for_enemy
end
else
if @active_battler.is_a?(Game_Actor)
@active_battler.current_action.decide_last_target_for_actor
elsif @active_battler.is_a?(Game_Enemy)
@active_battler.current_action.decide_last_target_for_enemy
end
end
elsif @active_battler.current_action.kind == 2
if BlizzCFG::ITEM_RANDOM.include?(@item.id)
if @active_battler.is_a?(Game_Actor)
@active_battler.current_action.decide_random_target_for_actor
elsif @active_battler.is_a?(Game_Enemy)
@active_battler.current_action.decide_random_target_for_enemy
end
else
if @active_battler.is_a?(Game_Actor)
@active_battler.current_action.decide_last_target_for_actor
elsif @active_battler.is_a?(Game_Enemy)
@active_battler.current_action.decide_last_target_for_enemy
end
end
elsif @active_battler.is_a?(Game_Actor)
if BlizzCFG::WEAPON_RANDOM.include?(@active_battler.weapon_id)
@active_battler.current_action.decide_random_target_for_actor
else
@active_battler.current_action.decide_last_target_for_actor
end
elsif @active_battler.is_a?(Game_Enemy)
if BlizzCFG::ENEMY_RANDOM.include?(@active_battler.id)
@active_battler.current_action.decide_random_target_for_enemy
else
@active_battler.current_action.decide_last_target_for_enemy
end
end
@phase4_step = 2 if @repeat[0] > 1 && @repeat[2] > 0
@repeat[0] -= 1
end
alias make_skill_action_result_multi_hit_later make_skill_action_result
def make_skill_action_result(battler = nil, plus_id = nil)
if battler != nil
if plus_id != nil
make_skill_action_result_multi_hit_later(battler, plus_id)
else
make_skill_action_result_multi_hit_later(battler)
end
return
end
if @repeat[2] == 5
sp_cost = @skill.sp_cost
if $game_system.SP_COST_MOD
sp_cost = BlizzCFG.get_cost_mod(@active_battler.states, sp_cost)
end
@active_battler.sp += sp_cost
@status_window.refresh
end
make_skill_action_result_multi_hit_later
end
alias make_item_action_result_multi_hit_later make_item_action_result
def make_item_action_result
if @repeat[2] == 5
$game_party.gain_item(@item.id, 1)
@status_window.refresh
end
make_item_action_result_multi_hit_later
end
# Compatibility fix for LockeZ Sacrifice HP
if method_defined?(:sacrifice_hp)
alias sacrifice_hp_if_not_repeating sacrifice_hp
def sacrifice_hp(battler, action)
sacrifice_hp_if_not_repeating(battler, action) unless @repeat[2] == 5
end
end
end
It addresses MP cost issues and consuming items multiple times.
Original thread:
https://forums.rpgmakerweb.com/index.php?threads/xp-tons-of-add-ons-multi-hit-bug.171550/