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

Project1

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

[已经过期] 仓库系统bug怎么解决?

[复制链接]

Lv2.观梦者

梦石
0
星屑
284
在线时间
34 小时
注册时间
2022-10-6
帖子
5
跳转到指定楼层
1
发表于 2023-8-12 11:52:27 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 x24678 于 2023-8-12 11:56 编辑

存物品是,选择最大数量后存进去只相当于存了一个,可以重复操作卡装备刷,该怎么修复
  1. # =============================================================================
  2. # TheoAllen - 仓库系统
  3. # Version : 1.2
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script is translated by AbsoluteIce)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_ChestSystem] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.08.19 - Compatibility Patch with Limited Inventory
  12. # 2013.06.28 - Add custom chest name
  13. # 2013.06.01 - Adjust control and GUI
  14. # 2013.05.24 - Finished script
  15. # 2013.05.23 - Started Script
  16. # =============================================================================
  17. =begin

  18.   介绍 :
  19.   本脚本可以设定一个仓库,允许玩家存放或取出物品.

  20.   使用方法 :
  21.   本脚本放在插件脚本之下,main之上

  22.   在使用脚本打开仓库前,使用以下事件注释:
  23.   <item: id, 数量>
  24.   <weapon: id, 数量>
  25.   <armor: id, 数量>

  26.   解释 :
  27.   id >> 物品/武器/护甲id
  28.   数量 >> 数量多少

  29.   使用以上注释后, 使用脚本 :
  30.   open_chest

  31.   对于自定义名称的仓库, 则可以 :
  32.   open_chest("小仓库")
  33.   open_chest("Eric的宝箱")

  34.   注意 : 所有事件中的所有注释都会读取一次,请确保在使用脚本之前使用了注释。

  35.   使用规定 :
  36.   属名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  37.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.

  38. =end
  39. # =============================================================================
  40. # 设定 :
  41. # =============================================================================
  42. module THEO
  43.   module CHEST
  44.     # =========================================================================
  45.     # Vocabs
  46.     # -------------------------------------------------------------------------
  47.       AMOUNT_VOCAB  = "数量 :"       # 数量.
  48.       ALL_VOCAB     = "全部"         # 全部类别.
  49.       INV_VOCAB     = "背包"         # 背包.
  50.       ST_VOCAB      = "库存"         # 库存.
  51.     # =========================================================================
  52.    
  53.     # =========================================================================
  54.       TRIGGER_GAIN_ALL  = :CTRL
  55.     # -------------------------------------------------------------------------
  56.     # 全部取出的按钮. 如果你设定为 :CTRL, 则在玩家按下CTRL和确定键 (z)后会取出
  57.     # 全部物品
  58.     # =========================================================================
  59.    
  60.     # =========================================================================
  61.       SHOW_AMOUNT_MIN   = 10
  62.     # -------------------------------------------------------------------------
  63.     # 显示窗口数量的最小值.
  64.     # =========================================================================
  65.    
  66.   end
  67. end
  68. # =============================================================================
  69. # 设定结束 (除非清除你在干什么,否则以下内容勿动)
  70. # =============================================================================
  71. module THEO
  72.   module CHEST
  73.   module REGEXP
  74.    
  75.     ITEM_REGEX   = /<(?:ITEM|item):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
  76.     WEAPON_REGEX = /<(?:WEAPON|weapon):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
  77.     ARMOR_REGEX  = /<(?:ARMOR|armor):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
  78.    
  79.   end
  80.   end
  81. end

  82. class Scene_Chest < Scene_MenuBase
  83.   
  84.   include THEO::CHEST
  85.   
  86.   def initialize(key,st_vocab)
  87.     $game_party.init_chest_cursors
  88.     @last_active = :stash
  89.     @key = key
  90.     @st_vocab = st_vocab
  91.   end
  92.   
  93.   def start
  94.     super
  95.     create_header_windows
  96.     create_footer_window
  97.     create_main_windows
  98.     create_amount_window
  99.     prepare
  100.   end
  101.   
  102.   def create_header_windows
  103.     create_help_window
  104.     create_category_window
  105.   end
  106.   
  107.   def create_main_windows
  108.     create_inventory_window
  109.     create_stash_window
  110.   end
  111.   
  112.   def create_help_window
  113.     @help = Window_Help.new
  114.     @help.viewport = @viewport
  115.   end
  116.   
  117.   def create_category_window
  118.     @category = Window_ChestCategory.new
  119.     @category.viewport = @viewport
  120.     @category.y = @help.height
  121.     @category.set_handler(:ok, method(:on_category_ok))
  122.     @category.set_handler(:cancel, method(:return_scene))
  123.   end
  124.   
  125.   def create_footer_window
  126.     create_inv_footer
  127.     create_st_footer
  128.   end
  129.   
  130.   def create_inv_footer
  131.     if $imported[:Theo_LimInventory]
  132.       x = 0
  133.       y = Graphics.height - 48
  134.       w = Graphics.width/2
  135.       @inv_footer = Window_ChestFreeSlot.new(x,y,w)
  136.       @inv_footer.viewport = @viewport
  137.     else
  138.       @inv_footer = Window_ChestFooter.new(INV_VOCAB,$game_party,0)
  139.       @inv_footer.viewport = @viewport
  140.     end
  141.   end
  142.   
  143.   def create_st_footer
  144.     @st_footer = Window_ChestFooter.new(@st_vocab,$game_chests[@key],1)
  145.     @st_footer.viewport = @viewport
  146.   end
  147.   
  148.   def create_inventory_window
  149.     x = 0
  150.     y = @help.height + @category.height
  151.     w = Graphics.width/2
  152.     h = Graphics.height - y - @inv_footer.height
  153.     @inventory = Window_Inventory.new(x,y,w,h)
  154.     @inventory.viewport = @viewport
  155.     @inventory.set_handler(:ok, method(:item_inventory_ok))
  156.     @inventory.set_handler(:cancel, method(:on_inventory_cancel))
  157.     @inventory.help_window = @help
  158.     @category.item_window = @inventory
  159.   end
  160.   
  161.   def create_stash_window
  162.     x = Graphics.width / 2
  163.     y = @inventory.y
  164.     w = x
  165.     h = @inventory.height
  166.     @stash = Window_Stash.new(x,y,w,h,@key)
  167.     @stash.viewport = @viewport
  168.     @stash.set_handler(:ok, method(:item_stash_ok))
  169.     @stash.set_handler(:cancel, method(:on_stash_cancel))
  170.     @stash.help_window = @help
  171.     @category.stash_window = @stash
  172.   end
  173.   
  174.   def create_amount_window
  175.     @amount = Window_ChestAmount.new
  176.     @amount.viewport = @viewport
  177.     @amount.inv_window = @inv_footer if $imported[:Theo_LimInventory]
  178.   end
  179.   
  180.   # for future plan ~
  181.   def refresh_all_footers
  182.     @inv_footer.refresh
  183.     @st_footer.refresh
  184.   end
  185.   
  186.   def prepare
  187.     unselect_all
  188.     @category.show
  189.     @category.activate
  190.     @item_phase = false
  191.     deactivate_item_windows
  192.     hide_amount
  193.   end
  194.   
  195.   def deactivate_item_windows
  196.     @inventory.deactivate
  197.     @stash.deactivate
  198.   end
  199.   
  200.   def on_category_ok
  201.     @category.deactivate
  202.     activate_itemlist
  203.     @item_phase = true
  204.   end
  205.   
  206.   def item_inventory_ok
  207.     unless @inventory.item
  208.       @inventory.activate
  209.       return
  210.     end
  211.     if @inventory.item_number < SHOW_AMOUNT_MIN
  212.       store_items(1)
  213.       @inventory.activate
  214.       refresh_itemlist
  215.     else
  216.       @last_active = :inventory
  217.       input_amount(@inventory)
  218.     end
  219.   end
  220.   
  221.   def item_stash_ok
  222.     unless @stash.item
  223.       @stash.activate
  224.       return
  225.     end
  226.     if @stash.item_number < SHOW_AMOUNT_MIN
  227.       gain_items(1)
  228.       @stash.activate
  229.       refresh_itemlist
  230.     else
  231.       @last_active = :stash
  232.       input_amount(@stash)
  233.     end
  234.   end
  235.   
  236.   def on_stash_cancel
  237.     @last_active = :stash
  238.     memorize_st
  239.     prepare
  240.   end
  241.   
  242.   def on_inventory_cancel
  243.     @last_active = :inventory
  244.     memorize_inv
  245.     prepare
  246.   end
  247.   
  248.   def input_amount(window)
  249.     memorize_all
  250.     if window.equal?(@stash)
  251.       @inventory.unselect
  252.     else
  253.       @stash.unselect
  254.     end
  255.     @amount.open
  256.     @amount.item_window = window
  257.     deactivate_item_windows
  258.   end
  259.   
  260.   def hide_amount
  261.     Sound.play_cancel
  262.     @amount.close
  263.     @amount.reset_amount
  264.   end
  265.   
  266.   def update
  267.     super
  268.     @amount.mode = @last_active
  269.     @inv_footer.mode = @last_active if $imported[:Theo_LimInventory]
  270.     select_item_phase if @item_phase
  271.     input_amount_phase if @amount.open?
  272.   end
  273.   
  274.   def select_item_phase
  275.     gain_all_items if trigger_gain_all_item?
  276.     switch_window if Input.repeat?(:RIGHT) || Input.repeat?(:LEFT)
  277.   end
  278.   
  279.   def input_amount_phase
  280.     activate_itemlist if Input.trigger?(:B)
  281.     if @amount.item_window.equal?(@stash) && Input.trigger?(:C)
  282.       gain_items(@amount.amount)
  283.     elsif @amount.item_window.equal?(@inventory) && Input.trigger?(:C)
  284.       store_items(@amount.amount)
  285.     end
  286.   end
  287.   
  288.   def switch_window
  289.     if @inventory.active
  290.       switch_stash
  291.     elsif @stash.active
  292.       switch_inventory
  293.     end
  294.   end
  295.   
  296.   def switch_inventory
  297.     memorize_st
  298.     @stash.deactivate
  299.     @stash.unselect
  300.     @inventory.activate
  301.     inv_select
  302.   end
  303.   
  304.   def switch_stash
  305.     @stash.activate
  306.     st_select
  307.     memorize_inv
  308.     @inventory.deactivate
  309.     @inventory.unselect
  310.   end
  311.   
  312.   def gain_all_items
  313.     if @stash.active
  314.       @stash.data.each do |item|
  315.         gain_items(@stash.item_number(item),item)
  316.       end
  317.       @stash.select(0)
  318.     else
  319.       @inventory.data.each do |item|
  320.         store_items(@inventory.item_number(item),item)
  321.       end
  322.       @inventory.select(0)
  323.     end
  324.     refresh_itemlist
  325.     refresh_all_footers
  326.   end
  327.   
  328.   def trigger_gain_all_item?
  329.     Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL) && Input.trigger?(:C)
  330.   end
  331.   
  332.   def gain_items(amount, item = @stash.item)
  333.     if $imported[:Theo_LimInventory]
  334.       amount = [[amount,0].max,$game_party.inv_max_item(item)].min
  335.     end
  336.     $game_party.gain_item(item,amount)
  337.     $game_chests[@key].lose_item(item,amount)
  338.     on_amount_confirm if @amount.open?
  339.   end
  340.   
  341.   def store_items(amount, item = @inventory.item)
  342.     $game_chests[@key].gain_item(item,amount)
  343.     $game_party.lose_item(item,amount)
  344.     on_amount_confirm if @amount.open?
  345.   end
  346.   
  347.   def refresh_itemlist
  348.     @stash.refresh   
  349.     @inventory.refresh
  350.   end
  351.   
  352.   def on_amount_confirm
  353.     Sound.play_ok
  354.     refresh_itemlist
  355.     unselect_all
  356.     activate_itemlist
  357.   end
  358.   
  359.   def activate_itemlist
  360.     hide_amount
  361.     case @last_active
  362.     when :stash
  363.       activate_stash
  364.     when :inventory
  365.       activate_inventory
  366.     end
  367.     @item_phase = true
  368.   end
  369.   
  370.   def activate_inventory
  371.     @inventory.activate
  372.     @stash.unselect
  373.     inv_select
  374.   end
  375.   
  376.   def activate_stash
  377.     @stash.activate
  378.     @inventory.unselect
  379.     st_select
  380.   end
  381.   
  382.   def memorize_inv
  383.     $game_party.last_inv = @inventory.index
  384.   end
  385.   
  386.   def memorize_st
  387.     $game_party.last_st = @stash.index
  388.   end
  389.   
  390.   def inv_select
  391.     @inventory.index = [[$game_party.last_inv,@inventory.item_max-1].min,0].max
  392.   end
  393.   
  394.   def st_select
  395.     @stash.index = [[$game_party.last_st,@stash.item_max-1].min,0].max
  396.   end
  397.   
  398.   def unselect_all
  399.     @inventory.unselect
  400.     @stash.unselect
  401.   end
  402.   
  403.   def memorize_all
  404.     memorize_inv
  405.     memorize_st
  406.   end
  407.   
  408. end

  409. if $imported[:Theo_LimInventory]
  410. class Window_ChestFreeSlot < Window_FreeSlot
  411.   attr_accessor :item
  412.   attr_accessor :mode
  413.   
  414.   def initialize(x,y,w)
  415.     @add_number = 0
  416.     @mode = :stash
  417.     super(x,y,w)
  418.   end
  419.   
  420.   def add_number=(number)
  421.     temp = @add_number
  422.     @add_number = number
  423.     refresh if temp != number
  424.   end
  425.   
  426.   def draw_inv_slot(x,y,width = contents.width,align = 2)
  427.     item_size = @item.nil? ? 0 : @item.inv_size
  428.     item_size = -item_size if @mode == :inventory
  429.     txt = sprintf("%d/%d",$game_party.total_inv_size + @add_number *
  430.     item_size, $game_party.inv_max)
  431.     color = Theo::LimInv::NearMaxed_Color
  432.     near_max = ($game_party.total_inv_size + @add_number * item_size).to_f /
  433.       $game_party.inv_max >= (100 - Theo::LimInv::NearMaxed_Percent)/100.0
  434.     if near_max
  435.       change_color(text_color(color))
  436.     else
  437.       change_color(normal_color)
  438.     end
  439.     draw_text(x,y,width,line_height,txt,align)
  440.     change_color(normal_color)
  441.   end
  442.   
  443. end
  444. end

  445. class Window_ChestCategory < Window_ItemCategory
  446.   attr_reader :stash_window
  447.   
  448.   def col_max
  449.     return 1
  450.   end
  451.   
  452.   def update
  453.     super
  454.     @stash_window.category = current_symbol if @stash_window
  455.   end
  456.   
  457.   def make_command_list
  458.     add_command("普通道具", :item)
  459.     add_command("恢复道具", :kapad)
  460.     add_command("战斗道具", :battleitem)
  461.     add_command("人类装备", :weapon)
  462.     add_command("战车装备", :armor)
  463.     add_command("特殊物品", :key_item)
  464.    
  465.   end
  466.   
  467.   def stash_window=(stash_window)
  468.     @stash_window = stash_window
  469.     update
  470.   end
  471.   
  472. end

  473. class Window_Inventory < Window_ItemList
  474.   attr_reader :data
  475.   
  476.   def col_max
  477.     return 1
  478.   end
  479.   
  480.   def current_item_enabled?
  481.     return true
  482.   end
  483.   
  484.   def include?(item)
  485.     case @category
  486.     when :item
  487.       if item != nil
  488.         /物品种类\[(\d+)\]/ =~ item.note
  489.         if $1 == nil
  490.           item.is_a?(RPG::Item) && !item.key_item?
  491.         end
  492.       end
  493.     when :weapon
  494.       if item != nil
  495.         /物品种类\[(\d+)\]/ =~ item.note
  496.         if $1.to_i == 4
  497.           return
  498.         end
  499.         item.is_a?(RPG::Weapon) or item.is_a?(RPG::Armor)
  500.       end
  501.     when :kapad
  502.       if item != nil
  503.         /物品种类\[(\d+)\]/ =~ item.note
  504.         if $1 == nil
  505.           return
  506.         end
  507.         item.is_a?(RPG::Item) && $1.to_i == 1
  508.       end
  509.     when :battleitem
  510.       if item != nil
  511.         /物品种类\[(\d+)\]/ =~ item.note
  512.         if $1 == nil
  513.           return
  514.         end
  515.         item.is_a?(RPG::Item) && $1.to_i == 2
  516.       end
  517.       when :armor
  518.       if item != nil
  519.         /物品种类\[(\d+)\]/ =~ item.note
  520.         if $1 == nil
  521.           return
  522.         end
  523.         (item.is_a?(RPG::Weapon) && $1.to_i == 4) or (item.is_a?(RPG::Armor) && $1.to_i == 4)
  524.       end
  525.       when :key_item
  526.         item.is_a?(RPG::Item) && item.key_item?
  527.     else
  528.       false
  529.     end
  530.   end
  531.   
  532.   def draw_item(index)
  533.     item = @data[index]
  534.     if item
  535.       rect = item_rect(index)
  536.       rect.width -= 4
  537.       draw_item_name(item, rect.x, rect.y, true,contents.width)
  538.       draw_item_number(rect, item)
  539.     end
  540.   end
  541.   
  542.   def item_number(item = @data[index])
  543.     $game_party.item_number(item)
  544.   end
  545.   
  546.   def process_ok
  547.     return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
  548.     super
  549.   end
  550.   
  551. end

  552. class Window_Stash < Window_ItemList
  553.   attr_reader :data
  554.   
  555.   def initialize(x, y, width, height, key)
  556.     @key = key
  557.     super(x,y,width,height)
  558.     @category = :none
  559.     @data = []
  560.   end
  561.   
  562.   def col_max
  563.     return 1
  564.   end
  565.   
  566.   def current_item_enabled?
  567.     enable?(item)
  568.   end
  569.   
  570.   def enable?(item)
  571.     return true unless $imported[:Theo_LimInventory]
  572.     return $game_party.inv_max_item(item) > 0
  573.   end
  574.   
  575.   def include?(item)
  576.     case @category
  577.     when :item
  578.       item.is_a?(RPG::Item) && !item.key_item?
  579.     when :weapon
  580.       item.is_a?(RPG::Weapon)
  581.     when :armor
  582.       item.is_a?(RPG::Armor)
  583.     when :all
  584.       item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
  585.     when :key_item
  586.         item.is_a?(RPG::Item) && item.key_item?
  587.     else
  588.       false
  589.     end
  590.   end
  591.   
  592.   def make_item_list
  593.     @data = $game_chests[@key].all_items.select {|item| include?(item) }
  594.     @data.push(nil) if include?(nil)
  595.   end
  596.   
  597.   def draw_item(index)
  598.     item = @data[index]
  599.     if item
  600.       rect = item_rect(index)
  601.       rect.width -= 4
  602.       draw_item_name(item, rect.x, rect.y, enable?(item),contents.width)
  603.       draw_item_number(rect, item)
  604.     end
  605.   end
  606.   
  607.   def draw_item_number(rect, item)
  608.     draw_text(rect, sprintf(":%2d", $game_chests[@key].item_number(item)), 2)
  609.   end
  610.   
  611.   def item_number(item = @data[index])
  612.     $game_chests[@key].item_number(item)
  613.   end
  614.   
  615.   def process_ok
  616.     return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
  617.     super
  618.   end
  619.   
  620. end

  621. class Window_ChestAmount < Window_Base  
  622.   attr_accessor :item_window
  623.   attr_accessor :mode
  624.   attr_reader   :amount
  625.   
  626.   def initialize
  627.     super(0,0,window_width,window_height)
  628.     self.openness = 0
  629.     @mode = :stash
  630.     reset_amount
  631.     update_position
  632.     refresh
  633.   end
  634.   
  635.   def inv_window=(window)
  636.     @inv_window = window
  637.   end
  638.   
  639.   def reset_amount
  640.     @amount = 0
  641.     refresh
  642.   end
  643.   
  644.   def open
  645.     super
  646.     reset_amount
  647.   end
  648.   
  649.   def update_position
  650.     self.x = (Graphics.width / 2) - (self.width / 2)
  651.     self.y = (Graphics.height / 2) - (self.height / 2)
  652.   end
  653.   
  654.   def refresh
  655.     contents.clear
  656.     draw_text(0,0,contents.width,24,THEO::CHEST::AMOUNT_VOCAB,)
  657.     draw_text(0,0,contents.width,24,@amount,2)
  658.   end
  659.   
  660.   def window_width
  661.     return 200
  662.   end
  663.   
  664.   def window_height
  665.     return 24+24
  666.   end
  667.   
  668.   def update
  669.     super
  670.     if @inv_window
  671.       @inv_window.add_number = @amount
  672.       @inv_window.item = @item_window.item if @item_window
  673.     end
  674.     if open?
  675.       increment if Input.repeat?(:RIGHT)
  676.       decrement if Input.repeat?(:LEFT)
  677.       ten_increment if Input.repeat?(:UP)
  678.       ten_decrement if Input.repeat?(:DOWN)
  679.     end
  680.   end
  681.   
  682.   def increment
  683.     change_amount(1)
  684.   end
  685.   
  686.   def decrement
  687.     change_amount(-1)
  688.   end
  689.   
  690.   def ten_increment
  691.     change_amount(10)
  692.   end
  693.   
  694.   def ten_decrement
  695.     change_amount(-10)
  696.   end
  697.   
  698.   def change_amount(modifier)
  699.     @amount = [[@amount+modifier,0].max,max_amount].min
  700.     refresh
  701.   end
  702.   
  703.   def show
  704.     super
  705.     reset_amount
  706.   end
  707.   
  708.   def max_amount
  709.     if $imported[:Theo_LimInventory]
  710.       if @mode == :inventory
  711.         @item_window.item_number rescue 0
  712.       elsif @mode == :stash
  713.         [@item_window.item_number,$game_party.inv_max_item(@item_window.item)].min
  714.       end
  715.     else
  716.       @item_window.item_number rescue 0
  717.     end
  718.   end
  719.   
  720. end

  721. class Window_ChestFooter < Window_Base
  722.   
  723.   include THEO::CHEST
  724.   
  725.   def initialize(vocab,object,x)
  726.     w = Graphics.width/2
  727.     h = fitting_height(1)
  728.     y = Graphics.height - h
  729.     x = (Graphics.width/2) * x
  730.     @vocab = vocab
  731.     super(x,y,w,h)
  732.     @object = object
  733.     refresh
  734.   end
  735.   
  736.   def refresh
  737.     contents.clear
  738.     cx = text_size(@vocab).width
  739.     draw_text(0,0,contents.width,line_height,@vocab,1)
  740.   end
  741.   
  742. end

  743. module DataManager
  744.   
  745.   class << self
  746.     alias pre_create_chest create_game_objects
  747.     alias pre_chest_save_contents make_save_contents
  748.     alias pre_extract_chests extract_save_contents
  749.   end
  750.   
  751.   def self.create_game_objects
  752.     pre_create_chest
  753.     create_chest_object
  754.   end
  755.   
  756.   def self.create_chest_object
  757.     $game_chests = Game_Chest.new
  758.   end
  759.   
  760.   def self.make_save_contents
  761.     contents = pre_chest_save_contents
  762.     contents[:chest] = $game_chests
  763.     contents
  764.   end
  765.   
  766.   def extract_save_contents(contents)
  767.     pre_extract_chests(contents)
  768.     $game_chests = contents[:chest]
  769.   end
  770.   
  771. end

  772. class Game_Chest
  773.   
  774.   def initialize
  775.     @data = {}
  776.     @explored = {}
  777.   end
  778.   
  779.   def[](key)
  780.     (@data[key] ||= Game_Stash.new)
  781.   end
  782.   
  783.   def explored
  784.     @explored
  785.   end
  786.   
  787. end

  788. class Game_Stash
  789.   attr_accessor :items_stash
  790.   attr_accessor :weapons_stash
  791.   attr_accessor :armors_stash
  792.   
  793.   def initialize
  794.     @items_stash = {}
  795.     @weapons_stash = {}
  796.     @armors_stash = {}
  797.   end
  798.   
  799.   def refresh
  800.     evaluate(@items_stash)
  801.     evaluate(@weapons_stash)
  802.     evaluate(@armors_stash)
  803.   end
  804.   
  805.   def evaluate(stash)
  806.     stash.keys.each do |key|
  807.       stash.delete(key) if stash[key] <= 0
  808.     end
  809.   end
  810.   
  811.   def items
  812.     @items_stash.keys.collect {|id| $data_items[id] }
  813.   end
  814.   
  815.   def weapons
  816.     @weapons_stash.keys.collect {|id| $data_weapons[id] }
  817.   end
  818.   
  819.   def armors
  820.     @armors_stash.keys.collect {|id| $data_armors[id] }
  821.   end
  822.   
  823.   def all_items
  824.     items + weapons + armors
  825.   end
  826.   
  827.   def item_number(item)
  828.     if item.is_a?(RPG::Item)
  829.       return @items_stash[item.id] ||= 0
  830.     elsif item.is_a?(RPG::Weapon)
  831.       return @weapons_stash[item.id] ||= 0
  832.     elsif item.is_a?(RPG::Armor)
  833.       return @armors_stash[item.id] ||= 0
  834.     end
  835.     refresh
  836.   end
  837.   
  838.   def gain_item(item, amount)
  839.     return unless item
  840.     stash = pick_stash(item)
  841.     stash[item.id] = 0 if stash[item.id].nil?
  842.     stash[item.id] += amount
  843.     refresh
  844.   end
  845.   
  846.   def lose_item(item,amount)
  847.     gain_item(item,-amount)
  848.   end
  849.   
  850.   def pick_stash(item)
  851.     if item.is_a?(RPG::Item)
  852.       return @items_stash
  853.     elsif item.is_a?(RPG::Weapon)
  854.       return @weapons_stash
  855.     elsif item.is_a?(RPG::Armor)
  856.       return @armors_stash
  857.     end
  858.   end
  859.   
  860. end

  861. class Game_Party
  862.   attr_accessor :last_inv
  863.   attr_accessor :last_st
  864.   
  865.   alias pre_chest_init initialize
  866.   def initialize
  867.     pre_chest_init
  868.     init_chest_cursors
  869.   end
  870.   
  871.   def init_chest_cursors
  872.     @last_inv   = 0
  873.     @last_st = 0
  874.   end
  875.   
  876. end

  877. class Game_Interpreter
  878.   
  879.   def open_chest(st_vocab = THEO::CHEST::ST_VOCAB,key = [@map_id,@event_id])
  880.     if st_vocab.is_a?(Numeric)
  881.       key = st_vocab
  882.       st_vocab = THEO::CHEST::ST_VOCAB
  883.     end
  884.     SceneManager.call_chest(key,st_vocab)
  885.   end
  886.   
  887.   alias pre_chest_command_108 command_108
  888.   def command_108
  889.     pre_chest_command_108
  890.     read_chest_comments
  891.   end
  892.   
  893.   def read_chest_comments
  894.     map = @map_id
  895.     event = @event_id
  896.     key = [map,event]
  897.     return if $game_chests.explored[key]
  898.     @comments.each do |comment|
  899.       case comment
  900.       when THEO::CHEST::REGEXP::ITEM_REGEX
  901.         x = $1.scan(/\d+/)
  902.         $game_chests[key].items_stash[x[0].to_i] = x[1].to_i
  903.       when THEO::CHEST::REGEXP::WEAPON_REGEX
  904.         x = $1.scan(/\d+/)
  905.         $game_chests[key].weapons_stash[x[0].to_i] = x[1].to_i
  906.       when THEO::CHEST::REGEXP::ARMOR_REGEX
  907.         x = $1.scan(/\d+/)
  908.         $game_chests[key].armors_stash[x[0].to_i] = x[1].to_i
  909.       end
  910.     end
  911.     $game_chests.explored[key] = next_event_code != 108
  912.   end
  913.   
  914. end

  915. module SceneManager
  916.   
  917.   def self.call_chest(key,st_vocab = THEO::CHEST::ST_VOCAB)
  918.     @stack.push(@scene)
  919.     @scene = Scene_Chest.new(key,st_vocab)
  920.   end
  921.   
  922. end
复制代码

Screenshot_2023-08-12-11-46-42-803_com.miui.gallery.jpg (716.61 KB, 下载次数: 12)

Screenshot_2023-08-12-11-46-42-803_com.miui.gallery.jpg

Lv5.捕梦者

梦石
0
星屑
24302
在线时间
5048 小时
注册时间
2016-3-8
帖子
1618
2
发表于 2023-8-12 12:38:00 | 只看该作者
本帖最后由 alexncf125 于 2023-8-12 12:42 编辑

虽然你说的Bug咱在新建的工程上没测见, 但可以测出另一个Bug, 就是, 存进了仓库的物品, 在存档后关闭游戏窗口, 再重启游戏读档后, 会从仓库中消失
咱的建议是, 换一个仓库脚本吧
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-28 05:45

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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