$imported = {} unless $imported $imported[:real_two_swords_style] = true module KS_Extend #設定項目 値0で無効化 両方設定時は変数の設定が優先_/_/_/_/_/_/_/_/_/_/_/_/_/ # 二刀流時に左右の手で別々の攻撃を行う。 # 左手攻撃をフォローしているスクリプトと併用する場合はfalseにしてください。 USE_REAL_TWO_SWORDS_ATTACK = true # 武器変更(change_equipでequip_typeが0)のequip_typeを左手(-1)にするスイッチ。 OFF_HAND_SWITCH = 0 # 武器変更(change_equipでequip_typeが0)の実行時に # equip_typeを書き換えるのに使う変数。設定値*-1に書き換える。(-1が左手武器) SUB_WEAPON_VAR = 0 # 通常攻撃か"物理攻撃"がチェックされたスキルやアイテムでのみ左手攻撃を行う設定。 OFF_HAND_ONLY_PHISICAL_ATTACK = true # スキルやアイテムの場合打撃関係度がいくつ以上で左手攻撃が可能カの設定 OFF_HAND_LIMIT_OF_ATK_F = 1 #設定完了_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ # スキルやアイテムのメモに記述し、左下攻撃が可能かを個別に設定するための書式 OFF_HAND_OK = /<逆手(通常攻撃|攻撃|発動)(|可能|不可(?:能|)|\s*(?:-|)\d+(,(?:-|)\d+)*)>/i OFFHAND_ATTACK_SKILL = /<逆手攻撃\s*(\[((?:-|)\d+)\,(\d+)\,(\d+)\,(\d+)\](?:\s*\[((?:-|)\d+)\,(\d+)\,(\d+)\,(\d+)\])*)>/i end $imported[:real_two_swords_attack] = KS_Extend::USE_REAL_TWO_SWORDS_ATTACK class RPG::BaseItem SHIELDS_POS = 0 unless defined?(SHIELDS_POS)# armors 関数で返される配列上での盾の位置(通常は0) end =begin ★ks_二刀流拡張 制作 MaidensnowOnline 暴兎 使用プロジェクトを公開する場合、readme等に当HP名とそのアドレスを記述してください。 使用報告はしてくれると喜びます。 二刀流の武器と、盾を記録するインスタンス変数を別にし、 設定により戦闘時に左右の武器で別々に攻撃するようにします。 別途、"★ks_両手持・二刀流可能盾"を導入する事で、 設定により、二刀流+盾扱いの装備などが可能になります。 例)長剣と短剣の二刀流+マント イベントで左手の武器を持ち替えたい場合は、 上の設定で指定したスイッチや変数を使う事で実行できます。 ステータス画面などの見た目の攻撃力は左右の武器を加算した値のままです。 スキルやアイテムに関しても、使用後に左手攻撃を実行するか設定でき、 るのですが、とりあえず現状ではMaidensnow用にしか調整していないので未実装です。 現在は以下のどの"可能"を指定しても左手では通常攻撃が出ます。 -------------未実装項目------------- 左手攻撃可否個別設定例 <逆手攻撃可能> 左手で発動する事が可能で、 右手攻撃で使った場合は左手ではも同じオブジェクトで攻撃をします。 <逆手通常攻撃> 左手で発動することはできず、右手攻撃で使った場合は左手では通常攻撃します。 <逆手発動可能> 右手で発動した場合に左手で同じオブジェクトで攻撃をすることはできませんが、 左手の通常攻撃がこのオブジェクトで場合、左手で発動する事ができます。 -------------未実装項目------------- <逆手発動不可> 左手で発動することはでませんが、右手攻撃で使った場合は左手攻撃ができます。 <逆手攻撃不可> 左手で発動することはできず、右手攻撃で使った場合は左手攻撃はできません。 =end #------------------------------------------------------------------------------ # ■ Kernel #------------------------------------------------------------------------------ module Kernel alias judge_note_line_for_real_two_swords_style judge_note_line def judge_note_line(line) judge_note_line_for_real_two_swords_style(line) if line =~ KS_Extend::OFF_HAND_OK activate = false if line =~ /通常攻撃/i elsif line =~ /発動/i activate = true end if line =~ /通常攻撃/i @__off_hand_ok = -1 elsif line =~ /\s*(?:-|)\d+(,(?:-|)\d+)*/i @__off_hand_ok = []#line[/\d+/i].to_i line[/\s*(?:-|)\d+(,(?:-|)\d+)*/i].scan(/(?:-|)\d+/).each {|str| @__off_hand_ok << str.to_i } elsif line =~ /可能/i @__off_hand_ok = @id unless activate else @__off_hand_ok = false unless activate @__main_hand_only = true end @__off_hand_ok = -1 if activate #pp @id,@name,line, @__off_hand_ok elsif line =~ KS_Extend::OFFHAND_ATTACK_SKILL $1.scan(/\[((?:-|)\d+)\,(\d+)\,(\d+)\,(\d+)\]/).each { |num| dat = Ks_Action_Applyer.new(num[0].to_i, num[1].to_i) dat.set_flag(:new_target) if num[2].to_i == 0 dat.set_flag(:cost_free) if num[3].to_i > 0 dat.set_flag(:can_use_free) if num[3].to_i == 2 @__offhand_attack_skill << dat } #pp @id,@name,line, @__offhand_attack_skill end end end module KS_Extend_Data def offhand_attack_skill ; create_ks_param_cache unless @__ks_cache_done return @__offhand_attack_skill ; end end #------------------------------------------------------------------------------ # ■ RPG::UsableItem #------------------------------------------------------------------------------ class RPG::UsableItem alias create_ks_param_cache_for_real_two_swords_style create_ks_param_cache def create_ks_param_cache# RPG::UsableItem alias create_ks_param_cache_for_real_two_swords_style phys = !KS_Extend::OFF_HAND_ONLY_PHISICAL_ATTACK || @physical_attack phys_f = KS_Extend::OFF_HAND_LIMIT_OF_ATK_F < @atk_f @__off_hand_ok = -1 if !@__off_hand_ok && phys && phys_f end def can_off_hand_attack? return self.off_hand_ok? end def off_hand_ok? ; create_ks_param_cache unless @__ks_cache_done return @__off_hand_ok ; end def off_hand_active? ; create_ks_param_cache unless @__ks_cache_done return @__off_hand_ok == @id ; end def main_hand_only? ; create_ks_param_cache unless @__ks_cache_done return !@__off_hand_ok || @__main_hand_only end end #------------------------------------------------------------------------------ # ■ RPG::Actor #------------------------------------------------------------------------------ class RPG::Actor def two_swords_style unless @__ks_cache_done create_ks_param_cache end return @two_swords_style ; end end #------------------------------------------------------------------------------ # ■ RPG::Enemy #------------------------------------------------------------------------------ class RPG::Enemy def two_swords_style ; create_ks_param_cache unless @__ks_cache_done return @two_swords_style ; end end #------------------------------------------------------------------------------ # ■ Game_Battler #------------------------------------------------------------------------------ class Game_Battler attr_reader :off_hand_exec def start_off_hand_attack# Game_Battler @off_hand_exec = true end def end_off_hand_attack# Game_Battler @off_hand_exec = false end def sub_weapon# Game_Battler return nil end def shield return armor(RPG::BaseItem::SHIELDS_POS) end def two_swords_style return false end def real_two_swords_style return false end BASIC_OFF_HAND = Ks_Action_Applyer.new(-1) BASIC_OFF_HAND[:cost_free] = true BASIC_OFF_HAND[:new_target] = true BASIC_OFF_HAND.freeze if $TEST def offhand_attack_skill(obj) skills = [] return skills unless can_off_hand_attack?(obj,true) applyer = nil if obj for set in obj.offhand_attack_skill skill = set.skill if !skill || set.can_use_free || skill_can_use?(skill) skills << set else applyer = BASIC_OFF_HAND#.dup skills << applyer end end if skills.empty? && !@off_hand_exec && !@additional_exec && can_off_hand_attack?(obj) applyer = BASIC_OFF_HAND skills << applyer end elsif !@off_hand_exec && !@additional_exec && can_off_hand_attack?(obj) applyer = BASIC_OFF_HAND skills << applyer end skills += off_hand_attack_skill_list if skills.include?(applyer) last_hand = record_hand(obj) start_off_hand_attack last_flags = set_applyer_flags(applyer) if applyer.skill && !skill_can_use?(applyer.skill) applyer.skill_id = -1 end restre_applyer_flags(last_flags) restre_hand(last_hand) end return skills end end #------------------------------------------------------------------------------ # ■ Game_Actor #------------------------------------------------------------------------------ class Game_Actor if $imported[:real_two_swords_attack] def atk_animation_id# Game_Actor 再定義 return active_weapon == nil ? actor.animation_id : active_weapon.animation_id end def atk_animation_id2# Game_Actor 再定義 return 0 end end# if $imported[:real_two_swords_attack] def sub_weapon# Game_Actor 新規定義 return weapon(0) if @off_hand_exec return weapon(-1) end # 他の処理をごまかすため、見かけ上falseにする def two_swords_style# Game_Actor 再定義 return false end def real_two_swords_style# Game_Actor return actor.two_swords_style end def shield_legal?# Game_Actor return !(shield and weapons[1] || weapon(0).two_handed) end def can_off_hand_attack?(obj = nil, no_check_battler = false)# Game_Actor return false if obj != nil && !obj.can_off_hand_attack? return false if active_weapon && active_weapon.two_handed return false unless no_check_battler || real_two_swords_style || weapons[1] return true end def off_hand_attack_skill_list# Game_Actor skills = BAT_ARY[0].clear skills += active_weapon.offhand_attack_skill unless active_weapon == nil skills += actor.offhand_attack_skill return skills end unless $imported[:ks_rogue] #-------------------------------------------------------------------------- # ● 通常攻撃の属性取得 #-------------------------------------------------------------------------- alias element_set_for_real_two_swords_style element_set def element_set result = element_set_for_real_two_swords_style result -= sub_weapon.element_set if sub_weapon if active_weapon result |= active_weapon.element_set else result |= actor.attack_element_set end return result end #-------------------------------------------------------------------------- # ● 通常攻撃の追加効果 (ステート変化) 取得 #-------------------------------------------------------------------------- alias plus_state_set_for_plus_state_set plus_state_set def plus_state_set result = plus_state_set_for_plus_state_set result -= sub_weapon.state_set if sub_weapon if active_weapon result |= active_weapon.state_set else result |= actor.plus_state_set end return result end #-------------------------------------------------------------------------- # ● 通常攻撃の追加効果 (ステート変化) 取得 #-------------------------------------------------------------------------- alias minus_state_set_for_plus_state_set minus_state_set def minus_state_set result = minus_state_set_for_plus_state_set result -= sub_weapon.minus_state_set if sub_weapon if active_weapon result |= active_weapon.minus_state_set else result |= actor.minus_state_set end return result end end# unless $imported[:ks_rogue] #-------------------------------------------------------------------------- # ● 装備の変更 (ID で指定) #-------------------------------------------------------------------------- def change_equip_by_id(equip_type, item_id, test = false)# Game_Actor 再定義 if equip_type <= 0# or (equip_type == 1 and two_swords_style) change_equip(equip_type, $data_weapons[item_id], test) else change_equip(equip_type, $data_armors[item_id], test) end end #-------------------------------------------------------------------------- # ● 装備の変更 (ID で指定) #-------------------------------------------------------------------------- def change_equip(equip_type, item, test = false)# Game_Actor 再定義 last_item = equip(equip_type) unless test return if $game_party.item_number(item) == 0 if item != nil $game_party.gain_item(last_item, 1) $game_party.lose_item(item, 1) end item_id = item == nil ? 0 : item.id case equip_type when -2 # 固定装備 @luncher = item_id when -1 # 武器2 @weapon2_id = item_id lf = $game_temp.flags[:ceq_rts] $game_temp.flags[:ceq_rts] = false change_equip(1, nil, test) unless shield_legal? unless two_hands_legal? && real_two_swords_style if KS_Extend::OFF_HAND_SWITCH != 0 lt = $game_switches[KS_Extend::OFF_HAND_SWITCH] $game_switches[KS_Extend::OFF_HAND_SWITCH] = false end if KS_Extend::SUB_WEAPON_VAR != 0 lv = $game_variables[KS_Extend::SUB_WEAPON_VAR] $game_variables[KS_Extend::SUB_WEAPON_VAR] = 0 end change_equip(0, nil, test) # 逆の手の装備を外す $game_switches[KS_Extend::OFF_HAND_SWITCH] = lt if KS_Extend::OFF_HAND_SWITCH != 0 $game_variables[KS_Extend::SUB_WEAPON_VAR] = lv if KS_Extend::SUB_WEAPON_VAR != 0 @weapon2_id = 0 @weapon_id = item_id # メイン武器として装備する end $game_temp.flags[:ceq_rts] = lf when 0 # 武器 @weapon_id = item_id lf = $game_temp.flags[:ceq_rts] $game_temp.flags[:ceq_rts] = false change_equip(1, nil, test) unless shield_legal? unless two_hands_legal? # 両手持ち違反の場合 change_equip(-1, nil, test) # 逆の手の装備を外す end $game_temp.flags[:ceq_rts] = lf when 1 # 盾 @armor1_id = item_id lf = $game_temp.flags[:ceq_rts] $game_temp.flags[:ceq_rts] = false change_equip(-1, nil, test) unless shield_legal? unless two_hands_legal? # 両手持ち違反の場合 change_equip(0, nil, test) # 逆の手の装備を外す end $game_temp.flags[:ceq_rts] = lf when 2 # 頭 @armor2_id = item_id when 3 # 身体 @armor3_id = item_id when 4 # 装飾品 @armor4_id = item_id end end #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias setup_for_real_two_swords_style setup def setup(actor_id) setup_for_real_two_swords_style(actor_id) if real_two_swords_style @weapon2_id = @armor1_id @armor1_id = 0 end end end #------------------------------------------------------------------------------ # ■ Game_Enemy #------------------------------------------------------------------------------ class Game_Enemy def two_swords_style# Game_Enemy return false end def real_two_swords_style# Game_Enemy return enemy.two_swords_style end def can_off_hand_attack?(obj = nil, no_check_battler = false)# Game_Enemy return false if obj != nil && !obj.can_off_hand_attack? return no_check_battler || real_two_swords_style end def off_hand_attack_skill_list# Game_Enemy return enemy.offhand_attack_skill end end #============================================================================== # ■ Scene_Battle #============================================================================== if $imported[:real_two_swords_attack] if defined?(Scene_Battle) && Scene_Battle.is_a?(Class) class Scene_Battle < Scene_Base# if defined?(Scene_Battle) && Scene_Battle.is_a?(Class) #-------------------------------------------------------------------------- # ● 使ってない方の武器の攻撃力を引く #-------------------------------------------------------------------------- def apply_subweapon_atk @applyed_atk = 0 unless defined?(@applyed_atk) @active_battler.atk += @applyed_atk @applyed_atk = 0 if @active_battler.sub_weapon vv = @active_battler.sub_weapon.atk @active_battler.atk -= vv @applyed_atk += vv end end def reset_subweapon_atk @applyed_atk = 0 unless defined?(@applyed_atk) @active_battler.atk += @applyed_atk @applyed_atk = 0 end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : 攻撃 #-------------------------------------------------------------------------- alias execute_action_attack_for_real_two_swords_style execute_action_attack def execute_action_attack# Scene_Battle alias apply_subweapon_atk execute_action_attack_for_real_two_swords_style execute_off_hand_attack if @active_battler.can_off_hand_attack?(nil) reset_subweapon_atk end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : スキル #-------------------------------------------------------------------------- alias execute_action_skill_for_real_two_swords_style execute_action_skill def execute_action_skill# Scene_Battle alias apply_subweapon_atk execute_action_skill_for_real_two_swords_style obj = @active_battler.action.skill execute_off_hand_attack if @active_battler.can_off_hand_attack?(obj) reset_subweapon_atk end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : アイテム #-------------------------------------------------------------------------- alias execute_action_item_for_real_two_swords_style execute_action_item def execute_action_item# Scene_Battle alias apply_subweapon_atk execute_action_item_for_real_two_swords_style obj = @active_battler.action.item execute_off_hand_attack if @active_battler.can_off_hand_attack?(obj) reset_subweapon_atk end #-------------------------------------------------------------------------- # ● 逆手攻撃の実行 #-------------------------------------------------------------------------- def execute_off_hand_attack# Scene_Battle formar_action = @active_battler.former_action @active_battler.action.set_attack @active_battler.start_off_hand_attack apply_subweapon_atk @message_window.clear execute_action_attack_for_real_two_swords_style @active_battler.end_off_hand_attack @active_battler.action_swap(formar_action) end #-------------------------------------------------------------------------- # ● 攻撃アニメーションの表示 #-------------------------------------------------------------------------- alias display_attack_animation_for_real_two_two_swords_style display_attack_animation def display_attack_animation(targets) @offhand_mirror = @active_battler.off_hand_exec display_attack_animation_for_real_two_two_swords_style(targets) @offhand_mirror = false end #-------------------------------------------------------------------------- # ● 通常アニメーションの表示 #-------------------------------------------------------------------------- alias display_normal_animation_for_real_two_two_swords_style display_normal_animation def display_normal_animation(targets, animation_id, mirror = false) mirror = !mirror if @offhand_mirror display_normal_animation_for_real_two_two_swords_style(targets, animation_id, mirror) end end# defined?(Scene_Battle) && Scene_Battle.is_a?(Class) end# $imported[:real_two_swords_attack] end #============================================================================== # ■ Scene_Equip #============================================================================== class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # ● アイテムウィンドウの作成 #-------------------------------------------------------------------------- def create_item_windows @item_windows = [] @item_x = 0 unless @item_x @item_y = 208 unless @item_y for i in 0...@actor.equips.size#EQUIP_TYPE_MAX ii = i ii -= 1 if @actor.real_two_swords_style ii = 0 if ii < 0 @item_windows[i] = Window_EquipItem.new(@item_x, @item_y, Graphics.width - @item_x, Graphics::height - @item_y, @actor, ii) @item_windows[i].help_window = @help_window @item_windows[i].visible = (@equip_index == i) @item_windows[i].y = @item_y @item_windows[i].height = Graphics::height - @item_y @item_windows[i].active = false @item_windows[i].index = -1 end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの更新 #-------------------------------------------------------------------------- def update_item_windows for i in 0...@actor.equips.size#EQUIP_TYPE_MAX @item_windows[i].visible = (@equip_window.index == i) @item_windows[i].update end @item_window = @item_windows[@equip_window.index] end end class Window_Equip < Window_Selectable #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] for item in @actor.equips do @data.push(item) end @item_max = @data.size self.contents.font.color = system_color if @actor.real_two_swords_style self.contents.draw_text(4, WLH * 0, 92, WLH, Vocab::weapon1) self.contents.draw_text(4, WLH * 1, 92, WLH, Vocab::weapon2) i = 1 else self.contents.draw_text(4, WLH * 0, 92, WLH, Vocab::weapon) i = 0 end self.contents.draw_text(4, WLH * (i + 1), 92, WLH, Vocab::armor1) self.contents.draw_text(4, WLH * (i + 2), 92, WLH, Vocab::armor2) self.contents.draw_text(4, WLH * (i + 3), 92, WLH, Vocab::armor3) self.contents.draw_text(4, WLH * (i + 4), 92, WLH, Vocab::armor4) for i in 0...@data.size draw_item_name(@data[i], 92, WLH * i) end end end begin class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ● 戦闘テスト用パーティのセットアップ #-------------------------------------------------------------------------- def setup_battle_test_members# Game_Party 再定義 @actors = [] for battler in $data_system.test_battlers actor = $game_actors[battler.actor_id] #p battler.armor1_id, battler, actor actor.change_level(battler.level, false) actor.change_equip_by_id(0, battler.weapon_id, true) if actor.real_two_swords_style actor.change_equip_by_id(-1, battler.armor1_id, true) else actor.change_equip_by_id(1, battler.armor1_id, true) end actor.change_equip_by_id(2, battler.armor2_id, true) actor.change_equip_by_id(3, battler.armor3_id, true) actor.change_equip_by_id(4, battler.armor4_id, true) actor.recover_all @actors.push(actor.id) end @items = {} for i in 1...$data_items.size if $data_items[i].battle_ok? @items[i] = 99 unless $data_items[i].name.empty? end end end end rescue end