######################### 武器にスキル効果を持たせる ######################### # # # 攻撃を選ぶと設定されたスキルとまったく同じ効果を発揮するようにします。 # # 武器の属性に「スキル攻撃:n」(:は半角、nは任意の整数、半角で)と入力。 # # その武器を装備して攻撃を選ぶと、そのIDのスキルと同様の効果を発揮します。 # # 「スキル攻撃:1」の場合通常攻撃の効果はスキルID1のスキルと同じになります。 # # 一つの装備に複数のスキル攻撃効果を持たせることはできません。 # # 「スキル攻撃:1」の「スキル習得:」の部分を変更したいなら設定で変更可能。 # # # # 例えば相手を回復させたり、全体攻撃だったり、SPを消費する武器、 # # 腕力以外の能力値をダメージ計算に用いるなど、スキルと同様に製作可能に。 # # # ############################################################################## # ここから設定 module Annex SKILL_WEAPON_KEY = "スキル攻撃:" end # ここまで設定 #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ◎ 追加:装備している武器にスキル攻撃効果があるかを確認 #-------------------------------------------------------------------------- def get_weapon_skill # 属性を取得 element_set = self.element_set # 属性名からそのあとに続く数字を取得 id = get_element_key_id(element_set, Annex::SKILL_WEAPON_KEY) # 空配列で無い場合、最初のものを返す if id != [] return id[0] end # 無い場合 0 を返す return 0 end #-------------------------------------------------------------------------- # ◎ 追加:「属性名+数字」の形式の属性が含まれていればその数字部分を取得。 # element_set : 属性の配列 # key : 取得する属性名 #-------------------------------------------------------------------------- def get_element_key_id(element_set, key) id = [] for i in element_set if $data_system.elements[i] =~ /#{key}([0-9]+)/ # ID取得 id.push($1.to_i) end end return id end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ○ スキルの使用可能判定 # skill_id : スキル ID #-------------------------------------------------------------------------- alias skill_weapon_skill_can_use? skill_can_use? def skill_can_use?(skill_id) # 戦闘中で、なおかつ通常攻撃時に発動するスキルとして設定されている場合、 # スキルを習得しているか否かの確認をせず、沈黙状態でも使用可能に設定。 if $game_temp.in_battle and @current_action.kind == 0 # SP が足りない場合は使用不可 if $data_skills[skill_id].sp_cost > self.sp return false end # 戦闘不能の場合は使用不可 if dead? return false end occasion = $data_skills[skill_id].occasion # [常時] または [バトルのみ] なら使用可 return (occasion == 0 or occasion == 1) end # 呼び戻し return skill_weapon_skill_can_use?(skill_id) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ○ アクターコマンドウィンドウのセットアップ #-------------------------------------------------------------------------- alias skill_weapon_phase3_setup_command_window phase3_setup_command_window def phase3_setup_command_window # コマンド再描画 @actor_command_window.refresh # 呼び戻し skill_weapon_phase3_setup_command_window # アクター取得 actor = $game_party.actors[@actor_index] # 強制的に行動を基本コマンドに actor.current_action.kind = 0 # 武器からスキル攻撃属性があるかをチェック skill_id = actor.get_weapon_skill # skill_id が 0 でない場合、そのIDのスキルを選んだものとする。 if skill_id > 0 # スキル取得 skill = $data_skills[skill_id] # 使用できない場合 if skill == nil or not actor.skill_can_use?(skill.id) @actor_command_window.disable_item(0) end end end #-------------------------------------------------------------------------- # ○ フレーム更新 (アクターコマンドフェーズ : 基本コマンド) #-------------------------------------------------------------------------- alias skill_weapon_update_phase3_basic_command update_phase3_basic_command def update_phase3_basic_command # 通常攻撃が呼び出された場合 if Input.trigger?(Input::C) and @actor_command_window.index == 0 # 武器からスキル攻撃属性があるかをチェック skill_id = @active_battler.get_weapon_skill # skill_id が 0 でない場合、そのIDのスキルを選んだものとする。 if skill_id > 0 # アクションを設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # スキル取得 skill = $data_skills[skill_id] # 使用できない場合 if skill == nil or not @active_battler.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 == 1 # エネミーの選択を開始 start_enemy_select # 効果範囲が味方単体の場合 elsif skill.scope == 3 or skill.scope == 5 # アクターの選択を開始 start_actor_select # 効果範囲が単体ではない場合 else # 次のアクターのコマンド入力へ phase3_next_actor end return else # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # エネミーの選択を開始 start_enemy_select end return end # 呼び戻し skill_weapon_update_phase3_basic_command end #-------------------------------------------------------------------------- # ○ 基本アクション 結果作成 #-------------------------------------------------------------------------- alias skill_weapon_make_basic_action_result make_basic_action_result def make_basic_action_result # 攻撃の場合 if @active_battler.current_action.basic == 0 # 武器にスキルが設定されている場合 skill_id = @active_battler.get_weapon_skill if skill_id > 0 # スキルを取得 @skill = $data_skills[skill_id] # 強制アクションでなければ unless @active_battler.current_action.forcing # SP 切れなどで使用できなくなった場合 unless @active_battler.skill_can_use?(@skill.id) # アクション強制対象のバトラーをクリア $game_temp.forcing_battler = nil # ステップ 1 に移行 @phase4_step = 1 return end end # SP 消費 @active_battler.sp -= @skill.sp_cost # ステータスウィンドウをリフレッシュ @status_window.refresh # アニメーション ID を設定 @animation1_id = @skill.animation1_id @animation2_id = @skill.animation2_id # コモンイベント ID を設定 @common_event_id = @skill.common_event_id # 対象側バトラーを設定 set_target_battlers(@skill.scope) # スキルの効果を適用 for target in @target_battlers target.skill_effect(@active_battler, @skill) end return end end # 呼び戻し return skill_weapon_make_basic_action_result end end