赞 | 170 |
VIP | 6 |
好人卡 | 208 |
积分 | 230 |
经验 | 137153 |
最后登录 | 2024-11-16 |
在线时间 | 8638 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 22958
- 在线时间
- 8638 小时
- 注册时间
- 2011-12-31
- 帖子
- 3367
|
- #==============================================================================
- # ■ VXAce-RGSS3-2 アイテム捨てる [Ver.1.0.0] by Claimh
- #------------------------------------------------------------------------------
- # アイテム画面上でXボタンを押すと、アイテムを捨てることができます。
- #==============================================================================
- #==============================================================================
- # ■ Window_ItemList
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 決定やキャンセルなどのハンドリング処理
- #--------------------------------------------------------------------------
- def process_handling
- return unless open? && active
- return call_handler(:append_x) if handle?(:append_x) && Input.trigger?(:X)
- super
- end
- end
- #==============================================================================
- # ■ Window_ItemNumber
- #==============================================================================
- class Window_ItemNumber < Window_ShopNumber
- #--------------------------------------------------------------------------
- # ● 公開インスタンス変数
- #--------------------------------------------------------------------------
- attr_reader :number # 入力された個数
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- x = (Graphics.width - window_width) / 2
- super(x, 200, line_height*2 + 32)
- @item = nil
- @max = 1
- @number = 1
- end
- #--------------------------------------------------------------------------
- # ● アイテム、最大個数の設定
- #--------------------------------------------------------------------------
- def set(item, max)
- @item = item
- @max = max
- @number = 1
- refresh
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- contents.draw_text(0, 0, 200, line_height, "捨てる数:")
- draw_item_name(@item, 4, line_height)
- draw_number
- end
- #--------------------------------------------------------------------------
- # ● アイテム名表示行の Y 座標
- #--------------------------------------------------------------------------
- def item_y
- line_height
- end
- end
- #==============================================================================
- # ■ Scene_Item
- #==============================================================================
- class Scene_Item < Scene_ItemBase
- #--------------------------------------------------------------------------
- # ● 開始処理
- #--------------------------------------------------------------------------
- alias start_dump start
- def start
- start_dump
- create_item_dump_window
- end
- #--------------------------------------------------------------------------
- # ● アイテムウィンドウの作成
- #--------------------------------------------------------------------------
- alias create_item_window_dump create_item_window
- def create_item_window
- create_item_window_dump
- @item_window.set_handler(:append_x, method(:on_item_dump))
- end
- #--------------------------------------------------------------------------
- # ● アイテム数選択ウィンドウの作成
- #--------------------------------------------------------------------------
- def create_item_dump_window
- @number_window = Window_ItemNumber.new
- @number_window.viewport = @viewport
- @number_window.hide
- @number_window.set_handler(:ok, method(:on_number_ok))
- @number_window.set_handler(:cancel, method(:on_number_cancel))
- end
- #--------------------------------------------------------------------------
- # ● アイテム[捨てる]
- #--------------------------------------------------------------------------
- def on_item_dump
- if item_dumpable?
- Sound.play_ok
- @number_window.set(item, max_item)
- @number_window.show.activate
- @item_window.deactivate
- else
- Sound.play_buzzer
- end
- end
- #--------------------------------------------------------------------------
- # ● 個数入力[決定]
- #--------------------------------------------------------------------------
- def on_number_ok
- Sound.play_ok
- do_item_dump(@number_window.number)
- @number_window.hide
- activate_item_window
- end
- #--------------------------------------------------------------------------
- # ● 個数入力[キャンセル]
- #--------------------------------------------------------------------------
- def on_number_cancel
- Sound.play_cancel
- @number_window.hide
- activate_item_window
- end
- #--------------------------------------------------------------------------
- # ● 捨てるの実行
- #--------------------------------------------------------------------------
- def do_item_dump(number)
- $game_party.lose_item(item, number)
- end
- #--------------------------------------------------------------------------
- # ● アイテムを捨てる判定
- #--------------------------------------------------------------------------
- def item_dumpable?
- item.is_a?(RPG::Item) ? !item.key_item? : (!item.nil?)
- end
- #--------------------------------------------------------------------------
- # ● 所持数の取得
- #--------------------------------------------------------------------------
- def max_item
- $game_party.item_number(item)
- end
- end
复制代码 |
评分
-
查看全部评分
|