#============================================================================== # お気に入り装備 ver1.00 #------------------------------------------------------------------------------ #[導入上の注意] # 特になし # #[基本動作] # 現在装備中のアイテムを「お気に入り」として登録し、 # 装備変更の際、登録した「お気に入り」を選択することで # 「お気に入り」に登録されている装備品を装備する。 # # 登録は「お気に入り」以外を選択中に INPUT で設定したキーを押すことでできます。 # 登録すると名前入力モードに移行します。 # #「お気に入り」選択中に設定項目の INPUT で設定したキーを押すと、 # アイテムの編集を行えます。 # 1つ目の項目で「内容の確認」 # 2つ目の項目で「名前の変更」 # 3つ目の項目で「説明文の変更」 # 4つ目の項目で「削除」 # を行うことができます。 # #[オススメスクリプト] # 名前や説明文の入力には「名前の入力」を流用しています。 # そのため、デフォルトでは ひらがな か カタカナ しか使用できません。 # なので、漢字入力のできるスクリプトを導入することをお勧めします。 # # 作成:ぶちょー # ホム:http://nyannyannyan.bake-neko.net/ # 著作:自分で作ったとか言わないで>< # 改造はご自由にどうぞ。 # リードミーとかに私の名前の載せたりするのは任意で。 #============================================================================== #============================================================================== # バージョンアップ情報 # ver1.00 公開 #============================================================================== #============================================================================== # 設定項目 #============================================================================== module Kazari module Favorite # 装備欄に表示する名前(武器とか盾とかのところ) NAME = "お気に" # お気に入り関係の処理を実行するキー INPUT = Input::A # お気に入り登録する際のコマンドの名前 TEXT1 = "お気に入り登録をする" TEXT2 = "登録しない" # 「お気に入り」を編集する際のコマンドの名前 TEXT3 = "内容を確認する" TEXT4 = "名前を変更する" TEXT5 = "説明文を変更する" TEXT6 = "削除する" # 登録できる名前の最大文字数 NAME_MAX = 8 # 登録できる説明文の最大文字数 DESC_MAX = 14 end end #============================================================================== # ここまで #============================================================================== #============================================================================== # ■ Window_Equip #============================================================================== class Window_Equip < Window_Selectable include Kazari::Favorite #-------------------------------------------------------------------------- # ● オブジェクト初期化 ※ 再定義 #-------------------------------------------------------------------------- def initialize(x, y, actor) super(x, y, 336, WLH * 6 + 32) @actor = actor refresh self.index = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ ※ 再定義 #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] for item in @actor.equips do @data.push(item) end @data.push(@actor.equip_favorite) # 追加した @item_max = @data.size self.contents.font.color = system_color if @actor.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) else self.contents.draw_text(4, WLH * 0, 92, WLH, Vocab::weapon) self.contents.draw_text(4, WLH * 1, 92, WLH, Vocab::armor1) end self.contents.draw_text(4, WLH * 2, 92, WLH, Vocab::armor2) self.contents.draw_text(4, WLH * 3, 92, WLH, Vocab::armor3) self.contents.draw_text(4, WLH * 4, 92, WLH, Vocab::armor4) self.contents.draw_text(4, WLH * 5, 92, WLH, NAME) # 追加した draw_item_name(@data[0], 92, WLH * 0) draw_item_name(@data[1], 92, WLH * 1) draw_item_name(@data[2], 92, WLH * 2) draw_item_name(@data[3], 92, WLH * 3) draw_item_name(@data[4], 92, WLH * 4) draw_item_name(@data[5], 92, WLH * 5) # 追加した end #-------------------------------------------------------------------------- # ● アイテム名の描画 ※ 再定義 # アイコンインデックが 0 の場合、名前を横にずらさない。 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil dx = 0 if item.icon_index != 0 draw_icon(item.icon_index, x, y, enabled) dx = 24 end self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(x + dx, y, 172, WLH, item.name) end end end #============================================================================== # ■ Window_EquipItem #============================================================================== class Window_EquipItem < Window_Item #-------------------------------------------------------------------------- # ● アイテムをリストに含めるかどうか ※ 再定義 #-------------------------------------------------------------------------- def include?(item) return true if item == nil if @equip_type == 0 return false unless item.is_a?(RPG::Weapon) elsif @equip_type < 5 # 変更した return false unless item.is_a?(RPG::Armor) return false unless item.kind == @equip_type - 1 else # 追加した return false unless item.is_a?(RPG::Favorite) return true end return @actor.equippable?(item) end #-------------------------------------------------------------------------- # ● リフレッシュ ※ 再定義 #-------------------------------------------------------------------------- def refresh @data = [] for item in $game_party.items + @actor.favorite # 変更した next unless include?(item) @data.push(item) if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id self.index = @data.size - 1 end end @data.push(nil) if include?(nil) @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 ※ 再定義 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] if item != nil unless item.is_a?(RPG::Favorite) # 変更した number = $game_party.item_number(item) rect.width -= 4 self.contents.draw_text(rect, sprintf(":%2d", number), 2) end enabled = enable?(item) draw_item_name(item, rect.x, rect.y, enabled) end end #-------------------------------------------------------------------------- # ● アイテムを許可状態で表示するかどうか ※ 再定義 #-------------------------------------------------------------------------- def enable?(item) if item.is_a?(RPG::Favorite) return @actor.equippable?(item) else return true end end #-------------------------------------------------------------------------- # ● アイテム名の描画 ※ 再定義 # アイコンインデックが 0 の場合、名前を横にずらさない。 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil dx = 0 if item.icon_index != 0 draw_icon(item.icon_index, x, y, enabled) dx = 24 end self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(x + dx, y, 172, WLH, item.name) end end end #============================================================================== # ■ Window_CommandFavorite #============================================================================== class Window_CommandFavorite < Window_Selectable include Kazari::Favorite #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(156, 168, 232, WLH * 2 + 32) # 画面中央に表示する self.index = 0 self.openness = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(type) self.contents.clear self.index = 0 case type when 0 @item_max = 2 self.height = WLH * 2 + 32 self.y = (416 - self.height) / 2 create_contents self.contents.draw_text(0, WLH * 0, 200, WLH, TEXT1) self.contents.draw_text(0, WLH * 1, 200, WLH, TEXT2) when 1 @item_max = 4 self.height = WLH * 4 + 32 self.y = (416 - self.height) / 2 create_contents self.contents.draw_text(0, WLH * 0, 200, WLH, TEXT3) self.contents.draw_text(0, WLH * 1, 200, WLH, TEXT4) self.contents.draw_text(0, WLH * 2, 200, WLH, TEXT5) self.contents.draw_text(0, WLH * 3, 200, WLH, TEXT6) end end end #============================================================================== # ■ Window_Favorite #============================================================================== class Window_Favorite < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) super(104, 114, 336, WLH * 6.5 + 32) # 画面中央に表示 @actor = actor self.openness = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(favorite) self.contents.clear self.contents.font.color = system_color self.contents.draw_text(0, WLH * 0, self.width - 32, WLH, favorite.name) if @actor.two_swords_style self.contents.draw_text(4, WLH * 1.5, 92, WLH, Vocab::weapon1) self.contents.draw_text(4, WLH * 2.5, 92, WLH, Vocab::weapon2) else self.contents.draw_text(4, WLH * 1.5, 92, WLH, Vocab::weapon) self.contents.draw_text(4, WLH * 2.5, 92, WLH, Vocab::armor1) end self.contents.draw_text(4, WLH * 3.5, 92, WLH, Vocab::armor2) self.contents.draw_text(4, WLH * 4.5, 92, WLH, Vocab::armor3) self.contents.draw_text(4, WLH * 5.5, 92, WLH, Vocab::armor4) y = WLH * 1.5 for item in favorite.items enable = has_item?(item) draw_item_name(item, 92, y, enable) y += WLH end end #-------------------------------------------------------------------------- # ● アイテムの所持判定 #-------------------------------------------------------------------------- def has_item?(item) return true if $game_party.has_item?(item) return true if item == nil for i in @actor.equips if i.is_a?(RPG::Weapon) && item.is_a?(RPG::Weapon) return true if i.id == item.id elsif i.is_a?(RPG::Armor) && item.is_a?(RPG::Armor) return true if i.id == item.id end end return false end #-------------------------------------------------------------------------- # ● アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil draw_icon(item.icon_index, x, y) self.contents.font.color = enabled ? normal_color : power_down_color self.contents.draw_text(x + 24, y, 172, WLH, item.name) end end end #============================================================================== # ■ Window_FavoriteNameEdit #============================================================================== class Window_FavoriteNameEdit < Window_NameEdit #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear name_array = @name.split(//) for i in 0...@max_char c = name_array[i] c = '_' if c == nil self.contents.draw_text(item_rect(i), c, 1) end end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new(0, 0, 0, 0) rect.x = (336 - @max_char * 24) / 2 + index * 24 rect.y = 36 rect.width = 24 rect.height = WLH return rect end #-------------------------------------------------------------------------- # ● アイテムセット #-------------------------------------------------------------------------- def set_item(item, name, max_char) @actor = item @name = name @max_char = max_char @default_name = name @index = name.split(//).size refresh end end #============================================================================== # ■ Scene_Equip #============================================================================== class Scene_Equip < Scene_Base include Kazari::Favorite #-------------------------------------------------------------------------- # ● 定数 #-------------------------------------------------------------------------- EQUIP_TYPE_MAX = 6 # 装備部位の数 #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias favorite_start start def start favorite_start @f_command_window = Window_CommandFavorite.new @f_command_window.active = false @favorite_window = Window_Favorite.new(@actor) @favorite_window.active = false @edit_window = Window_FavoriteNameEdit.new(@actor, NAME_MAX) @edit_window.active = false @edit_window.visible = false @input_window = Window_NameInput.new @input_window.visible = false @turn = 0 @force = false end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- alias favorite_terminate terminate def terminate favorite_terminate @f_command_window.dispose @favorite_window.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 ※ 再定義 #-------------------------------------------------------------------------- def update super update_menu_background @help_window.update update_equip_window update_status_window update_item_windows @f_command_window.update # 追加した @favorite_window.update # 追加した if @f_command_window.active # 追加した update_f_command_window elsif @favorite_window.active # 追加した update_favorite_window elsif @edit_window.active # 追加した update_edit_window elsif @equip_window.active update_equip_selection elsif @item_window.active update_item_selection end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの作成 ※ 再定義 #-------------------------------------------------------------------------- def create_item_windows @item_windows = [] for i in 0...EQUIP_TYPE_MAX @item_windows[i] = Window_EquipItem.new(0, 232, 544, 184, @actor, i) # 変更した @item_windows[i].help_window = @help_window @item_windows[i].visible = (@equip_index == i) @item_windows[i].y = 232 # 変更した @item_windows[i].height = 184 # 変更した @item_windows[i].active = false @item_windows[i].index = -1 end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの更新 ※ 再定義 #-------------------------------------------------------------------------- def update_item_windows for i in 0...EQUIP_TYPE_MAX @item_windows[i].visible = (@equip_window.index == i) @item_windows[i].update end @item_window = @item_windows[@equip_window.index] @item_window.visible = ! @force end #-------------------------------------------------------------------------- # ● 装備部位選択の更新 #-------------------------------------------------------------------------- alias favorite_update_equip_selection update_equip_selection def update_equip_selection @turn = 0 favorite_update_equip_selection if Input.trigger?(INPUT) if @equip_window.index == EQUIP_TYPE_MAX - 1 return if @equip_window.item == nil Sound.play_decision @f_command_window.refresh(1) @f_command_window.active = true @f_command_window.open @equip_window.active = false else Sound.play_decision @f_command_window.refresh(0) @f_command_window.active = true @f_command_window.open @equip_window.active = false end end end #-------------------------------------------------------------------------- # ● アイテム選択の更新 ※ 再定義 #-------------------------------------------------------------------------- def update_item_selection @turn = 1 if Input.trigger?(Input::B) Sound.play_cancel @equip_window.active = true @item_window.active = false @item_window.index = -1 elsif Input.trigger?(Input::C) if @actor.equippable?(@item_window.item) Sound.play_equip @actor.change_equip(@equip_window.index, @item_window.item) @equip_window.active = true @item_window.active = false @item_window.index = -1 @equip_window.refresh for item_window in @item_windows item_window.refresh end else Sound.play_buzzer end elsif Input.trigger?(INPUT) # 追加した if @equip_window.index == EQUIP_TYPE_MAX - 1 return if @item_window.item == nil Sound.play_decision @f_command_window.refresh(1) @f_command_window.active = true @f_command_window.open end end end #-------------------------------------------------------------------------- # ● お気に入りコマンドウィンドウの更新 #-------------------------------------------------------------------------- def update_f_command_window if @f_command_window.openness == 255 if Input.trigger?(INPUT) || Input.trigger?(Input::B) Sound.play_cancel @f_command_window.active = false @f_command_window.close if @turn == 0 @equip_window.active = true else @item_window.active = true end elsif Input.trigger?(Input::C) Sound.play_decision @f_command_window.active = false @f_command_window.close if @turn == 0 @equip_window.active = true else @item_window.active = true end if @equip_window.index == EQUIP_TYPE_MAX - 1 case @f_command_window.index when 0 # 内容確認 item = @turn == 0 ? @equip_window.item : @item_window.item @favorite_window.active = true @favorite_window.refresh(item) @favorite_window.open if @turn == 0 @equip_window.active = false else @item_window.active = false end when 1 # 名前変更 @item = @turn == 0 ? @equip_window.item : @item_window.item @edit_window.set_item(@item, @item.name, NAME_MAX) input_mode when 2 # 説明文変更 @item = @turn == 0 ? @equip_window.item : @item_window.item @edit_window.set_item(@item, @item.description, DESC_MAX) input_mode when 3 # 削除する item = @turn == 0 ? @equip_window.item : @item_window.item @actor.del_favorite(item.id) @item_window.refresh @equip_window.refresh end else case @f_command_window.index when 0 # 登録する @item = @actor.set_favorite @equip_window.refresh @item_windows[EQUIP_TYPE_MAX - 1].refresh @edit_window.set_item(@item, @item.name, NAME_MAX) input_mode end end end end end #-------------------------------------------------------------------------- # ● お気に入りウィンドウの更新 #-------------------------------------------------------------------------- def update_favorite_window if @favorite_window.openness == 255 if Input.trigger?(Input::B) Sound.play_cancel @favorite_window.active = false @favorite_window.close if @turn == 0 @equip_window.active = true else @item_window.active = true end elsif Input.trigger?(Input::C) Sound.play_decision @favorite_window.active = false @favorite_window.close if @turn == 0 @equip_window.active = true else @item_window.active = true end end end end #-------------------------------------------------------------------------- # ● 名前編集の更新 #-------------------------------------------------------------------------- def update_edit_window @edit_window.update @input_window.update if Input.repeat?(Input::B) if @edit_window.index > 0 # 文字位置が左端ではない Sound.play_cancel @edit_window.back end elsif Input.trigger?(Input::C) if @input_window.is_decision # カーソル位置が [決定] の場合 if @edit_window.name == "" # 名前が空の場合 @edit_window.restore_default # デフォルトの名前に戻す if @edit_window.name == "" Sound.play_buzzer else Sound.play_decision end else Sound.play_decision if @f_command_window.index == 2 @item.description = @edit_window.name # 説明文を変更 else @item.name = @edit_window.name # 名前を変更 end normal_mode end elsif @input_window.character != "" # 文字が空ではない場合 if @edit_window.index == @edit_window.max_char # 文字位置が右端 Sound.play_buzzer else Sound.play_decision @edit_window.add(@input_window.character) # 文字を追加 end end end end #-------------------------------------------------------------------------- # ● 名前編集モード #-------------------------------------------------------------------------- def input_mode @force = true @equip_window.visible = false @equip_window.active = false for i in 0...EQUIP_TYPE_MAX @item_windows[i].visible = false @item_windows[i].active = false end @item_window.visible = false @item_window.active = false @help_window.visible = false @status_window.visible = false @f_command_window.close @edit_window.active = true @edit_window.visible = true @input_window.visible = true end #-------------------------------------------------------------------------- # ● 通常モード #-------------------------------------------------------------------------- def normal_mode @item_window.refresh @item_windows[EQUIP_TYPE_MAX - 1].refresh @equip_window.refresh @force = false @equip_window.visible = true @equip_window.active = @turn == 0 update_item_windows @item_window.active = @turn == 1 @help_window.visible = true @status_window.visible = true @edit_window.active = false @edit_window.visible = false @input_window.visible = false end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :favorite attr_reader :favorite_id #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias favorite_setup setup def setup(actor_id) favorite_setup(actor_id) @favorite = [] @favorite_id = 0 end #-------------------------------------------------------------------------- # ● 装備可能判定 #-------------------------------------------------------------------------- alias favorite_equippable? equippable? def equippable?(item) return true if item == nil if item.is_a?(RPG::Favorite) return false unless has_item?(item.weapon) return false unless has_item?(item.armor1) return false unless has_item?(item.armor2) return false unless has_item?(item.armor3) return false unless has_item?(item.armor4) return true else favorite_equippable?(item) end end #-------------------------------------------------------------------------- # ● アイテムの所持判定 #-------------------------------------------------------------------------- def has_item?(item) return true if $game_party.has_item?(item) return true if item == nil for i in equips if i.is_a?(RPG::Weapon) && item.is_a?(RPG::Weapon) return true if i.id == item.id elsif i.is_a?(RPG::Armor) && item.is_a?(RPG::Armor) return true if i.id == item.id end end return false end #-------------------------------------------------------------------------- # ● 装備の破棄 ※ 再定義 #-------------------------------------------------------------------------- def discard_equip(item) if item.is_a?(RPG::Weapon) if @weapon_id == item.id @weapon_id = 0 @favorite_id = @favorite.size if item.id == equip_favorite.weapon.id elsif two_swords_style and @armor1_id == item.id @armor1_id = 0 @favorite_id = @favorite.size if item.id == equip_favorite.armor1.id end elsif item.is_a?(RPG::Armor) if not two_swords_style and @armor1_id == item.id @armor1_id = 0 @favorite_id = @favorite.size if item.id == equip_favorite.armor1.id elsif @armor2_id == item.id @armor2_id = 0 @favorite_id = @favorite.size if item.id == equip_favorite.armor2.id elsif @armor3_id == item.id @armor3_id = 0 @favorite_id = @favorite.size if item.id == equip_favorite.armor3.id elsif @armor4_id == item.id @armor4_id = 0 @favorite_id = @favorite.size if item.id == equip_favorite.armor4.id end end end #-------------------------------------------------------------------------- # ● 装備の変更 (オブジェクトで指定) #-------------------------------------------------------------------------- alias favorite_change_equip change_equip def change_equip(equip_type, item, test = false) if equip_type < 5 favorite_change_equip(equip_type, item, test) @favorite_id = @favorite.size else if item == nil @favorite_id = @favorite.size return end for i in 0..4 case i when 0 # 武器 favorite_change_equip(i, item.weapon, test) when 1 # 盾 favorite_change_equip(i, item.armor1, test) when 2 # 頭 favorite_change_equip(i, item.armor2, test) when 3 # 身体 favorite_change_equip(i, item.armor3, test) when 4 # 装飾品 favorite_change_equip(i, item.armor4, test) end end @favorite_id = item.id end end #-------------------------------------------------------------------------- # ● 現在装備中のお気に入り装備 #-------------------------------------------------------------------------- def equip_favorite return @favorite[@favorite_id] end #-------------------------------------------------------------------------- # ● お気に入り装備の登録 #-------------------------------------------------------------------------- def set_favorite @favorite.push(RPG::Favorite.new(self)) @favorite[@favorite.size - 1].id = @favorite.size - 1 equip_favorite return @favorite[@favorite.size - 1] end #-------------------------------------------------------------------------- # ● お気に入り装備の削除 #-------------------------------------------------------------------------- def del_favorite(id) @favorite[id] = nil @favorite.compact! for i in id...@favorite.size @favorite[i].id -= 1 end if @favorite_id == id @favorite_id = @favorite.size end end end #============================================================================== # ■ RPG::Favorite #============================================================================== class RPG::Favorite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :name attr_accessor :id attr_accessor :icon_index attr_accessor :description attr_accessor :weapon attr_accessor :armor1 attr_accessor :armor2 attr_accessor :armor3 attr_accessor :armor4 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) @name = "お気に入り" @id = 0 @icon_index = 0 @description = "" @weapon = actor.equips[0] @armor1 = actor.equips[1] @armor2 = actor.equips[2] @armor3 = actor.equips[3] @armor4 = actor.equips[4] end #-------------------------------------------------------------------------- # ● 装備品オブジェクトの配列取得 #-------------------------------------------------------------------------- def items return [@weapon, @armor1, @armor2, @armor3, @armor4] end #-------------------------------------------------------------------------- # ● 名前の登録 #-------------------------------------------------------------------------- def name=(name) @name = name end #-------------------------------------------------------------------------- # ● IDの登録 #-------------------------------------------------------------------------- def id=(id) @id = id end #-------------------------------------------------------------------------- # ● 説明文の登録 #-------------------------------------------------------------------------- def description=(description) @description = description end end