Project1
标题:
大佬们有没有类似于重装机兵中的物品仓库脚本
[打印本页]
作者:
1114905982
时间:
2020-4-9 09:59
标题:
大佬们有没有类似于重装机兵中的物品仓库脚本
因为有负重脚本的原因想给游戏里面加一个仓库脚本
作者:
sansy
时间:
2020-4-9 10:00
仓库系统的话这里倒是有一个,不过不知道是不是你要的那种咯
#==============================================================================
# ■ RGSS3 アイテム預かり所 Ver1.03 by 星潟
#------------------------------------------------------------------------------
# アイテムを預ける事が出来るようになります。
# 莫大な数のアイテムが登場する作品におすすめです。
#
# 最大所持数を越える量のアイテムを引き出せないようにする機能や
# 預けられないアイテムの作成、預けられる数の限界設定の他、
# アイテムの預かり?引き出しに関わるイベントコマンドをいくつか実装します。
#
# アイテム?武器?防具のメモ欄に以下のように書き込む事で
# それぞれ特殊な設定が行われます。
#
# <保存禁止>……このアイテムは預かり所で預ける事が出来ません。
#
# <保存制限:20>……このアイテムは預かり所にも20個までしか預ける事が出来ません。
#
# 以下、イベントコマンドです。(全て、スクリプトを用います)
#
# SceneManager.call(Scene_Item_Keep)
# アイテム預かり所画面を呼び出します。
#
# item_keep_all(data_a)
# data_aが0の時……預けられるアイテムを預けられるだけ預けます。
# data_aが1の時……アイテムを全て引き出せるだけ引き出します。
#
# weapon_keep_all(data_a)
# data_aが0の時……預けられる武器を預けられるだけ預けます。
# data_aが1の時……武器を全て引き出せるだけ引き出します。
#
# armor_keep_all(data_a)
# data_aが0の時……預けられる防具を預けられるだけ預けます。
# data_aが1の時……防具を全て引き出せるだけ引き出します。
#
# item_keep(data_a, data_b)
# data_aが0の時……data_bで指定したIDのアイテムを預けられるだけ預けます。
# data_aが1の時……data_bで指定したIDのアイテムを引き出せるだけ引き出します。
#
# weapon_keep(data_a, data_b)
# data_aが0の時……data_bで指定したIDの武器を預けられるだけ預けます。
# data_aが1の時……data_bで指定したIDの武器を引き出せるだけ引き出します。
#
# armor_keep(data_a, data_b)
# data_aが0の時……data_bで指定したIDの防具を預けられるだけ預けます。
# data_aが1の時……data_bで指定したIDの防具を引き出せるだけ引き出します。
#
# word_keep_all(data_a, data_b)
#
# data_aが0の時……
# data_bで指定した言葉がメモ欄に含まれる
# アイテム?武器?防具を預けられるだけ預けます。
#
# data_aが1の時……
# data_bで指定した言葉がメモ欄に含まれる
# アイテム?武器?防具を引き出せるだけ引き出します。
#
# word_keep_allで、data_bで設定する言葉は、前後を""で囲んでください。
# 【例.word_keep_all(1, "回復")】
# この場合、回復という言葉をメモ欄に含んだアイテム?武器?防具を
# 預かり所から全て引き出します。
#------------------------------------------------------------------------------
# Ver1.01 導入前のセーブデータを使用した場合に正常に機能しなくなる不具合を修正。
# 軽量化スクリプトと統合し、軽量化モード切替機能を追加。
# 説明ウィンドウ機能を追加。
#
# Ver1.02 一部機能を更に軽量化。
# Scene_Shop及び継承しているシーンクラスにおいて
# 買った物を直接預かり所へ送る機能を追加。
# 所持限界数を超えてアイテムを入手した際に
# 自動的に預かり所に送る機能を追加。
#
# Ver1.03 ロード時に更に一部軽量化。
#==============================================================================
module ITEM_KEEPER
#ショップ画面で預かり所への売買機能を付与するかを設定できます。
SHOP = false
#ショップ画面で預かり所モードへの切り替えボタンを設定できます。
KEY = :Z
#預かり所モードから所持品モードに切り替えた際のメッセージを設定します。
TEXT1 = "切换到所持有的物品模式"
#所持品モードから預かり所モードに切り替えた際のメッセージを設定します。
TEXT2 = "转换为保存模式"
#モードに切り替え時のSEを設定します。
#配列内は、名前、音量、ピッチの順に設定して下さい。
SE = ["Decision3",80,100]
#ショップでの預けている数の項目名を設定します。
SHOP_POS = "保存数量"
#預かり所モードの際の数字入力幅の増加値を設定します。(3桁以上の入力を考慮)
SHOP_FIG = 1
#ショップでの預り所への売買機能を無効化する為のスイッチを指定します。
SWITCH1 = 1
#保存禁止アイテムについて、預かり所で表示しないようにするかを設定できます。
#true 表示しない false 表示する
UNVISIBLE = false
#保存禁止アイテムについて、預かり所で表示しないようにするかを設定できます。
#true 表示しない false 表示する
WORD1 = "禁止保存"
#保存に個数制限を設ける為の設定用キーワードです。
WORD2 = "保存限制"
#保存制限のないアイテムについていくつまで預けられるかを設定します。
LIMIT = 999
#所持数を超えて入手したアイテムが自動で預かり所に送られるかどうかを設定します。
AUTOKEEP = true
#所持数を超えて入手したアイテムが自動で預かり所に送られる機能を
#一時的に封印するスイッチを指定します。
SWITCH2 = 1000
#説明ウィンドウを表示するかどうかを設定します。
DESCRIPT = true
#数量ウィンドウと説明ウィンドウの背景透明度を変更します。
B_OPACITY = 255
#軽量化フラグ。
FLAG = true
#説明ウィンドウに表示する項目を設定します。
#(基本的にこの部分を変更する必要はありません)
D = [
["下键",":引出一个"],
["上键",":保存一个"],
["左键",":引出10个"],
["右键",":保存10个"],
["CTRL键",":引出100个"],
["SHIFT键",":保存100个"]
]
end
class RPG::BaseItem
#--------------------------------------------------------------------------
# 保存禁止のフラグ
#--------------------------------------------------------------------------
def keep_seal_flag
#キャッシュがある場合はキャッシュを返す。
return @keep_seal_flag if @keep_seal_flag != nil
#データを取得。
@keep_seal_flag = self.note.include?("<" + ITEM_KEEPER::WORD1 + ">") ? true : false
#データを返す。
@keep_seal_flag
end
#--------------------------------------------------------------------------
# 最大保管数を取得
#--------------------------------------------------------------------------
def max_item_keep_number
#キャッシュが存在する場合はキャッシュを返す。
return @max_item_keep_number if @max_item_keep_number != nil
#メモ欄からデータを取得し、取得できない場合はデフォルト数を返す。
memo = self.note.scan(/<#{ITEM_KEEPER::WORD2}[::](\S+)>/).flatten
@max_item_keep_number = memo != nil && !memo.empty? ? memo[0].to_i : ITEM_KEEPER::LIMIT
#データを返す。
@max_item_keep_number
end
end
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_ik initialize
def initialize
#本来の処理を実行。
initialize_ik
#パーティー外全アイテムリストを初期化。
init_all_items_ik
end
#--------------------------------------------------------------------------
# パーティー外全アイテムリストの初期化(強制)
#--------------------------------------------------------------------------
def init_all_items_ik
#それぞれ、空のハッシュを生成。
@items_k = {}
@weapons_k = {}
@armors_k = {}
end
#--------------------------------------------------------------------------
# パーティー外全アイテムリストの初期化(nilの場合)
#--------------------------------------------------------------------------
def init_all_items_ik_un_nil
#それぞれ、存在しない場合のみハッシュを生成。
@items_k = {} if @items_k == nil
@weapons_k = {} if @weapons_k == nil
@armors_k = {} if @armors_k == nil
end
#--------------------------------------------------------------------------
# アイテムの最大保管数取得
#--------------------------------------------------------------------------
def max_item_keep_number(item)
#アイテムが存在しない場合はfalseを返す。
return false if item == nil
#アイテムの最大保管数を返す。
item.max_item_keep_number
end
#--------------------------------------------------------------------------
# アイテムの保管数取得
#--------------------------------------------------------------------------
def item_keep_number(item)
#コンテナを取得。
container = item_keep_container(item.class)
#コンテナにデータが存在しない場合は0を返す。
container ? container[item.id] || 0 : 0
end
#--------------------------------------------------------------------------
# アイテムの保管
#--------------------------------------------------------------------------
def item_keep(item, number, get = false)
#数量データを取得。
number_data = number
#アイテム保管を実行。
item_keep_execute(item, number_data)
#所持アイテムを減らす。
gain_item(item, -number_data) if get == false
end
#--------------------------------------------------------------------------
# 預けているアイテムのクラスに対応するコンテナオブジェクトを取得
#--------------------------------------------------------------------------
def item_keep_container(item_class)
#アイテムの種類に応じてコンテナを取得。
return @items_k if item_class == RPG::Item
return @weapons_k if item_class == RPG::Weapon
return @armors_k if item_class == RPG::Armor
return nil
end
#--------------------------------------------------------------------------
# アイテムの増加(減少)
#--------------------------------------------------------------------------
def item_keep_execute(item, amount)
#コンテナを取得。
container = item_keep_container(item.class)
#コンテナが存在しない場合は処理をしない。
return if container == nil
#処理前の保管数を取得。
last_number = item_keep_number(item)
#処理後の保管数を取得。
new_number = last_number + amount
#保管数を変更する。
container[item.id] = new_number
#保管数が0となった場合はハッシュから削除する。
container.delete(item.id) if container[item.id] == 0
#マップのリフレッシュフラグを立てる。
$game_map.need_refresh = true
end
#自動倉庫送りが有効な場合のみ変更
if ITEM_KEEPER::AUTOKEEP
#--------------------------------------------------------------------------
# アイテムの増加(減少)
#--------------------------------------------------------------------------
alias gain_item_ik gain_item
def gain_item(item, amount, include_equip = false)
#自動倉庫送りスイッチが無効もしくは、スイッチがOFFの時で
#なおかつアイテムが存在し、それが預かり所禁止出ない場合
if (ITEM_KEEPER::SWITCH2 == 0 or !$game_switches[ITEM_KEEPER::SWITCH2]) && (item != nil && !item.keep_seal_flag)
#アイテムコンテナを取得。
container = item_container(item.class)
#アイテムコンテナが存在しない場合は処理を飛ばす。
return unless container
#所持数と入手数の合計値を取得。
ex_amount = item_number(item) + amount
#合計値が最大所持数を上回る場合
if ex_amount > max_item_number(item)
#合計値から最大所持数を引いた値を取得。
data = ex_amount - max_item_number(item)
#倉庫アイテムコンテナを取得。
ik_container = item_keep_container(item.class)
#倉庫アイテムの数を変更する。
ik_container[item.id] = [item_keep_number(item) + data, max_item_keep_number(item)].min
#入手数を減らす。
amount -= data
end
end
#本来の処理を実行。
gain_item_ik(item, amount, include_equip)
end
end
end
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ロード成功時の処理
#--------------------------------------------------------------------------
alias on_load_success_ik on_load_success
def on_load_success
$game_party.init_all_items_ik_un_nil
on_load_success_ik
end
end
class Scene_Item_Keep < Scene_Item
#--------------------------------------------------------------------------
# 開始処理
#--------------------------------------------------------------------------
def start
#スーパークラスの処理を実行。
super
#説明ウィンドウの作成
create_description_window
#個数入力ウィンドウの作成
create_number_window
end
#--------------------------------------------------------------------------
# カテゴリウィンドウの作成
#--------------------------------------------------------------------------
def create_category_window
@category_window = Window_ItemCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @help_window.height
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# アイテムウィンドウの作成
#--------------------------------------------------------------------------
def create_item_window
wy = @category_window.y + @category_window.height
wh = Graphics.height - wy
@item_window = Window_PTItemList.new(0, wy, Graphics.width, wh)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@category_window.item_window = @item_window
end
#--------------------------------------------------------------------------
# 説明ウィンドウの作成
#--------------------------------------------------------------------------
def create_description_window
#説明ウィンドウを作成しない場合は処理を行わない。
return unless ITEM_KEEPER::DESCRIPT
@description_window = Window_IKDescription.new
@description_window.z = 100
@description_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# 個数入力ウィンドウの作成
#--------------------------------------------------------------------------
def create_number_window
@number_window = Window_IKInput.new
@number_window.z = 100
@number_window.item_window = @item_window
@number_window.description_window = @description_window if ITEM_KEEPER::DESCRIPT
@number_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# カテゴリ[決定]
#--------------------------------------------------------------------------
def on_category_ok
@item_window.activate
@item_window.select_last
@category_window.deactivate
end
#--------------------------------------------------------------------------
# アイテム[決定]
#--------------------------------------------------------------------------
def on_item_ok
$game_party.last_item.object = item
item == nil ? @item_window.activate : determine_item
end
#--------------------------------------------------------------------------
# アイテムの決定
#--------------------------------------------------------------------------
def determine_item
@number_window.number = 0
item = @item_window.item
@number_window.show
@number_window.refresh
@description_window.show if ITEM_KEEPER::DESCRIPT
@item_window.deactivate
end
#--------------------------------------------------------------------------
# アイテム[キャンセル]
#--------------------------------------------------------------------------
def on_item_cancel
@item_window.unselect
@category_window.activate
end
end
#==============================================================================
# ■ Window_PTItemList
#------------------------------------------------------------------------------
# アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_PTItemList < Window_ItemList
#--------------------------------------------------------------------------
# アイテムをリストに含めるかどうか
#--------------------------------------------------------------------------
alias include_ik? include?
def include?(item)
#アイテムが存在しない場合、ウィンドウが不可視の場合
#保管禁止アイテムを非表示にする場合は表示しない。
return false if item == nil
return false if self.visible == false
return false if ITEM_KEEPER::UNVISIBLE == true && item.keep_seal_flag
#本来の処理を実行。
include_ik?(item)
end
#--------------------------------------------------------------------------
# アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
def enable?(item)
#アイテムが存在しない場合、もしくは保管禁止アイテムの場合はfalseを返す。
return false if item == nil
return false if item.keep_seal_flag
#return false if @category == :key_item
return true
end
#--------------------------------------------------------------------------
# アイテムリストの作成
#--------------------------------------------------------------------------
def make_item_list
#全ての中から、所持アイテムか倉庫アイテムとして存在する物のみ取得する。
item_data = $data_items + $data_weapons + $data_armors
@data = item_data.select {|item| include?(item) && ($game_party.item_number(item) > 0 or $game_party.item_keep_number(item) > 0)}
@data.push(nil) if include?(nil)
end
#--------------------------------------------------------------------------
# 選択項目の有効状態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# 桁数の取得
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
def update
super
end
#--------------------------------------------------------------------------
# 項目の描画
#--------------------------------------------------------------------------
def draw_item(index, flag = false)
#データからアイテムを取得し、各種データを記述する。
item = @data[index]
#アイテムが存在しない場合は処理を行わない。
return unless item
rect = item_rect(index)
contents.clear_rect(rect) if flag
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item))
change_color(text_color(16))
draw_text(180, rect.y, 100, line_height, "所持", 2)
change_color(text_color(0))
draw_text(220, rect.y, 100, line_height, $game_party.item_number(item), 2)
draw_text(240, rect.y, 100, line_height,"/", 2)
draw_text(270, rect.y, 100, line_height, $game_party.max_item_number(item), 2)
change_color(text_color(16))
draw_text(330, rect.y, 100, line_height, "仓库", 2)
change_color(text_color(0))
draw_text(370, rect.y, 100, line_height, $game_party.item_keep_number(item), 2)
draw_text(390, rect.y, 100, line_height, "/", 2)
draw_text(420, rect.y, 100, line_height, $game_party.max_item_keep_number(item), 2)
end
end
class Window_IKInput < Window_Selectable
#--------------------------------------------------------------------------
# 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :item_window
attr_accessor :number
attr_accessor :description_window
#--------------------------------------------------------------------------
# オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
#ウィンドウを生成する。
super(Graphics.width / 2 - 122, Graphics.height / 2 - 50, 244, 100)
#設定に応じて背景透明度を変更する。
self.back_opacity = ITEM_KEEPER::B_OPACITY
#一旦隠す。
hide
#非アクティブにする。
deactivate
end
#--------------------------------------------------------------------------
# 数字の変更処理
#--------------------------------------------------------------------------
def update
#見えない場合は更新しない。
return unless self.visible
#入力関連の各種処理を実行。
if Input.press?(:UP) or Input.press?(:DOWN) or Input.press?(:RIGHT) or Input.press?(:LEFT) or Input.press?(Input::SHIFT) or Input.press?(Input::CTRL)
if Input.press?(Input::SHIFT) #100個預ける
begin
keep_exe(@item_window.item, 100) unless @item_window.item.key_item?
Sound.play_buzzer if @item_window.item.key_item?
rescue
keep_exe(@item_window.item, 100)
end
elsif Input.press?(Input::CTRL) #100個引き出す
get_exe(@item_window.item, 100)
elsif Input.repeat?(:RIGHT) #10個預ける
begin
keep_exe(@item_window.item, 10) unless @item_window.item.key_item?
Sound.play_buzzer if @item_window.item.key_item?
rescue
keep_exe(@item_window.item, 100)
end
elsif Input.repeat?(:LEFT) #10個引き出す
get_exe(@item_window.item, 10)
elsif Input.repeat?(:UP) #1個預ける
begin
keep_exe(@item_window.item, 1) unless @item_window.item.key_item?
Sound.play_buzzer if @item_window.item.key_item?
rescue
keep_exe(@item_window.item, 1)
end
elsif Input.repeat?(:DOWN) #1個引き出す
get_exe(@item_window.item, 1)
end
refresh_number
end
if Input.trigger?(:C)
#決定音を鳴らす。
Sound.play_ok
#数に応じてアイテム数を変更。
$game_party.item_keep(@item_window.item, @number)
#ウィンドウを隠す。
self.hide
#ウィンドウを非アクティブにする。
self.deactivate
#説明ウィンドウが存在する場合、説明ウィンドウを隠す。
@description_window.hide if ITEM_KEEPER::DESCRIPT
#条件に応じてアイテムウィンドウを変更する。
ITEM_KEEPER::FLAG ? @item_window.draw_item(@item_window.index, true) : @item_window.refresh
#アイテムウィンドウをアクティブにする。
@item_window.activate
elsif Input.trigger?(:B)
#決定音を鳴らす。
Sound.play_cancel
#ウィンドウを隠す。
self.hide
#ウィンドウを非アクティブにする。
self.deactivate
#説明ウィンドウが存在する場合、説明ウィンドウを隠す。
@description_window.hide if ITEM_KEEPER::DESCRIPT
#アイテムウィンドウをアクティブにする。
@item_window.activate
end
end
#--------------------------------------------------------------------------
# 預けられる限界をチェック
#--------------------------------------------------------------------------
def limitcheck1
#所持数が既に0、もしくは預ける限界に達している場合はfalseを返す。
return false if $game_party.item_number(@item_window.item) - @number == 0
return false if $game_party.item_keep_number(@item_window.item) + @number == $game_party.max_item_keep_number(@item_window.item)
return true
end
#--------------------------------------------------------------------------
# 引き出せる限界をチェック
#--------------------------------------------------------------------------
def limitcheck2
#所持数が既に限界に達している場合、もしくは預けている数が0の場合はfalseを返す。
return false if $game_party.item_number(@item_window.item) - @number == $game_party.max_item_number(@item_window.item)
return false if $game_party.item_keep_number(@item_window.item) + @number == 0
return true
end
#--------------------------------------------------------------------------
# 預ける
#--------------------------------------------------------------------------
def keep_exe(item, amount)
#数量分処理する。
amount.times do
@number += 1 if limitcheck1
end
end
#--------------------------------------------------------------------------
# 引き出す
#--------------------------------------------------------------------------
def get_exe(item, amount)
#数量分処理する。
amount.times do
@number -= 1 if limitcheck2
end
end
#--------------------------------------------------------------------------
# リフレッシュ
#--------------------------------------------------------------------------
def refresh
#不可視状態の場合はリフレッシュしない。
return false unless self.visible
#数量を更新する。
@last_number = @number
#ウィンドウの内容を消去する。
contents.clear
create_contents
#アイテム名を描写。
draw_item_name(@item_window.item, 0, 0)
change_color(system_color)
draw_text(0, line_height * 1, 80, line_height, "所持", 1)
draw_text(self.contents.width - 80, line_height * 1, 80, line_height, "仓库", 1)
draw_text(0, line_height * 1, self.contents.width, line_height, "→", 1)
draw_text(0, line_height * 2, self.contents.width, line_height, "←", 1)
#所持数データを描写。
$game_party.item_number(@item_window.item) + @number == $game_party.max_item_number(@item_window.item) ? change_color(text_color(3)) : change_color(normal_color)
draw_text(0, line_height * 2, 80, line_height, $game_party.item_number(@item_window.item) - @number, 1)
$game_party.item_keep_number(@item_window.item) + @number == $game_party.max_item_keep_number(@item_window.item) ? change_color(text_color(3)) : change_color(normal_color)
draw_text(self.contents.width - 80, line_height * 2, 80, line_height, $game_party.item_keep_number(@item_window.item) + @number, 1)
end
#--------------------------------------------------------------------------
# 数量のみリフレッシュ
#--------------------------------------------------------------------------
def refresh_number
#不可視状態の場合はリフレッシュしない。
return false unless self.visible
#最後の数量と現在の数量が異なる場合は数量を更新する。
if @last_number != @number
Sound.play_cursor
@last_number = @number
end
#ウィンドウの内容を消去する。
contents.clear_rect(0, line_height * 2, 80, line_height)
contents.clear_rect(self.contents.width - 80, line_height * 2, 80, line_height)
#所持数データを描写。
$game_party.item_number(@item_window.item) + @number == $game_party.max_item_number(@item_window.item) ? change_color(text_color(3)) : change_color(normal_color)
draw_text(0, line_height * 2, 80, line_height, $game_party.item_number(@item_window.item) - @number, 1)
$game_party.item_keep_number(@item_window.item) + @number == $game_party.max_item_keep_number(@item_window.item) ? change_color(text_color(3)) : change_color(normal_color)
draw_text(self.contents.width - 80, line_height * 2, 80, line_height, $game_party.item_keep_number(@item_window.item) + @number, 1)
end
end
class Window_IKDescription < Window_Base
def initialize
#ウィンドウを生成する。
super(Graphics.width / 2 - 240, Graphics.height / 3 * 2, 480, 96)
#設定に応じて背景透明度を変更する。
self.back_opacity = ITEM_KEEPER::B_OPACITY
#システムカラーで項目部分を描画する。
change_color(system_color)
draw_text(0, 0, self.contents.width / 2, line_height, ITEM_KEEPER::D[0][0], 0)
draw_text(self.contents.width / 2, 0, self.contents.width / 2, line_height, ITEM_KEEPER::D[1][0], 0)
draw_text(0, line_height * 1, self.contents.width / 2, line_height, ITEM_KEEPER::D[2][0], 0)
draw_text(self.contents.width / 2, line_height * 1, self.contents.width / 2, line_height, ITEM_KEEPER::D[3][0], 0)
draw_text(0, line_height * 2, self.contents.width / 2, line_height, ITEM_KEEPER::D[4][0], 0)
draw_text(self.contents.width / 2, line_height * 2, self.contents.width / 2, line_height, ITEM_KEEPER::D[5][0], 0)
#通常カラーで項目部分を描画する。
change_color(normal_color)
draw_text(90, 0, self.contents.width / 2, line_height, ITEM_KEEPER::D[0][1], 0)
draw_text(self.contents.width / 2 + 90, 0, self.contents.width / 2, line_height, ITEM_KEEPER::D[1][1], 0)
draw_text(90, line_height * 1, self.contents.width / 2, line_height, ITEM_KEEPER::D[2][1], 0)
draw_text(self.contents.width / 2 + 90, line_height * 1, self.contents.width / 2, line_height, ITEM_KEEPER::D[3][1], 0)
draw_text(90, line_height * 2, self.contents.width / 2, line_height, ITEM_KEEPER::D[4][1], 0)
draw_text(self.contents.width / 2 + 90, line_height * 2, self.contents.width / 2, line_height, ITEM_KEEPER::D[5][1], 0)
hide
end
end
class Game_Interpreter
#--------------------------------------------------------------------------
# アイテムを全て預ける/引き出す
#--------------------------------------------------------------------------
def item_keep_all(data)
#種類をアイテムとする。
item_data = $data_items
#共通処理を実行。
common_keep_all(item_data, data)
end
#--------------------------------------------------------------------------
# 武器を全て預ける/引き出す
#--------------------------------------------------------------------------
def weapon_keep_all(data)
#種類を武器とする。
item_data = $data_weapons
#共通処理を実行。
common_keep_all(item_data, data)
end
#--------------------------------------------------------------------------
# 防具を全て預ける/引き出す
#--------------------------------------------------------------------------
def armor_keep_all(data)
#種類を防具とする。
item_data = $data_armors
#共通処理を実行。
common_keep_all(item_data, data)
end
#--------------------------------------------------------------------------
# 全て預ける/引き出す場合の共通処理を実行
#--------------------------------------------------------------------------
def common_keep_all(item_data, data)
#存在するオブジェクトの数分だけ処理。
item_data.each do |i|
#nilの場合は処理しない。
next if i == nil
#預けられないアイテムの場合は処理しない。
next if i.keep_seal_flag
#各種データを取得。
data1 = $game_party.item_number(i)
data2 = $game_party.max_item_number(i)
data3 = $game_party.item_keep_number(i)
data4 = $game_party.max_item_keep_number(i)
#追加で所持できる数と、追加で預けられる数を計算。
data5 = data4 - data3
data6 = data2 - data1
#処理内容に応じて、預ける場合と引き出す場合とをそれぞれ処理。
amount = data == 0 ? (data5 < data1 ? data5 : data1) : (data6 < data3 ? -data6 : -data3)
$game_party.item_keep(i, amount)
end
end
#--------------------------------------------------------------------------
# アイテムを一定個数預ける/引き出す
#--------------------------------------------------------------------------
def item_keep(data_a, data_b)
#種類をアイテムとする。
item_data = $data_items
#共通処理を実行。
common_keep(item_data, data_a, data_b)
end
#--------------------------------------------------------------------------
# 武器を一定個数預ける/引き出す
#--------------------------------------------------------------------------
def weapon_keep(data_a, data_b)
#種類を武器とする。
item_data = $data_weapons
#共通処理を実行。
common_keep(item_data, data_a, data_b)
end
#--------------------------------------------------------------------------
# 防具を一定個数預ける/引き出す
#--------------------------------------------------------------------------
def armor_keep(data_a, data_b)
#種類を防具とする。
item_data = $data_armors
#共通処理を実行。
common_keep(item_data, data_a, data_b)
end
#--------------------------------------------------------------------------
# 一定個数預ける/引き出す場合の共通処理を実行します。
#--------------------------------------------------------------------------
def common_keep(item_data, data_a, data_b)
#nilの場合は処理しない。
return if item_data[data_b] == nil
#預けられないアイテムの場合は処理しない。
return if item_data[data_b].keep_seal_flag
#各種データを取得。
data1 = $game_party.item_number(item_data[data_b])
data2 = $game_party.max_item_number(item_data[data_b])
data3 = $game_party.item_keep_number(item_data[data_b])
data4 = $game_party.max_item_keep_number(item_data[data_b])
#追加で所持できる数と、追加で預けられる数を計算。
data5 = data4 - data3
data6 = data2 - data1
#処理内容に応じて、預ける場合と引き出す場合とをそれぞれ処理。
amount = data_a == 0 ? (data5 < data1 ? data5 : data1) : (data6 < data3 ? -data6 : -data3)
$game_party.item_keep(item_data[data_b], amount)
end
#--------------------------------------------------------------------------
# 特定ワードを含む単語を全て預ける/引き出す場合の処理を行う。
#--------------------------------------------------------------------------
def word_keep_all(data_a, data_b)
#アイテム?武器?防具全てを含める配列を生成。
item_data = $data_items + $data_weapons + $data_armors
#存在するオブジェクトの数分だけ処理。
item_data.each do |i|
#nilの場合は処理しない。
next if i == nil
#預けられないアイテムの場合は処理しない。
next if i.keep_seal_flag
#指定されたワードがメモ欄に含まれていない場合は処理しない。
next unless i.note.include?(data_b)
#各種データを取得。
data1 = $game_party.item_number(i)
data2 = $game_party.max_item_number(i)
data3 = $game_party.item_keep_number(i)
data4 = $game_party.max_item_keep_number(i)
#追加で所持できる数と、追加で預けられる数を計算。
data5 = data4 - data3
data6 = data2 - data1
#処理内容に応じて、預ける場合と引き出す場合とをそれぞれ処理。
amount = data_a == 0 ? (data5 < data1 ? data5 : data1) : (data6 < data3 ? -data6 : -data3)
$game_party.item_keep(i, amount)
end
end
end
if ITEM_KEEPER::SHOP
class Game_Party < Game_Unit
attr_accessor :shop_ik
#--------------------------------------------------------------------------
# 預かり所モードかどうかを確認
#--------------------------------------------------------------------------
def shop_ik?
@shop_ik
end
#--------------------------------------------------------------------------
# 全てのアイテムオブジェクトの配列取得
#--------------------------------------------------------------------------
alias all_items_ik all_items
def all_items
#預かり所モードでなければ、本来の処理を行う。
return all_items_ik unless $game_party.shop_ik?
#アイテム?武器?防具の預かり所データを取得し、まとめる。
data1 = @items_k.keys.sort.collect {|id| $data_items[id] }
data2 = @weapons_k.keys.sort.collect {|id| $data_weapons[id] }
data3 = @armors_k.keys.sort.collect {|id| $data_armors[id] }
data1 + data2 + data3
end
#--------------------------------------------------------------------------
# アイテムのクラスに対応するコンテナオブジェクトを取得
#--------------------------------------------------------------------------
alias item_container_ik item_container
def item_container(item_class)
#預かり所モードでなければ、本来の処理を行う。
return item_container_ik(item_class) unless $game_party.shop_ik?
#預かり所モードの場合に限り、預かり所データを返す。
return @items_k if item_class == RPG::Item
return @weapons_k if item_class == RPG::Weapon
return @armors_k if item_class == RPG::Armor
return nil
end
#--------------------------------------------------------------------------
# アイテムの所持数取得
#--------------------------------------------------------------------------
alias item_number_ik item_number
def item_number(item)
#預かり所モードでなければ、本来の処理を行う。
return item_number_ik(item) unless $game_party.shop_ik?
#預かり所のデータを返す。
item_keep_number(item)
end
#--------------------------------------------------------------------------
# アイテムの最大所持数取得
#--------------------------------------------------------------------------
alias max_item_number_ik max_item_number
def max_item_number(item)
#預かり所モードでなければ、本来の処理を行う。
return max_item_number_ik(item) unless $game_party.shop_ik?
#預かり所のデータを返す。
max_item_keep_number(item)
end
end
class Scene_Shop < Scene_MenuBase
#--------------------------------------------------------------------------
# モードチェンジ
#--------------------------------------------------------------------------
def item_keep_mode_change
#ナンバーウィンドウがアクティブの場合は実行しない。
return if @number_window.active
#指定スイッチのIDが0より大きく、そのスイッチがONの場合は実行しない。
return if ITEM_KEEPER::SWITCH1 > 0 && $game_switches[ITEM_KEEPER::SWITCH1]
#預かり所フラグを切り替える。
$game_party.shop_ik = $game_party.shop_ik? ? false : true
#切り替えを示すウィンドウを表示。
w = 400
h = 48
x = (Graphics.width - w) / 2
y = (Graphics.height - h) / 2
RPG::SE.new(ITEM_KEEPER::SE[0],ITEM_KEEPER::SE[1],ITEM_KEEPER::SE[2]).play
@mode_change_window = Window_Base.new(x, y, w, h)
@mode_change_window.back_opacity = 255
@mode_change_window.z = 10000
text = $game_party.shop_ik ? ITEM_KEEPER::TEXT2 : ITEM_KEEPER::TEXT1
@mode_change_window.draw_text(0, 0, w - 32, 24, text, 1)
60.times {Graphics.update}
@mode_change_window.dispose
@mode_change_window = nil
#各ウィンドウをリフレッシュする。
@status_window.refresh
@buy_window.refresh
@sell_window.refresh
@sell_window.index = 0 if @sell_window.active
@number_window.refresh
end
#--------------------------------------------------------------------------
# フレーム更新
#--------------------------------------------------------------------------
alias update_ik update
def update
#本来の処理を実行。
update_ik
#指定したキーが押された場合、モードチェンジ実行。
item_keep_mode_change if Input.trigger?(ITEM_KEEPER::KEY)
end
end
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
alias enable_ik? enable?
def enable?(item)
#本来の処理を実行。
flag1 = enable_ik?(item)
#預かり所モードの場合、預かり所禁止アイテムは購入不可。
flag2 = $game_party.shop_ik? ? !item.keep_seal_flag : true
#どちらの条件も満たす場合のみ表示。
flag1 && flag2
end
end
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# 所持数の描画
#--------------------------------------------------------------------------
alias draw_possession_ik draw_possession
def draw_possession(x, y)
#預かり所モードでなければ、本来の処理を行う。
return draw_possession_ik(x, y) unless $game_party.shop_ik?
#本来の処理を少し改変した物を実行。
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(system_color)
draw_text(rect, ITEM_KEEPER::SHOP_POS)
change_color(normal_color)
draw_text(rect, $game_party.item_keep_number(@item), 2)
end
end
class Window_ShopNumber < Window_Selectable
#--------------------------------------------------------------------------
# 個数表示の最大桁数を取得
#--------------------------------------------------------------------------
alias figures_ik figures
def figures
#3桁以上を考慮して預かり所モードの場合は補正をかける。
figures_ik + ($game_party.shop_ik? ? ITEM_KEEPER::SHOP_FIG : 0)
end
end
class Scene_MenuBase < Scene_Base
#--------------------------------------------------------------------------
# 終了処理
#--------------------------------------------------------------------------
alias terminate_ik terminate
def terminate
#預かり所モードフラグを消去。
$game_party.shop_ik = nil
#本来の処理を実行。
terminate_ik
end
end
end
复制代码
作者:
刈飒的风
时间:
2020-4-9 16:20
# =============================================================================
# TheoAllen - 仓库系统
# Version : 1.2
# Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
# (This script is translated by AbsoluteIce)
# =============================================================================
($imported ||= {})[:Theo_ChestSystem] = true
# =============================================================================
# CHANGE LOGS:
# -----------------------------------------------------------------------------
# 2013.08.19 - Compatibility Patch with Limited Inventory
# 2013.06.28 - Add custom chest name
# 2013.06.01 - Adjust control and GUI
# 2013.05.24 - Finished script
# 2013.05.23 - Started Script
# =============================================================================
=begin
介绍 :
本脚本可以设定一个仓库,允许玩家存放或取出物品.
使用方法 :
本脚本放在插件脚本之下,main之上
在使用脚本打开仓库前,使用以下事件注释:
<item: id, 数量>
<weapon: id, 数量>
<armor: id, 数量>
解释 :
id >> 物品/武器/护甲id
数量 >> 数量多少
使用以上注释后, 使用脚本 :
open_chest
对于自定义名称的仓库, 则可以 :
open_chest("小仓库")
open_chest("Eric的宝箱")
注意 : 所有事件中的所有注释都会读取一次,请确保在使用脚本之前使用了注释。
使用规定 :
属名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.
=end
# =============================================================================
# 设定 :
# =============================================================================
module THEO
module CHEST
# =========================================================================
# Vocabs
# -------------------------------------------------------------------------
AMOUNT_VOCAB = "数量 :" # 数量.
ALL_VOCAB = "全部" # 全部类别.
INV_VOCAB = "背包" # 背包.
ST_VOCAB = "库存" # 库存.
# =========================================================================
# =========================================================================
TRIGGER_GAIN_ALL = :CTRL
# -------------------------------------------------------------------------
# 全部取出的按钮. 如果你设定为 :CTRL, 则在玩家按下CTRL和确定键 (z)后会取出
# 全部物品
# =========================================================================
# =========================================================================
SHOW_AMOUNT_MIN = 10
# -------------------------------------------------------------------------
# 显示窗口数量的最小值.
# =========================================================================
end
end
# =============================================================================
# 设定结束 (除非清除你在干什么,否则以下内容勿动)
# =============================================================================
module THEO
module CHEST
module REGEXP
ITEM_REGEX = /<(?:ITEM|item):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
WEAPON_REGEX = /<(?:WEAPON|weapon):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
ARMOR_REGEX = /<(?:ARMOR|armor):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
end
end
end
class Scene_Chest < Scene_MenuBase
include THEO::CHEST
def initialize(key,st_vocab)
$game_party.init_chest_cursors
@last_active = :stash
@key = key
@st_vocab = st_vocab
end
def start
super
create_header_windows
create_footer_window
create_main_windows
create_amount_window
prepare
end
def create_header_windows
create_help_window
create_category_window
end
def create_main_windows
create_inventory_window
create_stash_window
end
def create_help_window
@help = Window_Help.new
@help.viewport = @viewport
end
def create_category_window
@category = Window_ChestCategory.new
@category.viewport = @viewport
@category.y = @help.height
@category.set_handler(:ok, method(:on_category_ok))
@category.set_handler(:cancel, method(:return_scene))
end
def create_footer_window
create_inv_footer
create_st_footer
end
def create_inv_footer
if $imported[:Theo_LimInventory]
x = 0
y = Graphics.height - 48
w = Graphics.width/2
@inv_footer = Window_ChestFreeSlot.new(x,y,w)
@inv_footer.viewport = @viewport
else
@inv_footer = Window_ChestFooter.new(INV_VOCAB,$game_party,0)
@inv_footer.viewport = @viewport
end
end
def create_st_footer
@st_footer = Window_ChestFooter.new(@st_vocab,$game_chests[@key],1)
@st_footer.viewport = @viewport
end
def create_inventory_window
x = 0
y = @help.height + @category.height
w = Graphics.width/2
h = Graphics.height - y - @inv_footer.height
@inventory = Window_Inventory.new(x,y,w,h)
@inventory.viewport = @viewport
@inventory.set_handler(:ok, method(:item_inventory_ok))
@inventory.set_handler(:cancel, method(:on_inventory_cancel))
@inventory.help_window = @help
@category.item_window = @inventory
end
def create_stash_window
x = Graphics.width / 2
y = @inventory.y
w = x
h = @inventory.height
@stash = Window_Stash.new(x,y,w,h,@key)
@stash.viewport = @viewport
@stash.set_handler(:ok, method(:item_stash_ok))
@stash.set_handler(:cancel, method(:on_stash_cancel))
@stash.help_window = @help
@category.stash_window = @stash
end
def create_amount_window
@amount = Window_ChestAmount.new
@amount.viewport = @viewport
@amount.inv_window = @inv_footer if $imported[:Theo_LimInventory]
end
# for future plan ~
def refresh_all_footers
@inv_footer.refresh
@st_footer.refresh
end
def prepare
unselect_all
@category.show
@category.activate
@item_phase = false
deactivate_item_windows
hide_amount
end
def deactivate_item_windows
@inventory.deactivate
@stash.deactivate
end
def on_category_ok
@category.deactivate
activate_itemlist
@item_phase = true
end
def item_inventory_ok
unless @inventory.item
@inventory.activate
return
end
if @inventory.item_number < SHOW_AMOUNT_MIN
store_items(1)
@inventory.activate
refresh_itemlist
else
@last_active = :inventory
input_amount(@inventory)
end
end
def item_stash_ok
unless @stash.item
@stash.activate
return
end
if @stash.item_number < SHOW_AMOUNT_MIN
gain_items(1)
@stash.activate
refresh_itemlist
else
@last_active = :stash
input_amount(@stash)
end
end
def on_stash_cancel
@last_active = :stash
memorize_st
prepare
end
def on_inventory_cancel
@last_active = :inventory
memorize_inv
prepare
end
def input_amount(window)
memorize_all
if window.equal?(@stash)
@inventory.unselect
else
@stash.unselect
end
@amount.open
@amount.item_window = window
deactivate_item_windows
end
def hide_amount
Sound.play_cancel
@amount.close
@amount.reset_amount
end
def update
super
@amount.mode = @last_active
@inv_footer.mode = @last_active if $imported[:Theo_LimInventory]
select_item_phase if @item_phase
input_amount_phase if @amount.open?
end
def select_item_phase
gain_all_items if trigger_gain_all_item?
switch_window if Input.repeat?(:RIGHT) || Input.repeat?(:LEFT)
end
def input_amount_phase
activate_itemlist if Input.trigger?(:B)
if @amount.item_window.equal?(@stash) && Input.trigger?(:C)
gain_items(@amount.amount)
elsif @amount.item_window.equal?(@inventory) && Input.trigger?(:C)
store_items(@amount.amount)
end
end
def switch_window
if @inventory.active
switch_stash
elsif @stash.active
switch_inventory
end
end
def switch_inventory
memorize_st
@stash.deactivate
@stash.unselect
@inventory.activate
inv_select
end
def switch_stash
@stash.activate
st_select
memorize_inv
@inventory.deactivate
@inventory.unselect
end
def gain_all_items
if @stash.active
@stash.data.each do |item|
gain_items(@stash.item_number(item),item)
end
@stash.select(0)
else
@inventory.data.each do |item|
store_items(@inventory.item_number(item),item)
end
@inventory.select(0)
end
refresh_itemlist
refresh_all_footers
end
def trigger_gain_all_item?
Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL) && Input.trigger?(:C)
end
def gain_items(amount, item = @stash.item)
if $imported[:Theo_LimInventory]
amount = [[amount,0].max,$game_party.inv_max_item(item)].min
end
$game_party.gain_item(item,amount)
$game_chests[@key].lose_item(item,amount)
on_amount_confirm if @amount.open?
end
def store_items(amount, item = @inventory.item)
$game_chests[@key].gain_item(item,amount)
$game_party.lose_item(item,amount)
on_amount_confirm if @amount.open?
end
def refresh_itemlist
@stash.refresh
@inventory.refresh
end
def on_amount_confirm
Sound.play_ok
refresh_itemlist
unselect_all
activate_itemlist
end
def activate_itemlist
hide_amount
case @last_active
when :stash
activate_stash
when :inventory
activate_inventory
end
@item_phase = true
end
def activate_inventory
@inventory.activate
@stash.unselect
inv_select
end
def activate_stash
@stash.activate
@inventory.unselect
st_select
end
def memorize_inv
$game_party.last_inv = @inventory.index
end
def memorize_st
$game_party.last_st = @stash.index
end
def inv_select
@inventory.index = [[$game_party.last_inv,@inventory.item_max-1].min,0].max
end
def st_select
@stash.index = [[$game_party.last_st,@stash.item_max-1].min,0].max
end
def unselect_all
@inventory.unselect
@stash.unselect
end
def memorize_all
memorize_inv
memorize_st
end
end
if $imported[:Theo_LimInventory]
class Window_ChestFreeSlot < Window_FreeSlot
attr_accessor :item
attr_accessor :mode
def initialize(x,y,w)
@add_number = 0
@mode = :stash
super(x,y,w)
end
def add_number=(number)
temp = @add_number
@add_number = number
refresh if temp != number
end
def draw_inv_slot(x,y,width = contents.width,align = 2)
item_size = @item.nil? ? 0 : @item.inv_size
item_size = -item_size if @mode == :inventory
txt = sprintf("%d/%d",$game_party.total_inv_size + @add_number *
item_size, $game_party.inv_max)
color = Theo::LimInv::NearMaxed_Color
near_max = ($game_party.total_inv_size + @add_number * item_size).to_f /
$game_party.inv_max >= (100 - Theo::LimInv::NearMaxed_Percent)/100.0
if near_max
change_color(text_color(color))
else
change_color(normal_color)
end
draw_text(x,y,width,line_height,txt,align)
change_color(normal_color)
end
end
end
class Window_ChestCategory < Window_ItemCategory
attr_reader :stash_window
def col_max
return 4
end
def update
super
@stash_window.category = current_symbol if @stash_window
end
def make_command_list
add_command(THEO::CHEST::ALL_VOCAB, :all)
add_command(Vocab::item, :item)
add_command(Vocab::weapon, :weapon)
add_command(Vocab::armor, :armor)
end
def stash_window=(stash_window)
@stash_window = stash_window
update
end
end
class Window_Inventory < Window_ItemList
attr_reader :data
def col_max
return 1
end
def current_item_enabled?
return true
end
def include?(item)
case @category
when :item
item.is_a?(RPG::Item) && !item.key_item?
when :weapon
item.is_a?(RPG::Weapon)
when :armor
item.is_a?(RPG::Armor)
when :all
item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
else
false
end
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, true,contents.width)
draw_item_number(rect, item)
end
end
def item_number(item = @data[index])
$game_party.item_number(item)
end
def process_ok
return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
super
end
end
class Window_Stash < Window_ItemList
attr_reader :data
def initialize(x, y, width, height, key)
@key = key
super(x,y,width,height)
@category = :none
@data = []
end
def col_max
return 1
end
def current_item_enabled?
enable?(item)
end
def enable?(item)
return true unless $imported[:Theo_LimInventory]
return $game_party.inv_max_item(item) > 0
end
def include?(item)
case @category
when :item
item.is_a?(RPG::Item) && !item.key_item?
when :weapon
item.is_a?(RPG::Weapon)
when :armor
item.is_a?(RPG::Armor)
when :all
item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
else
false
end
end
def make_item_list
@data = $game_chests[@key].all_items.select {|item| include?(item) }
@data.push(nil) if include?(nil)
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item),contents.width)
draw_item_number(rect, item)
end
end
def draw_item_number(rect, item)
draw_text(rect, sprintf(":%2d", $game_chests[@key].item_number(item)), 2)
end
def item_number(item = @data[index])
$game_chests[@key].item_number(item)
end
def process_ok
return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
super
end
end
class Window_ChestAmount < Window_Base
attr_accessor :item_window
attr_accessor :mode
attr_reader :amount
def initialize
super(0,0,window_width,window_height)
self.openness = 0
@mode = :stash
reset_amount
update_position
refresh
end
def inv_window=(window)
@inv_window = window
end
def reset_amount
@amount = 0
refresh
end
def open
super
reset_amount
end
def update_position
self.x = (Graphics.width / 2) - (self.width / 2)
self.y = (Graphics.height / 2) - (self.height / 2)
end
def refresh
contents.clear
draw_text(0,0,contents.width,24,THEO::CHEST::AMOUNT_VOCAB,)
draw_text(0,0,contents.width,24,@amount,2)
end
def window_width
return 200
end
def window_height
return 24+24
end
def update
super
if @inv_window
@inv_window.add_number = @amount
@inv_window.item = @item_window.item if @item_window
end
if open?
increment if Input.repeat?(:RIGHT)
decrement if Input.repeat?(:LEFT)
ten_increment if Input.repeat?(:UP)
ten_decrement if Input.repeat?(:DOWN)
end
end
def increment
change_amount(1)
end
def decrement
change_amount(-1)
end
def ten_increment
change_amount(10)
end
def ten_decrement
change_amount(-10)
end
def change_amount(modifier)
@amount = [[@amount+modifier,0].max,max_amount].min
refresh
end
def show
super
reset_amount
end
def max_amount
if $imported[:Theo_LimInventory]
if @mode == :inventory
@item_window.item_number rescue 0
elsif @mode == :stash
[@item_window.item_number,$game_party.inv_max_item(@item_window.item)].min
end
else
@item_window.item_number rescue 0
end
end
end
class Window_ChestFooter < Window_Base
include THEO::CHEST
def initialize(vocab,object,x)
w = Graphics.width/2
h = fitting_height(1)
y = Graphics.height - h
x = (Graphics.width/2) * x
@vocab = vocab
super(x,y,w,h)
@object = object
refresh
end
def refresh
contents.clear
cx = text_size(@vocab).width
draw_text(0,0,contents.width,line_height,@vocab,1)
end
end
module DataManager
class << self
alias pre_create_chest create_game_objects
alias pre_chest_save_contents make_save_contents
alias pre_extract_chests extract_save_contents
end
def self.create_game_objects
pre_create_chest
create_chest_object
end
def self.create_chest_object
$game_chests = Game_Chest.new
end
def self.make_save_contents
contents = pre_chest_save_contents
contents[:chest] = $game_chests
contents
end
def extract_save_contents(contents)
pre_extract_chests(contents)
$game_chests = contents[:chest]
end
end
class Game_Chest
def initialize
@data = {}
@explored = {}
end
def[](key)
(@data[key] ||= Game_Stash.new)
end
def explored
@explored
end
end
class Game_Stash
attr_accessor :items_stash
attr_accessor :weapons_stash
attr_accessor :armors_stash
def initialize
@items_stash = {}
@weapons_stash = {}
@armors_stash = {}
end
def refresh
evaluate(@items_stash)
evaluate(@weapons_stash)
evaluate(@armors_stash)
end
def evaluate(stash)
stash.keys.each do |key|
stash.delete(key) if stash[key] <= 0
end
end
def items
@items_stash.keys.collect {|id| $data_items[id] }
end
def weapons
@weapons_stash.keys.collect {|id| $data_weapons[id] }
end
def armors
@armors_stash.keys.collect {|id| $data_armors[id] }
end
def all_items
items + weapons + armors
end
def item_number(item)
if item.is_a?(RPG::Item)
return @items_stash[item.id] ||= 0
elsif item.is_a?(RPG::Weapon)
return @weapons_stash[item.id] ||= 0
elsif item.is_a?(RPG::Armor)
return @armors_stash[item.id] ||= 0
end
refresh
end
def gain_item(item, amount)
return unless item
stash = pick_stash(item)
stash[item.id] = 0 if stash[item.id].nil?
stash[item.id] += amount
refresh
end
def lose_item(item,amount)
gain_item(item,-amount)
end
def pick_stash(item)
if item.is_a?(RPG::Item)
return @items_stash
elsif item.is_a?(RPG::Weapon)
return @weapons_stash
elsif item.is_a?(RPG::Armor)
return @armors_stash
end
end
end
class Game_Party
attr_accessor :last_inv
attr_accessor :last_st
alias pre_chest_init initialize
def initialize
pre_chest_init
init_chest_cursors
end
def init_chest_cursors
@last_inv = 0
@last_st = 0
end
end
class Game_Interpreter
def open_chest(st_vocab = THEO::CHEST::ST_VOCAB,key = [@map_id,@event_id])
if st_vocab.is_a?(Numeric)
key = st_vocab
st_vocab = THEO::CHEST::ST_VOCAB
end
SceneManager.call_chest(key,st_vocab)
end
alias pre_chest_command_108 command_108
def command_108
pre_chest_command_108
read_chest_comments
end
def read_chest_comments
map = @map_id
event = @event_id
key = [map,event]
return if $game_chests.explored[key]
@comments.each do |comment|
case comment
when THEO::CHEST::REGEXP::ITEM_REGEX
x = $1.scan(/\d+/)
$game_chests[key].items_stash[x[0].to_i] = x[1].to_i
when THEO::CHEST::REGEXP::WEAPON_REGEX
x = $1.scan(/\d+/)
$game_chests[key].weapons_stash[x[0].to_i] = x[1].to_i
when THEO::CHEST::REGEXP::ARMOR_REGEX
x = $1.scan(/\d+/)
$game_chests[key].armors_stash[x[0].to_i] = x[1].to_i
end
end
$game_chests.explored[key] = next_event_code != 108
end
end
module SceneManager
def self.call_chest(key,st_vocab = THEO::CHEST::ST_VOCAB)
@stack.push(@scene)
@scene = Scene_Chest.new(key,st_vocab)
end
end
复制代码
作者:
1114905982
时间:
2020-4-10 01:02
刈飒的风 发表于 2020-4-9 16:20
谢谢大佬
作者:
老子降临
时间:
2020-6-20 22:13
刈飒的风 发表于 2020-4-9 16:20
恩,想知道,这个如何创建一个仓库呢?我是说加入这个脚本后,游戏里是怎么实现??
作者:
samnle
时间:
2021-3-8 20:50
我也想知道下VA的
作者:
未来灬future
时间:
2021-3-9 18:12
脚本第30至45行有写,应该是那个
作者:
djs789783
时间:
2024-3-10 20:29
好用,给力,谢谢,么么哒爱你哟
作者:
重装爱好者
时间:
2024-3-22 22:48
新人问一下,这个脚本怎么用?
作者:
寂寞的青椒
时间:
2024-4-25 02:05
重装爱好者 发表于 2024-3-22 22:48
新人问一下,这个脚本怎么用?
点击上面的复制 然后VA编辑器里找到脚本的按钮 在Main前插入就行
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1