设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 133|回复: 1
打印 上一主题 下一主题

[有事请教] むー的物品负重脚本与Galv的事件容器脚本兼容问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1091
在线时间
114 小时
注册时间
2019-3-2
帖子
38
跳转到指定楼层
1
发表于 2025-6-10 04:04:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
300星屑
本帖最后由 sansy 于 2025-6-10 04:06 编辑

如题,两个脚本的功能分别为给物品设置负重,负重达到上限后无法继续获得物品以及将需要的事件变为一个可存入可取出物品的容器箱子
当这两个脚本同时使用时,从箱子里拿出物品可以超过负重上限(即可以继续取出,不会受到限制),但是实际上物品没有进入背包,而是直接消失掉了
如何让这个容器脚本对物品负重的处理变为类似于物品数量上限的处理:
即选择取出的数量时,最终容量不能超过物品上限(etc:物品A的上限为99个,队伍持有95个,而箱子里有10个,此时玩家选择要取出的数量时最多将数字设置为4)
且在当前队伍连一个该物品都拿不下时,选择拿出该物品的操作无效(类似于尝试拿取背包中数量已达上限的物品)。
如果内容过于复杂需要详细说明或者需要进行有偿支付,可以留下QQ联系方式。
脚本如下:
负重脚本前置:
RUBY 代码复制
  1. #==============================================================================
  2. # ■ むー素材用モジュール Ver1.0
  3. #------------------------------------------------------------------------------
  4. #    スクリプトに必要なモジュールです。                                 By むー
  5. #------------------------------------------------------------------------------
  6. #    使用スクリプト
  7. #    ・ドロップアイテム演出
  8. #    ・アイテム重量制
  9. #==============================================================================
  10. module MOO_GENERAL_MODULE
  11.  
  12.   #--------------------------------------------------------------------------
  13.   # 以下、設定箇所です。
  14.   #--------------------------------------------------------------------------
  15.  
  16.   # ウィンドウのサイズ(1=544x416 / 2=640x480)
  17.   WINDOW_SIZE = 1
  18.   # ここで指定しても、ウィンドウサイズが変わるわけではありません。
  19.  
  20.   #--------------------------------------------------------------------------
  21.   # ここまで。
  22.   #--------------------------------------------------------------------------
  23.  
  24.   #**************************************************************************
  25.   # ※ ここ以下は変更しないでください。
  26.   #**************************************************************************
  27.  
  28.   #--------------------------------------------------------------------------
  29.   # ● 左右どちらかに指定文字を埋める
  30.   #     word: 元々の文字列
  31.   #     len:  全部で何文字にするか
  32.   #     str:  埋める文字
  33.   #     lr:   埋める文字を付ける方向(1=左/2=右)
  34.   #       bury_plus("world", 8, " ", 1) → 結果: "   world"
  35.   #       bury_plus("world", 8, "@", 2) → 結果: "world@@@"
  36.   #--------------------------------------------------------------------------
  37.   def bury_plus(word, len, str, lr = 1)
  38.     return word if word.length >= len
  39.     str.to_s
  40.     pls = ""
  41.     for i in 1..len - word.length
  42.       pls += str
  43.     end
  44.     case lr
  45.       when 1; return pls + word
  46.       when 2; return word + pls
  47.     end
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
  51.   #--------------------------------------------------------------------------
  52.   def weight_item_window_x
  53.     return 384 if WINDOW_SIZE == 1
  54.     return 480 if WINDOW_SIZE == 2
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
  58.   #--------------------------------------------------------------------------
  59.   def weight_item_window_y
  60.     return 72  if WINDOW_SIZE == 1
  61.     return 72  if WINDOW_SIZE == 2
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
  65.   #--------------------------------------------------------------------------
  66.   def weight_item_window_w
  67.     return 160 if WINDOW_SIZE == 1
  68.     return 160 if WINDOW_SIZE == 2
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● 重量制限用:アイテムウィンドウで総重量を示すウィンドウの位置
  72.   #--------------------------------------------------------------------------
  73.   def weight_item_window_h
  74.     return 48  if WINDOW_SIZE == 1
  75.     return 48  if WINDOW_SIZE == 2
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 重量制限用:ショップの売却画面で総重量を示すウィンドウの幅調整
  79.   #--------------------------------------------------------------------------
  80.   def weight_shop_buy_category_window_adjust_w
  81.     return 32  if WINDOW_SIZE == 1
  82.     return 32  if WINDOW_SIZE == 2
  83.   end
  84. end

