Skills that use other skills when they remove states

Thu, 05 Jun 2008 08:21:11 -0400 - Author:
The script below is for RPG Maker VX. It is to be used on skills that remove one or more states. If the state is removed, the skill uses another skill, perhaps to complete its effect. To use the script, add the following note to the state-removing skill: [CallSkillIfRemoved: X] where X is the ID of the skill to use. If the skill has the same target, use this note instead: [CallSkillIfRemovedSameTarget: X] where X is the ID of the skill to use.

The tag must be applied to the skill that removes the state, not to skills that add the state or to states that the skill removes. This script should be the last script in the Materials section of the script editor.

class Game_BattleAction
 attr_accessor :specificTarget
 alias :petero_callskill_make_targets :make_targets
 def make_targets
  if @specificTarget
   return @specificTarget.is_a?(Array) ? @specificTarget : [@specificTarget]
  end
  return petero_callskill_make_targets
 end
end

class Game_Battler attr_accessor :action def setSkillAction(skillID) @action=Game_BattleAction.new(self) @action.kind=1 @action.forcing=false @action.skill_id=skillID end end

class Scene_Battle alias :petero_callskill_display_action_effects :display_action_effects @@_CallSkillIfRemoved=nil def display_action_effects(target,skill=nil) if @@_CallSkillIfRemoved==nil @@_CallSkillIfRemoved={} for dataState in $data_skills next if !dataState dataState.note.gsub!(/\[CallSkillIfRemoved\:\s*(\d+)\]/i){ @@_CallSkillIfRemoved[dataState.id]=$1.to_i; next "" } dataState.note.gsub!(/\[CallSkillIfRemovedSameTarget\:\s*(\d+)\]/i){ @@_CallSkillIfRemoved[dataState.id]=-$1.to_i; next "" } end end petero_callskill_display_action_effects(target,skill) if skill && skill.is_a?(RPG::Skill) stateRemoved=false for state in skill.minus_state_set stateRemoved=true if target.removed_states.include?($data_states[state]) end if stateRemoved && @@_CallSkillIfRemoved[skill.id] sameTarget=(@@_CallSkillIfRemoved[skill.id])<0 newSkillID=@@_CallSkillIfRemoved[skill.id].abs if newSkillID!=skill.id # to prevent infinite recursion oldAction=@active_battler.action @active_battler.setSkillAction(newSkillID) if sameTarget @active_battler.action.specificTarget=[target] end execute_action_skill @active_battler.action=oldAction end end end end end