# ▼▲▼ メルト・アイテム マテリアルカンパス ▼▲▼ # # update 2006/ 5/19 # #============================================================================== # カスタマイズポイント #============================================================================== module XRXS_MeLT_Item # # 背景設定 # SHOW_MAP = true # 背景にマップを表示 BG = "ItemBack" # 背景画像 (Titles) BG_OPACITY = 224 # 背景不透明度 # # 縁取り色 # HEMCOLOR = Color.new(80,80,0,255) # # 表示トランジション # TRANS_TIME = 16 TRANS_NAME = "Graphics/Transitions/016-Diamond02" end #============================================================================== # ■ Scene_Item #============================================================================== class Scene_Item #-------------------------------------------------------------------------- # ○ ウィンドウの作成 #-------------------------------------------------------------------------- def make_windows @bg_sprite = Spriteset_Map.new if XRXS_MeLT_Item::SHOW_MAP sprite = Sprite.new sprite.bitmap = RPG::Cache.title(XRXS_MeLT_Item::BG) sprite.z = 1 sprite.opacity = XRXS_MeLT_Item::BG_OPACITY @sprites.push(sprite) end def dispose_windows @bg_sprite.dispose if @bg_sprite != nil end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # アイテムウィンドウを作成 @item_window = Window_MenuItem.new @help_window = Window_ItemHelp.new @target_window = Window_Target.new @item_window.help_window = @help_window @slideout_count = 0 @slidewait_count = 0 # 追加ウィンドウの作成 @windows = [@item_window, @help_window, @target_window] @sprites = [] make_windows # トランジション実行 Graphics.transition(XRXS_MeLT_Item::TRANS_TIME, XRXS_MeLT_Item::TRANS_NAME) # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @windows.each{|window| window.dispose } @sprites.each{|sprite| sprite.dispose } dispose_windows end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @windows.each{|window| window.update } @sprites.each{|sprite| sprite.update } # スライドウェイト if @slidewait_count > 0 @slidewait_count -= 1 return end # スライドアウト if @slideout_count > 0 @slideout_count -= 1 if @slideout_count == 0 # メニュー画面に切り替え $scene = Scene_Menu.new(0) end return end # アイテムウィンドウがアクティブの場合: update_item を呼ぶ if @item_window.active update_item return end # ターゲットウィンドウがアクティブの場合: update_target を呼ぶ if @target_window.active update_target return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アイテムウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_item # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # @slideout_count = 5 @help_window.slideout! @target_window.slideout! return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アイテムウィンドウで現在選択されているデータを取得 @item = @item_window.item # 使用アイテムではない場合 unless @item.is_a?(RPG::Item) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 使用できない場合 unless $game_party.item_can_use?(@item.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 効果範囲が味方の場合 if @item.scope >= 3 @slidewait_count = 5 # ターゲットウィンドウをアクティブ化 @item_window.active = false @help_window.slideout! @target_window.visible = true @target_window.active = true @target_window.index = 0 @target_window.slidein! # 効果範囲 (単体/全体) に応じてカーソル位置を設定 if @item.scope == 4 || @item.scope == 6 @target_window.index = -1 else @target_window.index = 0 end # 効果範囲が味方以外の場合 else # コモンイベント ID が有効の場合 if @item.common_event_id > 0 # コモンイベント呼び出し予約 $game_temp.common_event_id = @item.common_event_id # アイテムの使用時 SE を演奏 $game_system.se_play(@item.menu_se) # 消耗品の場合 if @item.consumable # 使用したアイテムを 1 減らす $game_party.lose_item(@item.id, 1) # アイテムウィンドウの項目を再描画 @item_window.draw_item(@item_window.index) end # マップ画面に切り替え $scene = Scene_Map.new return end end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ターゲットウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_target # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # アイテム切れなどで使用できなくなった場合 unless $game_party.item_can_use?(@item.id) # アイテムウィンドウの内容を再作成 @item_window.refresh end # ターゲットウィンドウを消去 @item_window.active = true @target_window.visible = false @target_window.active = false @help_window.slidein! @target_window.slideout! @slidewait_count = 5 return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アイテムを使い切った場合 if $game_party.item_number(@item.id) == 0 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # ターゲットが全体の場合 if @target_window.index == -1 # パーティ全体にアイテムの使用効果を適用 used = false for i in $game_party.actors used |= i.item_effect(@item) end end # ターゲットが単体の場合 if @target_window.index >= 0 # ターゲットのアクターにアイテムの使用効果を適用 target = $game_party.actors[@target_window.index] used = target.item_effect(@item) end # アイテムを使った場合 if used # アイテムの使用時 SE を演奏 $game_system.se_play(@item.menu_se) # 消耗品の場合 if @item.consumable # 使用したアイテムを 1 減らす $game_party.lose_item(@item.id, 1) # アイテムウィンドウの項目を再描画 @item_window.draw_item(@item_window.index) end # ターゲットウィンドウの内容を再作成 @target_window.refresh # 全滅の場合 if $game_party.all_dead? # ゲームオーバー画面に切り替え $scene = Scene_Gameover.new return end # コモンイベント ID が有効の場合 if @item.common_event_id > 0 # コモンイベント呼び出し予約 $game_temp.common_event_id = @item.common_event_id # マップ画面に切り替え $scene = Scene_Map.new return end end # アイテムを使わなかった場合 unless used # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end return end end end #============================================================================== # □ Window_MenuItem #============================================================================== class Window_MenuItem < Window_Selectable #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(8, 0, 288, 480) @column_max = 1 self.opacity = 0 refresh self.index = 0 end #-------------------------------------------------------------------------- # ○ アイテムの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # アイテムを追加 for i in 1...$data_items.size if $game_party.item_number(i) > 0 @data.push($data_items[i]) end end # 戦闘中以外なら武器と防具も追加 unless $game_temp.in_battle for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.size = 18 for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id) #self.contents.font.color = normal_color self.contents.font.color = Color.new(80,64,0,255) opacity = 255 else self.contents.font.color = Color.new(80,64,0,128) opacity = 128 end x = 0 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 172, 32, item.name, 0) self.contents.draw_text(x + 208, y, 16, 32, ":", 1) self.contents.draw_text(x + 224, y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set(self.item) end end # ▼▲▼ メルト・アイテム プラグインA1 : メモランダム ▼▲▼ # # update 2006/ 5/18 # #============================================================================== # アイテムの説明文に改行機能を搭載 #============================================================================== module RPG class Item def description return @description.gsub(/\\n/) {""} end def description_lines return @description.split(/\\n/) end end end module RPG class Weapon def description return @description.gsub(/\\n/) {""} end def description_lines return @description.split(/\\n/) end end class Armor def description return @description.gsub(/\\n/) {""} end def description_lines return @description.split(/\\n/) end end end #============================================================================== # □ Window_ItemHelp #============================================================================== class Window_ItemHelp < Window_Base #-------------------------------------------------------------------------- # --- ウィンドウスライディングを搭載 --- #-------------------------------------------------------------------------- include XRXS_WindowSliding #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(320 + 32, 32, 320, 288) self.opacity = 0 @slide_x_speed = -8 # コンテンツキャッシュ機構 @contents_cache = {} end def set(item) # アイテムが無いときはクリアして終了 return self.contents = nil if item == nil # if @contents_cache[item] == nil bitmap = Bitmap.new(width - 32, height - 32) icon = RPG::Cache.icon(item.icon_name) bitmap.blt(0,0,icon, icon.rect) bitmap.font.size = 20 bitmap.draw_hemming_text(28, 2, 160, 20, item.name, 0, XRXS_MeLT_Item::HEMCOLOR) bitmap.font.size = 18 bitmap.font.bold = true descriptions = item.description_lines for i in 0..8 text = descriptions[i] break if text.nil? bitmap.draw_hemming_text(16, 32 + 24 * i, 272, 24, text, 0, XRXS_MeLT_Item::HEMCOLOR) end @contents_cache[item] = bitmap end self.contents = @contents_cache[item] end def slidein! @slidein_count = 4 @slideout_count = 0 end def dispose @contents_cache.values.each{|bitmap| bitmap.dispose } super end end # ▼▲▼ メルト・アイテム プラグインB1 : ターゲットリスト ▼▲▼ # # update 2006/ 5/19 # #============================================================================== # ■ Window_Target #============================================================================== class Window_Target < Window_Selectable #-------------------------------------------------------------------------- # --- ウィンドウスライディングを搭載 --- #-------------------------------------------------------------------------- include XRXS_WindowSliding #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize max = $game_party.actors.size super(320 + 32, 32, 348, [max, 6].min * 48 + 32) @column_max = 1 @item_max = max @slide_x_speed = -8 self.opacity = 0 self.visible = false self.active = false self.contents = Bitmap.new(width - 32, max * 48) refresh end def refresh self.contents.clear for i in 0...@item_max actor = $game_party.actors[i] hp_s = $data_system.words.hp + " " + actor.hp.to_s + " / " + actor.maxhp.to_s sp_s = $data_system.words.sp + " " + actor.sp.to_s + " / " + actor.maxsp.to_s self.contents.font.color = normal_color self.contents.font.bold = true self.contents.font.size = 14 self.contents.draw_hemming_text(4, i * 48 + 4, 64, 32, actor.name, 1, XRXS_MeLT_Item::HEMCOLOR) self.contents.font.size = 18 self.contents.draw_hemming_text(80, i * 48 + 2, 128, 22, hp_s, 0, XRXS_MeLT_Item::HEMCOLOR) self.contents.draw_hemming_text(80, i * 48 + 24, 128, 22, sp_s, 0, XRXS_MeLT_Item::HEMCOLOR) state_icon_names = [] for state_id in actor.states.sort icon_name = XRXS_MeLT::STATE_ICON[state_id] if icon_name != nil state_icon_names.push(icon_name) end end if state_icon_names.empty? self.contents.font.color = Color.new(64,64,16,255) self.contents.font.bold = false self.contents.font.size = 16 self.contents.draw_text(204 + 16, i * 48 + 12, 64, 24, "Lv." + actor.level.to_s) else ix = 204 for icon_name in state_icon_names icon = RPG::Cache.icon(icon_name) self.contents.blt(ix, i * 48 + 12, icon, icon.rect) ix += 24 end end end end def slidein! self.x = 352 self.contents_opacity = 0 @slidein_count = 4 @slideout_count = 0 end def update_cursor_rect if self.index == -1 self.cursor_rect.empty else self.cursor_rect.set(0, self.index * 48 + 1, 316, 46) end end end