负重脚本本体:
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 重量制 Ver 1.21                               By むー
  3. #------------------------------------------------------------------------------
  4. # アイテムに重量を付加し、所持可能な重量を指定できます。
  5. # 本スクリプトを利用するには、[むー素材用]スクリプトが別途必要になります。
  6. # 本スクリプトは[むー素材用]よりも下に設置して下さい。
  7. #------------------------------------------------------------------------------
  8. #
  9. # ★簡単な仕様★
  10. #
  11. # ・ゲームに重量を設置します。
  12. # ・設定した総重量以上の物は持てません。
  13. # ・チェックコマンドにて、イベントで入手可能チェックができます。
  14. # ・戦闘後のドロップアイテムは、持てる分だけ出ます。
  15. #   →3個出た場合、最初の2個は持てるけれど残りが持てない場合、
  16. #    2個分だけメッセージが出ます。入手も2個だけです。
  17. # ・重量オーバーの場合、店で購入ができません。
  18. # ・イベントでアイテムの増加をおこなう場合にもチェックが入ります。
  19. #   →特にメッセージは出ません。例えば5個入手で持てるだけ入手したい場合は、
  20. #    5個いぺっんに入手ではなく、1個入手を5回分作って下さい。
  21. #    5個いっぺんに入手する場合、5個持てなかったら1個も入手できません。
  22. #
  23. # ★チェック機能★
  24. #
  25. # イベントでアイテムを入手する時、重量オーバーになると取得できません。
  26. # イベントのスクリプトで、以下のように記述すると動作する機能があります。
  27. #
  28. # can_gain_item?(アイテム種類, ID, 数量, スイッチ番号, [取得フラグ])
  29. #
  30. #  アイテム種類: アイテム="I"、武器="W"、防具="A"
  31. #  ID     : 上記アイテム種類別のID ("W",3...) なら武器ID3
  32. #  数量    : 取得する数量
  33. #  スイッチ番号: 入手できる場合はON、できない場合はOFFが入るスイッチの番号
  34. #  取得フラグ : ついでに取得するか(true/false)
  35. #
  36. # アイテム種類は必ず""で囲って下さい。I、W、A以外のチェックしていません。
  37. # 数量が0の場合のエラーチェックはおこなっていません。
  38. # アイテム種類、ID、数量、スイッチ番号は必須です。
  39. # スイッチを使わない場合は、0にしておいて下さい。
  40. # 取得フラグをtrueにしておくと、取得可能な場合は自動的にアイテムを入手します。
  41. # falseまたは何も記述しなかった場合は取得しません。
  42. # またスイッチに入れなくとも、返り値でtrueかfalseが戻ります。
  43. #
  44. # ★注意点★
  45. #
  46. # ・ゲーム開始時に、基本重量を設定して下さい。
  47. # ・初期装備によって、総重量がオーバーしている場合があります。
  48. #
  49. #==============================================================================
  50. $rgsslab = {} if $rgsslab.nil?  # 併用対策
  51. #==============================================================================
  52. $moo_have_item_weight = true
  53. module MOO_HAVE_ITEM_WEIGHT
  54.  
  55.   #--------------------------------------------------------------------------
  56.   # 以下、設定箇所です。
  57.   #--------------------------------------------------------------------------
  58.  
  59.   # 総重量を代入する変数番号
  60.   MAX_WT = 11
  61.  
  62.   # 重量指定文字
  63.   WORD_WT = "重量"
  64.   # アイテム(および装備品)のメモ欄に書く文字です。
  65.   # "重量"の場合、<重量:5>とすれば、そのアイテムの重量は5になります。
  66.   # 他のスクリプトと重複する場合は変更してください。
  67.  
  68.   # 重量指定のないアイテムの重量
  69.   DEFAULT_WT = 1
  70.   # 重量の指定をしなかったアイテムの重量です。
  71.  
  72.   # 所持している総重量計算を個数×重量にするか
  73.   UNIT_WT = true
  74.   # 総重量の計算をどうするか決めます。
  75.   # trueの場合、アイテム個数×個別の重量の総計が、所持している総重量になります。
  76.   # falseの場合、アイテムが1個でも99個でも1個分の重さが総重量に加算されます。
  77.  
  78.   # アイテム欄の重量表示を個数×重量にするか
  79.   VIEW_WT = true
  80.   # アイテム個数の後ろに表示される重量表示をどうするか決めます。
  81.   # trueの場合、アイテムの重量が5で個数が4の場合、20と表示されます。
  82.   # falseの場合、個数に関係なく、単純にアイテムの重量だけが表示されます。
  83.   # このVIEW_WTをfalse、上記のUNIT_WTがtrueの場合、錯覚しないようご注意ください。
  84.   # その場合、()はあくまでそのアイテムの重量であり、総重量は個数×重量となります。
  85.   # また、UNIT_WTをfalse、VIEW_WTをtrueにすると、混乱の元となります(笑)
  86.  
  87.   # 重量計算に装備品を含むか
  88.   CONT_WT = false
  89.   # 装備品を総重量に含むかどうかを決めます。
  90.   # 袋(?)はあくまで袋、装備品は関係ない、などのような場合はfalseにして下さい。
  91.  
  92.   # 総重量を表示する上での文字
  93.   SUM_WEIGHT_WORD = "总重量"
  94.  
  95.   # アイテム欄で重量を囲う文字
  96.   PARENTHESIS_F = "重量:" # 前
  97.   PARENTHESIS_L = ""   # 後
  98.  
  99.   # 1つのアイテム重量の最大桁数
  100.   FIGURE_WT = 2
  101.   # 1つのアイテムに設定する重量の桁数です。99までなら2という感じで。
  102.   # 上の「アイテム欄で重量を囲う文字」と合わせて表示しますが、
  103.   # これが"(W:"と")"だった場合、画面上のアイテム欄には
  104.   # [アイテム名   10(W: 5)] のように表示されます。
  105.   # ↑       ↑ ↑
  106.   # アイテム名  個数 重さ(この部分の数字の前の空白に関わってきます)
  107.  
  108.   # 売買価格のレートを格納する変数 (1 = 1%)/おまけ機能
  109.   USE_RATE  = false # レート変動を使う場合
  110.   BUY_RATE  = 12    # 購入レート(USE_RATE=trueの場合のみ有効)
  111.   SELL_RATE = 13    # 売却レート(USE_RATE=trueの場合のみ有効)
  112.   # 指定しない場合、購入価格と売却価格は同じになります。
  113.   # 小数点以下の価格は切り捨てられます。
  114.  
  115.   # 販売不可アイテムの文字
  116.   CANT_SELL = "重量制販売不可"
  117.   # アイテムのメモ欄にこの文字があると、価格が0以上でも
  118.   # ショップで販売不可になります(0はデフォルトのまま販売不可です)。
  119.   # 重量制販売不可 とした場合、<重量制販売不可> と <>を一緒に記述して下さい。
  120.   # なお、これはあくまでデフォルト形態のショップだけに有効です。
  121.  
  122.   #--------------------------------------------------------------------------
  123.   # 以下、他のスクリプトを導入しているかどうかの判断です。
  124.   # これらのスクリプトを使用する場合、本スクリプトより上の位置に置いて下さい。
  125.   #--------------------------------------------------------------------------
  126.  
  127.   # ドロップアイテム系のスクリプトを導入しているか
  128.   DROP_ITEM = false
  129.   # 導入している場合は true にして下さい。通常は false にして下さい。
  130.   # その際、そのスクリプトに$game_party.gain_item(ナントカ)とあると思います。
  131.   # その前後に、本スクリプトの中身のように改造する必要があります。
  132.   #
  133.  
  134.   #--------------------------------------------------------------------------
  135.   # ここまで。
  136.   #--------------------------------------------------------------------------
  137.  
  138. end
  139.  
  140. #==============================================================================
  141. # ★ ここより下は変更しないで下さい。
  142. #==============================================================================
  143.  
  144. if MOO_HAVE_ITEM_WEIGHT::DROP_ITEM == false
  145. #==============================================================================
  146. # ■ BattleManager
  147. #------------------------------------------------------------------------------
  148. #  戦闘の進行を管理するモジュールです。
  149. #==============================================================================
  150. module BattleManager
  151.   def self.gain_drop_items
  152.     $game_troop.make_drop_items.each do |item|
  153.       if $game_party.gain_item_failed?(item)    # ドロップ系スクリプトに追加部分
  154.         $game_party.moo_gain_item(item, 1)
  155.         $game_message.add(sprintf(Vocab::ObtainItem, item.name))
  156.       end   # ドロップ系スクリプトに追加部分
  157.     end
  158.     wait_for_message
  159.   end
  160. end
  161. end
  162.  
  163. #==============================================================================
  164. # ■ Game_Party
  165. #------------------------------------------------------------------------------
  166. #  パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
  167. # スのインスタンスは $game_party で参照されます。
  168. #==============================================================================
  169. class Game_Party < Game_Unit
  170.   include MOO_GENERAL_MODULE
  171.   #--------------------------------------------------------------------------
  172.   # ● 公開インスタンス変数
  173.   #--------------------------------------------------------------------------
  174.   attr_reader   :gold                     # 所持金
  175.   attr_reader   :steps                    # 歩数
  176.   attr_reader   :last_item                # カーソル記憶用 : アイテム
  177.   #--------------------------------------------------------------------------
  178.   # ● オブジェクト初期化
  179.   #--------------------------------------------------------------------------
  180.   def initialize
  181.     super
  182.     @gold = 0
  183.     @steps = 0
  184.     @last_item = Game_BaseItem.new
  185.     @total_weight = 0   # 追加
  186.     @menu_actor_id = 0
  187.     @target_actor_id = 0
  188.     @actors = []
  189.     init_all_items
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ◎ アイテムの増加(減少)
  193.   #     include_equip : 装備品も含める
  194.   #--------------------------------------------------------------------------
  195.   alias moo_gain_item gain_item
  196.   def gain_item(item, amount, include_equip = false)
  197.     # gain_item内では、include_equipの関係からか、memberが使えません。
  198.     # ですので重量に装備品を含む場合、メンバーの装備情報が取得できません。
  199.     # 以下の"if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false"があるのはそのためです。
  200.     # 重量に装備品抜きの場合に限り、ここで重量のチェックをしています。
  201.     #
  202.     # 総重量を超える場合は取得不可能
  203.     # 1度に2以上取得しようとして引っかかった場合は、
  204.     # たとえ1個分の許容があったとしても、全て取得できません。
  205.     #
  206.     # 一応ここ以外にも、以下の箇所で入手可能かどうかのチェックをしています。
  207.     #
  208.     # ・イベントでアイテム、武器、防具を入手する時
  209.     # ・ショップでアイテムを購入する時
  210.     # ・戦闘後のドロップアイテム入手時
  211.     # ・装備を変更する時
  212.     #
  213.     # 普通に作成していれば、ここでチェックしなくてもよほど大丈夫だとはいますが、
  214.     # 他のスクリプトを導入する際、アイテム入手がある場合は注意して下さい。
  215.     # アイテム入手前に $game_party.gain_item(アイテム, 数量) を使って
  216.     # trueかfalseで判断するようにして下さい。
  217.     if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false
  218.       return if gain_item_failed?(item, amount) == false
  219.     end
  220.     # moo_gain_item(item, amount, include_equip)
  221.     container = item_container(item.class)
  222.     return unless container
  223.     last_number = item_number(item)
  224.     new_number = last_number + amount
  225.     container[item.id] = [[new_number, 0].max, max_item_number(item)].min
  226.     container.delete(item.id) if container[item.id] == 0
  227.     if include_equip && new_number < 0
  228.       discard_members_equip(item, -new_number)
  229.     end
  230.     $game_map.need_refresh = true
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ○ アイテムの個別重量を取得
  234.   #--------------------------------------------------------------------------
  235.   def weight_item(item)
  236.     return 0 if item == nil
  237.     # アイテムのメモ取得
  238.     memo = item.note.scan((/<#{MOO_HAVE_ITEM_WEIGHT::WORD_WT}[::](\S+)>/))
  239.     memo = memo.flatten
  240.     # 重量取得
  241.     if memo != nil and not memo.empty?
  242.       # 重量設定がある場合はそれを採用
  243.       wt = memo[0].to_i
  244.     else
  245.       # 重量設定がない場合は指定した重量とする
  246.       wt = MOO_HAVE_ITEM_WEIGHT::DEFAULT_WT
  247.     end
  248.     return wt
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ○ 所持アイテムの総重量を取得
  252.   #--------------------------------------------------------------------------
  253.   def weight_sum
  254.     # 変数初期化
  255.     wt = 0
  256.     # 所持しているアイテムの重量取得
  257.     $data_items.each do |item|
  258.       # アイテムの総重量
  259.       wt += weight_have_item(item) if item and item.name != ""
  260.     end
  261.     $data_weapons.each do |item|
  262.       # 武器の総重量
  263.       wt += weight_have_item(item) if item and item.name != ""
  264.     end
  265.     $data_armors.each do |item|
  266.       # 防具の総重量
  267.       wt += weight_have_item(item) if item and item.name != ""
  268.     end
  269.     return wt
  270.   end
  271.   #--------------------------------------------------------------------------
  272.   # ○ 所持アイテムの個別重量を取得(フラグがあれば装備品を含む)
  273.   #--------------------------------------------------------------------------
  274.   def weight_have_item(item)
  275.     return 0 if item == nil
  276.     # アイテムの個別重量を取得
  277.     wt = weight_item(item)
  278.     # 所持個数の取得
  279.     cn = item_number(item)
  280.     if MOO_HAVE_ITEM_WEIGHT::CONT_WT
  281.       if item.class == RPG::Weapon or item.class == RPG::Armor
  282.           members.each do |actor|
  283.           if item.class == RPG::Weapon
  284.             cn += 1 if $game_actors[actor.id].equips[0] == item
  285.             cn += 1 if $game_actors[actor.id].equips[1] == item
  286.           elsif item.class == RPG::Armor
  287.             cn += 1 if $game_actors[actor.id].equips[item.etype_id] == item
  288.           end
  289.         end
  290.       end
  291.     end
  292.     # 個数×重量の場合の計算
  293.     if cn == 0
  294.       wt = 0
  295.     else
  296.       wt *= cn if MOO_HAVE_ITEM_WEIGHT::UNIT_WT
  297.     end
  298.     return wt
  299.   end
  300.   #--------------------------------------------------------------------------
  301.   # ○ 重量をカッコ書き(アイテム一覧に書くため)
  302.   #--------------------------------------------------------------------------
  303.   def weight_item_draw(item)
  304.     wt = weight_item(item).to_i
  305.     wt *= item_number(item) if MOO_HAVE_ITEM_WEIGHT::VIEW_WT
  306.     wt = wt.to_s
  307.     wt = bury_plus(wt, MOO_HAVE_ITEM_WEIGHT::FIGURE_WT, " ", lr = 1)
  308.     wt = MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_F + wt + MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_L
  309.     return wt
  310.   end
  311.   #--------------------------------------------------------------------------
  312.   # ○ アイテムを取得可能かどうかの判断
  313.   #--------------------------------------------------------------------------
  314.   def gain_item_failed?(item, val = 1)
  315.     val = 1 if MOO_HAVE_ITEM_WEIGHT::UNIT_WT == false
  316.     if weight_sum + weight_item(item) * val > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT]
  317.       false
  318.     else
  319.       true
  320.     end
  321.   end
  322.   #--------------------------------------------------------------------------
  323.   # ○ 個数の限界によってアイテムを取得可能かどうかの判断
  324.   #--------------------------------------------------------------------------
  325.   def gain_item_max?(item, val = 1)
  326.     return false if item_number(item) + val > max_item_number(item)
  327.     return true
  328.   end
  329. end
  330.  
  331. #==============================================================================
  332. # ■ Game_Actor
  333. #------------------------------------------------------------------------------
  334. #  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
  335. # の内部で使用され、Game_Party クラス($game_party)からも参照されます。
  336. #==============================================================================
  337. class Game_Actor < Game_Battler
  338.   #--------------------------------------------------------------------------
  339.   # ◎ 装備の変更
  340.   #     slot_id : 装備スロット ID
  341.   #     item    : 武器/防具(nil なら装備解除)
  342.   #--------------------------------------------------------------------------
  343.   alias moo_change_equip change_equip
  344.   def change_equip(slot_id, item)
  345.     # equips[slot_id]: 装備中アイテム(nil=装備なし)
  346.     # item: これから装備しようとしているアイテム(nil=装備なし)
  347.     if MOO_HAVE_ITEM_WEIGHT::CONT_WT == false
  348.       wt_old = $game_party.weight_item(equips[slot_id])
  349.       wt_new = $game_party.weight_item(item)
  350.       wt_clc = $game_party.weight_sum + wt_old - wt_new
  351.       # wt_clc: 現在の重さ + 外す装備品の重さ - これから装備する物の重さ
  352.       if wt_clc > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT]
  353.         Sound.play_buzzer
  354.         return
  355.       end
  356.     end
  357.     moo_change_equip(slot_id, item)
  358.   end
  359.   #--------------------------------------------------------------------------
  360.   # ● パーティとアイテムを交換する
  361.   #     new_item : パーティから取り出すアイテム
  362.   #     old_item : パーティに返すアイテム
  363.   #--------------------------------------------------------------------------
  364.   alias moo_trade_item_with_party trade_item_with_party
  365.   def trade_item_with_party(new_item, old_item)
  366.     return false if new_item && !$game_party.has_item?(new_item)
  367.     # 入手と破棄を逆転
  368.     $game_party.lose_item(new_item, 1)
  369.     $game_party.gain_item(old_item, 1)
  370.     return true
  371.   end
  372. end
  373.  
  374. #==============================================================================
  375. # ■ Game_Interpreter
  376. #------------------------------------------------------------------------------
  377. #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
  378. # Game_Troop クラス、Game_Event クラスの内部で使用されます。
  379. #==============================================================================
  380. class Game_Interpreter
  381.   #--------------------------------------------------------------------------
  382.   # ● アイテムの増減
  383.   #--------------------------------------------------------------------------
  384.   def command_126
  385.     value = operate_value(@params[1], @params[2], @params[3])
  386.     if $game_party.gain_item_failed?($data_items[@params[0]], value)
  387.       $game_party.moo_gain_item($data_items[@params[0]], value)
  388.     end
  389.   end
  390.   #--------------------------------------------------------------------------
  391.   # ● 武器の増減
  392.   #--------------------------------------------------------------------------
  393.   def command_127
  394.     value = operate_value(@params[1], @params[2], @params[3])
  395.     if $game_party.gain_item_failed?($data_weapons[@params[0]], value)
  396.       $game_party.moo_gain_item($data_weapons[@params[0]], value, @params[4])
  397.     end
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # ● 防具の増減
  401.   #--------------------------------------------------------------------------
  402.   def command_128
  403.     value = operate_value(@params[1], @params[2], @params[3])
  404.     if $game_party.gain_item_failed?($data_armors[@params[0]], value)
  405.       $game_party.moo_gain_item($data_armors[@params[0]], value, @params[4])
  406.     end
  407.   end
  408.   #--------------------------------------------------------------------------
  409.   # ○ 所持品を追加できるかの判断
  410.   #     kind  : アイテム種類(/[IWA]/)
  411.   #     id    : アイテムID
  412.   #     num   : 入手する個数
  413.   #     val   : 入手可能かどうかを代入するスイッチ番号(使わない場合は0を指定)
  414.   #     gain  : 入手処理もついでに行なうか(省略時は行なわない)
  415.   #--------------------------------------------------------------------------
  416.   def can_gain_item?(kind, id, num = 1, val = 0, gain = false)
  417.     # アイテム変数初期値
  418.     item = nil
  419.     # アイテム種類分別
  420.     case kind
  421.       when "I"; item = $data_items[id]
  422.       when "W"; item = $data_weapons[id]
  423.       when "A"; item = $data_armors[id]
  424.     end
  425.     # 重量による取得可能チェック  
  426.     flg1 = $game_party.gain_item_failed?(item, num)
  427.     # 数量による取得可能チェック
  428.     flg2 = $game_party.gain_item_max?(item, num)
  429.     # 重量か数量いずれかで取得不能判定があった場合のフラグ
  430.     flg = true
  431.     flg = false if flg1 == false or flg2 == false
  432.     # 取得可能であり取得フラグが立っていたら取得
  433.     $game_party.moo_gain_item(item, num) if flg and gain
  434.     # スイッチに値を返す
  435.     $game_switches[val] = flg if val > 0 and val != nil
  436.     # 値を返す
  437.     return flg
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ○ 所持品の総重量を取得
  441.   #--------------------------------------------------------------------------
  442.   def get_weight_sum
  443.     $game_party.weight_sum
  444.   end
  445. end
  446.  
  447. #==============================================================================
  448. # ■ Window_ItemCategory
  449. #------------------------------------------------------------------------------
  450. #  アイテム画面またはショップ画面で、通常アイテムや装備品の分類を選択するウィ
  451. # ンドウです。
  452. #==============================================================================
  453. class Window_ItemCategory < Window_HorzCommand
  454.   #--------------------------------------------------------------------------
  455.   # ● ウィンドウ幅の取得
  456.   #--------------------------------------------------------------------------
  457.   def window_width
  458.     Graphics.width - 160
  459.   end
  460. end
  461.  
  462. #==============================================================================
  463. # ■ Window_ItemList
  464. #------------------------------------------------------------------------------
  465. #  アイテム画面で、所持アイテムの一覧を表示するウィンドウです。
  466. #==============================================================================
  467. class Window_ItemList < Window_Selectable
  468.   #--------------------------------------------------------------------------
  469.   # ● アイテムの個数を描画
  470.   #--------------------------------------------------------------------------
  471.   def draw_item_number(rect, item)
  472.     $game_party.weight_sum
  473.     # カッコ書きの重量文字列を取得
  474.     wt = $game_party.weight_item_draw(item)
  475.     # 数量の後に重量を追加
  476.     draw_text(rect, sprintf(":%2d", $game_party.item_number(item)) + wt, 2)
  477.   end
  478. end
  479.  
  480. #==============================================================================
  481. # ■ Window_ShopBuy
  482. #------------------------------------------------------------------------------
  483. #  ショップ画面で、購入できる商品の一覧を表示するウィンドウです。
  484. #==============================================================================
  485. class Window_ShopBuy
  486. #  include MOO_GENERAL_MODULE
  487.   #--------------------------------------------------------------------------
  488.   # ● オブジェクト初期化
  489.   #--------------------------------------------------------------------------
  490.   def initialize(x, y, height, shop_goods)
  491.     super(x, y, window_width, height)
  492.     @shop_goods = shop_goods
  493.     @money = 0
  494.   end
  495.   #--------------------------------------------------------------------------
  496.   # ● 商品の値段を取得
  497.   #--------------------------------------------------------------------------
  498.   def price(item)
  499.     if MOO_HAVE_ITEM_WEIGHT::USE_RATE
  500.       return Integer(@price[item] * $game_variables[MOO_HAVE_ITEM_WEIGHT::BUY_RATE] / 100)
  501.     else
  502.       return @price[item]
  503.     end
  504.   end
  505.   #--------------------------------------------------------------------------
  506.   # ● アイテムリストの作成
  507.   #--------------------------------------------------------------------------
  508.   def make_item_list
  509.     @data = []
  510.     @price = {}
  511.     @shop_goods.each do |goods|
  512.       case goods[0]
  513.       when 0;  item = $data_items[goods[1]]
  514.       when 1;  item = $data_weapons[goods[1]]
  515.       when 2;  item = $data_armors[goods[1]]
  516.       end
  517.       if item
  518.         @data.push(item)
  519.         @price[item] = goods[2] == 0 ? item.price : goods[3]
  520.       end
  521.     end
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # ● 項目の描画
  525.   #--------------------------------------------------------------------------
  526.   def draw_item(index)
  527.     item = @data[index]
  528.     rect = item_rect(index)
  529.     draw_item_name(item, rect.x, rect.y, enable?(item))
  530.     rect.width -= 4
  531. #    wt = $game_party.weight_item(item)
  532. #    wt = wt.to_s
  533. #    wt = bury_plus(wt, MOO_HAVE_ITEM_WEIGHT::FIGURE_WT, " ", 1)
  534. #    wt = MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_F + wt + MOO_HAVE_ITEM_WEIGHT::PARENTHESIS_L
  535. #    draw_text(rect, price(item).to_s + wt, 2)
  536.     draw_text(rect, price(item), 2)
  537.   end
  538. end
  539.  
  540. #==============================================================================
  541. # ■ Window_ShopSell
  542. #------------------------------------------------------------------------------
  543. #  ショップ画面で、売却のために所持アイテムの一覧を表示するウィンドウです。
  544. #==============================================================================
  545. class Window_ShopSell
  546.   #--------------------------------------------------------------------------
  547.   # ○ 桁数の取得
  548.   #--------------------------------------------------------------------------
  549.   def col_max
  550.     return 1
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # ○ 項目の描画
  554.   #--------------------------------------------------------------------------
  555.   def draw_item(index)
  556.     item = @data[index]
  557.     rect = item_rect(index)
  558.     draw_item_name(item, rect.x, rect.y, enable?(item))
  559.     rect.width -= 4
  560.     draw_text(rect, price(item), 2)
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ◎ アイテムを許可状態で表示するかどうか
  564.   #--------------------------------------------------------------------------
  565.   alias moo_weight_enable? enable?
  566.   def enable?(item)
  567.     flg = $data_items[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">")   if item.class == RPG::Item
  568.     flg = $data_weapons[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">") if item.class == RPG::Weapon
  569.     flg = $data_armors[item.id].note.include?("<" + MOO_HAVE_ITEM_WEIGHT::CANT_SELL + ">")  if item.class == RPG::Armor
  570.     return false if flg
  571.     moo_weight_enable?(item)
  572.   end
  573.   #--------------------------------------------------------------------------
  574.   # ○ 商品の値段を取得
  575.   #--------------------------------------------------------------------------
  576.   def price(item)
  577.     if MOO_HAVE_ITEM_WEIGHT::USE_RATE
  578.       return Integer(item.price * $game_variables[MOO_HAVE_ITEM_WEIGHT::SELL_RATE] / 100)
  579.     else
  580.       return item.price
  581.     end
  582.   end
  583. end
  584.  
  585. #==============================================================================
  586. # ■ Window_ShopNumber
  587. #------------------------------------------------------------------------------
  588. #  ショップ画面で、購入または売却するアイテムの個数を入力するウィンドウです。
  589. #==============================================================================
  590. class Window_ShopNumber < Window_Selectable
  591.   #--------------------------------------------------------------------------
  592.   # ● リフレッシュ
  593.   #--------------------------------------------------------------------------
  594.   def refresh
  595.     contents.clear
  596.     draw_item_name(@item, 0, item_y)
  597.     draw_number
  598.     draw_total_price
  599.     draw_total_weight(@item)
  600.   end
  601.   #--------------------------------------------------------------------------
  602.   # ○ 個数の総重量の描画
  603.   #--------------------------------------------------------------------------
  604.   def draw_total_weight(item)
  605.     width = contents_width - 8
  606.     cx = text_size(@currency_unit).width
  607.     change_color(system_color)
  608.     x_plus = 4
  609.     if MOO_GENERAL_MODULE::WINDOW_SIZE == 1
  610.       y_plus = 36
  611.     elsif MOO_GENERAL_MODULE::WINDOW_SIZE == 2
  612.       y_plus = 72
  613.     end
  614.     wd = MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD
  615.     draw_text(4, y + 24 + y_plus, width, line_height, wd)
  616.     change_color(normal_color)
  617.     cn = 1
  618.     cn = @number if MOO_HAVE_ITEM_WEIGHT::UNIT_WT
  619.     wt = $game_party.weight_item(item) * cn #@number
  620.     draw_text(x - cx - 2 + x_plus, y + 24 + y_plus, width, line_height, wt, 2)
  621.   end
  622. end
  623.  
  624. #==============================================================================
  625. # ■ Window_ShopStatus
  626. #------------------------------------------------------------------------------
  627. #  ショップ画面で、アイテムの所持数やアクターの装備を表示するウィンドウです。
  628. #==============================================================================
  629. class Window_ShopStatus < Window_Base
  630.   #--------------------------------------------------------------------------
  631.   # ● リフレッシュ
  632.   #--------------------------------------------------------------------------
  633.   def refresh
  634.     contents.clear
  635.     draw_possession(4, 0)
  636.     draw_weight_possession(4, 24)
  637.     y_plus = 0
  638.     y_plus = 24 if MOO_GENERAL_MODULE::WINDOW_SIZE == 2
  639.     draw_equip_info(4, line_height * 2 + y_plus) if @item.is_a?(RPG::EquipItem)
  640.   end
  641.   #--------------------------------------------------------------------------
  642.   # ○ 総重量の描画
  643.   #--------------------------------------------------------------------------
  644.   def draw_weight_possession(x, y)
  645.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  646.     change_color(system_color)
  647.     draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
  648.     change_color(normal_color)
  649.     str =  $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
  650.     draw_text(rect, str, 2)
  651.   end
  652. end
  653.  
  654. #==============================================================================
  655. # ■ Window_Weight_Sum_Menu
  656. #------------------------------------------------------------------------------
  657. #  メニューウィンドウで総重量を表示するクラスです。
  658. #==============================================================================
  659. class Window_Weight_Sum_Menu < Window_Base
  660.   #--------------------------------------------------------------------------
  661.   # ○ オブジェクト初期化
  662.   #--------------------------------------------------------------------------
  663.   def initialize(x, y, width, height)
  664.     super(x, y, width, height)
  665.     refresh
  666.   end
  667.   #--------------------------------------------------------------------------
  668.   # ○ リフレッシュ
  669.   #--------------------------------------------------------------------------
  670.   def refresh
  671.     contents.clear
  672.     rect = Rect.new(0, 0, width - 28, line_height)
  673.     change_color(system_color)
  674.     draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
  675.     change_color(normal_color)
  676.     str =  $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
  677.     draw_text(rect, str, 2)
  678.   end
  679. end
  680.  
  681. #==============================================================================
  682. # ■ Window_Weight_Sum_item
  683. #------------------------------------------------------------------------------
  684. #  アイテム一覧で総重量を表示するクラスです。
  685. #==============================================================================
  686. class Window_Weight_Sum_item < Window_ItemList
  687.   #--------------------------------------------------------------------------
  688.   # ○ オブジェクト初期化
  689.   #--------------------------------------------------------------------------
  690.   def initialize(x, y, width, height)
  691.     super(x, y, width, height)
  692.     refresh
  693.   end
  694.   #--------------------------------------------------------------------------
  695.   # ○ リフレッシュ
  696.   #--------------------------------------------------------------------------
  697.   def refresh
  698.     contents.clear
  699.     rect = Rect.new(0, 0, width - 28, line_height)
  700.     change_color(system_color)
  701.     draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
  702.     change_color(normal_color)
  703.     str =  $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
  704.     draw_text(rect, str, 2)
  705.   end
  706. end
  707.  
  708. #==============================================================================
  709. # ■ Window_Weight_Sum_Shop
  710. #------------------------------------------------------------------------------
  711. #  ショップの売却画面で総重量を表示するクラスです。
  712. #==============================================================================
  713. class Window_Weight_Sum_Shop < Window_ItemList
  714.   #--------------------------------------------------------------------------
  715.   # ○ オブジェクト初期化
  716.   #--------------------------------------------------------------------------
  717.   def initialize(x, y, width, height)
  718.     super(x, y, width, height)
  719.     refresh
  720.   end
  721.   #--------------------------------------------------------------------------
  722.   # ○ リフレッシュ
  723.   #--------------------------------------------------------------------------
  724.   def refresh
  725.     contents.clear
  726.     rect = Rect.new(0, 0, width - 28, line_height)
  727.     change_color(system_color)
  728.     draw_text(rect, MOO_HAVE_ITEM_WEIGHT::SUM_WEIGHT_WORD)
  729.     change_color(normal_color)
  730.     str =  $game_party.weight_sum.to_s + "/" + $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT].to_s
  731.     draw_text(rect, str, 2)
  732.   end
  733. end
  734.  
  735. #==============================================================================
  736. # ■ Scene_Menu
  737. #------------------------------------------------------------------------------
  738. #  メニュー画面の処理を行うクラスです。
  739. #==============================================================================
  740. class Scene_Menu < Scene_MenuBase
  741.   include MOO_GENERAL_MODULE
  742.   #--------------------------------------------------------------------------
  743.   # ● 開始処理
  744.   #--------------------------------------------------------------------------
  745.   def start
  746.     super
  747.     create_command_window
  748.     create_gold_window
  749.     create_status_window
  750.     @wt_x = 0
  751.     @wt_y = Graphics.height - @gold_window.height - weight_item_window_h
  752.     @wt_w = weight_item_window_w
  753.     @wt_h = @gold_window.height
  754.     create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h)
  755.   end
  756.   #--------------------------------------------------------------------------
  757.   # ○ 総重量ウィンドウの作成
  758.   #--------------------------------------------------------------------------
  759.   def create_weight_sum_window(x, y, width, height)
  760.     @weight_sum_window = Window_Weight_Sum_Menu.new(x, y, width, height)
  761.     @weight_sum_window.viewport = @viewport
  762.   end
  763. end
  764.  
  765. #==============================================================================
  766. # ■ Scene_Item
  767. #------------------------------------------------------------------------------
  768. #  アイテム画面の処理を行うクラスです。
  769. #==============================================================================
  770. class Scene_Item < Scene_ItemBase
  771.   include MOO_GENERAL_MODULE
  772.   #--------------------------------------------------------------------------
  773.   # ● 開始処理
  774.   #--------------------------------------------------------------------------
  775.   def start
  776.     super
  777.     create_help_window
  778.     create_category_window
  779.     create_item_window
  780.     @wt_x = weight_item_window_x
  781.     @wt_y = weight_item_window_y
  782.     @wt_w = weight_item_window_w
  783.     @wt_h = weight_item_window_h
  784.     create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h)
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ○ 総重量ウィンドウの作成
  788.   #--------------------------------------------------------------------------
  789.   def create_weight_sum_window(x, y, width, height)
  790.     @weight_sum_window = Window_Weight_Sum_item.new(x, y, width, height)
  791.     @weight_sum_window.viewport = @viewport
  792.     @weight_sum_window.y = @help_window.height
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ● アイテムの使用
  796.   #--------------------------------------------------------------------------
  797.   def use_item
  798.     super
  799.     @item_window.redraw_current_item
  800.     @weight_sum_window.refresh
  801.   end
  802. end
  803.  
  804. #==============================================================================
  805. # ■ Scene_Shop
  806. #------------------------------------------------------------------------------
  807. #  ショップ画面の処理を行うクラスです。
  808. #==============================================================================
  809. class Scene_Shop < Scene_MenuBase
  810.   include MOO_GENERAL_MODULE
  811.   #--------------------------------------------------------------------------
  812.   # ● 開始処理
  813.   #--------------------------------------------------------------------------
  814.   def start
  815.     super
  816.     create_help_window
  817.     create_gold_window
  818.     create_command_window
  819.     create_dummy_window
  820.     create_category_window
  821.     create_number_window
  822.     create_status_window
  823.     create_buy_window
  824.     @wt_x = weight_item_window_x
  825.     @wt_y = weight_item_window_y + 48
  826.     @wt_w = weight_item_window_w
  827.     @wt_h = weight_item_window_h
  828.     create_weight_sum_window(@wt_x, @wt_y, @wt_w, @wt_h)
  829.     create_sell_window
  830.   end
  831.   #--------------------------------------------------------------------------
  832.   # ○ 総重量ウィンドウの作成
  833.   #--------------------------------------------------------------------------
  834.   def create_weight_sum_window(x, y, width, height)
  835.     @weight_sum_window = Window_Weight_Sum_Shop.new(x, y, width, height)
  836.     @weight_sum_window.viewport = @viewport
  837.     @weight_sum_window.y = @help_window.height
  838.     @weight_sum_window.y = @dummy_window.y
  839.     @weight_sum_window.hide.deactivate
  840.   end
  841.   #--------------------------------------------------------------------------
  842.   # ● 個数入力[決定]
  843.   #--------------------------------------------------------------------------
  844.   def on_number_ok
  845.     case @command_window.current_symbol
  846.     when :buy
  847.       do_buy(@number_window.number)
  848.       @weight_sum_window.refresh
  849.       @weight_sum_window.hide
  850.     when :sell
  851.       do_sell(@number_window.number)
  852.       @weight_sum_window.refresh
  853.     end
  854.     end_number_input
  855.     @gold_window.refresh
  856.     @status_window.refresh
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # ● 購入の実行
  860.   #--------------------------------------------------------------------------
  861.   def do_buy(number)
  862.     if $game_party.gain_item_failed?(@item, number) == false
  863.       Sound.play_buzzer
  864.       return
  865.     end
  866.     Sound.play_shop
  867.     $game_party.lose_gold(number * buying_price)
  868.     $game_party.moo_gain_item(@item, number)
  869.   end
  870.   #--------------------------------------------------------------------------
  871.   # ● 売却ウィンドウのアクティブ化
  872.   #--------------------------------------------------------------------------
  873.   def activate_sell_window
  874.     @category_window.show
  875.     @weight_sum_window.show
  876.     @sell_window.refresh
  877.     @sell_window.show.activate
  878.     @status_window.hide
  879.   end
  880.   #--------------------------------------------------------------------------
  881.   # ● 購入ウィンドウのアクティブ化
  882.   #--------------------------------------------------------------------------
  883.   def activate_buy_window
  884.     @buy_window.money = money
  885.     @buy_window.show.activate
  886.     @status_window.show
  887.   end
  888.   #--------------------------------------------------------------------------
  889.   # ● コマンド[購入する]
  890.   #--------------------------------------------------------------------------
  891.   def command_buy
  892.     @dummy_window.hide
  893.     activate_buy_window
  894.     @buy_window.select(0)
  895.     @buy_window.refresh
  896.   end
  897.   #--------------------------------------------------------------------------
  898.   # ● コマンド[売却する]
  899.   #--------------------------------------------------------------------------
  900.   def command_sell
  901.     @dummy_window.hide
  902.     @category_window.show.activate
  903.     @weight_sum_window.show
  904.     @sell_window.show
  905.     @sell_window.unselect
  906.     @sell_window.refresh
  907.     @weight_sum_window.show
  908.   end
  909.   #--------------------------------------------------------------------------
  910.   # ● カテゴリ[キャンセル]
  911.   #--------------------------------------------------------------------------
  912.   def on_category_cancel
  913.     @command_window.activate
  914.     @dummy_window.show
  915.     @category_window.hide
  916.     @weight_sum_window.hide
  917.     @sell_window.hide
  918.   end
  919.   #--------------------------------------------------------------------------
  920.   # ● 売却[決定]
  921.   #--------------------------------------------------------------------------
  922.   def on_sell_ok
  923.     @item = @sell_window.item
  924.     @status_window.item = @item
  925.     @category_window.hide
  926.     @weight_sum_window.hide
  927.     @sell_window.hide
  928.     @number_window.set(@item, max_sell, selling_price, currency_unit)
  929.     @number_window.show.activate
  930.     @status_window.show
  931.   end
  932.   #--------------------------------------------------------------------------
  933.   # ● 売却[キャンセル]
  934.   #--------------------------------------------------------------------------
  935.   def on_sell_cancel
  936.     @sell_window.unselect
  937.     @category_window.activate
  938.     @weight_sum_window.activate
  939.     @status_window.item = nil
  940.     @help_window.clear
  941.   end
  942.   #--------------------------------------------------------------------------
  943.   # ● 売却の実行
  944.   #--------------------------------------------------------------------------
  945.   def do_sell(number)
  946.     Sound.play_shop
  947.     $game_party.gain_gold(number * selling_price)
  948.     $game_party.lose_item(@item, number)
  949.   end
  950.   #--------------------------------------------------------------------------
  951.   # ● 売値の取得
  952.   #--------------------------------------------------------------------------
  953.   def selling_price
  954.     @sell_window.price(@item)
  955.   end
  956. end

