#============================================================================== # ★ スキル・アイテム画面コモン ver1.0 by USK #------------------------------------------------------------------------------ # アイテムやスキルに、選択時決定ボタン以外のボタンを押した場合に起動するコモン # イベントを設定します。 #============================================================================== =begin ・アイテムとスキルのメモ欄にと記述すると、それぞれの選択画面で  対象にカーソルがあるとき、40行目のCommonCommand1で設定したコマンドを押すと(コ  モンID)で設定した番号のコモンイベントが発生します。メモ欄に記述がない場合、  41行目からのDefault~Command1で設定した番号のコモンイベントが発生します。何も起  こらないようにする場合は 0 にしてください。 ・アイテムとスキルのメモ欄にと記述すると、それぞれの選択画面で  対象にカーソルがあるとき、45行目のCommonCommand2で設定したコマンドを押すと(コ  モンID)で設定した番号のコモンイベントが発生します。メモ欄に記述がない場合、  46行目からのDefault~Command2で設定した番号のコモンイベントが発生します。何も起  こらないようにする場合は 0 にしてください。 ・50行目のItemIdVariableに設定した番号の変数に上記のコモンイベントを発生させた  スキルやアイテムのIDが代入されます。 ・51行目のActorIdVariableに設定した番号の変数に上記のコモンイベントを発生させた  スキルの所有アクターのIDが代入されます。 ・コモンイベントの名前の先頭に!(半角)と記述すると戦闘中のみコモンイベントが  有効になります。 ・コモンイベントの名前の先頭に?(半角)と記述するとメニューのみコモンイベントが  有効になります。 =end #============================================================================== # ■ #============================================================================== module CommandCommon #-------------------------------------------------------------------------- # ● 設定項目 #-------------------------------------------------------------------------- CommonCommand1 = :X #で設定したコモンのコマンド DefaultItemCommand1 = 0 #が設定されていないときのコモン(アイテム) DefaultWeaponCommand1 = 0 #が設定されていないときのコモン(武器) DefaultArmorCommand1 = 0 #が設定されていないときのコモン(防具) DefaultSkillCommand1 = 0 #が設定されていないときのコモン(スキル) CommonCommand2 = :A #で設定したコモンのコマンド DefaultItemCommand2 = 0 #が設定されていないときのコモン(アイテム) DefaultWeaponCommand2 = 0 #が設定されていないときのコモン(武器) DefaultArmorCommand2 = 0 #が設定されていないときのコモン(防具) DefaultSkillCommand2 = 0 #が設定されていないときのコモン(スキル) ItemIdVariable = 1 #選択したスキルやアイテムのIDを代入する変数のID ActorIdVariable = 2 #スキル選択時のアクターのIDを代入する変数のID #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def cc_flag=(bool) @cc_flag = bool end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def process_commandcommon1 @cc_flag = true call_handler(CommonCommand1) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def process_commandcommon2 @cc_flag = true call_handler(CommonCommand2) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def default_command1 case @category when :item DefaultItemCommand1 when :weapon DefaultWeaponCommand1 when :armor DefaultArmorCommand1 when :key_item DefaultItemCommand1 end end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def default_command2 case @category when :item DefaultItemCommand2 when :weapon DefaultWeaponCommand2 when :armor DefaultArmorCommand2 when :key_item DefaultItemCommand2 end end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common1 $game_variables[ItemIdVariable] = item ? item.id : 0 id = item ? item.command_common1 : default_command1 id = $data_common_events[id].cc_id if id > 0 id > 0 ? $data_common_events[id].list : [] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common2 $game_variables[ItemIdVariable] = item ? item.id : 0 id = item ? item.command_common2 : default_command2 id = $data_common_events[id].cc_id if id > 0 id > 0 ? $data_common_events[id].list : [] end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def set_cc_handler1(method) set_handler(CommonCommand1, method) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def set_cc_handler2(method) set_handler(CommonCommand2, method) end end #============================================================================== # ■ Window_ItemList #============================================================================== class Window_ItemList include CommandCommon #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- alias :usk_cc_process_handling :process_handling def process_handling usk_cc_process_handling return unless open? && active return process_commandcommon1 if handle?(CommonCommand1) && Input.trigger?(CommonCommand1) return process_commandcommon2 if handle?(CommonCommand2) && Input.trigger?(CommonCommand2) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- alias :usk_cc_update :update def update usk_cc_update unless @cc_flag end end #============================================================================== # ■ Window_SkillList #============================================================================== class Window_SkillList include CommandCommon #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias :usk_cc_refresh :refresh def refresh $game_variables[ActorIdVariable] = @actor ? @actor.id : 0 usk_cc_refresh end #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- alias :usk_cc_process_handling :process_handling def process_handling usk_cc_process_handling return unless open? && active return process_commandcommon1 if Input.trigger?(CommonCommand1) return process_commandcommon2 if Input.trigger?(CommonCommand2) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def default_command1 DefaultSkillCommand1 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def default_command2 DefaultSkillCommand2 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- alias :usk_cc_update :update def update usk_cc_update unless @cc_flag end end #============================================================================== # ■ Scene_ItemBase #============================================================================== class Scene_ItemBase attr_reader :screen #-------------------------------------------------------------------------- # ● 開始後処理 #-------------------------------------------------------------------------- alias :usk_cc_post_start :post_start def post_start @message_window = Window_Message.new @message_window.viewport = @viewport @scroll_text_window = Window_ScrollText.new @scroll_text_window.viewport = @viewport @picture_sprites = [] @interpreter = Game_Interpreter.new @screen = Game_Screen.new @item_window.set_cc_handler1(method(:item_common1)) @item_window.set_cc_handler2(method(:item_common2)) usk_cc_post_start end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common1 item_common(@item_window.item_common1) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common2 item_common(@item_window.item_common2) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common(list) @interpreter.setup(list) while @interpreter.running? if $game_message.busy? @message_window.update @scroll_text_window.update else @interpreter.update end Graphics.update Input.update update_pictures end screen.clear dispose_pictures @item_window.refresh @item_window.cc_flag = false end #-------------------------------------------------------------------------- # ● ピクチャスプライトの更新 #-------------------------------------------------------------------------- def update_pictures screen.update screen.pictures.each do |pic| @picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport, pic) @picture_sprites[pic.number].update @picture_sprites[pic.number].z += 100 end @viewport.tone.set(screen.tone) @viewport.ox = screen.shake @viewport.color.set(screen.flash_color) @viewport.color.set(0, 0, 0, 255 - screen.brightness) end #-------------------------------------------------------------------------- # ● ピクチャスプライトの解放 #-------------------------------------------------------------------------- def dispose_pictures @picture_sprites.compact.each {|sprite| sprite.dispose } @picture_sprites.clear end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 開始後処理 #-------------------------------------------------------------------------- alias :usk_cc_post_start :post_start def post_start @item_window.set_cc_handler1(method(:item_common1)) @item_window.set_cc_handler2(method(:item_common2)) @skill_window.set_cc_handler1(method(:skill_common1)) @skill_window.set_cc_handler2(method(:skill_common2)) usk_cc_post_start end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common1 item_common(@item_window.item_common1) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common2 item_common(@item_window.item_common2) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def skill_common1 item_common(@skill_window.item_common1) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def skill_common2 item_common(@skill_window.item_common2) end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def item_common(list) interpreter = Game_Interpreter.new interpreter.setup(list) while interpreter.running? if $game_message.busy? @message_window.update @scroll_text_window.update else interpreter.update end Graphics.update Input.update $game_troop.update @spriteset.update end @item_window.refresh @item_window.cc_flag = false @skill_window.refresh @skill_window.cc_flag = false end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● 画面系コマンドの対象を取得 #-------------------------------------------------------------------------- alias :usk_cc_screen :screen def screen SceneManager.scene.is_a?(Scene_ItemBase) ? SceneManager.scene.screen : usk_cc_screen end end #============================================================================== # ■ #============================================================================== class RPG::CommonEvent #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def cc_id case @name[0] when "!" SceneManager.scene_is?(Scene_Battle) ? @id : 0 when "?" SceneManager.scene_is?(Scene_Battle) ? 0 : @id else @id end end end #============================================================================== # ■ #============================================================================== class RPG::UsableItem #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def command_common1 @command_common1 ||= @note =~ //m ? $1.to_i : 0 end #-------------------------------------------------------------------------- # ● #-------------------------------------------------------------------------- def command_common2 @command_common2 ||= @note =~ //m ? $1.to_i : 0 end end