赞 | 1 |
VIP | 0 |
好人卡 | 0 |
积分 | 11 |
经验 | 0 |
最后登录 | 2025-6-11 |
在线时间 | 114 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1091
- 在线时间
- 114 小时
- 注册时间
- 2019-3-2
- 帖子
- 38
|
300星屑
本帖最后由 sansy 于 2025-6-10 04:06 编辑
如题,两个脚本的功能分别为给物品设置负重,负重达到上限后无法继续获得物品以及将需要的事件变为一个可存入可取出物品的容器箱子。
当这两个脚本同时使用时,从箱子里拿出物品可以超过负重上限(即可以继续取出,不会受到限制),但是实际上物品没有进入背包,而是直接消失掉了。
如何让这个容器脚本对物品负重的处理变为类似于物品数量上限的处理:
即选择取出的数量时,最终容量不能超过物品上限(etc:物品A的上限为99个,队伍持有95个,而箱子里有10个,此时玩家选择要取出的数量时最多将数字设置为4)
且在当前队伍连一个该物品都拿不下时,选择拿出该物品的操作无效(类似于尝试拿取背包中数量已达上限的物品)。
如果内容过于复杂需要详细说明或者需要进行有偿支付,可以留下QQ联系方式。
脚本如下:
负重脚本前置:
#============================================================================== # ■ むー素材用モジュール Ver1.0 #------------------------------------------------------------------------------ # スクリプトに必要なモジュールです。 By むー #------------------------------------------------------------------------------ # 使用スクリプト # ・ドロップアイテム演出 # ・アイテム重量制 #============================================================================== module MOO_GENERAL_MODULE #-------------------------------------------------------------------------- # 以下、設定箇所です。 #-------------------------------------------------------------------------- # ウィンドウのサイズ(1=544x416 / 2=640x480) WINDOW_SIZE = 1 # ここで指定しても、ウィンドウサイズが変わるわけではありません。 #-------------------------------------------------------------------------- # ここまで。 #-------------------------------------------------------------------------- #************************************************************************** # ※ ここ以下は変更しないでください。 #************************************************************************** #-------------------------------------------------------------------------- # ● 左右どちらかに指定文字を埋める # word: 元々の文字列 # len: 全部で何文字にするか # str: 埋める文字 # lr: 埋める文字を付ける方向(1=左/2=右) # bury_plus("world", 8, " ", 1) → 結果: " world" # bury_plus("world", 8, "@", 2) → 結果: "world@@@" #-------------------------------------------------------------------------- def bury_plus(word, len, str, lr = 1) return word if word.length >= len str.to_s pls = "" for i in 1..len - word.length pls += str end case lr when 1; return pls + word when 2; return word + pls end end #-------------------------------------------------------------------------- # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置 #-------------------------------------------------------------------------- def weight_item_window_x return 384 if WINDOW_SIZE == 1 return 480 if WINDOW_SIZE == 2 end #-------------------------------------------------------------------------- # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置 #-------------------------------------------------------------------------- def weight_item_window_y return 72 if WINDOW_SIZE == 1 return 72 if WINDOW_SIZE == 2 end #-------------------------------------------------------------------------- # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置 #-------------------------------------------------------------------------- def weight_item_window_w return 160 if WINDOW_SIZE == 1 return 160 if WINDOW_SIZE == 2 end #-------------------------------------------------------------------------- # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置 #-------------------------------------------------------------------------- def weight_item_window_h return 48 if WINDOW_SIZE == 1 return 48 if WINDOW_SIZE == 2 end #-------------------------------------------------------------------------- # ● 重量制限用:ショップの売却画面で総重量を示すウィンドウの幅調整 #-------------------------------------------------------------------------- def weight_shop_buy_category_window_adjust_w return 32 if WINDOW_SIZE == 1 return 32 if WINDOW_SIZE == 2 end end
#==============================================================================
# ■ むー素材用モジュール Ver1.0
#------------------------------------------------------------------------------
# スクリプトに必要なモジュールです。 By むー
#------------------------------------------------------------------------------
# 使用スクリプト
# ・ドロップアイテム演出
# ・アイテム重量制
#==============================================================================
module MOO_GENERAL_MODULE
#--------------------------------------------------------------------------
# 以下、設定箇所です。
#--------------------------------------------------------------------------
# ウィンドウのサイズ(1=544x416 / 2=640x480)
WINDOW_SIZE = 1
# ここで指定しても、ウィンドウサイズが変わるわけではありません。
#--------------------------------------------------------------------------
# ここまで。
#--------------------------------------------------------------------------
#**************************************************************************
# ※ ここ以下は変更しないでください。
#**************************************************************************
#--------------------------------------------------------------------------
# ● 左右どちらかに指定文字を埋める
# word: 元々の文字列
# len: 全部で何文字にするか
# str: 埋める文字
# lr: 埋める文字を付ける方向(1=左/2=右)
# bury_plus("world", 8, " ", 1) → 結果: " world"
# bury_plus("world", 8, "@", 2) → 結果: "world@@@"
#--------------------------------------------------------------------------
def bury_plus(word, len, str, lr = 1)
return word if word.length >= len
str.to_s
pls = ""
for i in 1..len - word.length
pls += str
end
case lr
when 1; return pls + word
when 2; return word + pls
end
end
#--------------------------------------------------------------------------
# ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
#--------------------------------------------------------------------------
def weight_item_window_x
return 384 if WINDOW_SIZE == 1
return 480 if WINDOW_SIZE == 2
end
#--------------------------------------------------------------------------
# ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
#--------------------------------------------------------------------------
def weight_item_window_y
return 72 if WINDOW_SIZE == 1
return 72 if WINDOW_SIZE == 2
end
#--------------------------------------------------------------------------
# ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
#--------------------------------------------------------------------------
def weight_item_window_w
return 160 if WINDOW_SIZE == 1
return 160 if WINDOW_SIZE == 2
end
#--------------------------------------------------------------------------
# ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
#--------------------------------------------------------------------------
def weight_item_window_h
return 48 if WINDOW_SIZE == 1
return 48 if WINDOW_SIZE == 2
end
#--------------------------------------------------------------------------
# ● 重量制限用:ショップの売却画面で総重量を示すウィンドウの幅調整
#--------------------------------------------------------------------------
def weight_shop_buy_category_window_adjust_w
return 32 if WINDOW_SIZE == 1
return 32 if WINDOW_SIZE == 2
end
end
负重脚本本体:
#============================================================================== # ■ 重量制 Ver 1.21 By むー #------------------------------------------------------------------------------ # アイテムに重量を付加し、所持可能な重量を指定できます。 # 本スクリプトを利用するには、[むー素材用]スクリプトが別途必要になります。 # 本スクリプトは[むー素材用]よりも下に設置して下さい。 #------------------------------------------------------------------------------ # # ★簡単な仕様★ # # ・ゲームに重量を設置します。 # ・設定した総重量以上の物は持てません。 # ・チェックコマンドにて、イベントで入手可能チェックができます。 # ・戦闘後のドロップアイテムは、持てる分だけ出ます。 # →3個出た場合、最初の2個は持てるけれど残りが持てない場合、 # 2個分だけメッセージが出ます。入手も2個だけです。 # ・重量オーバーの場合、店で購入ができません。 # ・イベントでアイテムの増加をおこなう場合にもチェックが入ります。 # →特にメッセージは出ません。例えば5個入手で持てるだけ入手したい場合は、 # 5個いぺっんに入手ではなく、1個入手を5回分作って下さい。 # 5個いっぺんに入手する場合、5個持てなかったら1個も入手できません。 # # ★チェック機能★ # # イベントでアイテムを入手する時、重量オーバーになると取得できません。 # イベントのスクリプトで、以下のように記述すると動作する機能があります。 # # can_gain_item?(アイテム種類, ID, 数量, スイッチ番号, [取得フラグ]) # # アイテム種類: アイテム="I"、武器="W"、防具="A" # ID : 上記アイテム種類別のID ("W",3...) なら武器ID3 # 数量 : 取得する数量 # スイッチ番号: 入手できる場合はON、できない場合はOFFが入るスイッチの番号 # 取得フラグ : ついでに取得するか(true/false) # # アイテム種類は必ず""で囲って下さい。I、W、A以外のチェックしていません。 # 数量が0の場合のエラーチェックはおこなっていません。 # アイテム種類、ID、数量、スイッチ番号は必須です。 # スイッチを使わない場合は、0にしておいて下さい。 # 取得フラグをtrueにしておくと、取得可能な場合は自動的にアイテムを入手します。 # falseまたは何も記述しなかった場合は取得しません。 # またスイッチに入れなくとも、返り値でtrueかfalseが戻ります。 # # ★注意点★ # # ・ゲーム開始時に、基本重量を設定して下さい。 # ・初期装備によって、総重量がオーバーしている場合があります。 # #============================================================================== $rgsslab = {} if $rgsslab.nil? # 併用対策 #============================================================================== $moo_have_item_weight = true module MOO_HAVE_ITEM_WEIGHT #-------------------------------------------------------------------------- # 以下、設定箇所です。 #-------------------------------------------------------------------------- # 総重量を代入する変数番号 MAX_WT = 11 # 重量指定文字 WORD_WT = "重量" # アイテム(および装備品)のメモ欄に書く文字です。 # "重量"の場合、<重量:5>とすれば、そのアイテムの重量は5になります。 # 他のスクリプトと重複する場合は変更してください。 # 重量指定のないアイテムの重量 DEFAULT_WT = 1 # 重量の指定をしなかったアイテムの重量です。 # 所持している総重量計算を個数×重量にするか UNIT_WT = true # 総重量の計算をどうするか決めます。 # trueの場合、アイテム個数×個別の重量の総計が、所持している総重量になります。 # falseの場合、アイテムが1個でも99個でも1個分の重さが総重量に加算されます。 # アイテム欄の重量表示を個数×重量にするか VIEW_WT = true # アイテム個数の後ろに表示される重量表示をどうするか決めます。 # trueの場合、アイテムの重量が5で個数が4の場合、20と表示されます。 # falseの場合、個数に関係なく、単純にアイテムの重量だけが表示されます。 # このVIEW_WTをfalse、上記のUNIT_WTがtrueの場合、錯覚しないようご注意ください。 # その場合、()はあくまでそのアイテムの重量であり、総重量は個数×重量となります。 # また、UNIT_WTをfalse、VIEW_WTをtrueにすると、混乱の元となります(笑) # 重量計算に装備品を含むか CONT_WT = false # 装備品を総重量に含むかどうかを決めます。 # 袋(?)はあくまで袋、装備品は関係ない、などのような場合はfalseにして下さい。 # 総重量を表示する上での文字 SUM_WEIGHT_WORD = "总重量" # アイテム欄で重量を囲う文字 PARENTHESIS_F = "重量:" # 前 PARENTHESIS_L = "" # 後 # 1つのアイテム重量の最大桁数 FIGURE_WT = 2 # 1つのアイテムに設定する重量の桁数です。99までなら2という感じで。 # 上の「アイテム欄で重量を囲う文字」と合わせて表示しますが、 # これが"(W:"と")"だった場合、画面上のアイテム欄には # [アイテム名 10(W: 5)] のように表示されます。 # ↑ ↑ ↑ # アイテム名 個数 重さ(この部分の数字の前の空白に関わってきます) # 売買価格のレートを格納する変数 (1 = 1%)/おまけ機能 USE_RATE = false # レート変動を使う場合 BUY_RATE = 12 # 購入レート(USE_RATE=trueの場合のみ有効) SELL_RATE = 13 # 売却レート(USE_RATE=trueの場合のみ有効) # 指定しない場合、購入価格と売却価格は同じになります。 # 小数点以下の価格は切り捨てられます。 # 販売不可アイテムの文字 CANT_SELL = "重量制販売不可" # アイテムのメモ欄にこの文字があると、価格が0以上でも # ショップで販売不可になります(0はデフォルトのまま販売不可です)。 # 重量制販売不可 とした場合、<重量制販売不可> と <>を一緒に記述して下さい。 # なお、これはあくまでデフォルト形態のショップだけに有効です。 #-------------------------------------------------------------------------- # 以下、他のスクリプトを導入しているかどうかの判断です。 # これらのスクリプトを使用する場合、本スクリプトより上の位置に置いて下さい。 #-------------------------------------------------------------------------- # ドロップアイテム系のスクリプトを導入しているか DROP_ITEM = false # 導入している場合は true にして下さい。通常は false にして下さい。 # その際、そのスクリプトに$game_party.gain_item(ナントカ)とあると思います。 # その前後に、本スクリプトの中身のように改造する必要があります。 # #-------------------------------------------------------------------------- # ここまで。 #-------------------------------------------------------------------------- end #============================================================================== # ★ ここより下は変更しないで下さい。 #============================================================================== if MOO_HAVE_ITEM_WEIGHT::DROP_ITEM == false #============================================================================== # ■ BattleManager #------------------------------------------------------------------------------ # 戦闘の進行を管理するモジュールです。 #============================================================================== module BattleManager def self.gain_drop_items $game_troop.make_drop_items.each do |item| if $game_party.gain_item_failed?(item) # ドロップ系スクリプトに追加部分 $game_party.moo_gain_item(item, 1) $game_message.add(sprintf(Vocab::ObtainItem, item.name)) end # ドロップ系スクリプトに追加部分 end wait_for_message end end end #============================================================================== # ■ Game_Party #------------------------------------------------------------------------------ # パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ # スのインスタンスは $game_party で参照されます。 #============================================================================== class Game_Party < Game_Unit include MOO_GENERAL_MODULE #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :gold # 所持金 attr_reader :steps # 歩数 attr_reader :last_item # カーソル記憶用 : アイテム #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super @gold = 0 @steps = 0 @last_item = Game_BaseItem.new @total_weight = 0 # 追加 @menu_actor_id = 0 @target_actor_id = 0 @actors = [] init_all_items end #-------------------------------------------------------------------------- # ◎ アイテムの増加(減少) # include_equip : 装備品も含める #-------------------------------------------------------------------------- alias moo_gain_item gain_item def gain_item(item, amount, include_equip = false) # gain_item内では、include_equipの関係からか、memberが使えません。 # ですので重量に装備品を含む場合、メンバーの装備情報が取得できません。 # 以下の"if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false"があるのはそのためです。 # 重量に装備品抜きの場合に限り、ここで重量のチェックをしています。 # # 総重量を超える場合は取得不可能 # 1度に2以上取得しようとして引っかかった場合は、 # たとえ1個分の許容があったとしても、全て取得できません。 # # 一応ここ以外にも、以下の箇所で入手可能かどうかのチェックをしています。 # # ・イベントでアイテム、武器、防具を入手する時 # ・ショップでアイテムを購入する時 # ・戦闘後のドロップアイテム入手時 # ・装備を変更する時 # # 普通に作成していれば、ここでチェックしなくてもよほど大丈夫だとはいますが、 # 他のスクリプトを導入する際、アイテム入手がある場合は注意して下さい。 # アイテム入手前に $game_party.gain_item(アイテム, 数量) を使って # trueかfalseで判断するようにして下さい。 if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false return if gain_item_failed?(item, amount) == false end # moo_gain_item(item, amount, include_equip) container = item_container(item.class) return unless container last_number = item_number(item) new_number = last_number + amount container[item.id] = [[new_number, 0].max, max_item_number(item)].min container.delete(item.id) if container[item.id] == 0 if include_equip && new_number < 0 discard_members_equip(item, -new_number) end $game_map.need_refresh = true end #-------------------------------------------------------------------------- # ○ アイテムの個別重量を取得 #-------------------------------------------------------------------------- def weight_item(item) return 0 if item == nil # アイテムのメモ取得 memo = item.note.scan((/<#{MOO_HAVE_ITEM_WEIGHT::WORD_WT}[::](\S+)>/)) memo = memo.flatten # 重量取得 if memo != nil and not memo.empty? # 重量設定がある場合はそれを採用 wt = memo[0].to_i else # 重量設定がない場合は指定した重量とする wt = MOO_HAVE_ITEM_WEIGHT::DEFAULT_WT end return wt end #-------------------------------------------------------------------------- # ○ 所持アイテムの総重量を取得 #-------------------------------------------------------------------------- def weight_sum # 変数初期化 wt = 0 # 所持しているアイテムの重量取得 $data_items.each do |item| # アイテムの総重量 wt += weight_have_item(item) if item and item.name != "" end $data_weapons.each do |item| # 武器の総重量 wt += weight_have_item(item) if item and item.name != "" end $data_armors.each do |item| # 防具の総重量 wt += weight_have_item(item) if item and item.name != "" end return wt end #-------------------------------------------------------------------------- # ○ 所持アイテムの個別重量を取得(フラグがあれば装備品を含む) #-------------------------------------------------------------------------- def weight_have_item(item) return 0 if item == nil # アイテムの個別重量を取得 wt = weight_item(item) # 所持個数の取得 cn = item_number(item) if MOO_HAVE_ITEM_WEIGHT::CONT_WT if item.class == RPG::Weapon or item.class == RPG::Armor members.each do |actor| if item.class == RPG::Weapon cn += 1 if $game_actors[actor.id].equips[0] == item cn += 1 if $game_actors[actor.id].equips[1] == item elsif item.class == RPG::Armor cn += 1 if $game_actors[actor.id].equips[item.etype_id] == item end end end end # 個数×重量の場合の計算 if cn == 0 wt = 0 else wt *= cn if MOO_HAVE_ITEM_WEIGHT::UNIT_WT end return wt end #-------------------------------------------------------------------------- # ○ 重量をカッコ書き(アイテム一覧に書くため) #-------------------------------------------------------------------------- def weight_item_draw(item) wt = weight_item(item).to_i wt *= item_number(item) if MOO_HAVE_ITEM_WEIGHT::VIEW_WT wt = wt.to_s wt = bury_plus(wt, MOO_HAVE_ITEM_WEIGHT::FIGURE_WT, " ", lr = 1) wt = MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_F + wt + MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_L return wt end #-------------------------------------------------------------------------- # ○ アイテムを取得可能かどうかの判断 #-------------------------------------------------------------------------- def gain_item_failed?(item, val = 1) val = 1 if MOO_HAVE_ITEM_WEIGHT::UNIT_WT == false if weight_sum + weight_item(item) * val > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT] false else true end end #-------------------------------------------------------------------------- # ○ 個数の限界によってアイテムを取得可能かどうかの判断 #-------------------------------------------------------------------------- def gain_item_max?(item, val = 1) return false if item_number(item) + val > max_item_number(item) return true end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ # アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors) # の内部で使用され、Game_Party クラス($game_party)からも参照されます。 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ◎ 装備の変更 # slot_id : 装備スロット ID # item : 武器/防具(nil なら装備解除) #-------------------------------------------------------------------------- alias moo_change_equip change_equip def change_equip(slot_id, item) # equips[slot_id]: 装備中アイテム(nil=装備なし) # item: これから装備しようとしているアイテム(nil=装備なし) if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false wt_old = $game_party.weight_item(equips[slot_id]) wt_new = $game_party.weight_item(item) wt_clc = $game_party.weight_sum + wt_old - wt_new # wt_clc: 現在の重さ + 外す装備品の重さ - これから装備する物の重さ if wt_clc > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT] Sound.play_buzzer return end end moo_change_equip(slot_id, item) end #-------------------------------------------------------------------------- # ● パーティとアイテムを交換する # new_item : パーティから取り出すアイテム # old_item : パーティに返すアイテム #-------------------------------------------------------------------------- alias moo_trade_item_with_party trade_item_with_party def trade_item_with_party(new_item, old_item) return false if new_item && !$game_party.has_item?(new_item) # 入手と破棄を逆転 $game_party.lose_item(new_item, 1) $game_party.gain_item(old_item, 1) return true end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ # イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● アイテムの増減 #-------------------------------------------------------------------------- def command_126 value = operate_value(@params[1], @params[2], @params[3]) if $game_party.gain_item_failed?($data_items[@params[0]], value) $game_party.moo_gain_item($data_items[@params[0]], value) end end #-------------------------------------------------------------------------- # ● 武器の増減 #-------------------------------------------------------------------------- def command_127 value = operate_value(@params[1], @params[2], @params[3]) if $game_party.gain_item_failed?($data_weapons[@params[0]], value) $game_party.moo_gain_item($data_weapons[@params[0]], value, @params[4]) end end #-------------------------------------------------------------------------- # ● 防具の増減 #-------------------------------------------------------------------------- def command_128 value = operate_value(@params[1], @params[2], @params[3]) if $game_party.gain_item_failed?($data_armors[@params[0]], value) $game_party.moo_gain_item($data_armors[@params[0]], value, @params[4]) end end #-------------------------------------------------------------------------- # ○ 所持品を追加できるかの判断 # kind : アイテム種類(/[IWA]/) # id : アイテムID # num : 入手する個数 # val : 入手可能かどうかを代入するスイッチ番号(使わない場合は0を指定) # gain : 入手処理もついでに行なうか(省略時は行なわない) #-------------------------------------------------------------------------- def can_gain_item?(kind, id, num = 1, val = 0, gain = false) # アイテム変数初期値 item = nil # アイテム種類分別 case kind when "I"; item = $data_items[id] when "W"; item = $data_weapons[id] when "A"; item = $data_armors[id] end # 重量による取得可能チェック flg1 = $game_party.gain_item_failed?(item, num) # 数量による取得可能チェック flg2 = $game_party.gain_item_max?(item, num) # 重量か数量いずれかで取得不能判定があった場合のフラグ flg = true flg = false if flg1 == false or flg2 == false # 取得可能であり取得フラグが立っていたら取得 $game_party.moo_gain_item(item, num) if flg and gain # スイッチに値を返す $game_switches[val] = flg if val > 0 and val != nil # 値を返す return flg end #-------------------------------------------------------------------------- # ○ 所持品の総重量を取得 #-------------------------------------------------------------------------- def get_weight_sum $game_party.weight_sum end end #============================================================================== # ■ Window_ItemCategory #------------------------------------------------------------------------------ # アイテム画面またはショップ画面で、通常アイテムや装備品の分類を選択するウィ # ンドウです。 #============================================================================== class Window_ItemCategory < Window_HorzCommand #-------------------------------------------------------------------------- # ● ウィンドウ幅の取得 #-------------------------------------------------------------------------- def window_width Graphics.width - 160 end end #============================================================================== # ■ Window_ItemList #------------------------------------------------------------------------------ # アイテム画面で、所持アイテムの一覧を表示するウィンドウです。 #============================================================================== class Window_ItemList < Window_Selectable #-------------------------------------------------------------------------- # ● アイテムの個数を描画 #-------------------------------------------------------------------------- def draw_item_number(rect, item) $game_party.weight_sum # カッコ書きの重量文字列を取得 wt = $game_party.weight_item_draw(item) # 数量の後に重量を追加 draw_text(rect, sprintf(":%2d", $game_party.item_number(item)) + wt, 2) end end #============================================================================== # ■ Window_ShopBuy #------------------------------------------------------------------------------ # ショップ画面で、購入できる商品の一覧を表示するウィンドウです。 #============================================================================== class Window_ShopBuy # include MOO_GENERAL_MODULE #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, height, shop_goods) super(x, y, window_width, height) @shop_goods = shop_goods @money = 0 end #-------------------------------------------------------------------------- # ● 商品の値段を取得 #-------------------------------------------------------------------------- def price(item) if MOO_HAVE_ITEM_WEIGHT::USE_RATE return Integer(@price[item] * $game_variables[MOO_HAVE_ITEM_WEIGHT::BUY_RATE] / 100) else return @price[item] end end #-------------------------------------------------------------------------- # ● アイテムリストの作成 #-------------------------------------------------------------------------- def make_item_list @data = [] @price = {} @shop_goods.each do |goods| case goods[0] when 0; item = $data_items[goods[1]] when 1; item = $data_weapons[goods[1]] when 2; item = $data_armors[goods[1]] end if item @data.push(item) @price[item] = goods[2] == 0 ? item.price : goods[3] end end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] rect = item_rect(index) draw_item_name(item, rect.x, rect.y, enable?(item)) rect.width -= 4 # wt = $game_party.weight_item(item) # wt = wt.to_s # wt = bury_plus(wt, MOO_HAVE_ITEM_WEIGHT::FIGURE_WT, " ", 1) # wt = MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_F + wt + MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_L # draw_text(rect, price(item).to_s + wt, 2) draw_text(rect, price(item), 2) end end #============================================================================== # ■ Window_ShopSell #------------------------------------------------------------------------------ # ショップ画面で、売却のために所持アイテムの一覧を表示するウィンドウです。 #============================================================================== class Window_ShopSell #-------------------------------------------------------------------------- # ○ 桁数の取得 #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # ○ 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] rect = item_rect(index) draw_item_name(item, rect.x, rect.y, enable?(item)) rect.width -= 4 draw_text(rect, price(item), 2) end #-------------------------------------------------------------------------- # ◎ アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- alias moo_weight_enable? enable? def enable?(item) flg = $data_items[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Item flg = $data_weapons[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Weapon flg = $data_armors[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Armor return false if flg moo_weight_enable?(item) end #-------------------------------------------------------------------------- # ○ 商品の値段を取得 #-------------------------------------------------------------------------- def price(item) if MOO_HAVE_ITEM_WEIGHT::USE_RATE return Integer(item.price * $game_variables[MOO_HAVE_ITEM_WEIGHT::SELL_RATE] / 100) else return item.price end end end #============================================================================== # ■ Window_ShopNumber #------------------------------------------------------------------------------ # ショップ画面で、購入または売却するアイテムの個数を入力するウィンドウです。 #============================================================================== class Window_ShopNumber < Window_Selectable #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear draw_item_name(@item, 0, item_y) draw_number draw_total_price draw_total_weight(@item) end #-------------------------------------------------------------------------- # ○ 個数の総重量の描画 #-------------------------------------------------------------------------- def draw_total_weight(item) width = contents_width - 8 cx = text_size(@currency_unit).width change_color(system_color) x_plus = 4 if MOO_GENERAL_MODULE::WINDOW_SIZE == 1 y_plus = 36 elsif MOO_GENERAL_MODULE::WINDOW_SIZE == 2 y_plus = 72 end wd = MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD draw_text(4, y + 24 + y_plus, width, line_height, wd) change_color(normal_color) cn = 1 cn = @number if MOO_HAVE_ITEM_WEIGHT::UNIT_WT wt = $game_party.weight_item(item) * cn #@number draw_text(x - cx - 2 + x_plus, y + 24 + y_plus, width, line_height, wt, 2) end end #============================================================================== # ■ Window_ShopStatus #------------------------------------------------------------------------------ # ショップ画面で、アイテムの所持数やアクターの装備を表示するウィンドウです。 #============================================================================== class Window_ShopStatus < Window_Base #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear draw_possession(4, 0) draw_weight_possession(4, 24) y_plus = 0 y_plus = 24 if MOO_GENERAL_MODULE::WINDOW_SIZE == 2 draw_equip_info(4, line_height * 2 + y_plus) if @item.is_a?(RPG::EquipItem) end #-------------------------------------------------------------------------- # ○ 総重量の描画 #-------------------------------------------------------------------------- def draw_weight_possession(x, y) rect = Rect.new(x, y, contents.width - 4 - x, line_height) change_color(system_color) draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD) change_color(normal_color) str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s draw_text(rect, str, 2) end end #============================================================================== # ■ Window_Weight_Sum_Menu #------------------------------------------------------------------------------ # メニューウィンドウで総重量を表示するクラスです。 #============================================================================== class Window_Weight_Sum_Menu < Window_Base #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) refresh end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear rect = Rect.new(0, 0, width - 28, line_height) change_color(system_color) draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD) change_color(normal_color) str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s draw_text(rect, str, 2) end end #============================================================================== # ■ Window_Weight_Sum_item #------------------------------------------------------------------------------ # アイテム一覧で総重量を表示するクラスです。 #============================================================================== class Window_Weight_Sum_item < Window_ItemList #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) refresh end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear rect = Rect.new(0, 0, width - 28, line_height) change_color(system_color) draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD) change_color(normal_color) str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s draw_text(rect, str, 2) end end #============================================================================== # ■ Window_Weight_Sum_Shop #------------------------------------------------------------------------------ # ショップの売却画面で総重量を表示するクラスです。 #============================================================================== class Window_Weight_Sum_Shop < Window_ItemList #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) refresh end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear rect = Rect.new(0, 0, width - 28, line_height) change_color(system_color) draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD) change_color(normal_color) str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s draw_text(rect, str, 2) end end #============================================================================== # ■ Scene_Menu #------------------------------------------------------------------------------ # メニュー画面の処理を行うクラスです。 #============================================================================== class Scene_Menu < Scene_MenuBase include MOO_GENERAL_MODULE #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_command_window create_gold_window create_status_window @wt_x = 0 @wt_y = Graphics.height - @gold_window.height - weight_item_window_h @wt_w = weight_item_window_w @wt_h = @gold_window.height create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h) end #-------------------------------------------------------------------------- # ○ 総重量ウィンドウの作成 #-------------------------------------------------------------------------- def create_weight_sum_window(x, y, width, height) @weight_sum_window = Window_Weight_Sum_Menu.new(x, y, width, height) @weight_sum_window.viewport = @viewport end end #============================================================================== # ■ Scene_Item #------------------------------------------------------------------------------ # アイテム画面の処理を行うクラスです。 #============================================================================== class Scene_Item < Scene_ItemBase include MOO_GENERAL_MODULE #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_help_window create_category_window create_item_window @wt_x = weight_item_window_x @wt_y = weight_item_window_y @wt_w = weight_item_window_w @wt_h = weight_item_window_h create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h) end #-------------------------------------------------------------------------- # ○ 総重量ウィンドウの作成 #-------------------------------------------------------------------------- def create_weight_sum_window(x, y, width, height) @weight_sum_window = Window_Weight_Sum_item.new(x, y, width, height) @weight_sum_window.viewport = @viewport @weight_sum_window.y = @help_window.height end #-------------------------------------------------------------------------- # ● アイテムの使用 #-------------------------------------------------------------------------- def use_item super @item_window.redraw_current_item @weight_sum_window.refresh end end #============================================================================== # ■ Scene_Shop #------------------------------------------------------------------------------ # ショップ画面の処理を行うクラスです。 #============================================================================== class Scene_Shop < Scene_MenuBase include MOO_GENERAL_MODULE #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_help_window create_gold_window create_command_window create_dummy_window create_category_window create_number_window create_status_window create_buy_window @wt_x = weight_item_window_x @wt_y = weight_item_window_y + 48 @wt_w = weight_item_window_w @wt_h = weight_item_window_h create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h) create_sell_window end #-------------------------------------------------------------------------- # ○ 総重量ウィンドウの作成 #-------------------------------------------------------------------------- def create_weight_sum_window(x, y, width, height) @weight_sum_window = Window_Weight_Sum_Shop.new(x, y, width, height) @weight_sum_window.viewport = @viewport @weight_sum_window.y = @help_window.height @weight_sum_window.y = @dummy_window.y @weight_sum_window.hide.deactivate end #-------------------------------------------------------------------------- # ● 個数入力[決定] #-------------------------------------------------------------------------- def on_number_ok case @command_window.current_symbol when :buy do_buy(@number_window.number) @weight_sum_window.refresh @weight_sum_window.hide when :sell do_sell(@number_window.number) @weight_sum_window.refresh end end_number_input @gold_window.refresh @status_window.refresh end #-------------------------------------------------------------------------- # ● 購入の実行 #-------------------------------------------------------------------------- def do_buy(number) if $game_party.gain_item_failed?(@item, number) == false Sound.play_buzzer return end Sound.play_shop $game_party.lose_gold(number * buying_price) $game_party.moo_gain_item(@item, number) end #-------------------------------------------------------------------------- # ● 売却ウィンドウのアクティブ化 #-------------------------------------------------------------------------- def activate_sell_window @category_window.show @weight_sum_window.show @sell_window.refresh @sell_window.show.activate @status_window.hide end #-------------------------------------------------------------------------- # ● 購入ウィンドウのアクティブ化 #-------------------------------------------------------------------------- def activate_buy_window @buy_window.money = money @buy_window.show.activate @status_window.show end #-------------------------------------------------------------------------- # ● コマンド[購入する] #-------------------------------------------------------------------------- def command_buy @dummy_window.hide activate_buy_window @buy_window.select(0) @buy_window.refresh end #-------------------------------------------------------------------------- # ● コマンド[売却する] #-------------------------------------------------------------------------- def command_sell @dummy_window.hide @category_window.show.activate @weight_sum_window.show @sell_window.show @sell_window.unselect @sell_window.refresh @weight_sum_window.show end #-------------------------------------------------------------------------- # ● カテゴリ[キャンセル] #-------------------------------------------------------------------------- def on_category_cancel @command_window.activate @dummy_window.show @category_window.hide @weight_sum_window.hide @sell_window.hide end #-------------------------------------------------------------------------- # ● 売却[決定] #-------------------------------------------------------------------------- def on_sell_ok @item = @sell_window.item @status_window.item = @item @category_window.hide @weight_sum_window.hide @sell_window.hide @number_window.set(@item, max_sell, selling_price, currency_unit) @number_window.show.activate @status_window.show end #-------------------------------------------------------------------------- # ● 売却[キャンセル] #-------------------------------------------------------------------------- def on_sell_cancel @sell_window.unselect @category_window.activate @weight_sum_window.activate @status_window.item = nil @help_window.clear end #-------------------------------------------------------------------------- # ● 売却の実行 #-------------------------------------------------------------------------- def do_sell(number) Sound.play_shop $game_party.gain_gold(number * selling_price) $game_party.lose_item(@item, number) end #-------------------------------------------------------------------------- # ● 売値の取得 #-------------------------------------------------------------------------- def selling_price @sell_window.price(@item) end end
#==============================================================================
# ■ 重量制 Ver 1.21 By むー
#------------------------------------------------------------------------------
# アイテムに重量を付加し、所持可能な重量を指定できます。
# 本スクリプトを利用するには、[むー素材用]スクリプトが別途必要になります。
# 本スクリプトは[むー素材用]よりも下に設置して下さい。
#------------------------------------------------------------------------------
#
# ★簡単な仕様★
#
# ・ゲームに重量を設置します。
# ・設定した総重量以上の物は持てません。
# ・チェックコマンドにて、イベントで入手可能チェックができます。
# ・戦闘後のドロップアイテムは、持てる分だけ出ます。
# →3個出た場合、最初の2個は持てるけれど残りが持てない場合、
# 2個分だけメッセージが出ます。入手も2個だけです。
# ・重量オーバーの場合、店で購入ができません。
# ・イベントでアイテムの増加をおこなう場合にもチェックが入ります。
# →特にメッセージは出ません。例えば5個入手で持てるだけ入手したい場合は、
# 5個いぺっんに入手ではなく、1個入手を5回分作って下さい。
# 5個いっぺんに入手する場合、5個持てなかったら1個も入手できません。
#
# ★チェック機能★
#
# イベントでアイテムを入手する時、重量オーバーになると取得できません。
# イベントのスクリプトで、以下のように記述すると動作する機能があります。
#
# can_gain_item?(アイテム種類, ID, 数量, スイッチ番号, [取得フラグ])
#
# アイテム種類: アイテム="I"、武器="W"、防具="A"
# ID : 上記アイテム種類別のID ("W",3...) なら武器ID3
# 数量 : 取得する数量
# スイッチ番号: 入手できる場合はON、できない場合はOFFが入るスイッチの番号
# 取得フラグ : ついでに取得するか(true/false)
#
# アイテム種類は必ず""で囲って下さい。I、W、A以外のチェックしていません。
# 数量が0の場合のエラーチェックはおこなっていません。
# アイテム種類、ID、数量、スイッチ番号は必須です。
# スイッチを使わない場合は、0にしておいて下さい。
# 取得フラグをtrueにしておくと、取得可能な場合は自動的にアイテムを入手します。
# falseまたは何も記述しなかった場合は取得しません。
# またスイッチに入れなくとも、返り値でtrueかfalseが戻ります。
#
# ★注意点★
#
# ・ゲーム開始時に、基本重量を設定して下さい。
# ・初期装備によって、総重量がオーバーしている場合があります。
#
#==============================================================================
$rgsslab = {} if $rgsslab.nil? # 併用対策
#==============================================================================
$moo_have_item_weight = true
module MOO_HAVE_ITEM_WEIGHT
#--------------------------------------------------------------------------
# 以下、設定箇所です。
#--------------------------------------------------------------------------
# 総重量を代入する変数番号
MAX_WT = 11
# 重量指定文字
WORD_WT = "重量"
# アイテム(および装備品)のメモ欄に書く文字です。
# "重量"の場合、<重量:5>とすれば、そのアイテムの重量は5になります。
# 他のスクリプトと重複する場合は変更してください。
# 重量指定のないアイテムの重量
DEFAULT_WT = 1
# 重量の指定をしなかったアイテムの重量です。
# 所持している総重量計算を個数×重量にするか
UNIT_WT = true
# 総重量の計算をどうするか決めます。
# trueの場合、アイテム個数×個別の重量の総計が、所持している総重量になります。
# falseの場合、アイテムが1個でも99個でも1個分の重さが総重量に加算されます。
# アイテム欄の重量表示を個数×重量にするか
VIEW_WT = true
# アイテム個数の後ろに表示される重量表示をどうするか決めます。
# trueの場合、アイテムの重量が5で個数が4の場合、20と表示されます。
# falseの場合、個数に関係なく、単純にアイテムの重量だけが表示されます。
# このVIEW_WTをfalse、上記のUNIT_WTがtrueの場合、錯覚しないようご注意ください。
# その場合、()はあくまでそのアイテムの重量であり、総重量は個数×重量となります。
# また、UNIT_WTをfalse、VIEW_WTをtrueにすると、混乱の元となります(笑)
# 重量計算に装備品を含むか
CONT_WT = false
# 装備品を総重量に含むかどうかを決めます。
# 袋(?)はあくまで袋、装備品は関係ない、などのような場合はfalseにして下さい。
# 総重量を表示する上での文字
SUM_WEIGHT_WORD = "总重量"
# アイテム欄で重量を囲う文字
PARENTHESIS_F = "重量:" # 前
PARENTHESIS_L = "" # 後
# 1つのアイテム重量の最大桁数
FIGURE_WT = 2
# 1つのアイテムに設定する重量の桁数です。99までなら2という感じで。
# 上の「アイテム欄で重量を囲う文字」と合わせて表示しますが、
# これが"(W:"と")"だった場合、画面上のアイテム欄には
# [アイテム名 10(W: 5)] のように表示されます。
# ↑ ↑ ↑
# アイテム名 個数 重さ(この部分の数字の前の空白に関わってきます)
# 売買価格のレートを格納する変数 (1 = 1%)/おまけ機能
USE_RATE = false # レート変動を使う場合
BUY_RATE = 12 # 購入レート(USE_RATE=trueの場合のみ有効)
SELL_RATE = 13 # 売却レート(USE_RATE=trueの場合のみ有効)
# 指定しない場合、購入価格と売却価格は同じになります。
# 小数点以下の価格は切り捨てられます。
# 販売不可アイテムの文字
CANT_SELL = "重量制販売不可"
# アイテムのメモ欄にこの文字があると、価格が0以上でも
# ショップで販売不可になります(0はデフォルトのまま販売不可です)。
# 重量制販売不可 とした場合、<重量制販売不可> と <>を一緒に記述して下さい。
# なお、これはあくまでデフォルト形態のショップだけに有効です。
#--------------------------------------------------------------------------
# 以下、他のスクリプトを導入しているかどうかの判断です。
# これらのスクリプトを使用する場合、本スクリプトより上の位置に置いて下さい。
#--------------------------------------------------------------------------
# ドロップアイテム系のスクリプトを導入しているか
DROP_ITEM = false
# 導入している場合は true にして下さい。通常は false にして下さい。
# その際、そのスクリプトに$game_party.gain_item(ナントカ)とあると思います。
# その前後に、本スクリプトの中身のように改造する必要があります。
#
#--------------------------------------------------------------------------
# ここまで。
#--------------------------------------------------------------------------
end
#==============================================================================
# ★ ここより下は変更しないで下さい。
#==============================================================================
if MOO_HAVE_ITEM_WEIGHT::DROP_ITEM == false
#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
# 戦闘の進行を管理するモジュールです。
#==============================================================================
module BattleManager
def self.gain_drop_items
$game_troop.make_drop_items.each do |item|
if $game_party.gain_item_failed?(item) # ドロップ系スクリプトに追加部分
$game_party.moo_gain_item(item, 1)
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end # ドロップ系スクリプトに追加部分
end
wait_for_message
end
end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
# パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
# スのインスタンスは $game_party で参照されます。
#==============================================================================
class Game_Party < Game_Unit
include MOO_GENERAL_MODULE
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :gold # 所持金
attr_reader :steps # 歩数
attr_reader :last_item # カーソル記憶用 : アイテム
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super
@gold = 0
@steps = 0
@last_item = Game_BaseItem.new
@total_weight = 0 # 追加
@menu_actor_id = 0
@target_actor_id = 0
@actors = []
init_all_items
end
#--------------------------------------------------------------------------
# ◎ アイテムの増加(減少)
# include_equip : 装備品も含める
#--------------------------------------------------------------------------
alias moo_gain_item gain_item
def gain_item(item, amount, include_equip = false)
# gain_item内では、include_equipの関係からか、memberが使えません。
# ですので重量に装備品を含む場合、メンバーの装備情報が取得できません。
# 以下の"if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false"があるのはそのためです。
# 重量に装備品抜きの場合に限り、ここで重量のチェックをしています。
#
# 総重量を超える場合は取得不可能
# 1度に2以上取得しようとして引っかかった場合は、
# たとえ1個分の許容があったとしても、全て取得できません。
#
# 一応ここ以外にも、以下の箇所で入手可能かどうかのチェックをしています。
#
# ・イベントでアイテム、武器、防具を入手する時
# ・ショップでアイテムを購入する時
# ・戦闘後のドロップアイテム入手時
# ・装備を変更する時
#
# 普通に作成していれば、ここでチェックしなくてもよほど大丈夫だとはいますが、
# 他のスクリプトを導入する際、アイテム入手がある場合は注意して下さい。
# アイテム入手前に $game_party.gain_item(アイテム, 数量) を使って
# trueかfalseで判断するようにして下さい。
if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false
return if gain_item_failed?(item, amount) == false
end
# moo_gain_item(item, amount, include_equip)
container = item_container(item.class)
return unless container
last_number = item_number(item)
new_number = last_number + amount
container[item.id] = [[new_number, 0].max, max_item_number(item)].min
container.delete(item.id) if container[item.id] == 0
if include_equip && new_number < 0
discard_members_equip(item, -new_number)
end
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# ○ アイテムの個別重量を取得
#--------------------------------------------------------------------------
def weight_item(item)
return 0 if item == nil
# アイテムのメモ取得
memo = item.note.scan((/<#{MOO_HAVE_ITEM_WEIGHT::WORD_WT}[::](\S+)>/))
memo = memo.flatten
# 重量取得
if memo != nil and not memo.empty?
# 重量設定がある場合はそれを採用
wt = memo[0].to_i
else
# 重量設定がない場合は指定した重量とする
wt = MOO_HAVE_ITEM_WEIGHT::DEFAULT_WT
end
return wt
end
#--------------------------------------------------------------------------
# ○ 所持アイテムの総重量を取得
#--------------------------------------------------------------------------
def weight_sum
# 変数初期化
wt = 0
# 所持しているアイテムの重量取得
$data_items.each do |item|
# アイテムの総重量
wt += weight_have_item(item) if item and item.name != ""
end
$data_weapons.each do |item|
# 武器の総重量
wt += weight_have_item(item) if item and item.name != ""
end
$data_armors.each do |item|
# 防具の総重量
wt += weight_have_item(item) if item and item.name != ""
end
return wt
end
#--------------------------------------------------------------------------
# ○ 所持アイテムの個別重量を取得(フラグがあれば装備品を含む)
#--------------------------------------------------------------------------
def weight_have_item(item)
return 0 if item == nil
# アイテムの個別重量を取得
wt = weight_item(item)
# 所持個数の取得
cn = item_number(item)
if MOO_HAVE_ITEM_WEIGHT::CONT_WT
if item.class == RPG::Weapon or item.class == RPG::Armor
members.each do |actor|
if item.class == RPG::Weapon
cn += 1 if $game_actors[actor.id].equips[0] == item
cn += 1 if $game_actors[actor.id].equips[1] == item
elsif item.class == RPG::Armor
cn += 1 if $game_actors[actor.id].equips[item.etype_id] == item
end
end
end
end
# 個数×重量の場合の計算
if cn == 0
wt = 0
else
wt *= cn if MOO_HAVE_ITEM_WEIGHT::UNIT_WT
end
return wt
end
#--------------------------------------------------------------------------
# ○ 重量をカッコ書き(アイテム一覧に書くため)
#--------------------------------------------------------------------------
def weight_item_draw(item)
wt = weight_item(item).to_i
wt *= item_number(item) if MOO_HAVE_ITEM_WEIGHT::VIEW_WT
wt = wt.to_s
wt = bury_plus(wt, MOO_HAVE_ITEM_WEIGHT::FIGURE_WT, " ", lr = 1)
wt = MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_F + wt + MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_L
return wt
end
#--------------------------------------------------------------------------
# ○ アイテムを取得可能かどうかの判断
#--------------------------------------------------------------------------
def gain_item_failed?(item, val = 1)
val = 1 if MOO_HAVE_ITEM_WEIGHT::UNIT_WT == false
if weight_sum + weight_item(item) * val > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT]
false
else
true
end
end
#--------------------------------------------------------------------------
# ○ 個数の限界によってアイテムを取得可能かどうかの判断
#--------------------------------------------------------------------------
def gain_item_max?(item, val = 1)
return false if item_number(item) + val > max_item_number(item)
return true
end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ◎ 装備の変更
# slot_id : 装備スロット ID
# item : 武器/防具(nil なら装備解除)
#--------------------------------------------------------------------------
alias moo_change_equip change_equip
def change_equip(slot_id, item)
# equips[slot_id]: 装備中アイテム(nil=装備なし)
# item: これから装備しようとしているアイテム(nil=装備なし)
if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false
wt_old = $game_party.weight_item(equips[slot_id])
wt_new = $game_party.weight_item(item)
wt_clc = $game_party.weight_sum + wt_old - wt_new
# wt_clc: 現在の重さ + 外す装備品の重さ - これから装備する物の重さ
if wt_clc > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT]
Sound.play_buzzer
return
end
end
moo_change_equip(slot_id, item)
end
#--------------------------------------------------------------------------
# ● パーティとアイテムを交換する
# new_item : パーティから取り出すアイテム
# old_item : パーティに返すアイテム
#--------------------------------------------------------------------------
alias moo_trade_item_with_party trade_item_with_party
def trade_item_with_party(new_item, old_item)
return false if new_item && !$game_party.has_item?(new_item)
# 入手と破棄を逆転
$game_party.lose_item(new_item, 1)
$game_party.gain_item(old_item, 1)
return true
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
# イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● アイテムの増減
#--------------------------------------------------------------------------
def command_126
value = operate_value(@params[1], @params[2], @params[3])
if $game_party.gain_item_failed?($data_items[@params[0]], value)
$game_party.moo_gain_item($data_items[@params[0]], value)
end
end
#--------------------------------------------------------------------------
# ● 武器の増減
#--------------------------------------------------------------------------
def command_127
value = operate_value(@params[1], @params[2], @params[3])
if $game_party.gain_item_failed?($data_weapons[@params[0]], value)
$game_party.moo_gain_item($data_weapons[@params[0]], value, @params[4])
end
end
#--------------------------------------------------------------------------
# ● 防具の増減
#--------------------------------------------------------------------------
def command_128
value = operate_value(@params[1], @params[2], @params[3])
if $game_party.gain_item_failed?($data_armors[@params[0]], value)
$game_party.moo_gain_item($data_armors[@params[0]], value, @params[4])
end
end
#--------------------------------------------------------------------------
# ○ 所持品を追加できるかの判断
# kind : アイテム種類(/[IWA]/)
# id : アイテムID
# num : 入手する個数
# val : 入手可能かどうかを代入するスイッチ番号(使わない場合は0を指定)
# gain : 入手処理もついでに行なうか(省略時は行なわない)
#--------------------------------------------------------------------------
def can_gain_item?(kind, id, num = 1, val = 0, gain = false)
# アイテム変数初期値
item = nil
# アイテム種類分別
case kind
when "I"; item = $data_items[id]
when "W"; item = $data_weapons[id]
when "A"; item = $data_armors[id]
end
# 重量による取得可能チェック
flg1 = $game_party.gain_item_failed?(item, num)
# 数量による取得可能チェック
flg2 = $game_party.gain_item_max?(item, num)
# 重量か数量いずれかで取得不能判定があった場合のフラグ
flg = true
flg = false if flg1 == false or flg2 == false
# 取得可能であり取得フラグが立っていたら取得
$game_party.moo_gain_item(item, num) if flg and gain
# スイッチに値を返す
$game_switches[val] = flg if val > 0 and val != nil
# 値を返す
return flg
end
#--------------------------------------------------------------------------
# ○ 所持品の総重量を取得
#--------------------------------------------------------------------------
def get_weight_sum
$game_party.weight_sum
end
end
#==============================================================================
# ■ Window_ItemCategory
#------------------------------------------------------------------------------
# アイテム画面またはショップ画面で、通常アイテムや装備品の分類を選択するウィ
# ンドウです。
#==============================================================================
class Window_ItemCategory < Window_HorzCommand
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
Graphics.width - 160
end
end
#==============================================================================
# ■ Window_ItemList
#------------------------------------------------------------------------------
# アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_ItemList < Window_Selectable
#--------------------------------------------------------------------------
# ● アイテムの個数を描画
#--------------------------------------------------------------------------
def draw_item_number(rect, item)
$game_party.weight_sum
# カッコ書きの重量文字列を取得
wt = $game_party.weight_item_draw(item)
# 数量の後に重量を追加
draw_text(rect, sprintf(":%2d", $game_party.item_number(item)) + wt, 2)
end
end
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# ショップ画面で、購入できる商品の一覧を表示するウィンドウです。
#==============================================================================
class Window_ShopBuy
# include MOO_GENERAL_MODULE
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, height, shop_goods)
super(x, y, window_width, height)
@shop_goods = shop_goods
@money = 0
end
#--------------------------------------------------------------------------
# ● 商品の値段を取得
#--------------------------------------------------------------------------
def price(item)
if MOO_HAVE_ITEM_WEIGHT::USE_RATE
return Integer(@price[item] * $game_variables[MOO_HAVE_ITEM_WEIGHT::BUY_RATE] / 100)
else
return @price[item]
end
end
#--------------------------------------------------------------------------
# ● アイテムリストの作成
#--------------------------------------------------------------------------
def make_item_list
@data = []
@price = {}
@shop_goods.each do |goods|
case goods[0]
when 0; item = $data_items[goods[1]]
when 1; item = $data_weapons[goods[1]]
when 2; item = $data_armors[goods[1]]
end
if item
@data.push(item)
@price[item] = goods[2] == 0 ? item.price : goods[3]
end
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
draw_item_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
# wt = $game_party.weight_item(item)
# wt = wt.to_s
# wt = bury_plus(wt, MOO_HAVE_ITEM_WEIGHT::FIGURE_WT, " ", 1)
# wt = MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_F + wt + MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_L
# draw_text(rect, price(item).to_s + wt, 2)
draw_text(rect, price(item), 2)
end
end
#==============================================================================
# ■ Window_ShopSell
#------------------------------------------------------------------------------
# ショップ画面で、売却のために所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_ShopSell
#--------------------------------------------------------------------------
# ○ 桁数の取得
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# ○ 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
draw_item_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
draw_text(rect, price(item), 2)
end
#--------------------------------------------------------------------------
# ◎ アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
alias moo_weight_enable? enable?
def enable?(item)
flg = $data_items[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Item
flg = $data_weapons[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Weapon
flg = $data_armors[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Armor
return false if flg
moo_weight_enable?(item)
end
#--------------------------------------------------------------------------
# ○ 商品の値段を取得
#--------------------------------------------------------------------------
def price(item)
if MOO_HAVE_ITEM_WEIGHT::USE_RATE
return Integer(item.price * $game_variables[MOO_HAVE_ITEM_WEIGHT::SELL_RATE] / 100)
else
return item.price
end
end
end
#==============================================================================
# ■ Window_ShopNumber
#------------------------------------------------------------------------------
# ショップ画面で、購入または売却するアイテムの個数を入力するウィンドウです。
#==============================================================================
class Window_ShopNumber < Window_Selectable
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
draw_total_price
draw_total_weight(@item)
end
#--------------------------------------------------------------------------
# ○ 個数の総重量の描画
#--------------------------------------------------------------------------
def draw_total_weight(item)
width = contents_width - 8
cx = text_size(@currency_unit).width
change_color(system_color)
x_plus = 4
if MOO_GENERAL_MODULE::WINDOW_SIZE == 1
y_plus = 36
elsif MOO_GENERAL_MODULE::WINDOW_SIZE == 2
y_plus = 72
end
wd = MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD
draw_text(4, y + 24 + y_plus, width, line_height, wd)
change_color(normal_color)
cn = 1
cn = @number if MOO_HAVE_ITEM_WEIGHT::UNIT_WT
wt = $game_party.weight_item(item) * cn #@number
draw_text(x - cx - 2 + x_plus, y + 24 + y_plus, width, line_height, wt, 2)
end
end
#==============================================================================
# ■ Window_ShopStatus
#------------------------------------------------------------------------------
# ショップ画面で、アイテムの所持数やアクターの装備を表示するウィンドウです。
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_possession(4, 0)
draw_weight_possession(4, 24)
y_plus = 0
y_plus = 24 if MOO_GENERAL_MODULE::WINDOW_SIZE == 2
draw_equip_info(4, line_height * 2 + y_plus) if @item.is_a?(RPG::EquipItem)
end
#--------------------------------------------------------------------------
# ○ 総重量の描画
#--------------------------------------------------------------------------
def draw_weight_possession(x, y)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(system_color)
draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
change_color(normal_color)
str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
draw_text(rect, str, 2)
end
end
#==============================================================================
# ■ Window_Weight_Sum_Menu
#------------------------------------------------------------------------------
# メニューウィンドウで総重量を表示するクラスです。
#==============================================================================
class Window_Weight_Sum_Menu < Window_Base
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
refresh
end
#--------------------------------------------------------------------------
# ○ リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
rect = Rect.new(0, 0, width - 28, line_height)
change_color(system_color)
draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
change_color(normal_color)
str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
draw_text(rect, str, 2)
end
end
#==============================================================================
# ■ Window_Weight_Sum_item
#------------------------------------------------------------------------------
# アイテム一覧で総重量を表示するクラスです。
#==============================================================================
class Window_Weight_Sum_item < Window_ItemList
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
refresh
end
#--------------------------------------------------------------------------
# ○ リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
rect = Rect.new(0, 0, width - 28, line_height)
change_color(system_color)
draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
change_color(normal_color)
str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
draw_text(rect, str, 2)
end
end
#==============================================================================
# ■ Window_Weight_Sum_Shop
#------------------------------------------------------------------------------
# ショップの売却画面で総重量を表示するクラスです。
#==============================================================================
class Window_Weight_Sum_Shop < Window_ItemList
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
refresh
end
#--------------------------------------------------------------------------
# ○ リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
rect = Rect.new(0, 0, width - 28, line_height)
change_color(system_color)
draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
change_color(normal_color)
str = $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
draw_text(rect, str, 2)
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# メニュー画面の処理を行うクラスです。
#==============================================================================
class Scene_Menu < Scene_MenuBase
include MOO_GENERAL_MODULE
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_command_window
create_gold_window
create_status_window
@wt_x = 0
@wt_y = Graphics.height - @gold_window.height - weight_item_window_h
@wt_w = weight_item_window_w
@wt_h = @gold_window.height
create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h)
end
#--------------------------------------------------------------------------
# ○ 総重量ウィンドウの作成
#--------------------------------------------------------------------------
def create_weight_sum_window(x, y, width, height)
@weight_sum_window = Window_Weight_Sum_Menu.new(x, y, width, height)
@weight_sum_window.viewport = @viewport
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# アイテム画面の処理を行うクラスです。
#==============================================================================
class Scene_Item < Scene_ItemBase
include MOO_GENERAL_MODULE
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_category_window
create_item_window
@wt_x = weight_item_window_x
@wt_y = weight_item_window_y
@wt_w = weight_item_window_w
@wt_h = weight_item_window_h
create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h)
end
#--------------------------------------------------------------------------
# ○ 総重量ウィンドウの作成
#--------------------------------------------------------------------------
def create_weight_sum_window(x, y, width, height)
@weight_sum_window = Window_Weight_Sum_item.new(x, y, width, height)
@weight_sum_window.viewport = @viewport
@weight_sum_window.y = @help_window.height
end
#--------------------------------------------------------------------------
# ● アイテムの使用
#--------------------------------------------------------------------------
def use_item
super
@item_window.redraw_current_item
@weight_sum_window.refresh
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# ショップ画面の処理を行うクラスです。
#==============================================================================
class Scene_Shop < Scene_MenuBase
include MOO_GENERAL_MODULE
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_gold_window
create_command_window
create_dummy_window
create_category_window
create_number_window
create_status_window
create_buy_window
@wt_x = weight_item_window_x
@wt_y = weight_item_window_y + 48
@wt_w = weight_item_window_w
@wt_h = weight_item_window_h
create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h)
create_sell_window
end
#--------------------------------------------------------------------------
# ○ 総重量ウィンドウの作成
#--------------------------------------------------------------------------
def create_weight_sum_window(x, y, width, height)
@weight_sum_window = Window_Weight_Sum_Shop.new(x, y, width, height)
@weight_sum_window.viewport = @viewport
@weight_sum_window.y = @help_window.height
@weight_sum_window.y = @dummy_window.y
@weight_sum_window.hide.deactivate
end
#--------------------------------------------------------------------------
# ● 個数入力[決定]
#--------------------------------------------------------------------------
def on_number_ok
case @command_window.current_symbol
when :buy
do_buy(@number_window.number)
@weight_sum_window.refresh
@weight_sum_window.hide
when :sell
do_sell(@number_window.number)
@weight_sum_window.refresh
end
end_number_input
@gold_window.refresh
@status_window.refresh
end
#--------------------------------------------------------------------------
# ● 購入の実行
#--------------------------------------------------------------------------
def do_buy(number)
if $game_party.gain_item_failed?(@item, number) == false
Sound.play_buzzer
return
end
Sound.play_shop
$game_party.lose_gold(number * buying_price)
$game_party.moo_gain_item(@item, number)
end
#--------------------------------------------------------------------------
# ● 売却ウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate_sell_window
@category_window.show
@weight_sum_window.show
@sell_window.refresh
@sell_window.show.activate
@status_window.hide
end
#--------------------------------------------------------------------------
# ● 購入ウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate_buy_window
@buy_window.money = money
@buy_window.show.activate
@status_window.show
end
#--------------------------------------------------------------------------
# ● コマンド[購入する]
#--------------------------------------------------------------------------
def command_buy
@dummy_window.hide
activate_buy_window
@buy_window.select(0)
@buy_window.refresh
end
#--------------------------------------------------------------------------
# ● コマンド[売却する]
#--------------------------------------------------------------------------
def command_sell
@dummy_window.hide
@category_window.show.activate
@weight_sum_window.show
@sell_window.show
@sell_window.unselect
@sell_window.refresh
@weight_sum_window.show
end
#--------------------------------------------------------------------------
# ● カテゴリ[キャンセル]
#--------------------------------------------------------------------------
def on_category_cancel
@command_window.activate
@dummy_window.show
@category_window.hide
@weight_sum_window.hide
@sell_window.hide
end
#--------------------------------------------------------------------------
# ● 売却[決定]
#--------------------------------------------------------------------------
def on_sell_ok
@item = @sell_window.item
@status_window.item = @item
@category_window.hide
@weight_sum_window.hide
@sell_window.hide
@number_window.set(@item, max_sell, selling_price, currency_unit)
@number_window.show.activate
@status_window.show
end
#--------------------------------------------------------------------------
# ● 売却[キャンセル]
#--------------------------------------------------------------------------
def on_sell_cancel
@sell_window.unselect
@category_window.activate
@weight_sum_window.activate
@status_window.item = nil
@help_window.clear
end
#--------------------------------------------------------------------------
# ● 売却の実行
#--------------------------------------------------------------------------
def do_sell(number)
Sound.play_shop
$game_party.gain_gold(number * selling_price)
$game_party.lose_item(@item, number)
end
#--------------------------------------------------------------------------
# ● 売値の取得
#--------------------------------------------------------------------------
def selling_price
@sell_window.price(@item)
end
end
事件物品容器脚本:
#------------------------------------------------------------------------------# # Galv's Multiple Storage Containers #------------------------------------------------------------------------------# # For: RPGMAKER VX ACE # Version 1.5 #------------------------------------------------------------------------------# # 2015-10-21 - Version 1.5 - fixed a bug in "take all" and item limits # 2013-01-20 - Version 1.4 - fixed a "take all" bug in a dangerous container # 2013-01-17 - Version 1.3 - take all command added # taking/adding items can change a variable and # be displayed in the scene with custom text. # added chance to be caught stealing allowing # actors and equips to modify that chance. # 2012-10-24 - Version 1.2 - changing alias names for compatibility. # 2012-10-24 - Version 1.1 - forgot to alias game_temp initialize method... fixed # 2012-10-23 - Version 1.0 - release #------------------------------------------------------------------------------# # Allows you to make any event a storage container and able to add or remove # items from it. Populate your containers any time you choose with script calls. # # Each container has a status - colored text of your choice that displays at # the bottom of the screen with a variable. Adding or taking items from the # container can increase or decrease this variable how you see fit. Can also # set a % chance the player will be caught if he tries to steal. When this # happens, the scene closes and a switch is turned on - you use conditional # branches to determine what happens. (The switch could even be for all people # to attack you!) # #------------------------------------------------------------------------------# # # INSTRUCTIONS: # To set up an event as a container: # # 1. use the 'c_add' script call to populate containers with items # you want in there. You choose how you want to do this. In my demo I chose to # add items to containers when the player searched them (and use a self switch # to make sure they don't keep getting free items). You could populate your # containers at any point you like, though. # # 2. add the open_container("name") script command. # # That's all there is to it unless you look at the c_status script call, you # can make each container act a bit differently. # #------------------------------------------------------------------------------# # Script calls to use: #------------------------------------------------------------------------------# # # open_container("name") # Opens event container # # Uses "name" in scene. # # c_add("type", item_id, amount, event_id, map_id) # Adds item to container. # # c_rem("type", item_id, amount, event_id, map_id) # removes item from container # # c_count("type", id, event_id, map_id) # counts certain item in # # container. Use in condition # # branches and variables. # # c_status("text",color,take_rep,give_rep,caught_chance) # # # Changes the container status. # # All containers opened after this call will have this status (So you could # # set it for a location or set it before each container opens - see below) # #------------------------------------------------------------------------------# # EXPLAINATION: # type this can be "weapon", "armor" or "item" # item_id the ID of the item/armor/weapon you want to add # amount the number of the item/armor/weapon/gold you want to remove # event_id the event ID of the container you want to add items to. Set this # to 0 to add an item to the event the script call is in. # map_id the ID of the map the container you want is on. Make this 0 if you # want to refer to the same map as the script call was made. # # EXAMPLE OF USE: # c_add("item",2,3,5,4) # adds an item to event 5 on map 4 # c_add("weapon",2,3,0,0) # adds a weapon to the same event as the call # c_rem("armor",3,6,10,2) # removes armor from event 10 on map 2 # c_count("item",1,5,1) # counts item ID 1 stored in event 5 on map 1 # c_status("Safe",4,-10,5,8) # shows "Safe" in blue(4) at the bottom # # -10 rep for each item taken. # # +5 rep for each item put. # # 8% chance each time you take to get caught # # You cant 'take all' when there's a chance to # # get caught in a container. #------------------------------------------------------------------------------# # Note tag for ARMORS, WEAPONS and ACTORS #------------------------------------------------------------------------------# # # <take_mod: x> # increases or decreases the % chance to be caught when # # stealing if one of these things have the note tag. # # # Ideas for use: Actors that are thieves, 'thief glove' or 'lockpick' # # accessories. # #------------------------------------------------------------------------------# # Note tag for ARMORS, WEAPONS and ITEMS #------------------------------------------------------------------------------# # # <take_value: x> # increases or decreases the amount of rep you gain or # # lose by this number. This is to make more expensive or # # rarer items have a bigger effect on rep when taking or # # adding them to containers. In the c_status script call, # # if it is 0 to rep change, this will not add/take from it # # # Ideas for use: Treasure hunting. Gain more rep for taking a higher value # # item from a chest. Just be sure you don't set it up so that they can # # manipulate their rep by adding and taking items. # #------------------------------------------------------------------------------# # I recommend downloading the demo to see how to set up container events as # this got a bit complicated with adding features. # # More setup options further down. #------------------------------------------------------------------------------# ($imported ||= {})["Galvs_Item_Containers"] = true module Galv_Container #------------------------------------------------------------------------------# # SCRIPT SETUP OPTIONS #------------------------------------------------------------------------------# # COMMAND LIST VOCAB REMOVE = "Remove" STORE = "Store" CANCEL = "Cancel" # OTHER VOCAB IN_STORAGE = "In Container" IN_INVENTORY = "In Inventory" TAKE_TEXT = "Remove how many?" STORE_TEXT = "Store how many?" TAKE_ALL = "A: Take All" # Text displayed bottom left REP = "Reputation" # Text displayed in the bottom right # Make this "" to not use it. REP_VAR = 1 # Variable displayed after the REP text. This is the variable # that can change when you take or put things into a container # Make this 0 to not use. # OTHER OPTIONS SE = ["Equip2", 90, 100] # Sound effect when storing/removing an item STORE_PRICELESS = true # Items worth 0 can be stored? true or false STORE_KEY = true # Key items can be stored? true or false C_SE = ["Buzzer1", 90, 100] # Sound effect when caught stealing C_SWITCH = 2 # Switch is turned ON when you are caught # PARTY LIMITS # NOTE: These limits set to 0 will use the default limits. In theory this will # be compatible with a limit breaker script by leaving them at 0. Or you can # set the party limits below to whatever you like. MAX_ITEMS = 0 # Max items your PARTY can carry. # This will overwrite the default limit. # 0 means do not use this. TAKE_ONLY_SWITCH = 1 # Switch ID. Turn ON to only allow taking from all # containers. Switch OFF to allow both again. #------------------------------------------------------------------------------# # SCRIPT SETUP OPTIONS #------------------------------------------------------------------------------# end class Game_Temp attr_accessor :contents attr_accessor :container_name alias galv_container_initialize initialize def initialize galv_container_initialize @contents = [] @container_name = "" end end # Game_Temp class RPG::BaseItem def take_mod if @take_mod.nil? if @note =~ /<take_mod: (.*)>/i @take_mod = $1.to_i else @take_mod = 0 end end @take_mod end def take_value if @take_value.nil? if @note =~ /<take_value: (.*)>/i @take_value = $1.to_i else @take_value = 0 end end @take_value end end class Scene_Container < Scene_MenuBase def start super check_storage_exists create_help_window create_name_window create_info_window create_command_window create_dummy_window create_number_window create_status_window create_category_window create_take_window create_give_window end def check_storage_exists if $game_party.container[$game_temp.contents].nil? $game_party.container[$game_temp.contents] = {} end return @btn_active = false if danger_box? @btn_active = true if !$game_party.container[$game_temp.contents].empty? end def danger_box? $game_party.container_status[4] > 0 end def update super check_key end def check_key if Input.trigger?(:X) if @btn_active take_all else Sound.play_buzzer end end end #-------------------------------------------------------------------------- # Create Windows #-------------------------------------------------------------------------- def create_name_window @name_window = Window_ContainerName.new @name_window.viewport = @viewport @name_window.x = Graphics.width - @name_window.width @name_window.y = @help_window.height end def create_info_window @info_window = Window_Info.new @info_window.viewport = @viewport @info_window.x = 0 @info_window.y = Graphics.height - @info_window.height end def create_command_window @command_window = Window_ContainerCommand.new(@name_window.x) @command_window.viewport = @viewport @command_window.y = @help_window.height @command_window.set_handler(:give, method(:command_give)) @command_window.set_handler(:take, method(:command_take)) @command_window.set_handler(:cancel, method(:return_scene)) end def create_dummy_window wy = @command_window.y + @command_window.height wh = Graphics.height - wy - @name_window.height @dummy_window = Window_Base.new(0, wy, Graphics.width, wh) @dummy_window.viewport = @viewport @dummy_window.hide end def create_number_window wy = @dummy_window.y wh = @dummy_window.height @number_window = Window_ContainerNumber.new(0, wy, wh) @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 create_status_window wx = @number_window.width wy = @dummy_window.y ww = Graphics.width - wx wh = @dummy_window.height @status_window = Window_ContainerItems.new(wx, wy, ww, wh) @status_window.viewport = @viewport @status_window.hide end def create_category_window @category_window = Window_ItemCategory.new @category_window.viewport = @viewport @category_window.help_window = @help_window @category_window.y = @dummy_window.y @category_window.hide.deactivate @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:on_category_cancel)) end def create_give_window wy = @category_window.y + @category_window.height wh = Graphics.height - wy - @name_window.height @give_window = Window_ContainerGive.new(0, wy, Graphics.width, wh) @give_window.viewport = @viewport @give_window.help_window = @help_window @give_window.hide @give_window.set_handler(:ok, method(:on_give_ok)) @give_window.set_handler(:cancel, method(:on_give_cancel)) @category_window.item_window = @give_window end def create_take_window wy = @command_window.y + @command_window.height wh = Graphics.height - wy - @name_window.height @take_window = Window_ContainerTake.new(0, wy, Graphics.width, wh) @take_window.viewport = @viewport @take_window.help_window = @help_window @take_window.set_handler(:ok, method(:on_take_ok)) @take_window.set_handler(:cancel, method(:on_take_cancel)) @category_window.item_window = @take_window end #-------------------------------------------------------------------------- # * Activate Windows #-------------------------------------------------------------------------- def activate_give_window @category_window.show @give_window.refresh @give_window.show.activate @status_window.hide end def activate_take_window @take_window.select(0) @take_window.refresh @take_window.show.activate @status_window.hide end def btn_activate return btn_deactivate if danger_box? return btn_deactivate if $game_party.container[$game_temp.contents].empty? @info_window.refresh(true) @btn_active = true end def btn_deactivate @info_window.refresh(false) @btn_active = false end #-------------------------------------------------------------------------- # HANDLER METHODS #-------------------------------------------------------------------------- def on_category_ok activate_give_window @give_window.select(0) btn_deactivate end def on_category_cancel @command_window.activate @take_window.show @take_window.refresh @category_window.hide @give_window.hide btn_activate end def command_give @take_window.hide @category_window.show.activate @give_window.show @give_window.unselect @give_window.refresh btn_deactivate end def on_give_ok @item = @give_window.item if @item.nil? RPG::SE.stop Sound.play_buzzer @give_window.activate @give_window.refresh return else @status_window.item = @item @category_window.hide @give_window.hide @number_window.set(@item, max_give, @command_window.current_symbol) @number_window.show.activate @status_window.show btn_deactivate end end def on_give_cancel @give_window.unselect @category_window.activate @status_window.item = nil @help_window.clear end def command_take activate_take_window @take_window.show @take_window.refresh btn_activate end def on_take_ok btn_deactivate @item = @take_window.item if @item.nil? || $game_party.container[$game_temp.contents].empty? || $game_party.item_number(@item) == $game_party.max_item_number(@item) RPG::SE.stop Sound.play_buzzer @take_window.activate @take_window.refresh return elsif @item = @take_window.item @status_window.item = @item @take_window.hide @number_window.set(@item, max_take, @command_window.current_symbol) @number_window.show.activate @status_window.show end end def on_take_cancel @take_window.unselect @command_window.activate @take_window.show @status_window.item = nil @help_window.clear end def on_number_ok RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play case @command_window.current_symbol when :take do_take(@number_window.number) btn_activate when :give do_give(@number_window.number) btn_deactivate end end_number_input @status_window.refresh end def on_number_cancel Sound.play_cancel end_number_input end def end_number_input @number_window.hide case @command_window.current_symbol when :take activate_take_window btn_activate when :give activate_give_window end end #-------------------------------------------------------------------------- # * Giving and taking methods #-------------------------------------------------------------------------- def max_take if $game_party.container[$game_temp.contents][@item] > $game_party.max_item_number(@item) - $game_party.item_number(@item) $game_party.max_item_number(@item) - $game_party.item_number(@item) else $game_party.container[$game_temp.contents][@item] end end def max_give $game_party.item_number(@item) end def do_give(number) $game_party.lose_item(@item, number) if $game_party.container[$game_temp.contents][@item].nil? $game_party.container[$game_temp.contents][@item] = number else $game_party.container[$game_temp.contents][@item] += number end get_take_value(3) $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[3] + @take_value) * number end def do_take(number) check_capture return if @item.nil? $game_party.gain_item(@item, number) $game_party.container[$game_temp.contents][@item] -= number $game_party.container[$game_temp.contents].delete(@item) if $game_party.container[$game_temp.contents][@item] <= 0 if $game_party.container[$game_temp.contents].empty? @take_window.activate end get_take_value(2) $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number end def take_all return Sound.play_buzzer if $game_party.container[$game_temp.contents].empty? || max_of_items RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play $game_party.container[$game_temp.contents].each do |i| if i[1] > $game_party.max_item_number(i[0]) - $game_party.item_number(i[0]) number = $game_party.max_item_number(i[0]) - $game_party.item_number(i[0]) else number = i[1] - $game_party.item_number(i[0]) end p number $game_party.gain_item(i[0], number) i[1] -= number $game_party.container[$game_temp.contents][i[0]] -= number $game_party.container[$game_temp.contents].delete(i[0]) if i[1] <= 0 @item = i[0] get_take_value(2) $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number end btn_activate @take_window.refresh end def max_of_items # if all items in box are maxed, return true $game_party.container[$game_temp.contents].each { |item| return false if $game_party.item_number(item[0]) < $game_party.max_item_number(item[0]) } return true end def get_take_value(pos) return @take_value = 0 if @item.nil? if $game_party.container_status[pos] == 0 @take_value = 0 elsif $game_party.container_status[pos] > 0 @take_value = @item.take_value else $game_party.container_status[pos] < 0 @take_value = -@item.take_value end end def check_capture a = rand(100) chance = $game_party.container_status[4] + actor_mod + equip_mod if a < chance RPG::SE.new(Galv_Container::C_SE[0], Galv_Container::C_SE[1], Galv_Container::C_SE[2]).play $game_switches[Galv_Container::C_SWITCH] = true SceneManager.goto(Scene_Map) end end def equip_mod equip_mod = 0 $game_party.members.each do |m| m.equips.each do |eq| next if eq.nil? equip_mod += eq.take_mod end end return equip_mod end def actor_mod actor_mod = 0 $game_party.members.each do |m| actor_mod += $data_actors[m.id].take_mod end return actor_mod end end # Scene_Container < Scene_MenuBase #------------------------------------------------------------------------------# # Window Container Name #------------------------------------------------------------------------------# class Window_ContainerName < Window_Base def initialize super(0, 0, window_width, fitting_height(1)) refresh end def window_width return 180 end def refresh contents.clear c_name = convert_escape_characters($game_temp.container_name) draw_text(x - 10, y, window_width, line_height, c_name,1) end def open refresh super end end #------------------------------------------------------------------------------# # Window Info #------------------------------------------------------------------------------# class Window_Info < Window_Base def initialize super(0, 0, Graphics.width, fitting_height(1)) @btn_state = true if !$game_party.container[$game_temp.contents].empty? @btn_state = false if $game_party.container_status[4] > 0 refresh(@btn_state) end def refresh(btn) @btn_state = btn contents.clear draw_texts end def draw_texts change_color(normal_color, @btn_state) draw_text(0, 0, contents.width, line_height, Galv_Container::TAKE_ALL, 0) change_color(text_color($game_party.container_status[1])) draw_text(0, 0, contents.width, line_height, $game_party.container_status[0], 1) if Galv_Container::REP_VAR <= 0 repvar = "" else repvar = $game_variables[Galv_Container::REP_VAR] end change_color(normal_color) draw_text(0, 0, contents.width, line_height, Galv_Container::REP + " " + repvar.to_s, 2) end end #------------------------------------------------------------------------------# # Window Stored Items #------------------------------------------------------------------------------# class Window_StoreList < Window_Selectable def initialize(x, y, width, height) super @category = :none @data = [] end def category=(category) return if @category == category @category = category refresh self.oy = 0 end def col_max return 2 end def item_max @data ? @data.size : 1 end def item @data && index >= 0 ? @data[index] : nil end def current_item_enabled? enable?(@data[index]) 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 :key_item item.is_a?(RPG::Item) && item.key_item? else false end end def enable?(item) $game_party.container[$game_temp.contents].has_key?(item) end def make_item_list @data = $game_party.container[$game_temp.contents].keys {|item| include?(item) } @data.push(nil) if include?(nil) end def select_last select(@data.index($game_party.last_item.object) || 0) 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)) draw_item_number(rect, item) end end def draw_item_number(rect, item) draw_text(rect, sprintf(":%2d", $game_party.container[$game_temp.contents][item]), 2) end def update_help @help_window.set_item(item) end def refresh make_item_list create_contents draw_all_items end end # Window_StoreList < Window_Selectable #------------------------------------------------------------------------------# # Window Stored Item amount #------------------------------------------------------------------------------# class Window_ContainerNumber < Window_Selectable attr_reader :number def initialize(x, y, height) super(x, y, window_width, height) @item = nil @max = 1 @number = 1 end def window_width return 304 end def set(item, max, cmd) @item = item @max = max @number = 1 @cmd = cmd refresh end def refresh contents.clear draw_item_name(@item, 0, item_y) draw_number draw_how_many end def draw_number change_color(normal_color) draw_text(cursor_x - 28, item_y, 22, line_height, "×") draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2) end def item_y contents_height / 2 - line_height * 3 / 2 end def cursor_width figures * 10 + 12 end def cursor_x contents_width - cursor_width - 4 end def figures return 2 end def update super if active last_number = @number update_number if @number != last_number Sound.play_cursor refresh end end end def update_number change_number(1) if Input.repeat?(:RIGHT) change_number(-1) if Input.repeat?(:LEFT) change_number(10) if Input.repeat?(:UP) change_number(-10) if Input.repeat?(:DOWN) end def change_number(amount) @number = [[@number + amount, @max].min, 1].max end def update_cursor cursor_rect.set(cursor_x, item_y, cursor_width, line_height) end def draw_how_many change_color(system_color) case @cmd when :take draw_text(4, 4, contents.width, line_height, Galv_Container::TAKE_TEXT) when :give draw_text(4, 4, contents.width, line_height, Galv_Container::STORE_TEXT) end change_color(normal_color) end end # Window_ContainerNumber < Window_Selectable #------------------------------------------------------------------------------# # Window Store Item Status #------------------------------------------------------------------------------# class Window_ContainerItems < Window_Base def initialize(x, y, width, height) super(x, y, width, height) @item = nil @page_index = 0 refresh end def refresh contents.clear draw_possession(4, 0) draw_stored(4, line_height) draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem) end def item=(item) @item = item refresh end def draw_possession(x, y) rect = Rect.new(x, y, contents.width - 4 - x, line_height) change_color(system_color) draw_text(rect, Galv_Container::IN_INVENTORY) change_color(normal_color) draw_text(rect, $game_party.item_number(@item), 2) end def draw_stored(x, y) rect = Rect.new(x, y, contents.width - 4 - x, line_height) change_color(system_color) draw_text(rect, Galv_Container::IN_STORAGE) change_color(normal_color) stored_amount = $game_party.container[$game_temp.contents][@item] stored_amount = 0 if stored_amount.nil? draw_text(rect, stored_amount, 2) end def draw_equip_info(x, y) status_members.each_with_index do |actor, i| draw_actor_equip_info(x, y + line_height * (i * 2.4), actor) end end def status_members $game_party.members[@page_index * page_size, page_size] end def page_size return 4 end def page_max ($game_party.members.size + page_size - 1) / page_size end def draw_actor_equip_info(x, y, actor) enabled = actor.equippable?(@item) change_color(normal_color, enabled) draw_text(x, y, 112, line_height, actor.name) item1 = current_equipped_item(actor, @item.etype_id) draw_actor_param_change(x, y, actor, item1) if enabled draw_item_name(item1, x, y + line_height, enabled) end def draw_actor_param_change(x, y, actor, item1) rect = Rect.new(x, y, contents.width - 4 - x, line_height) change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0) change_color(param_change_color(change)) draw_text(rect, sprintf("%+d", change), 2) end def param_id @item.is_a?(RPG::Weapon) ? 2 : 3 end def current_equipped_item(actor, etype_id) list = [] actor.equip_slots.each_with_index do |slot_etype_id, i| list.push(actor.equips[i]) if slot_etype_id == etype_id end list.min_by {|item| item ? item.params[param_id] : 0 } end def update super update_page end def update_page if visible && Input.trigger?(:A) && page_max > 1 @page_index = (@page_index + 1) % page_max refresh end end end # Window_ContainerItems < Window_Base #------------------------------------------------------------------------------# # Window Give Item #------------------------------------------------------------------------------# class Window_ContainerGive < Window_ItemList def initialize(x, y, width, height) super(x, y, width, height) end def current_item_enabled? enable?(@data[index]) end def enable?(item) if item.is_a?(RPG::Item) return false if item.key_item? && !Galv_Container::STORE_KEY end if Galv_Container::STORE_PRICELESS true else item && item.price > 0 end end end # Window_ContainerGive < Window_ItemList #------------------------------------------------------------------------------# # Window Take Item #------------------------------------------------------------------------------# class Window_ContainerTake < Window_StoreList def initialize(x, y, width, height) super(x, y, width, height) end def current_item_enabled? enable?(@data[index]) end def enable?(item) $game_party.container[$game_temp.contents][item] != 0 && $game_party.item_number(item) < $game_party.max_item_number(@item) end end # Window_ContainerTake < Window_StoreList #------------------------------------------------------------------------------# # Window Command #------------------------------------------------------------------------------# class Window_ContainerCommand < Window_HorzCommand def initialize(window_width) @window_width = window_width super(0, 0) end def window_width @window_width end def col_max return 2 if $game_switches[Galv_Container::TAKE_ONLY_SWITCH] return 3 end def make_command_list add_command(Galv_Container::REMOVE, :take) add_command(Galv_Container::STORE, :give) if !$game_switches[Galv_Container::TAKE_ONLY_SWITCH] add_command(Galv_Container::CANCEL, :cancel) end end # Window_ContainerCommand < Window_HorzCommand #------------------------------------------------------------------------------# # Game Party Additions #------------------------------------------------------------------------------# class Game_Party < Game_Unit attr_accessor :container attr_accessor :container_status alias galv_mcontatiners_initialize initialize def initialize galv_mcontatiners_initialize init_containers end def init_containers @container_status = ["",0,0,0,0] # text,color,take_rep,give_rep,catch_chance @container = {} end alias galv_container_max_item_number max_item_number def max_item_number(item) return Galv_Container::MAX_ITEMS if Galv_Container::MAX_ITEMS > 0 return 99 if item.nil? galv_container_max_item_number(item) end end # Game_Party < Game_Unit class Game_Interpreter def c_add(type, id, amount, event_id, map_id) if event_id <= 0 add_where = @event_id else add_where = event_id end if map_id <= 0 add_where_map = $game_map.map_id else add_where_map = map_id end $game_temp.contents = [add_where, add_where_map] if $game_party.container[$game_temp.contents].nil? $game_party.container[$game_temp.contents] = {} end case type when "weapon" @item = $data_weapons[id] when "item" @item = $data_items[id] when "armor" @item = $data_armors[id] end if $game_party.container[$game_temp.contents][@item].nil? $game_party.container[$game_temp.contents][@item] = amount else $game_party.container[$game_temp.contents][@item] += amount end end def c_rem(type, id, amount, event_id, map_id) if event_id <= 0 rem_where = @event_id else rem_where = event_id end if map_id <= 0 rem_where_map = $game_map.map_id else rem_where_map = map_id end $game_temp.contents = [rem_where, rem_where_map] if $game_party.container[$game_temp.contents].nil? $game_party.container[$game_temp.contents] = {} end case type when "weapon" @item = $data_weapons[id] when "item" @item = $data_items[id] when "armor" @item = $data_armors[id] end return if $game_party.container[$game_temp.contents][@item].nil? if $game_party.container[$game_temp.contents][@item] <= amount $game_party.container[$game_temp.contents].delete(@item) else $game_party.container[$game_temp.contents][@item] -= amount end end def c_count(type, id, event_id, map_id) if event_id <= 0 container_id = @event_id else container_id = event_id end if map_id <= 0 container_id_map = $game_map.map_id else container_id_map = map_id end $game_temp.contents = [container_id, container_id_map] if $game_party.container[$game_temp.contents].nil? $game_party.container[$game_temp.contents] = {} end case type when "weapon" @item = $data_weapons[id] when "item" @item = $data_items[id] when "armor" @item = $data_armors[id] end return 0 if $game_party.container[$game_temp.contents][@item].nil? $game_party.container[$game_temp.contents][@item] end def c_status(text,color,take_rep,give_rep,catch_chance) $game_party.container_status = [text,color,take_rep,give_rep,catch_chance] end def c_empty?(event_id,map_id) !$game_party.container[[event_id,map_id]].nil? && $game_party.container[[event_id,map_id]].empty? end def open_container(name) $game_temp.container_name = name $game_temp.contents = [@event_id, $game_map.map_id] SceneManager.call(Scene_Container) wait(1) end end # Game_Interpreter
#------------------------------------------------------------------------------#
# Galv's Multiple Storage Containers
#------------------------------------------------------------------------------#
# For: RPGMAKER VX ACE
# Version 1.5
#------------------------------------------------------------------------------#
# 2015-10-21 - Version 1.5 - fixed a bug in "take all" and item limits
# 2013-01-20 - Version 1.4 - fixed a "take all" bug in a dangerous container
# 2013-01-17 - Version 1.3 - take all command added
# taking/adding items can change a variable and
# be displayed in the scene with custom text.
# added chance to be caught stealing allowing
# actors and equips to modify that chance.
# 2012-10-24 - Version 1.2 - changing alias names for compatibility.
# 2012-10-24 - Version 1.1 - forgot to alias game_temp initialize method... fixed
# 2012-10-23 - Version 1.0 - release
#------------------------------------------------------------------------------#
# Allows you to make any event a storage container and able to add or remove
# items from it. Populate your containers any time you choose with script calls.
#
# Each container has a status - colored text of your choice that displays at
# the bottom of the screen with a variable. Adding or taking items from the
# container can increase or decrease this variable how you see fit. Can also
# set a % chance the player will be caught if he tries to steal. When this
# happens, the scene closes and a switch is turned on - you use conditional
# branches to determine what happens. (The switch could even be for all people
# to attack you!)
#
#------------------------------------------------------------------------------#
#
# INSTRUCTIONS:
# To set up an event as a container:
#
# 1. use the 'c_add' script call to populate containers with items
# you want in there. You choose how you want to do this. In my demo I chose to
# add items to containers when the player searched them (and use a self switch
# to make sure they don't keep getting free items). You could populate your
# containers at any point you like, though.
#
# 2. add the open_container("name") script command.
#
# That's all there is to it unless you look at the c_status script call, you
# can make each container act a bit differently.
#
#------------------------------------------------------------------------------#
# Script calls to use:
#------------------------------------------------------------------------------#
#
# open_container("name") # Opens event container
# # Uses "name" in scene.
#
# c_add("type", item_id, amount, event_id, map_id) # Adds item to container.
#
# c_rem("type", item_id, amount, event_id, map_id) # removes item from container
#
# c_count("type", id, event_id, map_id) # counts certain item in
# # container. Use in condition
# # branches and variables.
#
# c_status("text",color,take_rep,give_rep,caught_chance)
#
# # Changes the container status.
# # All containers opened after this call will have this status (So you could
# # set it for a location or set it before each container opens - see below)
#
#------------------------------------------------------------------------------#
# EXPLAINATION:
# type this can be "weapon", "armor" or "item"
# item_id the ID of the item/armor/weapon you want to add
# amount the number of the item/armor/weapon/gold you want to remove
# event_id the event ID of the container you want to add items to. Set this
# to 0 to add an item to the event the script call is in.
# map_id the ID of the map the container you want is on. Make this 0 if you
# want to refer to the same map as the script call was made.
#
# EXAMPLE OF USE:
# c_add("item",2,3,5,4) # adds an item to event 5 on map 4
# c_add("weapon",2,3,0,0) # adds a weapon to the same event as the call
# c_rem("armor",3,6,10,2) # removes armor from event 10 on map 2
# c_count("item",1,5,1) # counts item ID 1 stored in event 5 on map 1
# c_status("Safe",4,-10,5,8) # shows "Safe" in blue(4) at the bottom
# # -10 rep for each item taken.
# # +5 rep for each item put.
# # 8% chance each time you take to get caught
# # You cant 'take all' when there's a chance to
# # get caught in a container.
#------------------------------------------------------------------------------#
# Note tag for ARMORS, WEAPONS and ACTORS
#------------------------------------------------------------------------------#
#
# <take_mod: x> # increases or decreases the % chance to be caught when
# # stealing if one of these things have the note tag.
#
# # Ideas for use: Actors that are thieves, 'thief glove' or 'lockpick'
# # accessories.
#
#------------------------------------------------------------------------------#
# Note tag for ARMORS, WEAPONS and ITEMS
#------------------------------------------------------------------------------#
#
# <take_value: x> # increases or decreases the amount of rep you gain or
# # lose by this number. This is to make more expensive or
# # rarer items have a bigger effect on rep when taking or
# # adding them to containers. In the c_status script call,
# # if it is 0 to rep change, this will not add/take from it
#
# # Ideas for use: Treasure hunting. Gain more rep for taking a higher value
# # item from a chest. Just be sure you don't set it up so that they can
# # manipulate their rep by adding and taking items.
#
#------------------------------------------------------------------------------#
# I recommend downloading the demo to see how to set up container events as
# this got a bit complicated with adding features.
#
# More setup options further down.
#------------------------------------------------------------------------------#
($imported ||= {})["Galvs_Item_Containers"] = true
module Galv_Container
#------------------------------------------------------------------------------#
# SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
# COMMAND LIST VOCAB
REMOVE = "Remove"
STORE = "Store"
CANCEL = "Cancel"
# OTHER VOCAB
IN_STORAGE = "In Container"
IN_INVENTORY = "In Inventory"
TAKE_TEXT = "Remove how many?"
STORE_TEXT = "Store how many?"
TAKE_ALL = "A: Take All" # Text displayed bottom left
REP = "Reputation" # Text displayed in the bottom right
# Make this "" to not use it.
REP_VAR = 1 # Variable displayed after the REP text. This is the variable
# that can change when you take or put things into a container
# Make this 0 to not use.
# OTHER OPTIONS
SE = ["Equip2", 90, 100] # Sound effect when storing/removing an item
STORE_PRICELESS = true # Items worth 0 can be stored? true or false
STORE_KEY = true # Key items can be stored? true or false
C_SE = ["Buzzer1", 90, 100] # Sound effect when caught stealing
C_SWITCH = 2 # Switch is turned ON when you are caught
# PARTY LIMITS
# NOTE: These limits set to 0 will use the default limits. In theory this will
# be compatible with a limit breaker script by leaving them at 0. Or you can
# set the party limits below to whatever you like.
MAX_ITEMS = 0 # Max items your PARTY can carry.
# This will overwrite the default limit.
# 0 means do not use this.
TAKE_ONLY_SWITCH = 1 # Switch ID. Turn ON to only allow taking from all
# containers. Switch OFF to allow both again.
#------------------------------------------------------------------------------#
# SCRIPT SETUP OPTIONS
#------------------------------------------------------------------------------#
end
class Game_Temp
attr_accessor :contents
attr_accessor :container_name
alias galv_container_initialize initialize
def initialize
galv_container_initialize
@contents = []
@container_name = ""
end
end # Game_Temp
class RPG::BaseItem
def take_mod
if @take_mod.nil?
if @note =~ /<take_mod: (.*)>/i
@take_mod = $1.to_i
else
@take_mod = 0
end
end
@take_mod
end
def take_value
if @take_value.nil?
if @note =~ /<take_value: (.*)>/i
@take_value = $1.to_i
else
@take_value = 0
end
end
@take_value
end
end
class Scene_Container < Scene_MenuBase
def start
super
check_storage_exists
create_help_window
create_name_window
create_info_window
create_command_window
create_dummy_window
create_number_window
create_status_window
create_category_window
create_take_window
create_give_window
end
def check_storage_exists
if $game_party.container[$game_temp.contents].nil?
$game_party.container[$game_temp.contents] = {}
end
return @btn_active = false if danger_box?
@btn_active = true if !$game_party.container[$game_temp.contents].empty?
end
def danger_box?
$game_party.container_status[4] > 0
end
def update
super
check_key
end
def check_key
if Input.trigger?(:X)
if @btn_active
take_all
else
Sound.play_buzzer
end
end
end
#--------------------------------------------------------------------------
# Create Windows
#--------------------------------------------------------------------------
def create_name_window
@name_window = Window_ContainerName.new
@name_window.viewport = @viewport
@name_window.x = Graphics.width - @name_window.width
@name_window.y = @help_window.height
end
def create_info_window
@info_window = Window_Info.new
@info_window.viewport = @viewport
@info_window.x = 0
@info_window.y = Graphics.height - @info_window.height
end
def create_command_window
@command_window = Window_ContainerCommand.new(@name_window.x)
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.set_handler(:give, method(:command_give))
@command_window.set_handler(:take, method(:command_take))
@command_window.set_handler(:cancel, method(:return_scene))
end
def create_dummy_window
wy = @command_window.y + @command_window.height
wh = Graphics.height - wy - @name_window.height
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
@dummy_window.hide
end
def create_number_window
wy = @dummy_window.y
wh = @dummy_window.height
@number_window = Window_ContainerNumber.new(0, wy, wh)
@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 create_status_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@status_window = Window_ContainerItems.new(wx, wy, ww, wh)
@status_window.viewport = @viewport
@status_window.hide
end
def create_category_window
@category_window = Window_ItemCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @dummy_window.y
@category_window.hide.deactivate
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:on_category_cancel))
end
def create_give_window
wy = @category_window.y + @category_window.height
wh = Graphics.height - wy - @name_window.height
@give_window = Window_ContainerGive.new(0, wy, Graphics.width, wh)
@give_window.viewport = @viewport
@give_window.help_window = @help_window
@give_window.hide
@give_window.set_handler(:ok, method(:on_give_ok))
@give_window.set_handler(:cancel, method(:on_give_cancel))
@category_window.item_window = @give_window
end
def create_take_window
wy = @command_window.y + @command_window.height
wh = Graphics.height - wy - @name_window.height
@take_window = Window_ContainerTake.new(0, wy, Graphics.width, wh)
@take_window.viewport = @viewport
@take_window.help_window = @help_window
@take_window.set_handler(:ok, method(:on_take_ok))
@take_window.set_handler(:cancel, method(:on_take_cancel))
@category_window.item_window = @take_window
end
#--------------------------------------------------------------------------
# * Activate Windows
#--------------------------------------------------------------------------
def activate_give_window
@category_window.show
@give_window.refresh
@give_window.show.activate
@status_window.hide
end
def activate_take_window
@take_window.select(0)
@take_window.refresh
@take_window.show.activate
@status_window.hide
end
def btn_activate
return btn_deactivate if danger_box?
return btn_deactivate if $game_party.container[$game_temp.contents].empty?
@info_window.refresh(true)
@btn_active = true
end
def btn_deactivate
@info_window.refresh(false)
@btn_active = false
end
#--------------------------------------------------------------------------
# HANDLER METHODS
#--------------------------------------------------------------------------
def on_category_ok
activate_give_window
@give_window.select(0)
btn_deactivate
end
def on_category_cancel
@command_window.activate
@take_window.show
@take_window.refresh
@category_window.hide
@give_window.hide
btn_activate
end
def command_give
@take_window.hide
@category_window.show.activate
@give_window.show
@give_window.unselect
@give_window.refresh
btn_deactivate
end
def on_give_ok
@item = @give_window.item
if @item.nil?
RPG::SE.stop
Sound.play_buzzer
@give_window.activate
@give_window.refresh
return
else
@status_window.item = @item
@category_window.hide
@give_window.hide
@number_window.set(@item, max_give, @command_window.current_symbol)
@number_window.show.activate
@status_window.show
btn_deactivate
end
end
def on_give_cancel
@give_window.unselect
@category_window.activate
@status_window.item = nil
@help_window.clear
end
def command_take
activate_take_window
@take_window.show
@take_window.refresh
btn_activate
end
def on_take_ok
btn_deactivate
@item = @take_window.item
if @item.nil? || $game_party.container[$game_temp.contents].empty? || $game_party.item_number(@item) == $game_party.max_item_number(@item)
RPG::SE.stop
Sound.play_buzzer
@take_window.activate
@take_window.refresh
return
elsif
@item = @take_window.item
@status_window.item = @item
@take_window.hide
@number_window.set(@item, max_take, @command_window.current_symbol)
@number_window.show.activate
@status_window.show
end
end
def on_take_cancel
@take_window.unselect
@command_window.activate
@take_window.show
@status_window.item = nil
@help_window.clear
end
def on_number_ok
RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play
case @command_window.current_symbol
when :take
do_take(@number_window.number)
btn_activate
when :give
do_give(@number_window.number)
btn_deactivate
end
end_number_input
@status_window.refresh
end
def on_number_cancel
Sound.play_cancel
end_number_input
end
def end_number_input
@number_window.hide
case @command_window.current_symbol
when :take
activate_take_window
btn_activate
when :give
activate_give_window
end
end
#--------------------------------------------------------------------------
# * Giving and taking methods
#--------------------------------------------------------------------------
def max_take
if $game_party.container[$game_temp.contents][@item] > $game_party.max_item_number(@item) - $game_party.item_number(@item)
$game_party.max_item_number(@item) - $game_party.item_number(@item)
else
$game_party.container[$game_temp.contents][@item]
end
end
def max_give
$game_party.item_number(@item)
end
def do_give(number)
$game_party.lose_item(@item, number)
if $game_party.container[$game_temp.contents][@item].nil?
$game_party.container[$game_temp.contents][@item] = number
else
$game_party.container[$game_temp.contents][@item] += number
end
get_take_value(3)
$game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[3] + @take_value) * number
end
def do_take(number)
check_capture
return if @item.nil?
$game_party.gain_item(@item, number)
$game_party.container[$game_temp.contents][@item] -= number
$game_party.container[$game_temp.contents].delete(@item) if $game_party.container[$game_temp.contents][@item] <= 0
if $game_party.container[$game_temp.contents].empty?
@take_window.activate
end
get_take_value(2)
$game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number
end
def take_all
return Sound.play_buzzer if $game_party.container[$game_temp.contents].empty? ||
max_of_items
RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play
$game_party.container[$game_temp.contents].each do |i|
if i[1] > $game_party.max_item_number(i[0]) - $game_party.item_number(i[0])
number = $game_party.max_item_number(i[0]) - $game_party.item_number(i[0])
else
number = i[1] - $game_party.item_number(i[0])
end
p number
$game_party.gain_item(i[0], number)
i[1] -= number
$game_party.container[$game_temp.contents][i[0]] -= number
$game_party.container[$game_temp.contents].delete(i[0]) if i[1] <= 0
@item = i[0]
get_take_value(2)
$game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number
end
btn_activate
@take_window.refresh
end
def max_of_items
# if all items in box are maxed, return true
$game_party.container[$game_temp.contents].each { |item|
return false if $game_party.item_number(item[0]) < $game_party.max_item_number(item[0])
}
return true
end
def get_take_value(pos)
return @take_value = 0 if @item.nil?
if $game_party.container_status[pos] == 0
@take_value = 0
elsif $game_party.container_status[pos] > 0
@take_value = @item.take_value
else $game_party.container_status[pos] < 0
@take_value = -@item.take_value
end
end
def check_capture
a = rand(100)
chance = $game_party.container_status[4] + actor_mod + equip_mod
if a < chance
RPG::SE.new(Galv_Container::C_SE[0], Galv_Container::C_SE[1], Galv_Container::C_SE[2]).play
$game_switches[Galv_Container::C_SWITCH] = true
SceneManager.goto(Scene_Map)
end
end
def equip_mod
equip_mod = 0
$game_party.members.each do |m|
m.equips.each do |eq|
next if eq.nil?
equip_mod += eq.take_mod
end
end
return equip_mod
end
def actor_mod
actor_mod = 0
$game_party.members.each do |m|
actor_mod += $data_actors[m.id].take_mod
end
return actor_mod
end
end # Scene_Container < Scene_MenuBase
#------------------------------------------------------------------------------#
# Window Container Name
#------------------------------------------------------------------------------#
class Window_ContainerName < Window_Base
def initialize
super(0, 0, window_width, fitting_height(1))
refresh
end
def window_width
return 180
end
def refresh
contents.clear
c_name = convert_escape_characters($game_temp.container_name)
draw_text(x - 10, y, window_width, line_height, c_name,1)
end
def open
refresh
super
end
end
#------------------------------------------------------------------------------#
# Window Info
#------------------------------------------------------------------------------#
class Window_Info < Window_Base
def initialize
super(0, 0, Graphics.width, fitting_height(1))
@btn_state = true if !$game_party.container[$game_temp.contents].empty?
@btn_state = false if $game_party.container_status[4] > 0
refresh(@btn_state)
end
def refresh(btn)
@btn_state = btn
contents.clear
draw_texts
end
def draw_texts
change_color(normal_color, @btn_state)
draw_text(0, 0, contents.width, line_height, Galv_Container::TAKE_ALL, 0)
change_color(text_color($game_party.container_status[1]))
draw_text(0, 0, contents.width, line_height, $game_party.container_status[0], 1)
if Galv_Container::REP_VAR <= 0
repvar = ""
else
repvar = $game_variables[Galv_Container::REP_VAR]
end
change_color(normal_color)
draw_text(0, 0, contents.width, line_height, Galv_Container::REP + " " + repvar.to_s, 2)
end
end
#------------------------------------------------------------------------------#
# Window Stored Items
#------------------------------------------------------------------------------#
class Window_StoreList < Window_Selectable
def initialize(x, y, width, height)
super
@category = :none
@data = []
end
def category=(category)
return if @category == category
@category = category
refresh
self.oy = 0
end
def col_max
return 2
end
def item_max
@data ? @data.size : 1
end
def item
@data && index >= 0 ? @data[index] : nil
end
def current_item_enabled?
enable?(@data[index])
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 :key_item
item.is_a?(RPG::Item) && item.key_item?
else
false
end
end
def enable?(item)
$game_party.container[$game_temp.contents].has_key?(item)
end
def make_item_list
@data = $game_party.container[$game_temp.contents].keys {|item| include?(item) }
@data.push(nil) if include?(nil)
end
def select_last
select(@data.index($game_party.last_item.object) || 0)
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))
draw_item_number(rect, item)
end
end
def draw_item_number(rect, item)
draw_text(rect, sprintf(":%2d", $game_party.container[$game_temp.contents][item]), 2)
end
def update_help
@help_window.set_item(item)
end
def refresh
make_item_list
create_contents
draw_all_items
end
end # Window_StoreList < Window_Selectable
#------------------------------------------------------------------------------#
# Window Stored Item amount
#------------------------------------------------------------------------------#
class Window_ContainerNumber < Window_Selectable
attr_reader :number
def initialize(x, y, height)
super(x, y, window_width, height)
@item = nil
@max = 1
@number = 1
end
def window_width
return 304
end
def set(item, max, cmd)
@item = item
@max = max
@number = 1
@cmd = cmd
refresh
end
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
draw_how_many
end
def draw_number
change_color(normal_color)
draw_text(cursor_x - 28, item_y, 22, line_height, "×")
draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
end
def item_y
contents_height / 2 - line_height * 3 / 2
end
def cursor_width
figures * 10 + 12
end
def cursor_x
contents_width - cursor_width - 4
end
def figures
return 2
end
def update
super
if active
last_number = @number
update_number
if @number != last_number
Sound.play_cursor
refresh
end
end
end
def update_number
change_number(1) if Input.repeat?(:RIGHT)
change_number(-1) if Input.repeat?(:LEFT)
change_number(10) if Input.repeat?(:UP)
change_number(-10) if Input.repeat?(:DOWN)
end
def change_number(amount)
@number = [[@number + amount, @max].min, 1].max
end
def update_cursor
cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
end
def draw_how_many
change_color(system_color)
case @cmd
when :take
draw_text(4, 4, contents.width, line_height, Galv_Container::TAKE_TEXT)
when :give
draw_text(4, 4, contents.width, line_height, Galv_Container::STORE_TEXT)
end
change_color(normal_color)
end
end # Window_ContainerNumber < Window_Selectable
#------------------------------------------------------------------------------#
# Window Store Item Status
#------------------------------------------------------------------------------#
class Window_ContainerItems < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
@item = nil
@page_index = 0
refresh
end
def refresh
contents.clear
draw_possession(4, 0)
draw_stored(4, line_height)
draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)
end
def item=(item)
@item = item
refresh
end
def draw_possession(x, y)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(system_color)
draw_text(rect, Galv_Container::IN_INVENTORY)
change_color(normal_color)
draw_text(rect, $game_party.item_number(@item), 2)
end
def draw_stored(x, y)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(system_color)
draw_text(rect, Galv_Container::IN_STORAGE)
change_color(normal_color)
stored_amount = $game_party.container[$game_temp.contents][@item]
stored_amount = 0 if stored_amount.nil?
draw_text(rect, stored_amount, 2)
end
def draw_equip_info(x, y)
status_members.each_with_index do |actor, i|
draw_actor_equip_info(x, y + line_height * (i * 2.4), actor)
end
end
def status_members
$game_party.members[@page_index * page_size, page_size]
end
def page_size
return 4
end
def page_max
($game_party.members.size + page_size - 1) / page_size
end
def draw_actor_equip_info(x, y, actor)
enabled = actor.equippable?(@item)
change_color(normal_color, enabled)
draw_text(x, y, 112, line_height, actor.name)
item1 = current_equipped_item(actor, @item.etype_id)
draw_actor_param_change(x, y, actor, item1) if enabled
draw_item_name(item1, x, y + line_height, enabled)
end
def draw_actor_param_change(x, y, actor, item1)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0)
change_color(param_change_color(change))
draw_text(rect, sprintf("%+d", change), 2)
end
def param_id
@item.is_a?(RPG::Weapon) ? 2 : 3
end
def current_equipped_item(actor, etype_id)
list = []
actor.equip_slots.each_with_index do |slot_etype_id, i|
list.push(actor.equips[i]) if slot_etype_id == etype_id
end
list.min_by {|item| item ? item.params[param_id] : 0 }
end
def update
super
update_page
end
def update_page
if visible && Input.trigger?(:A) && page_max > 1
@page_index = (@page_index + 1) % page_max
refresh
end
end
end # Window_ContainerItems < Window_Base
#------------------------------------------------------------------------------#
# Window Give Item
#------------------------------------------------------------------------------#
class Window_ContainerGive < Window_ItemList
def initialize(x, y, width, height)
super(x, y, width, height)
end
def current_item_enabled?
enable?(@data[index])
end
def enable?(item)
if item.is_a?(RPG::Item)
return false if item.key_item? && !Galv_Container::STORE_KEY
end
if Galv_Container::STORE_PRICELESS
true
else
item && item.price > 0
end
end
end # Window_ContainerGive < Window_ItemList
#------------------------------------------------------------------------------#
# Window Take Item
#------------------------------------------------------------------------------#
class Window_ContainerTake < Window_StoreList
def initialize(x, y, width, height)
super(x, y, width, height)
end
def current_item_enabled?
enable?(@data[index])
end
def enable?(item)
$game_party.container[$game_temp.contents][item] != 0 && $game_party.item_number(item) < $game_party.max_item_number(@item)
end
end # Window_ContainerTake < Window_StoreList
#------------------------------------------------------------------------------#
# Window Command
#------------------------------------------------------------------------------#
class Window_ContainerCommand < Window_HorzCommand
def initialize(window_width)
@window_width = window_width
super(0, 0)
end
def window_width
@window_width
end
def col_max
return 2 if $game_switches[Galv_Container::TAKE_ONLY_SWITCH]
return 3
end
def make_command_list
add_command(Galv_Container::REMOVE, :take)
add_command(Galv_Container::STORE, :give) if !$game_switches[Galv_Container::TAKE_ONLY_SWITCH]
add_command(Galv_Container::CANCEL, :cancel)
end
end # Window_ContainerCommand < Window_HorzCommand
#------------------------------------------------------------------------------#
# Game Party Additions
#------------------------------------------------------------------------------#
class Game_Party < Game_Unit
attr_accessor :container
attr_accessor :container_status
alias galv_mcontatiners_initialize initialize
def initialize
galv_mcontatiners_initialize
init_containers
end
def init_containers
@container_status = ["",0,0,0,0] # text,color,take_rep,give_rep,catch_chance
@container = {}
end
alias galv_container_max_item_number max_item_number
def max_item_number(item)
return Galv_Container::MAX_ITEMS if Galv_Container::MAX_ITEMS > 0
return 99 if item.nil?
galv_container_max_item_number(item)
end
end # Game_Party < Game_Unit
class Game_Interpreter
def c_add(type, id, amount, event_id, map_id)
if event_id <= 0
add_where = @event_id
else
add_where = event_id
end
if map_id <= 0
add_where_map = $game_map.map_id
else
add_where_map = map_id
end
$game_temp.contents = [add_where, add_where_map]
if $game_party.container[$game_temp.contents].nil?
$game_party.container[$game_temp.contents] = {}
end
case type
when "weapon"
@item = $data_weapons[id]
when "item"
@item = $data_items[id]
when "armor"
@item = $data_armors[id]
end
if $game_party.container[$game_temp.contents][@item].nil?
$game_party.container[$game_temp.contents][@item] = amount
else
$game_party.container[$game_temp.contents][@item] += amount
end
end
def c_rem(type, id, amount, event_id, map_id)
if event_id <= 0
rem_where = @event_id
else
rem_where = event_id
end
if map_id <= 0
rem_where_map = $game_map.map_id
else
rem_where_map = map_id
end
$game_temp.contents = [rem_where, rem_where_map]
if $game_party.container[$game_temp.contents].nil?
$game_party.container[$game_temp.contents] = {}
end
case type
when "weapon"
@item = $data_weapons[id]
when "item"
@item = $data_items[id]
when "armor"
@item = $data_armors[id]
end
return if $game_party.container[$game_temp.contents][@item].nil?
if $game_party.container[$game_temp.contents][@item] <= amount
$game_party.container[$game_temp.contents].delete(@item)
else
$game_party.container[$game_temp.contents][@item] -= amount
end
end
def c_count(type, id, event_id, map_id)
if event_id <= 0
container_id = @event_id
else
container_id = event_id
end
if map_id <= 0
container_id_map = $game_map.map_id
else
container_id_map = map_id
end
$game_temp.contents = [container_id, container_id_map]
if $game_party.container[$game_temp.contents].nil?
$game_party.container[$game_temp.contents] = {}
end
case type
when "weapon"
@item = $data_weapons[id]
when "item"
@item = $data_items[id]
when "armor"
@item = $data_armors[id]
end
return 0 if $game_party.container[$game_temp.contents][@item].nil?
$game_party.container[$game_temp.contents][@item]
end
def c_status(text,color,take_rep,give_rep,catch_chance)
$game_party.container_status = [text,color,take_rep,give_rep,catch_chance]
end
def c_empty?(event_id,map_id)
!$game_party.container[[event_id,map_id]].nil? &&
$game_party.container[[event_id,map_id]].empty?
end
def open_container(name)
$game_temp.container_name = name
$game_temp.contents = [@event_id, $game_map.map_id]
SceneManager.call(Scene_Container)
wait(1)
end
end # Game_Interpreter
|
|