事件物品容器脚本:
RUBY 代码复制
  1. #------------------------------------------------------------------------------#
  2. #  Galv's Multiple Storage Containers
  3. #------------------------------------------------------------------------------#
  4. #  For: RPGMAKER VX ACE
  5. #  Version 1.5
  6. #------------------------------------------------------------------------------#
  7. #  2015-10-21 - Version 1.5 - fixed a bug in "take all" and item limits
  8. #  2013-01-20 - Version 1.4 - fixed a "take all" bug in a dangerous container
  9. #  2013-01-17 - Version 1.3 - take all command added
  10. #                             taking/adding items can change a variable and
  11. #                             be displayed in the scene with custom text.
  12. #                             added chance to be caught stealing allowing
  13. #                             actors and equips to modify that chance.
  14. #  2012-10-24 - Version 1.2 - changing alias names for compatibility.
  15. #  2012-10-24 - Version 1.1 - forgot to alias game_temp initialize method... fixed
  16. #  2012-10-23 - Version 1.0 - release
  17. #------------------------------------------------------------------------------#
  18. #  Allows you to make any event a storage container and able to add or remove
  19. #  items from it. Populate your containers any time you choose with script calls.
  20. #
  21. #  Each container has a status - colored text of your choice that displays at
  22. #  the bottom of the screen with a variable. Adding or taking items from the
  23. #  container can increase or decrease this variable how you see fit. Can also
  24. #  set a % chance the player will be caught if he tries to steal. When this
  25. #  happens, the scene closes and a switch is turned on - you use conditional
  26. #  branches to determine what happens. (The switch could even be for all people
  27. #  to attack you!)
  28. #
  29. #------------------------------------------------------------------------------#
  30. #
  31. #  INSTRUCTIONS:
  32. #  To set up an event as a container:
  33. #
  34. #  1. use the 'c_add' script call to populate containers with items
  35. #  you want in there. You choose how you want to do this. In my demo I chose to
  36. #  add items to containers when the player searched them (and use a self switch
  37. #  to make sure they don't keep getting free items). You could populate your
  38. #  containers at any point you like, though.
  39. #
  40. #  2. add the open_container("name") script command.
  41. #
  42. #  That's all there is to it unless you look at the c_status script call, you
  43. #  can make each container act a bit differently.
  44. #
  45. #------------------------------------------------------------------------------#
  46. #  Script calls to use:
  47. #------------------------------------------------------------------------------#
  48. #
  49. #  open_container("name")                            # Opens event container
  50. #                                                    # Uses "name" in scene.
  51. #
  52. #  c_add("type", item_id, amount, event_id, map_id)  # Adds item to container.
  53. #
  54. #  c_rem("type", item_id, amount, event_id, map_id)  # removes item from container
  55. #
  56. #  c_count("type", id, event_id, map_id)             # counts certain item in
  57. #                                                    # container. Use in condition
  58. #                                                    # branches and variables.
  59. #
  60. #  c_status("text",color,take_rep,give_rep,caught_chance)
  61. #
  62. #  # Changes the container status.
  63. #  # All containers opened after this call will have this status (So you could
  64. #  # set it for a location or set it before each container opens - see below)
  65. #
  66. #------------------------------------------------------------------------------#
  67. #  EXPLAINATION:
  68. #  type      this can be "weapon", "armor" or "item"
  69. #  item_id   the ID of the item/armor/weapon you want to add
  70. #  amount    the number of the item/armor/weapon/gold you want to remove
  71. #  event_id  the event ID of the container you want to add items to. Set this
  72. #            to 0 to add an item to the event the script call is in.
  73. #  map_id    the ID of the map the container you want is on. Make this 0 if you
  74. #            want to refer to the same map as the script call was made.
  75. #
  76. #  EXAMPLE OF USE:
  77. #  c_add("item",2,3,5,4)          # adds an item to event 5 on map 4
  78. #  c_add("weapon",2,3,0,0)        # adds a weapon to the same event as the call
  79. #  c_rem("armor",3,6,10,2)        # removes armor from event 10 on map 2
  80. #  c_count("item",1,5,1)          # counts item ID 1 stored in event 5 on map 1
  81. #  c_status("Safe",4,-10,5,8)     # shows "Safe" in blue(4) at the bottom
  82. #                                 # -10 rep for each item taken.
  83. #                                 # +5 rep for each item put.
  84. #                                 # 8% chance each time you take to get caught
  85. #                                 # You cant 'take all' when there's a chance to
  86. #                                 # get caught in a container.
  87. #------------------------------------------------------------------------------#
  88. #  Note tag for ARMORS, WEAPONS and ACTORS
  89. #------------------------------------------------------------------------------#
  90. #
  91. #  <take_mod: x>      # increases or decreases the % chance to be caught when
  92. #                     # stealing if one of these things have the note tag.
  93. #
  94. #  # Ideas for use: Actors that are thieves, 'thief glove' or 'lockpick'
  95. #  # accessories.
  96. #
  97. #------------------------------------------------------------------------------#
  98. #  Note tag for ARMORS, WEAPONS and ITEMS
  99. #------------------------------------------------------------------------------#
  100. #
  101. #  <take_value: x>    # increases or decreases the amount of rep you gain or
  102. #                     # lose by this number. This is to make more expensive or
  103. #                     # rarer items have a bigger effect on rep when taking or
  104. #                     # adding them to containers. In the c_status script call,
  105. #                     # if it is 0 to rep change, this will not add/take from it
  106. #
  107. #  # Ideas for use: Treasure hunting. Gain more rep for taking a higher value
  108. #  # item from a chest. Just be sure you don't set it up so that they can
  109. #  # manipulate their rep by adding and taking items.
  110. #
  111. #------------------------------------------------------------------------------#
  112. #  I recommend downloading the demo to see how to set up container events as
  113. #  this got a bit complicated with adding features.
  114. #
  115. #  More setup options further down.
  116. #------------------------------------------------------------------------------#
  117.  
  118. ($imported ||= {})["Galvs_Item_Containers"] = true
  119. module Galv_Container
  120.  
  121. #------------------------------------------------------------------------------#
  122. #  SCRIPT SETUP OPTIONS
  123. #------------------------------------------------------------------------------#
  124.  
  125.   # COMMAND LIST VOCAB
  126.   REMOVE = "Remove"
  127.   STORE = "Store"
  128.   CANCEL = "Cancel"
  129.  
  130.   # OTHER VOCAB
  131.   IN_STORAGE = "In Container"
  132.   IN_INVENTORY = "In Inventory"
  133.  
  134.   TAKE_TEXT = "Remove how many?"
  135.   STORE_TEXT = "Store how many?"
  136.  
  137.   TAKE_ALL = "A: Take All"  # Text displayed bottom left
  138.   REP = "Reputation"        # Text displayed in the bottom right
  139.                             # Make this "" to not use it.
  140.   REP_VAR = 1    # Variable displayed after the REP text. This is the variable
  141.                  # that can change when you take or put things into a container
  142.                  # Make this 0 to not use.
  143.  
  144.   # OTHER OPTIONS
  145.   SE = ["Equip2", 90, 100]     # Sound effect when storing/removing an item
  146.  
  147.   STORE_PRICELESS = true       # Items worth 0 can be stored? true or false
  148.   STORE_KEY = true             # Key items can be stored? true or false
  149.  
  150.  
  151.   C_SE = ["Buzzer1", 90, 100]   # Sound effect when caught stealing
  152.   C_SWITCH = 2                 # Switch is turned ON when you are caught
  153.  
  154.  
  155.   # PARTY LIMITS
  156.   # NOTE: These limits set to 0 will use the default limits. In theory this will
  157.   # be compatible with a limit breaker script by leaving them at 0. Or you can
  158.   # set the party limits below to whatever you like.
  159.  
  160.  
  161.   MAX_ITEMS = 0           # Max items your PARTY can carry.
  162.                           # This will overwrite the default limit.
  163.                           # 0 means do not use this.
  164.  
  165.  
  166.   TAKE_ONLY_SWITCH = 1    # Switch ID. Turn ON to only allow taking from all
  167.                           # containers. Switch OFF to allow both again.
  168.  
  169. #------------------------------------------------------------------------------#
  170. #  SCRIPT SETUP OPTIONS
  171. #------------------------------------------------------------------------------#
  172.  
  173. end
  174.  
  175.  
  176. class Game_Temp
  177.   attr_accessor :contents
  178.   attr_accessor :container_name
  179.  
  180.   alias galv_container_initialize initialize
  181.   def initialize
  182.     galv_container_initialize
  183.     @contents = []
  184.     @container_name = ""
  185.   end
  186. end # Game_Temp
  187.  
  188.  
  189. class RPG::BaseItem
  190.   def take_mod
  191.     if @take_mod.nil?
  192.       if @note =~ /<take_mod: (.*)>/i
  193.         @take_mod = $1.to_i
  194.       else
  195.         @take_mod = 0
  196.       end
  197.     end
  198.     @take_mod
  199.   end
  200.   def take_value
  201.     if @take_value.nil?
  202.       if @note =~ /<take_value: (.*)>/i
  203.         @take_value = $1.to_i
  204.       else
  205.         @take_value = 0
  206.       end
  207.     end
  208.     @take_value
  209.   end
  210. end
  211.  
  212.  
  213. class Scene_Container < Scene_MenuBase
  214.   def start
  215.     super
  216.     check_storage_exists
  217.     create_help_window
  218.     create_name_window
  219.     create_info_window
  220.     create_command_window
  221.     create_dummy_window
  222.     create_number_window
  223.     create_status_window
  224.     create_category_window
  225.     create_take_window
  226.     create_give_window
  227.   end
  228.   def check_storage_exists
  229.     if $game_party.container[$game_temp.contents].nil?
  230.       $game_party.container[$game_temp.contents] = {}
  231.     end
  232.     return @btn_active = false if danger_box?
  233.     @btn_active = true if !$game_party.container[$game_temp.contents].empty?
  234.   end
  235.  
  236.   def danger_box?
  237.     $game_party.container_status[4] > 0
  238.   end
  239.  
  240.   def update
  241.     super
  242.     check_key
  243.   end
  244.  
  245.   def check_key
  246.     if Input.trigger?(:X)
  247.       if @btn_active
  248.         take_all
  249.       else
  250.         Sound.play_buzzer
  251.       end
  252.     end
  253.   end
  254.  
  255.   #--------------------------------------------------------------------------
  256.   # Create Windows
  257.   #--------------------------------------------------------------------------
  258.   def create_name_window
  259.     @name_window = Window_ContainerName.new
  260.     @name_window.viewport = @viewport
  261.     @name_window.x = Graphics.width - @name_window.width
  262.     @name_window.y = @help_window.height
  263.   end
  264.  
  265.   def create_info_window
  266.     @info_window = Window_Info.new
  267.     @info_window.viewport = @viewport
  268.     @info_window.x = 0
  269.     @info_window.y = Graphics.height - @info_window.height
  270.   end
  271.  
  272.   def create_command_window
  273.     @command_window = Window_ContainerCommand.new(@name_window.x)
  274.     @command_window.viewport = @viewport
  275.     @command_window.y = @help_window.height
  276.     @command_window.set_handler(:give,   method(:command_give))
  277.     @command_window.set_handler(:take,    method(:command_take))
  278.     @command_window.set_handler(:cancel, method(:return_scene))
  279.   end
  280.   def create_dummy_window
  281.     wy = @command_window.y + @command_window.height
  282.     wh = Graphics.height - wy - @name_window.height
  283.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  284.     @dummy_window.viewport = @viewport
  285.     @dummy_window.hide
  286.   end
  287.  
  288.   def create_number_window
  289.     wy = @dummy_window.y
  290.     wh = @dummy_window.height
  291.     @number_window = Window_ContainerNumber.new(0, wy, wh)
  292.     @number_window.viewport = @viewport
  293.     @number_window.hide
  294.     @number_window.set_handler(:ok,     method(:on_number_ok))
  295.     @number_window.set_handler(:cancel, method(:on_number_cancel))
  296.   end
  297.   def create_status_window
  298.     wx = @number_window.width
  299.     wy = @dummy_window.y
  300.     ww = Graphics.width - wx
  301.     wh = @dummy_window.height
  302.     @status_window = Window_ContainerItems.new(wx, wy, ww, wh)
  303.     @status_window.viewport = @viewport
  304.     @status_window.hide
  305.   end
  306.   def create_category_window
  307.     @category_window = Window_ItemCategory.new
  308.     @category_window.viewport = @viewport
  309.     @category_window.help_window = @help_window
  310.     @category_window.y = @dummy_window.y
  311.     @category_window.hide.deactivate
  312.     @category_window.set_handler(:ok,     method(:on_category_ok))
  313.     @category_window.set_handler(:cancel, method(:on_category_cancel))
  314.   end
  315.   def create_give_window
  316.     wy = @category_window.y + @category_window.height
  317.     wh = Graphics.height - wy - @name_window.height
  318.     @give_window = Window_ContainerGive.new(0, wy, Graphics.width, wh)
  319.     @give_window.viewport = @viewport
  320.     @give_window.help_window = @help_window
  321.     @give_window.hide
  322.     @give_window.set_handler(:ok,     method(:on_give_ok))
  323.     @give_window.set_handler(:cancel, method(:on_give_cancel))
  324.     @category_window.item_window = @give_window
  325.   end
  326.   def create_take_window
  327.     wy = @command_window.y + @command_window.height
  328.     wh = Graphics.height - wy - @name_window.height
  329.     @take_window = Window_ContainerTake.new(0, wy, Graphics.width, wh)
  330.     @take_window.viewport = @viewport
  331.     @take_window.help_window = @help_window
  332.     @take_window.set_handler(:ok,     method(:on_take_ok))
  333.     @take_window.set_handler(:cancel, method(:on_take_cancel))
  334.     @category_window.item_window = @take_window
  335.   end
  336.  
  337.   #--------------------------------------------------------------------------
  338.   # * Activate Windows
  339.   #--------------------------------------------------------------------------
  340.   def activate_give_window
  341.     @category_window.show
  342.     @give_window.refresh
  343.     @give_window.show.activate
  344.     @status_window.hide
  345.   end
  346.   def activate_take_window
  347.     @take_window.select(0)
  348.     @take_window.refresh
  349.     @take_window.show.activate
  350.     @status_window.hide
  351.   end
  352.  
  353.   def btn_activate
  354.     return btn_deactivate if danger_box?
  355.     return btn_deactivate if $game_party.container[$game_temp.contents].empty?
  356.     @info_window.refresh(true)
  357.     @btn_active = true
  358.   end
  359.  
  360.   def btn_deactivate
  361.     @info_window.refresh(false)
  362.     @btn_active = false
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # HANDLER METHODS
  366.   #--------------------------------------------------------------------------
  367.   def on_category_ok
  368.     activate_give_window
  369.     @give_window.select(0)
  370.     btn_deactivate
  371.   end
  372.   def on_category_cancel
  373.     @command_window.activate
  374.     @take_window.show
  375.     @take_window.refresh
  376.     @category_window.hide
  377.     @give_window.hide
  378.     btn_activate
  379.   end
  380.   def command_give
  381.     @take_window.hide
  382.     @category_window.show.activate
  383.     @give_window.show
  384.     @give_window.unselect
  385.     @give_window.refresh
  386.     btn_deactivate
  387.   end
  388.   def on_give_ok
  389.     @item = @give_window.item
  390.     if @item.nil?
  391.       RPG::SE.stop
  392.       Sound.play_buzzer
  393.       @give_window.activate
  394.       @give_window.refresh
  395.       return
  396.     else
  397.       @status_window.item = @item
  398.       @category_window.hide
  399.       @give_window.hide
  400.       @number_window.set(@item, max_give, @command_window.current_symbol)
  401.       @number_window.show.activate
  402.       @status_window.show
  403.       btn_deactivate
  404.     end
  405.   end
  406.   def on_give_cancel
  407.     @give_window.unselect
  408.     @category_window.activate
  409.     @status_window.item = nil
  410.     @help_window.clear
  411.   end
  412.   def command_take
  413.     activate_take_window
  414.     @take_window.show
  415.     @take_window.refresh
  416.     btn_activate
  417.   end
  418.   def on_take_ok
  419.     btn_deactivate
  420.     @item = @take_window.item
  421.     if @item.nil? || $game_party.container[$game_temp.contents].empty? || $game_party.item_number(@item) == $game_party.max_item_number(@item)
  422.       RPG::SE.stop
  423.       Sound.play_buzzer
  424.       @take_window.activate
  425.       @take_window.refresh
  426.       return
  427.     elsif
  428.       @item = @take_window.item
  429.       @status_window.item = @item
  430.       @take_window.hide
  431.       @number_window.set(@item, max_take, @command_window.current_symbol)
  432.       @number_window.show.activate
  433.       @status_window.show
  434.     end
  435.   end
  436.   def on_take_cancel
  437.     @take_window.unselect
  438.     @command_window.activate
  439.     @take_window.show
  440.     @status_window.item = nil
  441.     @help_window.clear
  442.   end
  443.   def on_number_ok
  444.     RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play
  445.     case @command_window.current_symbol
  446.     when :take
  447.       do_take(@number_window.number)
  448.       btn_activate
  449.     when :give
  450.       do_give(@number_window.number)
  451.       btn_deactivate
  452.     end
  453.     end_number_input
  454.     @status_window.refresh
  455.   end
  456.   def on_number_cancel
  457.     Sound.play_cancel
  458.     end_number_input
  459.   end
  460.   def end_number_input
  461.     @number_window.hide
  462.     case @command_window.current_symbol
  463.     when :take
  464.       activate_take_window
  465.       btn_activate
  466.     when :give
  467.       activate_give_window
  468.     end
  469.   end  
  470.  
  471.  
  472.   #--------------------------------------------------------------------------
  473.   # * Giving and taking methods
  474.   #--------------------------------------------------------------------------
  475.   def max_take
  476.     if $game_party.container[$game_temp.contents][@item] > $game_party.max_item_number(@item) - $game_party.item_number(@item)
  477.       $game_party.max_item_number(@item) - $game_party.item_number(@item)
  478.     else
  479.       $game_party.container[$game_temp.contents][@item]
  480.     end
  481.   end
  482.   def max_give
  483.     $game_party.item_number(@item)
  484.   end
  485.   def do_give(number)
  486.     $game_party.lose_item(@item, number)
  487.     if $game_party.container[$game_temp.contents][@item].nil?
  488.       $game_party.container[$game_temp.contents][@item] = number
  489.     else
  490.       $game_party.container[$game_temp.contents][@item] += number
  491.     end
  492.     get_take_value(3)
  493.     $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[3] + @take_value) * number
  494.   end
  495.  
  496.   def do_take(number)
  497.     check_capture
  498.     return if @item.nil?
  499.     $game_party.gain_item(@item, number)
  500.     $game_party.container[$game_temp.contents][@item] -= number
  501.     $game_party.container[$game_temp.contents].delete(@item) if $game_party.container[$game_temp.contents][@item] <= 0
  502.     if $game_party.container[$game_temp.contents].empty?
  503.       @take_window.activate
  504.     end
  505.     get_take_value(2)
  506.     $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number
  507.   end
  508.  
  509.   def take_all
  510.     return Sound.play_buzzer if $game_party.container[$game_temp.contents].empty? ||
  511.       max_of_items
  512.     RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play
  513.     $game_party.container[$game_temp.contents].each do |i|
  514.       if i[1] > $game_party.max_item_number(i[0]) - $game_party.item_number(i[0])
  515.         number = $game_party.max_item_number(i[0]) - $game_party.item_number(i[0])
  516.       else
  517.         number = i[1] - $game_party.item_number(i[0])
  518.       end
  519.       p number
  520.       $game_party.gain_item(i[0], number)
  521.       i[1] -= number
  522.       $game_party.container[$game_temp.contents][i[0]] -= number
  523.       $game_party.container[$game_temp.contents].delete(i[0]) if i[1] <= 0
  524.       @item = i[0]
  525.       get_take_value(2)
  526.       $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number
  527.  
  528.     end
  529.     btn_activate
  530.     @take_window.refresh
  531.   end
  532.  
  533.   def max_of_items
  534.     # if all items in box are maxed, return true
  535.     $game_party.container[$game_temp.contents].each { |item|
  536.       return false if $game_party.item_number(item[0]) < $game_party.max_item_number(item[0])
  537.     }
  538.     return true
  539.   end
  540.  
  541.   def get_take_value(pos)
  542.     return @take_value = 0 if @item.nil?
  543.     if $game_party.container_status[pos] == 0
  544.       @take_value = 0
  545.     elsif $game_party.container_status[pos] > 0
  546.       @take_value = @item.take_value
  547.     else $game_party.container_status[pos] < 0
  548.       @take_value = -@item.take_value
  549.     end
  550.   end
  551.  
  552.   def check_capture
  553.     a = rand(100)
  554.     chance = $game_party.container_status[4] + actor_mod + equip_mod
  555.     if a < chance
  556.       RPG::SE.new(Galv_Container::C_SE[0], Galv_Container::C_SE[1], Galv_Container::C_SE[2]).play
  557.       $game_switches[Galv_Container::C_SWITCH] = true
  558.       SceneManager.goto(Scene_Map)
  559.     end
  560.   end
  561.  
  562.   def equip_mod
  563.     equip_mod = 0
  564.     $game_party.members.each do |m|
  565.       m.equips.each do |eq|
  566.         next if eq.nil?
  567.         equip_mod += eq.take_mod
  568.       end
  569.     end
  570.     return equip_mod
  571.   end
  572.  
  573.   def actor_mod
  574.     actor_mod = 0
  575.     $game_party.members.each do |m|
  576.       actor_mod += $data_actors[m.id].take_mod
  577.     end
  578.     return actor_mod
  579.   end
  580.  
  581. end # Scene_Container < Scene_MenuBase
  582.  
  583.  
  584. #------------------------------------------------------------------------------#
  585. #  Window Container Name
  586. #------------------------------------------------------------------------------#
  587.  
  588. class Window_ContainerName < Window_Base
  589.   def initialize
  590.     super(0, 0, window_width, fitting_height(1))
  591.     refresh
  592.   end
  593.   def window_width
  594.     return 180
  595.   end
  596.   def refresh
  597.     contents.clear
  598.     c_name = convert_escape_characters($game_temp.container_name)
  599.     draw_text(x - 10, y, window_width, line_height, c_name,1)
  600.   end
  601.   def open
  602.     refresh
  603.     super
  604.   end
  605. end
  606.  
  607.  
  608. #------------------------------------------------------------------------------#
  609. #  Window Info
  610. #------------------------------------------------------------------------------#
  611.  
  612. class Window_Info < Window_Base
  613.   def initialize
  614.     super(0, 0, Graphics.width, fitting_height(1))
  615.     @btn_state = true if !$game_party.container[$game_temp.contents].empty?
  616.     @btn_state = false if $game_party.container_status[4] > 0
  617.     refresh(@btn_state)
  618.   end
  619.  
  620.   def refresh(btn)
  621.     @btn_state = btn
  622.     contents.clear
  623.     draw_texts
  624.   end
  625.  
  626.   def draw_texts
  627.     change_color(normal_color, @btn_state)
  628.     draw_text(0, 0, contents.width, line_height, Galv_Container::TAKE_ALL, 0)
  629.  
  630.     change_color(text_color($game_party.container_status[1]))
  631.     draw_text(0, 0, contents.width, line_height, $game_party.container_status[0], 1)
  632.  
  633.     if Galv_Container::REP_VAR <= 0
  634.       repvar = ""
  635.     else
  636.       repvar = $game_variables[Galv_Container::REP_VAR]
  637.     end
  638.     change_color(normal_color)
  639.     draw_text(0, 0, contents.width, line_height, Galv_Container::REP + " " + repvar.to_s, 2)
  640.   end
  641. end
  642.  
  643.  
  644. #------------------------------------------------------------------------------#
  645. #  Window Stored Items
  646. #------------------------------------------------------------------------------#
  647.  
  648. class Window_StoreList < Window_Selectable
  649.   def initialize(x, y, width, height)
  650.     super
  651.     @category = :none
  652.     @data = []
  653.   end
  654.   def category=(category)
  655.     return if @category == category
  656.     @category = category
  657.     refresh
  658.     self.oy = 0
  659.   end
  660.   def col_max
  661.     return 2
  662.   end
  663.   def item_max
  664.     @data ? @data.size : 1
  665.   end
  666.   def item
  667.     @data && index >= 0 ? @data[index] : nil
  668.   end
  669.   def current_item_enabled?
  670.     enable?(@data[index])
  671.   end
  672.   def include?(item)
  673.     case @category
  674.     when :item
  675.       item.is_a?(RPG::Item) && !item.key_item?
  676.     when :weapon
  677.       item.is_a?(RPG::Weapon)
  678.     when :armor
  679.       item.is_a?(RPG::Armor)
  680.     when :key_item
  681.       item.is_a?(RPG::Item) && item.key_item?
  682.     else
  683.       false
  684.     end
  685.   end
  686.   def enable?(item)
  687.     $game_party.container[$game_temp.contents].has_key?(item)
  688.   end
  689.   def make_item_list
  690.     @data = $game_party.container[$game_temp.contents].keys {|item| include?(item) }
  691.     @data.push(nil) if include?(nil)
  692.   end
  693.   def select_last
  694.     select(@data.index($game_party.last_item.object) || 0)
  695.   end
  696.   def draw_item(index)
  697.     item = @data[index]
  698.     if item
  699.       rect = item_rect(index)
  700.       rect.width -= 4
  701.       draw_item_name(item, rect.x, rect.y, enable?(item))
  702.       draw_item_number(rect, item)
  703.     end
  704.   end
  705.   def draw_item_number(rect, item)
  706.     draw_text(rect, sprintf(":%2d", $game_party.container[$game_temp.contents][item]), 2)
  707.   end
  708.   def update_help
  709.     @help_window.set_item(item)
  710.   end
  711.   def refresh
  712.     make_item_list
  713.     create_contents
  714.     draw_all_items
  715.   end
  716. end # Window_StoreList < Window_Selectable
  717.  
  718.  
  719. #------------------------------------------------------------------------------#
  720. #  Window Stored Item amount
  721. #------------------------------------------------------------------------------#
  722.  
  723. class Window_ContainerNumber < Window_Selectable
  724.   attr_reader :number
  725.   def initialize(x, y, height)
  726.     super(x, y, window_width, height)
  727.     @item = nil
  728.     @max = 1
  729.     @number = 1
  730.   end
  731.   def window_width
  732.     return 304
  733.   end
  734.   def set(item, max, cmd)
  735.     @item = item
  736.     @max = max
  737.     @number = 1
  738.     @cmd = cmd
  739.     refresh
  740.   end
  741.   def refresh
  742.     contents.clear
  743.     draw_item_name(@item, 0, item_y)
  744.     draw_number
  745.     draw_how_many
  746.   end
  747.   def draw_number
  748.     change_color(normal_color)
  749.     draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  750.     draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  751.   end
  752.   def item_y
  753.     contents_height / 2 - line_height * 3 / 2
  754.   end
  755.   def cursor_width
  756.     figures * 10 + 12
  757.   end
  758.   def cursor_x
  759.     contents_width - cursor_width - 4
  760.   end
  761.   def figures
  762.     return 2
  763.   end
  764.   def update
  765.     super
  766.     if active
  767.       last_number = @number
  768.       update_number
  769.       if @number != last_number
  770.         Sound.play_cursor
  771.         refresh
  772.       end
  773.     end
  774.   end
  775.   def update_number
  776.     change_number(1)   if Input.repeat?(:RIGHT)
  777.     change_number(-1)  if Input.repeat?(:LEFT)
  778.     change_number(10)  if Input.repeat?(:UP)
  779.     change_number(-10) if Input.repeat?(:DOWN)
  780.   end
  781.   def change_number(amount)
  782.     @number = [[@number + amount, @max].min, 1].max
  783.   end
  784.   def update_cursor
  785.     cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
  786.   end
  787.  
  788.   def draw_how_many
  789.     change_color(system_color)
  790.     case @cmd
  791.     when :take
  792.       draw_text(4, 4, contents.width, line_height, Galv_Container::TAKE_TEXT)
  793.     when :give
  794.       draw_text(4, 4, contents.width, line_height, Galv_Container::STORE_TEXT)
  795.     end
  796.     change_color(normal_color)
  797.   end
  798.  
  799. end # Window_ContainerNumber < Window_Selectable
  800.  
  801.  
  802. #------------------------------------------------------------------------------#
  803. #  Window Store Item Status
  804. #------------------------------------------------------------------------------#
  805.  
  806. class Window_ContainerItems < Window_Base
  807.   def initialize(x, y, width, height)
  808.     super(x, y, width, height)
  809.     @item = nil
  810.     @page_index = 0
  811.     refresh
  812.   end
  813.   def refresh
  814.     contents.clear
  815.     draw_possession(4, 0)
  816.     draw_stored(4, line_height)
  817.     draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)
  818.   end
  819.   def item=(item)
  820.     @item = item
  821.     refresh
  822.   end
  823.   def draw_possession(x, y)
  824.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  825.     change_color(system_color)
  826.     draw_text(rect, Galv_Container::IN_INVENTORY)
  827.     change_color(normal_color)
  828.     draw_text(rect, $game_party.item_number(@item), 2)
  829.   end
  830.   def draw_stored(x, y)
  831.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  832.     change_color(system_color)
  833.     draw_text(rect, Galv_Container::IN_STORAGE)
  834.     change_color(normal_color)
  835.     stored_amount = $game_party.container[$game_temp.contents][@item]
  836.     stored_amount = 0 if stored_amount.nil?
  837.     draw_text(rect, stored_amount, 2)
  838.   end
  839.   def draw_equip_info(x, y)
  840.     status_members.each_with_index do |actor, i|
  841.       draw_actor_equip_info(x, y + line_height * (i * 2.4), actor)
  842.     end
  843.   end
  844.   def status_members
  845.     $game_party.members[@page_index * page_size, page_size]
  846.   end
  847.   def page_size
  848.     return 4
  849.   end
  850.   def page_max
  851.     ($game_party.members.size + page_size - 1) / page_size
  852.   end
  853.   def draw_actor_equip_info(x, y, actor)
  854.     enabled = actor.equippable?(@item)
  855.     change_color(normal_color, enabled)
  856.     draw_text(x, y, 112, line_height, actor.name)
  857.     item1 = current_equipped_item(actor, @item.etype_id)
  858.     draw_actor_param_change(x, y, actor, item1) if enabled
  859.     draw_item_name(item1, x, y + line_height, enabled)
  860.   end
  861.   def draw_actor_param_change(x, y, actor, item1)
  862.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  863.     change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0)
  864.     change_color(param_change_color(change))
  865.     draw_text(rect, sprintf("%+d", change), 2)
  866.   end
  867.   def param_id
  868.     @item.is_a?(RPG::Weapon) ? 2 : 3
  869.   end
  870.   def current_equipped_item(actor, etype_id)
  871.     list = []
  872.     actor.equip_slots.each_with_index do |slot_etype_id, i|
  873.       list.push(actor.equips[i]) if slot_etype_id == etype_id
  874.     end
  875.     list.min_by {|item| item ? item.params[param_id] : 0 }
  876.   end
  877.   def update
  878.     super
  879.     update_page
  880.   end
  881.   def update_page
  882.     if visible && Input.trigger?(:A) && page_max > 1
  883.       @page_index = (@page_index + 1) % page_max
  884.       refresh
  885.     end
  886.   end
  887.  
  888. end # Window_ContainerItems < Window_Base
  889.  
  890.  
  891. #------------------------------------------------------------------------------#
  892. #  Window Give Item
  893. #------------------------------------------------------------------------------#
  894.  
  895. class Window_ContainerGive < Window_ItemList
  896.   def initialize(x, y, width, height)
  897.     super(x, y, width, height)
  898.   end
  899.   def current_item_enabled?
  900.     enable?(@data[index])
  901.   end
  902.   def enable?(item)
  903.     if item.is_a?(RPG::Item)
  904.       return false if item.key_item? && !Galv_Container::STORE_KEY
  905.     end
  906.     if Galv_Container::STORE_PRICELESS
  907.       true
  908.     else
  909.       item && item.price > 0
  910.     end
  911.   end
  912. end # Window_ContainerGive < Window_ItemList
  913.  
  914.  
  915. #------------------------------------------------------------------------------#
  916. #  Window Take Item
  917. #------------------------------------------------------------------------------#
  918.  
  919. class Window_ContainerTake < Window_StoreList
  920.   def initialize(x, y, width, height)
  921.     super(x, y, width, height)
  922.   end
  923.   def current_item_enabled?
  924.     enable?(@data[index])
  925.   end
  926.   def enable?(item)
  927.     $game_party.container[$game_temp.contents][item] != 0 && $game_party.item_number(item) < $game_party.max_item_number(@item)
  928.   end
  929. end # Window_ContainerTake < Window_StoreList
  930.  
  931.  
  932. #------------------------------------------------------------------------------#
  933. #  Window Command
  934. #------------------------------------------------------------------------------#
  935.  
  936. class Window_ContainerCommand < Window_HorzCommand
  937.   def initialize(window_width)
  938.     @window_width = window_width
  939.     super(0, 0)
  940.   end
  941.  
  942.   def window_width
  943.     @window_width
  944.   end
  945.  
  946.   def col_max
  947.     return 2 if $game_switches[Galv_Container::TAKE_ONLY_SWITCH]
  948.     return 3
  949.   end
  950.  
  951.   def make_command_list
  952.     add_command(Galv_Container::REMOVE, :take)
  953.     add_command(Galv_Container::STORE,  :give)  if !$game_switches[Galv_Container::TAKE_ONLY_SWITCH]
  954.     add_command(Galv_Container::CANCEL, :cancel)
  955.   end
  956. end # Window_ContainerCommand < Window_HorzCommand
  957.  
  958.  
  959. #------------------------------------------------------------------------------#
  960. #  Game Party Additions
  961. #------------------------------------------------------------------------------#
  962.  
  963. class Game_Party < Game_Unit
  964.   attr_accessor :container
  965.   attr_accessor :container_status
  966.  
  967.   alias galv_mcontatiners_initialize initialize
  968.   def initialize
  969.     galv_mcontatiners_initialize
  970.     init_containers
  971.   end
  972.  
  973.   def init_containers
  974.     @container_status = ["",0,0,0,0] # text,color,take_rep,give_rep,catch_chance
  975.     @container = {}
  976.   end
  977.  
  978.   alias galv_container_max_item_number max_item_number
  979.   def max_item_number(item)
  980.     return Galv_Container::MAX_ITEMS if Galv_Container::MAX_ITEMS > 0
  981.     return 99 if item.nil?
  982.     galv_container_max_item_number(item)
  983.   end
  984. end # Game_Party < Game_Unit
  985.  
  986.  
  987. class Game_Interpreter
  988.  
  989.   def c_add(type, id, amount, event_id, map_id)
  990.     if event_id <= 0
  991.       add_where = @event_id
  992.     else
  993.       add_where = event_id
  994.     end
  995.     if map_id <= 0
  996.       add_where_map = $game_map.map_id
  997.     else
  998.       add_where_map = map_id
  999.     end
  1000.     $game_temp.contents = [add_where, add_where_map]
  1001.     if $game_party.container[$game_temp.contents].nil?
  1002.       $game_party.container[$game_temp.contents] = {}
  1003.     end
  1004.     case type
  1005.     when "weapon"
  1006.       @item = $data_weapons[id]
  1007.     when "item"
  1008.       @item = $data_items[id]
  1009.     when "armor"
  1010.       @item = $data_armors[id]
  1011.     end
  1012.     if $game_party.container[$game_temp.contents][@item].nil?
  1013.       $game_party.container[$game_temp.contents][@item] = amount
  1014.     else
  1015.       $game_party.container[$game_temp.contents][@item] += amount
  1016.     end
  1017.   end
  1018.  
  1019.   def c_rem(type, id, amount, event_id, map_id)
  1020.     if event_id <= 0
  1021.       rem_where = @event_id
  1022.     else
  1023.       rem_where = event_id
  1024.     end
  1025.     if map_id <= 0
  1026.       rem_where_map = $game_map.map_id
  1027.     else
  1028.       rem_where_map = map_id
  1029.     end
  1030.     $game_temp.contents = [rem_where, rem_where_map]
  1031.     if $game_party.container[$game_temp.contents].nil?
  1032.       $game_party.container[$game_temp.contents] = {}
  1033.     end
  1034.     case type
  1035.     when "weapon"
  1036.       @item = $data_weapons[id]
  1037.     when "item"
  1038.       @item = $data_items[id]
  1039.     when "armor"
  1040.       @item = $data_armors[id]
  1041.     end
  1042.     return if $game_party.container[$game_temp.contents][@item].nil?
  1043.     if $game_party.container[$game_temp.contents][@item] <= amount
  1044.       $game_party.container[$game_temp.contents].delete(@item)
  1045.     else
  1046.       $game_party.container[$game_temp.contents][@item] -= amount
  1047.     end
  1048.   end
  1049.  
  1050.   def c_count(type, id, event_id, map_id)
  1051.     if event_id <= 0
  1052.       container_id = @event_id
  1053.     else
  1054.       container_id = event_id
  1055.     end
  1056.     if map_id <= 0
  1057.       container_id_map = $game_map.map_id
  1058.     else
  1059.       container_id_map = map_id
  1060.     end
  1061.     $game_temp.contents = [container_id, container_id_map]
  1062.     if $game_party.container[$game_temp.contents].nil?
  1063.       $game_party.container[$game_temp.contents] = {}
  1064.     end
  1065.     case type
  1066.     when "weapon"
  1067.       @item = $data_weapons[id]
  1068.     when "item"
  1069.       @item = $data_items[id]
  1070.     when "armor"
  1071.       @item = $data_armors[id]
  1072.     end
  1073.     return 0 if $game_party.container[$game_temp.contents][@item].nil?
  1074.     $game_party.container[$game_temp.contents][@item]
  1075.   end
  1076.  
  1077.   def c_status(text,color,take_rep,give_rep,catch_chance)
  1078.     $game_party.container_status = [text,color,take_rep,give_rep,catch_chance]
  1079.   end
  1080.  
  1081.   def c_empty?(event_id,map_id)
  1082.     !$game_party.container[[event_id,map_id]].nil? &&
  1083.       $game_party.container[[event_id,map_id]].empty?
  1084.   end
  1085.  
  1086.   def open_container(name)
  1087.     $game_temp.container_name = name
  1088.     $game_temp.contents = [@event_id, $game_map.map_id]
  1089.     SceneManager.call(Scene_Container)
  1090.     wait(1)
  1091.   end
  1092. end # Game_Interpreter

