# ▼▲▼ XRXS37. 特殊効果詰め合わせ ActionEX ver.1.9 ▼▲▼ built 220918 # by 桜雅 在土 (基本) # Tetra-Z (修正) #------------------------------------------------------------------------------ # ▽ カスタマイズポイント #============================================================================== module XRXS37 SP_COST = "SP消費" # 絶対消費SP属性 SP_COST_NOW = "SP消費残" # 現SP依存消費SP属性 SP_COST_ALL = "SP消費全" # 最大SP依存消費SP属性 HP_COST = "HP消費" # 絶対消費HP属性 HP_COST_NOW = "HP消費残" # 現HP依存消費HP属性 HP_COST_ALL = "HP消費全" # 最大HP依存消費HP属性 COST_REDUCE = "消費軽減" # 消費軽減属性 SKILL_DEAD_CAN_USE = false # 移動中、戦闘不能でもスキルを使える WILL_DIE_CAN_USE = false # HPが足りなくてもスキルを使える(SPは無理) OMAKE_DRAIN = false # 足りない分は隣の方のSPを2倍消費(工事中) end module XRXS19 # 空モジュール。でも消すな。 end #============================================================================== # ■ RPG #============================================================================== module RPG class Skill def sp_cost(battler = nil) # 属性から消費SPを計算 cost = @sp_cost + XRXS.element_amount(self.element_set, XRXS37::SP_COST) if battler == nil return cost else check = XRXS.element_check(self.element_set, XRXS37::SP_COST_NOW) if check[0] cost += self.sp * check[2] / 100 end check = XRXS.element_check(self.element_set, XRXS37::SP_COST_ALL) if check[0] cost += self.maxsp * (100 - check[2]) / 100 end # 軽減属性計算 if Game_Battler.method_defined?("multy_element_set") check = XRXS.element_check(battler.multy_element_set, XRXS37::COST_REDUCE) else check = XRXS.element_check(battler.equip_element_set, XRXS37::COST_REDUCE) end if check[0] cost = cost * (100 + check[2]) / 100 cost += check[1] end # 元の消費SPが0でないと、消費SPは1以上になる cost = [cost, 1].max if @sp_cost != 0 end return cost end def hp_cost(battler = nil) # 属性から消費HPを計算 base_cost = XRXS.element_amount(self.element_set, XRXS37::HP_COST) cost = base_cost if battler == nil return cost else check = XRXS.element_check(self.element_set, XRXS37::HP_COST_NOW) if check[0] cost += self.hp * check[2] / 100 end check = XRXS.element_check(self.element_set, XRXS37::HP_COST_ALL) if check[0] cost += self.maxhp * check[2] / 100 end # 軽減属性計算 if Game_Battler.method_defined?("multy_element_set") check = XRXS.element_check(battler.multy_element_set, XRXS37::COST_REDUCE) else check = XRXS.element_check(battler.equip_element_set, XRXS37::COST_REDUCE) end if check[0] cost = cost * (100 + check[2]) / 100 cost += check[1] end # 元の消費HPが0でないと、消費HPは1以上になる cost = [cost, 1].max if base_cost != 0 end return cost end end class Weapon def sp_cost(battler = nil) base_cost = XRXS.element_amount(self.element_set, XRXS37::SP_COST) cost = base_cost if battler == nil return cost else check = XRXS.element_check(self.element_set, XRXS37::SP_COST_NOW) if check[0] cost += self.sp * check[2] / 100 end check = XRXS.element_check(self.element_set, XRXS37::SP_COST_ALL) if check[0] cost += self.maxsp * (100 - check[2]) / 100 end if Game_Battler.method_defined?("multy_element_set") check = XRXS.element_check(battler.multy_element_set, XRXS37::COST_REDUCE) else check = XRXS.element_check(battler.equip_element_set, XRXS37::COST_REDUCE) end if check[0] cost = cost * (100 + check[2]) / 100 cost += check[1] end # 元の消費SPが0でないと、消費SPは1以上になる cost = [cost, 1].max if base_cost != 0 end return cost end def hp_cost(battler = nil) base_cost = XRXS.element_amount(self.element_set, XRXS37::HP_COST) cost = base_cost if battler == nil return cost else check = XRXS.element_check(self.element_set, XRXS37::HP_COST_NOW) if check[0] cost += self.hp * check[2] / 100 end check = XRXS.element_check(self.element_set, XRXS37::HP_COST_ALL) if check[0] cost += self.maxhp * check[2] / 100 end if Game_Battler.method_defined?("multy_element_set") check = XRXS.element_check(battler.multy_element_set, XRXS37::COST_REDUCE) else check = XRXS.element_check(battler.equip_element_set, XRXS37::COST_REDUCE) end if check[0] cost = cost * (100 + check[2]) / 100 cost += check[1] end # 元の消費HPが0でないと、消費HPは1以上になる cost = [cost, 1].max if base_cost != 0 end return cost end end class Item def sp_cost(battler = nil) base_cost = XRXS.element_amount(self.element_set, XRXS37::SP_COST) cost = base_cost if battler == nil return cost else check = XRXS.element_check(self.element_set, XRXS37::SP_COST_NOW) if check[0] cost += self.sp * check[2] / 100 end check = XRXS.element_check(self.element_set, XRXS37::SP_COST_ALL) if check[0] cost += self.maxsp * (100 - check[2]) / 100 end if Game_Battler.method_defined?("multy_element_set") check = XRXS.element_check(battler.multy_element_set, XRXS37::COST_REDUCE) else check = XRXS.element_check(battler.equip_element_set, XRXS37::COST_REDUCE) end if check[0] cost = cost * (100 + check[2]) / 100 cost += check[1] end # 元の消費SPが0でないと、消費SPは1以上になる cost = [cost, 1].max if base_cost != 0 end return cost end def hp_cost(battler = nil) base_cost = XRXS.element_amount(self.element_set, XRXS37::HP_COST) cost = base_cost if battler == nil return cost else check = XRXS.element_check(self.element_set, XRXS37::HP_COST_NOW) if check[0] cost += self.hp * check[2] / 100 end check = XRXS.element_check(self.element_set, XRXS37::HP_COST_ALL) if check[0] cost += self.maxhp * check[2] / 100 end if Game_Battler.method_defined?("multy_element_set") check = XRXS.element_check(battler.multy_element_set, XRXS37::COST_REDUCE) else check = XRXS.element_check(battler.equip_element_set, XRXS37::COST_REDUCE) end if check[0] cost = cost * (100 + check[2]) / 100 cost += check[1] end # 元の消費HPが0でないと、消費HPは1以上になる cost = [cost, 1].max if base_cost != 0 end return cost end end end #============================================================================== # ■ Window_Skill #============================================================================== class Window_Skill < Window_Selectable #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- alias :xrxs37_draw_item :draw_item def draw_item(index) xrxs37_draw_item(index) skill = @data[index] # 一度塗り潰せ x = 4 + index % @column_max * (288 + 32) y = index / @column_max * 32 rect = Rect.new(x + 232, y, 48, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) text = "" if skill.sp_cost(@actor) != 0 text += sprintf(" S%4d", skill.sp_cost(@actor)) end if skill.hp_cost(@actor) != 0 text += sprintf(" H%4d", skill.hp_cost(@actor)) end if text != "" text.sub!(/^\s/){} end split = text.split(//).reverse if skill.sp_cost(@actor) != 0 and skill.hp_cost(@actor) != 0 y += 16 for s in 0...split.size if split[s - 1] == "H" y -= 16 x += 72 elsif split[s] != "" string = RPG::Cache.text(12, 16, split[s], self.contents.font.color, self.contents.font.size - 4) self.contents.blt(x + 280 - (s + 1) * 12, y, string, string.rect) end end else for s in 0...split.size if split[s] != "" string = RPG::Cache.text(12, 32, split[s], self.contents.font.color, self.contents.font.size) self.contents.blt(x + 280 - (s + 1) * 12, y, string, string.rect) end end end end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 戦闘不能判定 #-------------------------------------------------------------------------- alias :xrxs37plus_dead? :dead? def dead? return (xrxs37plus_dead? and self != $scene.active_battler) end #-------------------------------------------------------------------------- # ● スキルの使用可能判定 # skill_id : スキル ID #-------------------------------------------------------------------------- def skill_can_use?(skill_id) return false if can_use?(1, skill_id) == false # 戦闘不能の場合は(一部例外を除き)使用不可 if dead? unless XRXS37::SKILL_DEAD_CAN_USE or $game_temp.in_battle return false end end if Numset.const_defined?("ATTACK") # 物理封じ状態の場合、物理スキルは使用不可 if self.restriction == 1 if XRXS.element_include?(skill.element_set, Numset::ATTACK) @states.each{|state| i = state.guard_element_set if XRXS.element_include?(i, Numset::ATTACK_SEAL) return false end } # 魔法封じ状態の場合、魔法スキルは使用不可 elsif XRXS.element_include?(skill.element_set, Numset::MAGIC) @states.each{|state| i = state.guard_element_set if XRXS.element_include?(i, Numset::MAGIC_SEAL) return false end } end end elsif XRXS19.const_defined?("ATTACK") # 物理封じ状態の場合、物理スキルは使用不可 if self.restriction == 1 if XRXS.element_include?(skill.element_set, XRXS19::ATTACK) @states.each{|state| i = state.guard_element_set if XRXS.element_include?(i, XRXS19::ATTACK_SEAL) return false end } # 魔法封じ状態の場合、魔法スキルは使用不可 elsif XRXS.element_include?(skill.element_set, XRXS19::MAGIC) @states.each{|state| i = state.guard_element_set if XRXS.element_include?(i, XRXS19::MAGIC_SEAL) return false end } end end else # 沈黙状態の場合、物理スキル以外は使用不可 if $data_skills[skill_id].atk_f == 0 and self.restriction == 1 return false end end # 使用可能時を取得 occasion = $data_skills[skill_id].occasion # 戦闘中の場合 if $game_temp.in_battle # [常時] または [バトルのみ] なら使用可 return (occasion == 0 or occasion == 1) # 戦闘中ではない場合 else # [常時] または [メニューのみ] なら使用可 return (occasion == 0 or occasion == 2) end end #-------------------------------------------------------------------------- # ○ スキル消費を回復させる #-------------------------------------------------------------------------- def cost_restore(skill) # HP消費スキルの場合 self.hp += skill.hp_cost(self) # SP消費スキルの場合 self.sp += skill.sp_cost(self) end #-------------------------------------------------------------------------- # ● 共通の使用可能判定 #-------------------------------------------------------------------------- def can_use?(kind, id = 0) # kindから使用タイプを判別 case kind when 0 act = $data_weapons[self.weapon_id] when 1 act = $data_skills[id] when 2 act = $data_items[id] end # SP が足りない場合は使用不可 if act.sp_cost(self) > self.sp return false # HP が足りない場合は(一部を除いて)使用不可 elsif act.hp_cost(self) > self.hp and not XRXS37::WILL_DIE_CAN_USE return false else return true end end end #============================================================================== # ■ Scene_Skill #============================================================================== class Scene_Skill #-------------------------------------------------------------------------- # ● フレーム更新 (スキルウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_skill # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # メニュー画面に切り替え $scene = Scene_Menu.new(1) return end # C ボタンが押された場合 if Input.trigger?(Input::C) # スキルウィンドウで現在選択されているデータを取得 @skill = @skill_window.skill # 使用できない場合 if @skill == nil or not @actor.skill_can_use?(@skill.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 効果範囲が味方の場合 if @skill.scope >= 3 # ターゲットウィンドウをアクティブ化 @skill_window.active = false @target_window.x = (@skill_window.index + 1) % 2 * 304 @target_window.visible = true @target_window.active = true # 効果範囲 (単体/全体) に応じてカーソル位置を設定 if @skill.scope == 4 || @skill.scope == 6 @target_window.index = -1 elsif @skill.scope == 7 @target_window.index = @actor_index - 10 else @target_window.index = 0 end # 効果範囲が味方以外の場合 else # コモンイベント ID が有効の場合 if @skill.common_event_id > 0 # コモンイベント呼び出し予約 $game_temp.common_event_id = @skill.common_event_id # スキルの使用時 SE を演奏 $game_system.se_play(@skill.menu_se) # SP 消費 @actor.sp -= @skill.sp_cost(@actor) @actor.hp -= @skill.hp_cost(@actor) # 各ウィンドウの内容を再作成 @status_window.refresh @skill_window.refresh @target_window.refresh # マップ画面に切り替え $scene = Scene_Map.new return end end return end # R ボタンが押された場合 if Input.trigger?(Input::R) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # 次のアクターへ @actor_index += 1 @actor_index %= $game_party.actors.size # 別のスキル画面に切り替え $scene = Scene_Skill.new(@actor_index) return end # L ボタンが押された場合 if Input.trigger?(Input::L) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # 前のアクターへ @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size # 別のスキル画面に切り替え $scene = Scene_Skill.new(@actor_index) return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ターゲットウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_target # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ターゲットウィンドウを消去 @skill_window.active = true @target_window.visible = false @target_window.active = false return end # C ボタンが押された場合 if Input.trigger?(Input::C) # SP 切れなどで使用できなくなった場合 unless @actor.skill_can_use?(@skill.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # ターゲットが全体の場合 if @target_window.index == -1 # パーティ全体にスキルの使用効果を適用 used = false for i in $game_party.actors used |= i.skill_effect(@actor, @skill) end end # ターゲットが使用者の場合 if @target_window.index <= -2 # ターゲットのアクターにスキルの使用効果を適用 target = $game_party.actors[@target_window.index + 10] used = target.skill_effect(@actor, @skill) end # ターゲットが単体の場合 if @target_window.index >= 0 # ターゲットのアクターにスキルの使用効果を適用 target = $game_party.actors[@target_window.index] used = target.skill_effect(@actor, @skill) end # スキルを使った場合 if used # スキルの使用時 SE を演奏 $game_system.se_play(@skill.menu_se) # SP 消費 @actor.sp -= @skill.sp_cost(@actor) @actor.hp -= @skill.hp_cost(@actor) # 各ウィンドウの内容を再作成 @status_window.refresh @skill_window.refresh @target_window.refresh # 全滅の場合 if $game_party.all_dead? # ゲームオーバー画面に切り替え $scene = Scene_Gameover.new return end # コモンイベント ID が有効の場合 if @skill.common_event_id > 0 # コモンイベント呼び出し予約 $game_temp.common_event_id = @skill.common_event_id # マップ画面に切り替え $scene = Scene_Map.new return end end # スキルを使わなかった場合 unless used # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end return end end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle attr_reader :active_battler #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド) #-------------------------------------------------------------------------- def update_phase3_basic_command # 優先度 @active_battler.current_action.speed_priority = 0 # C ボタンが押された場合 if Input.trigger?(Input::C) # アクターコマンドウィンドウのカーソル位置で分岐 if @actor_command_window.index == 0 # 攻撃 # 使用できない場合 unless @active_battler.can_use?(0) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 武器優先度の取得 # 特殊効果:優先度 returnar = XRXS.element_check(@active_battler.equip_element_set, XRXS37::SPEED_PRIORITY) if returnar[0] @active_battler.current_action.speed_priority = returnar[1] else @active_battler.current_action.speed_priority = 0 end end end # 呼び戻す xrxs37_update_phase3_basic_command end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択) #-------------------------------------------------------------------------- alias :xs37plus_update_phase3_item_select :update_phase3_item_select def update_phase3_item_select # C ボタンが押された場合 if Input.trigger?(Input::C) # 使用できない場合 unless @active_battler.can_use?(2, @item_window.item.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end end # 呼び戻す xs37plus_update_phase3_item_select end #-------------------------------------------------------------------------- # ● 基本アクション 結果作成 #-------------------------------------------------------------------------- alias :xs37plus_make_basic_action_result :make_basic_action_result def make_basic_action_result # 攻撃の場合 if @active_battler.current_action.basic == 0 # 武器IDの取得 @weapon_id = @active_battler.is_a?(Game_Actor) ? @active_battler.weapon_id : 0 # 消費 if @weapon_id > 0 @active_battler.hp -= $data_weapons[@weapon_id].hp_cost(@active_battler) @active_battler.sp -= $data_weapons[@weapon_id].sp_cost(@active_battler) end end # 呼び戻す xs37plus_make_basic_action_result end #-------------------------------------------------------------------------- # ● スキルアクション 結果作成 #-------------------------------------------------------------------------- def make_skill_action_result # スキルを取得 @skill = $data_skills[@active_battler.current_action.skill_id] # キャスト中でない場合 if @active_battler.current_action.cast_duration <= 0 # 特殊効果:詠唱発動 returnar = XRXS.element_check(@active_battler.skill_element_set(@skill), XRXS37::CAST_CHANT) if returnar[0] @active_battler.current_action.cast_duration = returnar[1] state_id = get_state_id_cast_chant @active_battler.current_action.condition_state_id = state_id @active_battler.add_state(state_id) if state_id > 0 # 実際にステート付加 end # 特殊効果:溜め発動 returnar = XRXS.element_check(@active_battler.skill_element_set(@skill), XRXS37::CAST_DURATION) if returnar[0] @active_battler.current_action.cast_duration = returnar[1] end end # キャスト中の場合 if @active_battler.current_action.cast_duration >= 2 @animation1_id = @skill.animation1_id @animation2_id = 0 return end # [消費ステート]の判別 if @active_battler.current_action.condition_state_id > 0 # 設定されている場合 if @active_battler.state?(@active_battler.current_action.condition_state_id) # 条件を満たした場合 ステートを解除する @active_battler.remove_state(@active_battler.current_action.condition_state_id) else # 条件を満たしていない場合 @animation1_id = 0 @animation2_id = 0 return end end # 既に一回以上行動している場合 if @phase4_act_times >= 1 or @phase4_hit_times >= 1 # # スキルの消費分を復旧させ、擬似的にHP/SPを減らさない ( HP消費に対応 ) # @active_battler.cost_restore(@skill) else # 使用するスキルの特殊効果の取得 @active_battler.current_action.set_xrxs37_special_effect(@active_battler.skill_element_set(@skill)) # 特殊効果:行動回数 @phase4_act_times_max = @active_battler.current_action.move_times @phase4_act_times_max = 1 if @phase4_act_times_max == 0 # 0は1にする # 特殊効果:ヒット回数 @phase4_hit_times_max = @active_battler.current_action.hit_times @phase4_hit_times_max = 1 if @phase4_hit_times_max == 0 # 0は1にする end # 足りるかを判定 unless @active_battler.skill_can_use?(@skill.id) # ステップ 1 に移行 @phase4_step = 1 return end # # SPとHPを消費 # ( make_skill_action_result メソッドにステータスウィンドウの # リフレッシュがあるため、呼び戻すより前に SPとHP を消費させる。) # @active_battler.hp -= @skill.hp_cost(@active_battler) @active_battler.sp -= @skill.sp_cost(@active_battler) # 都合によりSPの回復 @active_battler.sp += @skill.sp_cost # 呼び戻す xrxs37_make_skill_action_result # SPの制限の解除 @active_battler.sp0_ban = false # 既に一回以上ヒット/行動している、またはため中の場合 if (@phase4_hit_times >= 1 or @phase4_act_times >= 1) or (@active_battler.current_action.cast_duration >= 2) @help_window.visible = false end # ためスキル発動時はアニメ1を消す if @active_battler.current_action.cast_duration == 1 @animation1_id = 0 end end #-------------------------------------------------------------------------- # ● アイテムアクション 結果作成 #-------------------------------------------------------------------------- alias :xs37plus_make_item_action_result :make_item_action_result def make_item_action_result @item = $data_items[@active_battler.current_action.item_id] # 消費 @active_battler.hp -= @item.hp_cost(@active_battler) @active_battler.sp -= @item.sp_cost(@active_battler) # 呼び戻す xs37plus_make_item_action_result end end