#============================================================================== # アクター毎に装備部位設定 ver1.00 #------------------------------------------------------------------------------ #[特徴] # 装備箇所をアクター毎に設定します。 # #[設定上の注意] # 「武器2つ+盾」とか出来てしまうので、その辺は注意して設定してください。 # #[使用上の注意] # 再定義箇所が多いので、他の装備系スクリプトとの競合率が高いです。 # Kamesoft様の『装備拡張』とは競合性が高いので、 # このスクリプトとの共用は諦めていただくしかありません。orz # # 作成:ぶちょー # ホム:http://nyannyannyan.bake-neko.net/ # 著作:自分で作ったとか言わないで>< # 改造はご自由にどうぞ。 # リードミーとかに私の名前の載せたりするのは任意で。 #============================================================================== #============================================================================== # バージョンアップ情報 # ver1.00 公開 #============================================================================== #============================================================================== # 設定項目 #============================================================================== module Kazari module EQUIP_TYPE # 装備部位の最大数 MAX = 6 # 装備部位の設定。 # アクターID => [ID, ID] # 0 : 武器、1 : 盾、2 : 頭防具、3 : 体防具、4 : 装飾品 KIND = { 0 => [0, 1, 2, 3, 4, 4], # 下記で設定しなかった場合 1 => [0, 1, 2, 3, 4, 4], # アクター1 : 通常通り 2 => [0, 2, 3, 4, 4, 4], # アクター2 : 盾が装備できないけど、装飾品2つ 3 => [0, 0, 2, 3, 4, 4], # アクター3 : 二刀流 4 => [0, 0, 0, 2, 3, 4], # アクター5 : 三刀流(1本を口にくわえれば) } end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler include Kazari #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :equip_type attr_accessor :equip_id #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias equip_type_setup setup def setup(actor_id) equip_type_setup(actor_id) if EQUIP_TYPE::KIND[actor_id] @equip_type = EQUIP_TYPE::KIND[actor_id] else @equip_type = EQUIP_TYPE::KIND[0] end @equip_id = [@weapon_id, @armor1_id, @armor2_id, @armor3_id, @armor4_id] for i in 5...EQUIP_TYPE::MAX @equip_id.push(0) end end #-------------------------------------------------------------------------- # ● 武器数の取得 #-------------------------------------------------------------------------- def weapon_size number = 0 for type in @equip_type number += 1 if type == 0 end return number end #-------------------------------------------------------------------------- # ● 武器オブジェクトの配列取得 ※ 再定義 #-------------------------------------------------------------------------- def weapons result = [] for i in 0...@equip_type.size next unless @equip_type[i] == 0 result.push($data_weapons[@equip_id[i]]) end return result end #-------------------------------------------------------------------------- # ● 防具オブジェクトの配列取得 ※ 再定義 #-------------------------------------------------------------------------- def armors result = [] for i in 0...@equip_type.size next if @equip_type[i] == 0 result.push($data_armors[@equip_id[i]]) end return result end #-------------------------------------------------------------------------- # ● 命中率の取得 ※ 再定義 #-------------------------------------------------------------------------- def hit n = 100 for weapon in weapons.compact n = [n, weapon == nil ? 95 : weapon.hit].min end return n end #-------------------------------------------------------------------------- # ● 通常攻撃 アニメーション ID の取得 #-------------------------------------------------------------------------- def weapon_animation_id(i) return weapons[i] == nil ? 1 : weapons[i].animation_id end #-------------------------------------------------------------------------- # ● 装備の変更 (ID で指定) ※ 再定義 #-------------------------------------------------------------------------- def change_equip_by_id(index, item_id, test = false) if @equip_type[index] == 0 change_equip(index, $data_weapons[item_id], test) else change_equip(index, $data_armors[item_id], test) end end #-------------------------------------------------------------------------- # ● 装備の変更 (オブジェクトで指定) ※ 再定義 #-------------------------------------------------------------------------- def change_equip(index, item, test = false) last_item = equips[index] 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 @equip_id[index] = item == nil ? 0 : item.id case @equip_type[index] when 0 # 武器 unless two_hands_legal? # 両手持ち違反の場合 flag = false for i in 0...@equip_type.size next if i == index next unless @equip_type[i] == 0 flag = true change_equip(i, nil, test) # もう一つの武器を外す end unless flag # 武器がもう一つ見つからなかった場合、盾を外す index = @equip_type.index(1) change_equip(index, nil, test) if index end end when 1 # 盾 unless two_hands_legal? # 両手持ち違反の場合 index = @equip_type.index(0) change_equip(index, nil, test) if index end end end #-------------------------------------------------------------------------- # ● 装備の破棄 ※ 再定義 #-------------------------------------------------------------------------- def discard_equip(item) if item.is_a?(RPG::Weapon) for i in 0...@equip_type.size next unless @equip_type[i] == 0 if @equip_id[i] == item.id @equip_id[i] == 0 break end end elsif item.is_a?(RPG::Armor) for i in 0...@equip_type.size next if @equip_type[i] == 0 if @equip_id[i] == item.id @equip_id[i] == 0 break end end end end #-------------------------------------------------------------------------- # ● 両手装備合法判定 ※ 再定義 #-------------------------------------------------------------------------- def two_hands_legal? two_hand = 0 for weapon in weapons.compact do two_hand += 1 if weapon.two_handed end case two_hand when 0 ; return true # 両手武器を装備していない場合 when 2 ; return false # 両手武器を2つ装備している場合 end for i in 0...@equip_type.size next if @equip_type[i] > 1 return true unless equips[i] # 空いている手がある場合 end return false end #-------------------------------------------------------------------------- # ● 職業 ID の変更 ※ 再定義 #-------------------------------------------------------------------------- def class_id=(class_id) @class_id = class_id for i in 0...@equip_type.size # 装備できない装備品を外す change_equip(i, nil) unless equippable?(equips[i]) end end end #============================================================================== # ■ Window_EquipItem #============================================================================== class Window_EquipItem < Window_Item #-------------------------------------------------------------------------- # ● アイテムをリストに含めるかどうか ※ 再定義 #-------------------------------------------------------------------------- def include?(item) return true if item == nil return false if @actor.equip_type.size < @equip_type case @actor.equip_type[@equip_type] when 0 return false unless item.is_a?(RPG::Weapon) else return false unless item.is_a?(RPG::Armor) return false unless item.kind == @actor.equip_type[@equip_type] - 1 end return @actor.equippable?(item) end end #============================================================================== # ■ Window_Equip #============================================================================== class Window_Equip < Window_Selectable #-------------------------------------------------------------------------- # ● リフレッシュ ※ 再定義 #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] equip_text = [] for i in @actor.equip_type case i when 0 ; equip_text.push(Vocab::weapon) when 1 ; equip_text.push(Vocab::armor1) when 2 ; equip_text.push(Vocab::armor2) when 3 ; equip_text.push(Vocab::armor3) when 4 ; equip_text.push(Vocab::armor4) end end for item in @actor.equips do @data.push(item) end @item_max = @data.size create_contents for i in 0...equip_text.size self.contents.font.color = system_color self.contents.font.color.alpha = 255 self.contents.draw_text(4, WLH * i, 92, WLH, equip_text[i]) draw_item_name(@data[i], 92, WLH * i) end end end #============================================================================== # ■ Scene_Equip #============================================================================== class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # ● アイテムウィンドウの作成 ※ 再定義 #-------------------------------------------------------------------------- def create_item_windows @item_windows = [] for i in 0...Kazari::EQUIP_TYPE::MAX @item_windows[i] = Window_EquipItem.new(0, 208, 544, 208, @actor, i) @item_windows[i].help_window = @help_window @item_windows[i].visible = (@equip_index == i) @item_windows[i].y = 208 @item_windows[i].height = 208 @item_windows[i].active = false @item_windows[i].index = -1 end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの更新 ※ 再定義 #-------------------------------------------------------------------------- def update_item_windows for i in 0...Kazari::EQUIP_TYPE::MAX @item_windows[i].visible = (@equip_window.index == i) @item_windows[i].update end @item_window = @item_windows[@equip_window.index] end #-------------------------------------------------------------------------- # ● ステータスウィンドウの更新 ※ 再定義 #-------------------------------------------------------------------------- def update_status_window if @equip_window.active @status_window.set_new_parameters(nil, nil, nil, nil) elsif @item_window.active temp_actor = @actor.clone temp_actor.equip_id = @actor.equip_id.clone # 追加した temp_actor.change_equip(@equip_window.index, @item_window.item, true) new_atk = temp_actor.atk new_def = temp_actor.def new_spi = temp_actor.spi new_agi = temp_actor.agi @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi) end @status_window.update end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 攻撃アニメーションの表示 #-------------------------------------------------------------------------- alias equip_type_attack_animation display_attack_animation def display_attack_animation(targets) if @active_battler.is_a?(Game_Enemy) equip_type_attack_animation else actor = @active_battler aid = [] for i in 0...actor.weapon_size aid.push(actor.weapon_animation_id(i)) end for i in 0...aid.size mirror = i % 2 == 1 display_normal_animation(targets, aid[i], mirror) end wait_for_animation end end end #============================================================================== # ■ Window_ShopStatus #============================================================================== class Window_ShopStatus < Window_Base #-------------------------------------------------------------------------- # ● アクターが装備している一番弱い武器の取得 ※ 再定義 #-------------------------------------------------------------------------- def weaker_weapon(actor) weak = actor.weapons[0] for weapon in actor.weapons if weak == nil || weapon == nil return nil elsif weak.atk > weapon.atk weak = weapon end end return weak end end