Lv4.逐梦者

梦石
0
星屑
5846
在线时间
791 小时
注册时间
2019-1-20
帖子
210
2
发表于 6 天前 | 只看该作者
  1. =begin
  2. VA むー的物品负重 兼容 VA Galv的事件容器 sjr_20250616

  3. 插入顺序:
  4. VA むー的物品负重 前置
  5. VA むー的物品负重
  6. VA Galv的事件容器
  7. 本脚本

  8. 用A键全部取出时是按顺序尽可能取出该项物品,如果超重就会换下一个.

  9. 把默认 Galv的事件容器 显示数量方式改成 むー的物品负重 那种,
  10. 不喜欢就把两个#1之间的删除
  11. =end
  12. #1
  13. class Window_StoreList < Window_Selectable
  14.   def draw_item_number(rect, item)
  15.     $game_party.weight_sum
  16.     wt = $game_party.weight_item_draw(item)
  17.     draw_text(rect, sprintf(" %2d", $game_party.container[$game_temp.contents][item]) + wt, 2)
  18.   end
  19. end #
  20. #1

  21. class Window_Info < Window_Base
  22.   alias sjr_draw_texts draw_texts
  23.   def draw_texts
  24.    sjr_draw_texts
  25.    w="总重量 #{$game_party.weight_sum}/#{$game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT]}"
  26.    draw_text(0, 0, contents.width, line_height, w, 1)
  27.   end
  28. end #
  29. #
  30. class Window_ContainerTake < Window_StoreList
  31.   alias sjr_enable? enable?
  32.   def enable?(item)
  33.     sjr_20250616_tf=0  
  34.     sjr_20250616_tf=1 if item !=nil && $game_party.gain_item_failed?(item,1)==false  
  35.     sjr_20250616_tf==0 && sjr_enable?(item)
  36.   end
  37. end #  
  38. #  
  39. class Window_ContainerNumber < Window_Selectable
  40.   alias sjr_change_number change_number
  41.   def change_number(amount)
  42.     sjr_change_number(amount) #
  43.     if @cmd== :take   
  44.       while $game_party.gain_item_failed?(@item, @number) ==false
  45.       @number-=1
  46.       break if @number==0
  47.       end #whlie   
  48.     end #if
  49.   end
  50. end #
  51. #
  52. class Scene_Container < Scene_MenuBase
  53. def take_all
  54.     return Sound.play_buzzer if $game_party.container[$game_temp.contents].empty? ||
  55.       max_of_items
  56.     RPG::SE.new(Galv_Container::SE[0], Galv_Container::SE[1], Galv_Container::SE[2]).play
  57.     $game_party.container[$game_temp.contents].each do |i|
  58.       if i[1] > $game_party.max_item_number(i[0]) - $game_party.item_number(i[0])
  59.         number = $game_party.max_item_number(i[0]) - $game_party.item_number(i[0])
  60.       else
  61.         number = i[1] - $game_party.item_number(i[0])
  62.       end
  63.       #p number
  64.       
  65.       
  66.     break if $game_party.weight_sum > $game_variables[MOO_HAVE_ITEM_WEIGHT::MAX_WT]
  67.     ii=i[0]
  68.     while $game_party.gain_item_failed?(ii, number) ==false
  69.     number-=1
  70.     break if number==0
  71.     end #      
  72.       
  73.       
  74.       $game_party.gain_item(i[0], number)
  75.       i[1] -= number
  76.       $game_party.container[$game_temp.contents][i[0]] -= number
  77.       $game_party.container[$game_temp.contents].delete(i[0]) if i[1] <= 0
  78.       @item = i[0]
  79.       get_take_value(2)
  80.       $game_variables[Galv_Container::REP_VAR] += ($game_party.container_status[2] + @take_value) * number
  81.     end
  82.     btn_activate
  83.     @take_window.refresh
  84.   end
  85. end #  
  86. #
复制代码



提高解决问题的方法:
查看对应版本的帮助文件或者默认脚本中可能相似的部分 看有没有思路能照搬(不是)
改变问题为更有可能的,常见的,系统性的 如:天气自动变化成下雨→天气系统 要多想几种可能
使用论坛的搜索功能查找相关问题 咦?这跟我想的不一样啊!讨厌啦~\(≧□≦)/~啦啦啦
清楚说明实际上你想解决的问题  想看坛友的女装,想看!  
脚本自己有改过的地方要尽量标明  提高除BUG效率 ... ...
脚本有问题但不是默认脚本的要全部贴出来 大胆点,尽情发,我说的是女装照!
三包原则:包有BUG,包甩锅,包咕咕 长期下线,急事换人!难事换人!啥事都换人!换人换人换人!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-6-23 19:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表