[Ace] Galv's Substitute Functionality Crash

First off, here's the script:

Spoiler
#------------------------------------------------------------------------------## Galv's Cover (Substitute) Functionality#------------------------------------------------------------------------------## For: RPGMAKER VX ACE# Version 1.3# Requested by Leyla#------------------------------------------------------------------------------## 2013-03-12 - Version 1.3 - added notetag to remove cover state after used# 2013-02-17 - Version 1.2 - added option to change when cover takes effect# 2013-02-17 - Version 1.1 - fixed a crash with attacking# 2013-02-15 - Version 1.0 - release#------------------------------------------------------------------------------## Some extra options for the substitute feature, allowing you to specify actors# who cannot be covered and states that can only cover certain actors. Can also# make actors/enemies unable to be covered by others.#------------------------------------------------------------------------------## Notetag STATES, ACTORS or ENEMIES with:#------------------------------------------------------------------------------### <uncoverable> # This actor/enemy can never be covered for.## <cover: x,x,x> # A state, actor or enemy with this notetag AND the# # substitute feature will only cover (substitute) for# # friendly actors/enemies with ids listed in x's.## EXAMPLE:# <cover: 3,5,12,14,29> # Only those actor ID's can be covered.## NOTE:# If an actor has the substitute feature or state with substitute feature and# does not have the <cover: x> tag on either the actor or the state then they# will be able to cover anybody without restriction. If the cover tag is on# either the actor or the state, it will use that restriction.##------------------------------------------------------------------------------## Notetag STATES ONLY with:#------------------------------------------------------------------------------### <cover_once> # When a battler has a STATE with the substitute feature# # adding this tag will mean they can only substitute once# # before the state is removed.##------------------------------------------------------------------------------##------------------------------------------------------------------------------## SCRIPT CALL:#------------------------------------------------------------------------------### $game_actors[x].uncoverable = true/false # change if actor can be covered##------------------------------------------------------------------------------# ($imported ||= {})["Galv_Sub_Functions"] = truemodule Galv_Sub #------------------------------------------------------------------------------# # SETUP OPTIONS#------------------------------------------------------------------------------# SUB_HP_PERCENT = 100 # Percent of max hp a battler has remaining before # anyone will cover them using a skill. default 25. # Make this 0 to use default (and to potentially work # with another script that modifies this). #------------------------------------------------------------------------------# # END SETUP OPTIONS#------------------------------------------------------------------------------# end class Scene_Battle < Scene_Base alias galv_cant_sub_scene_battle_apply_substitute apply_substitute def apply_substitute(target, item) target.actor? ? id = target.id : id = target.enemy_id target.friends_unit.get_sub_target(id) galv_cant_sub_scene_battle_apply_substitute(target, item) end alias galv_cant_sub_scene_battle_check_substitute check_substitute def check_substitute(target, item) return false if cannot_sub(target) if Galv_Sub::SUB_HP_PERCENT > 0 return target.hp <= target.mhp * (Galv_Sub::SUB_HP_PERCENT.to_f / 100) && (!item || !item.certain?) end galv_cant_sub_scene_battle_check_substitute(target, item) end def cannot_sub(target) return true if target.uncoverable target.states.each {|s| return true if s.uncoverable } return false endend # Scene_Battle < Scene_Base class Window_BattleLog < Window_Selectable alias galv_cant_sub_window_bl_display_substitute display_substitute def display_substitute(substitute, target) galv_cant_sub_window_bl_display_substitute(substitute, target) substitute.states.each {|s| s.features.find {|sub| return substitute.remove_state(s.id) if sub.code == 62 && sub.data_id == 2 && s.cover_once } } endend # Window_BattleLog < Window_Selectable class Game_Unit def get_sub_target(target_id) @subtarget = target_id end #------------------------------------------------------------------------------## OVERWRITE#------------------------------------------------------------------------------# def substitute_battler members.find {|member| target_only = [] member.cover.each {|id| target_only << id } member.states.each {|s| s.cover.each {|id| target_only << id} } member.substitute? if target_only.include?(@subtarget) || target_only.empty? } endend # Game_Unit class Game_Actor < Game_Battler attr_accessor :uncoverable attr_accessor :cover alias galv_cant_sub_actor_setup setup def setup(actor_id) @uncoverable = $data_actors[actor_id].uncoverable @cover = $data_actors[actor_id].cover galv_cant_sub_actor_setup(actor_id) endend # Game_Actor < Game_Battler class Game_Enemy < Game_Battler attr_accessor :uncoverable attr_accessor :cover alias galv_cant_sub_enemy_initialize initialize def initialize(index, enemy_id) galv_cant_sub_enemy_initialize(index, enemy_id) @uncoverable = $data_enemies[enemy_id].uncoverable @cover = $data_enemies[enemy_id].cover endend # Game_Enemy < Game_Battler module Galv_Substitute def uncoverable if @uncoverable.nil? if @note =~ /<uncoverable>/i @uncoverable = true else @uncoverable = false end end @uncoverable end def cover if @cover.nil? if @note =~ /<cover:[ ](.*)>/i @cover = $1.to_s.split(",").map {|i| i.to_i} else @cover = [] end end @cover endend # Galv_Substitute class RPG::Actor include Galv_Substituteendclass RPG::Enemy include Galv_Substituteendclass RPG::State include Galv_Substitute def cover_once if @cover_once.nil? if @note =~ /<cover_once>/i @cover_once = true else @cover_once = false end end @cover_once endend
This is the error I'm getting:

Spoiler
[IMG]http://i.gyazo.com/8faf550bbdf0ea9c6ab01b68a993d2c8.png[/IMG]
And finally, this is the part of the script causing problems:
Spoiler
def substitute_battler members.find {|member| target_only = [] member.cover.each {|id| target_only << id } member.states.each {|s| s.cover.each {|id| target_only << id} } member.substitute? if target_only.include?(@subtarget) || target_only.empty? } end
I am using over a dozen other scripts, however, I've opened up a fresh project and tried using this script alone, and it caused the same error.

The problem occurs when anyone with low health is attacked. Regardless of whether anyone with the substitute flag is in the party or not.

I didn't edit the script beyond the setup options, and I got it here.
Try copying it again, incase you missed a portion of the script by mistake in the process.


If it's still bringing the error then post an unencrypted, zipped project with the script


set up in to this thread, someone will likely check it out for you then.
I copied that script directly and I have no problem.

Original thread: https://forums.rpgmakerweb.com/threads/ace-galvs-substitute-functionality-crash.25147/