# ▼▲▼ XAS.「Zボタンチェンジ」 ▼▲▼ # # # #============================================================================== # カスタマイズポイント #============================================================================== module XAS_Z # # アクション切り替えボタン # ACTION_CHANGE_BUTTON = Input::Z # # アクションタイプを保持する変数ID (Yボタンのそれと一致させる) # ACTION_VARIABLE_ID = 2 # # アクションID=>アイコン 関連付け # ACTION_ICON = { 2=>"Goods2", 3=>"Goods3", 4=>"Goods4", 5=>"Goods5", 21=>"Item1", 22=>"Item2", 23=>"Item3", 24=>"Item4", 25=>"Item5", 26=>"Item6" } # # 表示スイッチID # SWITCH_ID = 5 # # 表示位置 # X = 246 Y = 436 end #============================================================================== # --- パーティグッズ --- #============================================================================== class Game_Party def goods @goods = [] if @goods == nil return @goods end def gain_goods(action_id) @goods = [] if @goods == nil @goods.push(action_id) unless @goods.include?(action_id) end end #============================================================================== # --- XRXS. アクションアタッチメント機構 --- #============================================================================== module XAS_ACTION #-------------------------------------------------------------------------- # ○ 飛び道具の発射 (発生) #-------------------------------------------------------------------------- alias xas_z_shoot_bullet shoot_bullet def shoot_bullet(action_id) # 呼び戻す bullet_token = xas_z_shoot_bullet(action_id) # 道具の再描画 $scene.refresh_goods if bullet_token # return bullet_token end end #============================================================================== # --- Z ボタンチェンジ --- #============================================================================== class Scene_Map alias xrxs64_zc_main main def main @action_change = Spriteset_ActionChange.new if $game_switches[XAS_Z::SWITCH_ID] @action_change.show(nil, $game_variables[XAS_Z::ACTION_VARIABLE_ID], nil) end # 呼び戻す xrxs64_zc_main # スプライトの解放 @action_change.dispose if @action_change != nil end alias xrxs64_zc_update update def update # 呼び戻す xrxs64_zc_update # 非表示の場合は終了 unless $game_switches[XAS_Z::SWITCH_ID] return @action_change.visible = false end # スプライトの更新 @action_change.update # Y ボタンが押された場合 if Input.trigger?(XAS_Z::ACTION_CHANGE_BUTTON) # イベント実行中、メッセージウィンドウ表示中のいずれでもない場合 unless $game_system.map_interpreter.running? or $game_temp.message_window_showing # 現在のアクションIDの取得 action_id2 = $game_variables[XAS_Z::ACTION_VARIABLE_ID] # 使用可能グッズの取得 goods = $game_party.goods # 使えるグッズが無い場合 return if goods.size == 0 # 次のアクションIDの取得 index = (goods.index(action_id2).to_i + 1) % goods.size action_id3 = goods[index] # アクションを切り替え $game_variables[XAS_Z::ACTION_VARIABLE_ID] = action_id3 # スプライトの表示 @action_change.show(nil, action_id2, action_id3) @action_change.left_slide end end end #-------------------------------------------------------------------------- # ● プレイヤーの場所移動 #-------------------------------------------------------------------------- alias xrxs64_zc_transfer_player transfer_player def transfer_player xrxs64_zc_transfer_player # 可視状態 if $game_switches[XAS_Z::SWITCH_ID] @action_change.show(nil, $game_variables[XAS_Z::ACTION_VARIABLE_ID], nil) end end #-------------------------------------------------------------------------- # ○ グッズ表示のリフレッシュ #-------------------------------------------------------------------------- def refresh_goods @action_change.refresh if @action_change != nil end end #============================================================================== # □ Spriteset_ActionChange #============================================================================== class Spriteset_ActionChange #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @x = XAS_Z::X @y = XAS_Z::Y @icons = [] @action_ids = [nil, nil, nil] @font = Font.new @font.name = "Comic Sans MS" @font.size = 22 @font.bold = true self.clear @leftslide_duration = 0 @show_duration = 0 @fadeout_duration = 0 end #-------------------------------------------------------------------------- # ○ 解放と生成 #-------------------------------------------------------------------------- def dispose @icons.each {|sprite| sprite.dispose} @window.dispose if @window != nil @numbers.dispose if @numbers != nil end def clear self.dispose @window = Window_Base.new(@x, @y, 26, 26) @window.visible = false @window.back_opacity = 160 @window.z = 500 for i in 0..2 @icons[i] = Sprite.new @icons[i].z = 501 end @numbers = Spriteset_Numbers.new(@font) @numbers.visible = false @numbers.x = @x + 12 @numbers.y = @y + 12 @numbers.z = 502 end #-------------------------------------------------------------------------- # ○ 表示 #-------------------------------------------------------------------------- def show(action_id1, action_id2, action_id3) self.clear @window.visible = true @action_ids = [action_id1, action_id2, action_id3] for i in 0..2 icon_name = XAS_Z::ACTION_ICON[@action_ids[i]] if icon_name != nil @icons[i].bitmap = RPG::Cache.icon(icon_name) @icons[i].x = @x + (i - 1) * 48 @icons[i].y = @y + 16 - (i % 2) * 16 @icons[i].opacity = 96 + (i % 2) * 160 @icons[i].visible = true else @icons[i].bitmap = nil end end @show_duration = (action_id3 == nil ? 0 : 60) @leftslide_duration = 0 @fadeout_duration = (action_id3 == nil ? 12 : 0) @numbers.visible = self.need_number? @numbers.n = $game_party.item_number(self.item_id) if @numbers.visible end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh self.show(*@action_ids) end #-------------------------------------------------------------------------- # ○ 左スライド #-------------------------------------------------------------------------- def left_slide @leftslide_duration = 8 end #-------------------------------------------------------------------------- # ○ 可視状態の設定 #-------------------------------------------------------------------------- def visible=(b) @window.visible = b @icons.each{|sprite| sprite.visible = b } @numbers.visible = (b and need_number?) end #-------------------------------------------------------------------------- # ○ 現在のグッズが数字を必要とするか? #-------------------------------------------------------------------------- def need_number? return (self.item_id != nil) end def item_id return XAS::ITEM_COST[@action_ids[1]] end #-------------------------------------------------------------------------- # ○ フレーム更新 #-------------------------------------------------------------------------- def update # 左スライド if @leftslide_duration > 0 @leftslide_duration -= 1 @icons[0].opacity = @leftslide_duration * 20 @icons[1].x = @x - 48 + @leftslide_duration * 6 @icons[1].y = @y + 16 - @leftslide_duration * 2 @icons[1].opacity = @leftslide_duration * 20 + 96 @icons[2].x = @x + 48 - (8 - @leftslide_duration) * 6 @icons[2].y = @y + 16 - (8 - @leftslide_duration) * 2 @icons[2].opacity = (8 - @leftslide_duration) * 20 + 96 if @leftslide_duration == 0 show(@action_ids[1], @action_ids[2], nil) end return end # 一番目の自動フェードアウト if @icons[0].visible @icons[0].x += 2 @icons[0].opacity -= 22 @icons[0].visible = false if @icons[0].opacity == 0 return end end end