# ▽△▽ XRXSv17. MeLT_Equip. アーマーアレンジVX ▽△▽ # # publish 2010/ 3/15 # update - 11/ 1/ 8c # #============================================================================== # カスタマイズポイント:用語 #============================================================================== module Vocab EquipOff = "はずす" end #============================================================================== # カスタマイズポイント #============================================================================== class Scene_Equip < Scene_Base # # 3箇所目以降の装備部位 ( 2:頭 3:胴体 4:装飾 ) # EQUIP_TYPES = [2,3,4,4] end module XRXSV17 # # 装備リストの表示行数(VX標準:5) # EQUIP_LIST_LINES = 6 # # [一括設定] 全員二刀流可能にする? # (これにより、初期装備が盾の二刀流 が表現可能です) # TwoWeaponsForAll = false # # 6箇所目以降の装備名称(5箇所以内の場合この設定は無視されます) # EquipNames = ["装飾2", "装飾3","装飾4"] # # 装備品リストの背景に使用するウィンドウスキン # EquipSkin = "Window" end #============================================================================== # MeLT_Shop試着アイテム文字色の取得 #============================================================================== class Window_Base < Window def rental_color return text_color(3) end end #============================================================================== # 設定 #============================================================================== class Scene_Equip < Scene_Base EQUIP_TYPES = [0,1] + EQUIP_TYPES EQUIP_TYPE_MAX = EQUIP_TYPES.size end #============================================================================== # 二刀流対応 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● オプション [二刀流] の取得 * #-------------------------------------------------------------------------- alias two_swords_equippable two_swords_style attr_accessor :two_swords_style def two_swords_style @two_swords_style = self.actor.two_swords_style if @two_swords_style == nil return @two_swords_style end if XRXSV17::TwoWeaponsForAll def two_swords_equippable return true end end end #============================================================================== # 5番目以降の防具への対応 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 防具オブジェクトの配列取得 [再定義] #-------------------------------------------------------------------------- def armors result = [] set = self.armor_ids if self.two_swords_style set = set[1, set.size - 1] end for armor_id in set result.push($data_armors[armor_id.to_i]) end return result end #-------------------------------------------------------------------------- # 防具ID配列の取得 #-------------------------------------------------------------------------- def armor_ids @armor_ids = [] unless @armor_ids @armor_ids[0] = @armor1_id @armor_ids[1] = @armor2_id @armor_ids[2] = @armor3_id @armor_ids[3] = @armor4_id return @armor_ids end def armor_ids=(armor_ids) @armor_ids = armor_ids end #-------------------------------------------------------------------------- # ● 装備の変更 (オブジェクトで指定) #-------------------------------------------------------------------------- alias xrxsv17_change_equip change_equip def change_equip(equip_type, item, test = false) equip_index = equip_type # 判定を保持 result = true unless test result = false if $game_party.item_number(item) == 0 if item != nil end # 呼び戻す xrxsv17_change_equip(equip_index, item, test) # 後判定 return unless result # item_id = item == nil ? 0 : item.id if equip_index >= 5 self.armor_ids = self.armor_ids.dup if test self.armor_ids[equip_index - 1] = item_id end end #-------------------------------------------------------------------------- # ● 装備の破棄 #-------------------------------------------------------------------------- alias xrxsv17_discard_equip discard_equip def discard_equip(item) if item.is_a?(RPG::Armor) last_ids = [@armor1_id, @armor2_id, @armor3_id, @armor4_id] end xrxsv17_discard_equip(item) if item.is_a?(RPG::Armor) and (last_ids[0] = @armor1_id and last_ids[1] = @armor2_id and last_ids[2] = @armor3_id and last_ids[3] = @armor4_id) # 防具の破棄が発生しなかった場合。 # 追加防具の破棄 if item.is_a?(RPG::Armor) for i in 4...self.armor_ids.size armor_id = self.armor_ids[i] if armor_id == item.id self.armor_ids[i] = 0 break end end end end end end #============================================================================== # クラス変更時の装備解除 #============================================================================== class Game_Actor < Game_Battler alias xrxsv17_class_id_substitute class_id= def class_id=(class_id) xrxsv17_class_id_substitute(class_id) for i in 5...Scene_Equip::EQUIP_TYPE_MAX change_equip(i, nil) unless equippable?(equips[i]) end end end #============================================================================== # マテリアルバッグ機能 #============================================================================== class Game_Party < Game_Unit def bag @bag ||= [] return @bag end end class Game_Actor < Game_Battler def bag @bag ||= [] return @bag end end #============================================================================== # ピクチャへの対応 #============================================================================== class Scene_Base def create_picture end def dispose_picture end end #============================================================================== # 拡張ヘルプ対応 #============================================================================== class Window_HelpEX < Window_Help def set(item) self.set_text(item == nil ? "" : item.description) end end #============================================================================== # 試着アイテム管理 #============================================================================== class Game_Temp attr_accessor :shop_fitting_items end #============================================================================== # ■ Scene_Equip #============================================================================== class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super @actor = $game_party.members[@actor_index] create_menu_background create_main_windows create_item_windows create_picture if @actorpicture_sprite != nil @item_window.openness = 0 end if @menuback2_sprite != nil @status_window.opacity = 0 end end #-------------------------------------------------------------------------- # 各種ウィンドウの作成 #-------------------------------------------------------------------------- def create_main_windows y = Graphics.height - 24 * 5 - 32 - 56 @actorstatus_window = Window_SkillStatus.new(0, 0, @actor) @status_window = Window_SetStatus.new(0, y, @actor) @equip_window = Window_Equip.new(0, 56, @actor) @equip_window.index = @equip_index @help_window = Window_HelpEX.new @help_window.y = Graphics.height - @help_window.height #@help_window.visible = false @equip_window.help_window = @help_window @equip_window_last_index = -2 end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @help_window.dispose @equip_window.dispose @status_window.dispose @actorstatus_window.dispose dispose_picture dispose_item_windows end #-------------------------------------------------------------------------- # ● アイテムウィンドウの作成 #-------------------------------------------------------------------------- def create_item_windows n = EQUIP_TYPES[@equip_index] @item_window = Window_EquipTotalItems.new(@actor) style = @actor.two_swords_style @actor.two_swords_style = false @item_window.set_equip_type(n) @actor.two_swords_style = style @item_window.active = false #@item_window.x = Graphics.width @item_window.index = -1 @item_window.help_window = @help_window @item_windows = [@item_window] end #-------------------------------------------------------------------------- # ● アイテムウィンドウの更新 #-------------------------------------------------------------------------- def update_item_windows @item_window.update 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 if @equip_window.index == 1 and temp_actor.two_swords_equippable temp_actor.two_swords_style = @item_window.item.is_a?(RPG::Weapon) end temp_actor.change_equip(@equip_window.index, @item_window.item, true) @status_window.set_new_actor(temp_actor) end @status_window.update end #-------------------------------------------------------------------------- # ● 装備部位選択の更新 #-------------------------------------------------------------------------- def update_equip_selection if @equip_window_last_index != @equip_window.index @equip_window_last_index = @equip_window.index n = EQUIP_TYPES[@equip_window.index] style = @actor.two_swords_style @actor.two_swords_style = false @item_window.set_equip_type(n) @actor.two_swords_style = style end if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::A) Sound.play_cursor go_status_scene elsif Input.trigger?(Input::R) Sound.play_cursor next_actor elsif Input.trigger?(Input::L) Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) if @actor.fix_equipment Sound.play_buzzer else Sound.play_decision @equip_window.active = false @item_window.active = true @item_window.index = 0 @item_window.open if @actorpicture_sprite end end end #-------------------------------------------------------------------------- # ● アイテム選択の更新 #-------------------------------------------------------------------------- def update_item_selection if Input.trigger?(Input::B) Sound.play_cancel end_item_selection elsif Input.trigger?(Input::C) Sound.play_equip # 二刀流対応のため、解除→新装着を分割する* # 解除 @actor.change_equip(@equip_window.index, nil) # 装着 if @equip_window.index == 1 and @actor.two_swords_equippable @actor.two_swords_style = @item_window.item.is_a?(RPG::Weapon) end @actor.change_equip(@equip_window.index, @item_window.item) @actor.class_id = @actor.class_id #* @equip_window.refresh @item_window.refresh @actorpicture_sprite.refresh if @actorpicture_sprite @actorstatus_window.refresh end_item_selection end end #-------------------------------------------------------------------------- # アイテム選択の終了 #-------------------------------------------------------------------------- def end_item_selection @equip_window.active = true @item_window.active = false @item_window.index = -1 @item_window.close if @actorpicture_sprite != nil end #-------------------------------------------------------------------------- # ステータス画面へ #-------------------------------------------------------------------------- def go_status_scene $scene = Scene_Status.new(@actor_index) end end #============================================================================== # 装備品リストウィンドウ #============================================================================== class Window_Equip < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, actor) @clear_style = ((XRXSV10::BG_NAME rescue "").size >= 1) width = 320 height = 32 + XRXSV17::EQUIP_LIST_LINES * WLH if @clear_style h = WLH * Scene_Equip::EQUIP_TYPE_MAX x -= 16 width += 16 end super(x, y, width, height) @actor = actor @backskin = Cache.system(XRXSV17::EquipSkin) @item_max = Scene_Equip::EQUIP_TYPE_MAX create_contents refresh self.index = 0 if @clear_style self.opacity = 0 end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear if @clear_style draw_rect = Rect.new(0, 0, self.contents.width, self.contents.height) skin_rect = Rect.new(0, 16, 64, 32) self.contents.stretch_blt(draw_rect, @backskin, skin_rect, 96) skin_rect = Rect.new(0, 64, 64, 64) self.contents.stretch_blt(draw_rect, @backskin, skin_rect, 160) end vocabs = [] if @actor.two_swords_equippable vocabs.push(Vocab::weapon1) vocabs.push(Vocab::weapon2) else vocabs.push(Vocab::weapon) vocabs.push(Vocab::armor1) end vocabs += [Vocab::armor2, Vocab::armor3, Vocab::armor4] for name in XRXSV17::EquipNames vocabs.push(name) end self.contents.font.color = system_color for i in 0...Scene_Equip::EQUIP_TYPE_MAX self.contents.draw_text(12, WLH * i, 64, WLH, vocabs[i].to_s) end # @data = [] equips = @actor.equips for i in 0...Scene_Equip::EQUIP_TYPE_MAX @data[i] = equips[i] item = @data[i] draw_item_name(item, 12 + 64, WLH * i) end end #-------------------------------------------------------------------------- # アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil w = self.contents.width - 128 width = [self.contents.text_size(item.name).width+2, w].min draw_icon(item.icon_index, x, y, enabled) rental = $game_temp.shop_fitting_include?(item) self.contents.font.color = (rental ? rental_color : normal_color) self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(x + 24, y, width, WLH, item.name) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set(item) end end #============================================================================== # 総合装備アイテムウィンドウ #============================================================================== class Window_EquipTotalItems < Window_Item #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) @contents_cache = [] @data_cache = [] @equip_type = 0 @actor = actor super(320, 56, 224, 304) self.x = Graphics.width - self.width @column_max = 1 self.z += 2 refresh end #-------------------------------------------------------------------------- # 解放とキャッシュ機能 #-------------------------------------------------------------------------- def dispose super for cache in @contents_cache.compact cache.dispose end @contents_cache.clear end #-------------------------------------------------------------------------- # 装備種別のセット #-------------------------------------------------------------------------- def set_equip_type(equip_type) if equip_type == 1 and @actor.two_swords_equippable # 二刀流可能なら equip_type = 5 # 盾を「武器・盾」に変更 end @equip_type = equip_type cache = @contents_cache[@equip_type] if cache self.contents = cache @data = @data_cache[@equip_type] @item_max = @data.size else self.contents = Bitmap.new(16,16) refresh end end #-------------------------------------------------------------------------- # ▽ リフレッシュ #-------------------------------------------------------------------------- def refresh case @equip_type when 0,1,5 set = [0,1,5] else set = [@equip_type] end for i in set if @contents_cache[i] @contents_cache[i].dispose @contents_cache[i] = nil end end # ※(RGGS2)二刀流状態だと盾装備不可と判定される # そのために二刀流状態を一時退避して refresh する。 b = @actor.two_swords_style @actor.two_swords_style = false super @actor.two_swords_style = b # @contents_cache[@equip_type] = self.contents @data_cache[@equip_type] = @data end #-------------------------------------------------------------------------- # ▽ アイテムをリストに含めるかどうか #-------------------------------------------------------------------------- def include?(item) return true if item == nil case @equip_type when 0 return false unless item.is_a?(RPG::Weapon) when 5 return false if (item.is_a?(RPG::Armor) and (item.kind >= 1)) else return false unless item.is_a?(RPG::Armor) return false unless item.kind == @equip_type - 1 end return @actor.equippable?(item) end #-------------------------------------------------------------------------- # ▽ 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] rect.width -= 4 if item != nil number = $game_party.item_number(item) enabled = enable?(item) draw_item_name(item, rect.x, rect.y, enabled) self.contents.draw_text(rect, sprintf(":%2d", number), 2) else self.contents.font.color = normal_color self.contents.draw_text(rect.x + 24, rect.y, 140, WLH, Vocab::EquipOff) end end #-------------------------------------------------------------------------- # ▽ アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(item) return true end #-------------------------------------------------------------------------- # ▽ アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil width = [self.contents.text_size(item.name).width+2, 140].min #width = width * ($game_system.wide_screen ? 3 : 4) / 4 draw_icon(item.icon_index, x, y, enabled) rental = $game_temp.shop_fitting_include?(item) self.contents.font.color = (rental ? rental_color : normal_color) self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(x + 24, y, width, WLH, item.name) end end #-------------------------------------------------------------------------- # ▽ ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set(item) end end #============================================================================== # レンタルアイテム判定 #============================================================================== class Game_Temp def shop_fitting_include?(item) rental = false if self.shop_fitting_items for rental_item in self.shop_fitting_items if rental_item == item or ((item.materialized? and (rental_item == item.material.original_item)) rescue false) rental = true break end end end return rental end end #============================================================================== # 基本イクイップステータスの拡張 #============================================================================== class Window_EquipStatus < Window_Base def initialize(x, y, actor) super(x, y, 320, WLH * 5 + 32) @actor = actor refresh end def set_new_actor(actor) if actor set_new_parameters(actor.atk, actor.def, actor.spi, actor.agi) else set_new_parameters(nil, nil, nil, nil) end end end #============================================================================== # ステータスセットウィンドウ #============================================================================== class Window_SetStatus < Window_EquipStatus end