# ▼▲▼ XRXS69. 特殊効果詰め合わせ ScopeEX ▼▲▼ built 201513 # by 桜雅 在土 # ▼▲▼ XRXS29. XRXS.条件機構+スキル使用条件 ▼▲▼ built 092013 # by 和希 (基本) # 桜雅 在土 (改訂) # Tetra-Z (強化) #============================================================================== # --- XRXS.条件機構 --- #============================================================================== class Game_Temp attr_accessor :xrxs29_conditions end module XRXS_CONDITION_TO_USE #-------------------------------------------------------------------------- # ○ 条件オプション #-------------------------------------------------------------------------- OPERATING_CONDITIONS_OPTION = "lHMhmVPsdaicfWATSRLvt" #-------------------------------------------------------------------------- # ○ 使用可能か? # material : スキル・アイテム・武器・防具・バトラー # condition_name : 条件属性名 ("使用条件"など) #-------------------------------------------------------------------------- def condition_use?(material, condition_name) # 初期化 bool = false i = 1 # --- 各条件の判定 --- # ( "..条件"、"..条件2"、"..条件3"と条件がなくなるまで行う ) loop do suffix = (i == 1 ? "" : i.to_s) met = condition_met?(material, condition_name + suffix) case met when 2 # 条件が存在しない場合 bool = true if i == 1 break when 1 # 条件を満たしている場合 bool = true break else # 条件を満たしていない場合 i += 1 end end # 結果を返す return bool end #-------------------------------------------------------------------------- # ○ 条件を満たしているか? # 返却値 2 : 条件が存在しない ┬ true 判定 # 1 : 条件を満たしている ┘ # 0 : 条件を満たしていない ─ false 判定 #-------------------------------------------------------------------------- def condition_met?(material, condition_name, user = nil) # 属性の取得 case material.class when RPG::Armor, RPG::State elements = material.guard_element_set when RPG::Weapon, RPG::Item elements = material.element_set when Game_Battler if Game_Battler.method_defined?("multy_element_set") elements = material.multy_element_set else elements = material.equip_element_set end when RPG::Skill if user != nil elements = user.multy_element_set(material) else elements = material.element_set end else elements = [] end # はじめてのsetupの時は指定した条件の属性の一覧を作る if $game_temp.xrxs29_conditions.nil? $game_temp.xrxs29_conditions = {} end if $game_temp.xrxs29_conditions[condition_name].nil? # 検索に使用する正規表現 reg_str = /\A#{condition_name}( -[#{OPERATING_CONDITIONS_OPTION}] [><=!]?[\/*%]? ?[0-9]+ ([0-9]+)?)+/ $game_temp.xrxs29_conditions[condition_name] = [] # 一覧の初期化 # 検索〜 for i in 1...$data_system.elements.size next if $data_system.elements[i].nil? if ($data_system.elements[i] =~ reg_str) != nil $game_temp.xrxs29_conditions[condition_name].push(i) end end end # 属性から条件属性を抜き取る elements &= $game_temp.xrxs29_conditions[condition_name] # 条件の設定されていない場合は可能 if elements.empty? return 2 end # 条件を全て満たしているかチェック elements.each{|element_id| conditions = get_conditions(element_id) conditions.each{|condition| # 比較条件に沿って比較する case condition[2] # includeが条件 : 含まれていないと false when "i" return 0 if !method(condition[0]).call.include?(condition[1]) # not includeが条件 : 含まれていると false when "n" return 0 if method(condition[0]).call.include?(condition[1]) # <=が条件 : 基準値 > 実際の値 がfalse when "<" called = method(condition[0]).call if condition[2].size > 1 return 0 if !called.is_a?(Integer) condition[3] = 0 if condition.size < 4 case condition[2][1].chr when "*" return 0 if (called * condition[1]) > condition[3] when "/" return 0 if (called / condition[1]) > condition[3] when "%" return 0 if (called % condition[1]) > condition[3] end else return 0 unless called.is_a?(condition[1].class) return 0 if called > condition[1] end # >=が条件 : 基準値 < 実際の値 がfalse when ">" called = method(condition[0]).call if condition[2].size > 1 return 0 if !called.is_a?(Integer) condition[3] = 0 if condition.size < 4 case condition[2][1].chr when "*" return 0 if (called * condition[1]) < condition[3] when "/" return 0 if (called / condition[1]) < condition[3] when "%" return 0 if (called % condition[1]) < condition[3] end else return 0 unless called.is_a?(condition[1].class) return 0 if called < condition[1] end # ==が条件 : 基準値 != 実際の値 がfalse when "=" called = method(condition[0]).call if condition[2].size > 1 return 0 if !called.is_a?(Integer) condition[3] = 0 if condition.size < 4 case condition[2][1].chr when "*" return 0 if (called * condition[1]) != condition[3] when "/" return 0 if (called / condition[1]) != condition[3] when "%" return 0 if (called % condition[1]) != condition[3] end else return 0 if called != condition[1] end # !=が条件 : 基準値 == 実際の値 がfalse when "!" called = method(condition[0]).call if condition[2].size > 1 return 0 if !called.is_a?(Integer) condition[3] = 0 if condition.size < 4 case condition[2][1].chr when "*" return 0 if (called * condition[1]) == condition[3] when "/" return 0 if (called / condition[1]) == condition[3] when "%" return 0 if (called % condition[1]) == condition[3] end else return 0 unless called.is_a?(condition[1].class) return 0 if called == condition[1] end end } } return 1 end #-------------------------------------------------------------------------- # ○ 「条件」の取得 # element_id : 属性 ID #-------------------------------------------------------------------------- def get_conditions(element_id) conditions = [] # 属性名からオプションの取得 options = $data_system.elements[element_id].split(/ -/) options.each do |option| next if option[/^([#{OPERATING_CONDITIONS_OPTION}]) ([><=!][*\/%]?)? ?([0-9]+) ?([0-9]+)?/].nil? # 値の取得 value = $3.to_i if $4 != nil value2 = $4.to_i else value2 = nil end # 比較式の取得 comp = $2.to_s # どの能力かを取得。呼び出して比較できるようにメソッドのシンボルにする case $1 when "l" status = :level when "H" status = :maxhp when "M" status = :maxsp when "h" status = :hp when "m" status = :sp when "V" status = :hp_persent when "P" status = :sp_persent when "s" status = :str when "d" status = :dex when "a" status = :agi when "i" status = :int when "c" status = :class_id when "f" status = :get_switch_comp @switch_id = id @switch_comp = comp when "v" status = :get_variable_comp when "W" status = :weapon_id when "A" status = :armor_ids comp = (comp.include?("!") ? "n" : "i") # include条件 when "T" status = :states comp = (comp.include?("!") ? "n" : "i") # include条件 when "S" status = :skills comp = (comp.include?("!") ? "n" : "i") # include条件 when "t" status = :turn when "R" status = :random when "L" status = :element_set comp = (comp == "!" ? "n" : "i") # include条件 end # 取得したデータをセット if value2 != nil conditions.push([status, value, comp, value2]) else conditions.push([status, value, comp]) end end return conditions end #-------------------------------------------------------------------------- # ○ ランダム #-------------------------------------------------------------------------- def random return rand(65536) end #-------------------------------------------------------------------------- # ○ 残りHPをパーセントで返す #-------------------------------------------------------------------------- def hp_persent return 100 * self.hp / self.maxhp end #-------------------------------------------------------------------------- # ○ 残りSPをパーセントで返す #-------------------------------------------------------------------------- def sp_persent return 100 * self.sp / self.maxsp end #-------------------------------------------------------------------------- # ○ 指定したスイッチがオンかオフか #-------------------------------------------------------------------------- def get_switch_comp a = $game_switches[@switch_id] a = false if a.nil? # 比較条件に沿って比較する if @switch_comp == false a = !a end return a end #-------------------------------------------------------------------------- # ○ 指定した変数の取得 #-------------------------------------------------------------------------- def get_variable_comp a = $game_variables[@variable_id] a = false if a.nil? return a end #-------------------------------------------------------------------------- # ○ ターン数の取得 #-------------------------------------------------------------------------- def turn if Game_Battler.method_defined?("turn") return self.turn else return $game_temp.battle_turn end end end #============================================================================== # □ XRXS29 #============================================================================== module XRXS29 OPERATING_CONDITIONS_NAME = "使用条件" TARGET_CONDITIONS_NAME = "範囲条件" end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ インクルード #-------------------------------------------------------------------------- include XRXS_CONDITION_TO_USE #-------------------------------------------------------------------------- # ○ ターゲット可能判定 #-------------------------------------------------------------------------- def selectable?(kind, id) case kind when 0 if $scene.active_battler.is_a?(Game_Actor) return condition_use?($game_troop.enemies[id], XRXS29::TARGET_CONDITIONS_NAME) else return condition_use?($game_actors[id], XRXS29::TARGET_CONDITIONS_NAME) end when 1 return condition_use?($data_skills[id], XRXS29::TARGET_CONDITIONS_NAME) when 2 return condition_use?($data_items[id], XRXS29::TARGET_CONDITIONS_NAME) end end #-------------------------------------------------------------------------- # ● スキルの使用可能判定 #-------------------------------------------------------------------------- alias :xrxs29_skill_can_use :skill_can_use? def skill_can_use?(skill_id) if not condition_use?($data_skills[skill_id], XRXS29::OPERATING_CONDITIONS_NAME) return false end return xrxs29_skill_can_use(skill_id) end end #============================================================================== # ■ Arrow_Enemy #============================================================================== class Arrow_Enemy < Arrow_Base #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super kind = $scene.active_battler.current_action.kind id = $scene.action_id # 存在しないエネミーを指していたら飛ばす $game_troop.enemies.size.times do break if self.enemy.exist? and self.enemy.selectable?(kind, id) @index += 1 @index %= $game_troop.enemies.size end # カーソル右 if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += 1 @index %= $game_troop.enemies.size break if self.enemy.exist? and self.enemy.selectable?(kind, id) end end # カーソル左 if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += $game_troop.enemies.size - 1 @index %= $game_troop.enemies.size break if self.enemy.exist? and self.enemy.selectable?(kind, id) end end # スプライトの座標を設定 if self.enemy != nil self.x = self.enemy.screen_x self.y = self.enemy.screen_y end end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :active_battler # 現在行動中のバトラー #-------------------------------------------------------------------------- # ● 面倒なのでメソッド化 #-------------------------------------------------------------------------- def action_id case @active_battler.current_action.kind when 0 return @active_battler.id when 1 return @active_battler.current_action.skill_id when 2 return @active_battler.current_action.item_id end end #-------------------------------------------------------------------------- # ● スキルまたはアイテムの対象側バトラー設定 [武器もここを使用!] #-------------------------------------------------------------------------- def set_target_battlers(scope) # 範囲強制値 case @active_battler.current_action.scope_force when 12 # 「拡散」 case scope when 1, 2 scope = 2 when 3, 4, 7 scope = 4 when 5, 6 scope = 6 end when 0 # else scope = @active_battler.current_action.scope_force end kind = @active_battler.current_action.kind id = action_id # 効果範囲で分岐 case scope when 1 # 敵単体 index = @active_battler.current_action.target_index if @active_battler.is_a?(Game_Actor) @target_battlers.push($game_troop.smooth_target_enemy(index)) else @target_battlers.push($game_party.smooth_target_actor(index)) end when 2 # 敵全体 for battler in (@active_battler.is_a?(Game_Actor) ? $game_troop.enemies : $game_party.actors) if battler.exist? and battler.selectable?(kind, id) @target_battlers.push(battler) end end when 3 # 味方単体 index = @active_battler.current_action.target_index if @active_battler.is_a?(Game_Actor) @target_battlers.push($game_party.smooth_target_actor(index)) else @target_battlers.push($game_troop.smooth_target_enemy(index)) end when 4 # 味方全体 for battler in (@active_battler.is_a?(Game_Actor) ? $game_party.actors : $game_troop.enemies) if battler.exist? and battler.selectable?(kind, id) @target_battlers.push(battler) end end when 5 # 味方単体 (HP 0) index = @active_battler.current_action.target_index if @active_battler.is_a?(Game_Actor) @target_battlers.push($game_party.smooth_target_actor(index)) else @target_battlers.push($game_troop.smooth_target_enemy(index)) end if battler != nil and battler.selectable?(kind, id) and battler.hp0? @target_battlers.push(battler) end when 6 # 味方全体 (HP 0) for battler in (@active_battler.is_a?(Game_Actor) ? $game_party.actors : $game_troop.enemies) if battler != nil and battler.selectable?(kind, id) and battler.hp0? @target_battlers.push(battler) end end when 7 # 使用者 @target_battlers.push(@active_battler) when 8, 11 # 全域化、対象ランダム @target_battlers = [] for battler in ($game_party.actors + $game_troop.enemies) @target_battlers.push(battler) if battler.exist? and battler.selectable?(kind, id) end # 自分以外 if @active_battler.current_action.self_exclusion @target_battlers -= [@active_battler] end # 対象ランダムの場合は一体に絞る if scope == 11 @target_battlers = [@target_battlers[rand(@target_battlers.size)]] end when 9 # 敵ランダム targets = [] for battler in (@active_battler.is_a?(Game_Actor) ? $game_troop.enemies : $game_party.actors) targets.push(battler) if battler.exist? and battler.selectable?(kind, id) end # 自分以外 if @active_battler.current_action.self_exclusion targets -= [@active_battler] end @target_battlers = [targets[rand(targets.size)]] when 10 # 味方ランダム targets = [] for battler in (@active_battler.is_a?(Game_Actor) ? $game_troop.enemies : $game_party.actors) targets.push(battler) if battler.exist? and battler.selectable?(kind, id) end # 自分以外 if @active_battler.current_action.self_exclusion targets -= [@active_battler] end @target_battlers = [targets[rand(targets.size)]] end # nil が入った場合は削除 (ランダム範囲時) @target_battlers.compact! # 特殊効果「自分以外」 if @active_battler.current_action.self_exclusion @target_battlers -= [@active_battler] end # 特殊効果「諸刃」 if @active_battler.current_action.self_inclusion @target_battlers.push(@active_battler) unless @target_battlers.include?(@active_battler) end # 全滅時はクリア unless @target_battlers[0].is_a?(Game_Battler) @target_battlers.clear end end end