Project1
标题:
求丢弃物品脚本
[打印本页]
作者:
打酱油的小怪
时间:
2015-9-28 18:51
标题:
求丢弃物品脚本
有没有丢弃物品脚本
作者:
tseyik
时间:
2015-9-28 19:25
#==============================================================================
# ■ 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
复制代码
作者:
冷峻逸
时间:
2015-9-28 19:27
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1