#============================================================================== # ■ RGSS2 変数条件&変数変動アイテム・スキル Ver2.00 by 星潟 #------------------------------------------------------------------------------ # 変数が一定値以上もしくは一定値以下でなければ # 使用できないアイテム・スキルの作成を可能にします。 # # また、使用後に変数を増減させる効果を持たせる事もできます。 # # 以下、記入例です。(全て、アイテム・スキルのメモ欄に記述) # <変数指定以上:2,5> # 変数2が5以上の場合に使用可能。 # # <変数指定以下:4,2> # 変数4が2以下の場合に使用可能。 # # <変数増減:1,3> # アイテム・スキル使用後に変数1を3増やす。 # # <変数増減:3,-3,0> # アイテム・スキル使用後に変数3を3減らす。 # ただし、0以下になった場合は0にする。 # # <変数増減:5,-2,3> # アイテム・スキル使用後に変数5を2減らす。 # ただし、3以下になった場合は3にする。 #============================================================================== # Ver2.00 正常に動作しない不具合を修正し、処理を効率化しました。 #============================================================================== module VAR_SKILL T_V = "変数指定以上" B_V = "変数指定以下" C_V = "変数増減" end class Scene_Skill < Scene_Base alias use_skill_nontarget_variable use_skill_nontarget def use_skill_nontarget use_skill_nontarget_variable @skill.v_cost end end class Scene_Item < Scene_Base alias use_item_nontarget_variable use_item_nontarget def use_item_nontarget use_item_nontarget_variable @item.v_cost end end class Scene_Battle < Scene_Base alias execute_action_skill_variable execute_action_skill def execute_action_skill s = @active_battler.action.skill execute_action_skill_variable s.v_cost end alias execute_action_item_variable execute_action_item def execute_action_item i = @active_battler.action.item execute_action_item_variable i.v_cost end end class Game_Battler alias skill_can_use_variable? skill_can_use? def skill_can_use?(skill) data = skill_can_use_variable?(skill) return data if data == false skill.t_variables && skill.b_variables end end class Game_Party < Game_Unit alias item_can_use_variable? item_can_use? def item_can_use?(item) data = item_can_use_variable?(item) return data if data == false item.t_variables && item.b_variables end end module RPG class UsableItem < BaseItem def t_variables @t_variables ||= make_tb_variables(true) @t_variables.each_value {|a| return false if $game_variables[a[0]] < a[1]} true end def b_variables @b_variables ||= make_tb_variables(false) @b_variables.each_value {|a| return false if $game_variables[a[0]] > a[1]} true end def v_cost @v_cost ||= make_v_cost @v_cost.each_value {|a| $game_variables[a[0]] += a[1] $game_variables[a[0]] = a[2] if a[2] && $game_variables[a[0]] < a[2]} end def make_tb_variables(type) hash = {} word = type ? VAR_SKILL::T_V : VAR_SKILL::B_V self.note.each_line {|l| a = /<#{word}[::](\S+),(\S+)>/ =~ l ? [$1.to_i,$2.to_i] : false hash[hash.size] = a if a} hash end def make_v_cost hash = {} self.note.each_line {|l| a = /<#{VAR_SKILL::C_V}[::](\S+)/ =~ l ? $1.to_s : false next unless a a = a.split(/\s*,\s*/) next if a.size != 2 && a.size != 3 a.each_with_index {|d,i| a[i] = d.to_i} hash[hash.size] = a} hash end end end