查看: 2742|回复: 5

[已经过期] 如何让仓库里没有东西可以触发事件

[复制链接]
梦石
0
星屑
864
在线时间
299 小时
注册时间
2014-8-1
回帖
31
发表于 2020-6-17 15:20:26 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 风华尽绽 于 2020-6-18 15:35 编辑

如题,楼主做了一款小沙盒,可以自由摆放家具可以收回。用了仓库系统,把家具柜子设定为仓库了,可以储藏东西,问题来了,我想根据仓库里有无物品再收回,仓库里有东西就不能收回家具(事件),没东西就可以收回
  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 4
  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(THEO::CHEST::ALL_VOCAB, :all)
  459.     add_command(Vocab::item,     :item)
  460.     add_command(Vocab::weapon,   :weapon)
  461.     add_command(Vocab::armor,    :armor)
  462.   end
  463.   
  464.   def stash_window=(stash_window)
  465.     @stash_window = stash_window
  466.     update
  467.   end
  468.   
  469. end

  470. class Window_Inventory < Window_ItemList
  471.   attr_reader :data
  472.   
  473.   def col_max
  474.     return 1
  475.   end
  476.   
  477.   def current_item_enabled?
  478.     return true
  479.   end
  480.   
  481.   def include?(item)
  482.     case @category
  483.     when :item
  484.       item.is_a?(RPG::Item) && !item.key_item?
  485.     when :weapon
  486.       item.is_a?(RPG::Weapon)
  487.     when :armor
  488.       item.is_a?(RPG::Armor)
  489.     when :all
  490.       item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
  491.     else
  492.       false
  493.     end
  494.   end
  495.   
  496.   def draw_item(index)
  497.     item = @data[index]
  498.     if item
  499.       rect = item_rect(index)
  500.       rect.width -= 4
  501.       draw_item_name(item, rect.x, rect.y, true,contents.width)
  502.       draw_item_number(rect, item)
  503.     end
  504.   end
  505.   
  506.   def item_number(item = @data[index])
  507.     $game_party.item_number(item)
  508.   end
  509.   
  510.   def process_ok
  511.     return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
  512.     super
  513.   end
  514.   
  515. end

  516. class Window_Stash < Window_ItemList
  517.   attr_reader :data
  518.   
  519.   def initialize(x, y, width, height, key)
  520.     @key = key
  521.     super(x,y,width,height)
  522.     @category = :none
  523.     @data = []
  524.   end
  525.   
  526.   def col_max
  527.     return 1
  528.   end
  529.   
  530.   def current_item_enabled?
  531.     enable?(item)
  532.   end
  533.   
  534.   def enable?(item)
  535.     return true unless $imported[:Theo_LimInventory]
  536.     return $game_party.inv_max_item(item) > 0
  537.   end
  538.   
  539.   def include?(item)
  540.     case @category
  541.     when :item
  542.       item.is_a?(RPG::Item) && !item.key_item?
  543.     when :weapon
  544.       item.is_a?(RPG::Weapon)
  545.     when :armor
  546.       item.is_a?(RPG::Armor)
  547.     when :all
  548.       item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
  549.     else
  550.       false
  551.     end
  552.   end
  553.   
  554.   def make_item_list
  555.     @data = $game_chests[@key].all_items.select {|item| include?(item) }
  556.     @data.push(nil) if include?(nil)
  557.   end
  558.   
  559.   def draw_item(index)
  560.     item = @data[index]
  561.     if item
  562.       rect = item_rect(index)
  563.       rect.width -= 4
  564.       draw_item_name(item, rect.x, rect.y, enable?(item),contents.width)
  565.       draw_item_number(rect, item)
  566.     end
  567.   end
  568.   
  569.   def draw_item_number(rect, item)
  570.     draw_text(rect, sprintf(":%2d", $game_chests[@key].item_number(item)), 2)
  571.   end
  572.   
  573.   def item_number(item = @data[index])
  574.     $game_chests[@key].item_number(item)
  575.   end
  576.   
  577.   def process_ok
  578.     return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
  579.     super
  580.   end
  581.   
  582. end

  583. class Window_ChestAmount < Window_Base  
  584.   attr_accessor :item_window
  585.   attr_accessor :mode
  586.   attr_reader   :amount
  587.   
  588.   def initialize
  589.     super(0,0,window_width,window_height)
  590.     self.openness = 0
  591.     @mode = :stash
  592.     reset_amount
  593.     update_position
  594.     refresh
  595.   end
  596.   
  597.   def inv_window=(window)
  598.     @inv_window = window
  599.   end
  600.   
  601.   def reset_amount
  602.     @amount = 0
  603.     refresh
  604.   end
  605.   
  606.   def open
  607.     super
  608.     reset_amount
  609.   end
  610.   
  611.   def update_position
  612.     self.x = (Graphics.width / 2) - (self.width / 2)
  613.     self.y = (Graphics.height / 2) - (self.height / 2)
  614.   end
  615.   
  616.   def refresh
  617.     contents.clear
  618.     draw_text(0,0,contents.width,24,THEO::CHEST::AMOUNT_VOCAB,)
  619.     draw_text(0,0,contents.width,24,@amount,2)
  620.   end
  621.   
  622.   def window_width
  623.     return 200
  624.   end
  625.   
  626.   def window_height
  627.     return 24+24
  628.   end
  629.   
  630.   def update
  631.     super
  632.     if @inv_window
  633.       @inv_window.add_number = @amount
  634.       @inv_window.item = @item_window.item if @item_window
  635.     end
  636.     if open?
  637.       increment if Input.repeat?(:RIGHT)
  638.       decrement if Input.repeat?(:LEFT)
  639.       ten_increment if Input.repeat?(:UP)
  640.       ten_decrement if Input.repeat?(:DOWN)
  641.     end
  642.   end
  643.   
  644.   def increment
  645.     change_amount(1)
  646.   end
  647.   
  648.   def decrement
  649.     change_amount(-1)
  650.   end
  651.   
  652.   def ten_increment
  653.     change_amount(10)
  654.   end
  655.   
  656.   def ten_decrement
  657.     change_amount(-10)
  658.   end
  659.   
  660.   def change_amount(modifier)
  661.     @amount = [[@amount+modifier,0].max,max_amount].min
  662.     refresh
  663.   end
  664.   
  665.   def show
  666.     super
  667.     reset_amount
  668.   end
  669.   
  670.   def max_amount
  671.     if $imported[:Theo_LimInventory]
  672.       if @mode == :inventory
  673.         @item_window.item_number rescue 0
  674.       elsif @mode == :stash
  675.         [@item_window.item_number,$game_party.inv_max_item(@item_window.item)].min
  676.       end
  677.     else
  678.       @item_window.item_number rescue 0
  679.     end
  680.   end
  681.   
  682. end

  683. class Window_ChestFooter < Window_Base
  684.   
  685.   include THEO::CHEST
  686.   
  687.   def initialize(vocab,object,x)
  688.     w = Graphics.width/2
  689.     h = fitting_height(1)
  690.     y = Graphics.height - h
  691.     x = (Graphics.width/2) * x
  692.     @vocab = vocab
  693.     super(x,y,w,h)
  694.     @object = object
  695.     refresh
  696.   end
  697.   
  698.   def refresh
  699.     contents.clear
  700.     cx = text_size(@vocab).width
  701.     draw_text(0,0,contents.width,line_height,@vocab,1)
  702.   end
  703.   
  704. end

  705. module DataManager
  706.   
  707.   class << self
  708.     alias pre_create_chest create_game_objects
  709.     alias pre_chest_save_contents make_save_contents
  710.     alias pre_extract_chests extract_save_contents
  711.   end
  712.   
  713.   def self.create_game_objects
  714.     pre_create_chest
  715.     create_chest_object
  716.   end
  717.   
  718.   def self.create_chest_object
  719.     $game_chests = Game_Chest.new
  720.   end
  721.   
  722.   def self.make_save_contents
  723.     contents = pre_chest_save_contents
  724.     contents[:chest] = $game_chests
  725.     contents
  726.   end
  727.   
  728.   def extract_save_contents(contents)
  729.     pre_extract_chests(contents)
  730.     $game_chests = contents[:chest]
  731.   end
  732.   
  733. end

  734. class Game_Chest
  735.   
  736.   def initialize
  737.     @data = {}
  738.     @explored = {}
  739.   end
  740.   
  741.   def[](key)
  742.     (@data[key] ||= Game_Stash.new)
  743.   end
  744.   
  745.   def explored
  746.     @explored
  747.   end
  748.   
  749. end

  750. class Game_Stash
  751.   attr_accessor :items_stash
  752.   attr_accessor :weapons_stash
  753.   attr_accessor :armors_stash
  754.   
  755.   def initialize
  756.     @items_stash = {}
  757.     @weapons_stash = {}
  758.     @armors_stash = {}
  759.   end
  760.   
  761.   def refresh
  762.     evaluate(@items_stash)
  763.     evaluate(@weapons_stash)
  764.     evaluate(@armors_stash)
  765.   end
  766.   
  767.   def evaluate(stash)
  768.     stash.keys.each do |key|
  769.       stash.delete(key) if stash[key] <= 0
  770.     end
  771.   end
  772.   
  773.   def items
  774.     @items_stash.keys.collect {|id| $data_items[id] }
  775.   end
  776.   
  777.   def weapons
  778.     @weapons_stash.keys.collect {|id| $data_weapons[id] }
  779.   end
  780.   
  781.   def armors
  782.     @armors_stash.keys.collect {|id| $data_armors[id] }
  783.   end
  784.   
  785.   def all_items
  786.     items + weapons + armors
  787.   end
  788.   
  789.   def item_number(item)
  790.     if item.is_a?(RPG::Item)
  791.       return @items_stash[item.id] ||= 0
  792.     elsif item.is_a?(RPG::Weapon)
  793.       return @weapons_stash[item.id] ||= 0
  794.     elsif item.is_a?(RPG::Armor)
  795.       return @armors_stash[item.id] ||= 0
  796.     end
  797.     refresh
  798.   end
  799.   
  800.   def gain_item(item, amount)
  801.     return unless item
  802.     stash = pick_stash(item)
  803.     stash[item.id] = 0 if stash[item.id].nil?
  804.     stash[item.id] += amount
  805.     refresh
  806.   end
  807.   
  808.   def lose_item(item,amount)
  809.     gain_item(item,-amount)
  810.   end
  811.   
  812.   def pick_stash(item)
  813.     if item.is_a?(RPG::Item)
  814.       return @items_stash
  815.     elsif item.is_a?(RPG::Weapon)
  816.       return @weapons_stash
  817.     elsif item.is_a?(RPG::Armor)
  818.       return @armors_stash
  819.     end
  820.   end
  821.   
  822. end

  823. class Game_Party
  824.   attr_accessor :last_inv
  825.   attr_accessor :last_st
  826.   
  827.   alias pre_chest_init initialize
  828.   def initialize
  829.     pre_chest_init
  830.     init_chest_cursors
  831.   end
  832.   
  833.   def init_chest_cursors
  834.     @last_inv   = 0
  835.     @last_st = 0
  836.   end
  837.   
  838. end

  839. class Game_Interpreter
  840.   
  841.   def open_chest(st_vocab = THEO::CHEST::ST_VOCAB,key = [@map_id,@event_id])
  842.     if st_vocab.is_a?(Numeric)
  843.       key = st_vocab
  844.       st_vocab = THEO::CHEST::ST_VOCAB
  845.     end
  846.     SceneManager.call_chest(key,st_vocab)
  847.   end
  848.   
  849.   alias pre_chest_command_108 command_108
  850.   def command_108
  851.     pre_chest_command_108
  852.     read_chest_comments
  853.   end
  854.   
  855.   def read_chest_comments
  856.     map = @map_id
  857.     event = @event_id
  858.     key = [map,event]
  859.     return if $game_chests.explored[key]
  860.     @comments.each do |comment|
  861.       case comment
  862.       when THEO::CHEST::REGEXP::ITEM_REGEX
  863.         x = $1.scan(/\d+/)
  864.         $game_chests[key].items_stash[x[0].to_i] = x[1].to_i
  865.       when THEO::CHEST::REGEXP::WEAPON_REGEX
  866.         x = $1.scan(/\d+/)
  867.         $game_chests[key].weapons_stash[x[0].to_i] = x[1].to_i
  868.       when THEO::CHEST::REGEXP::ARMOR_REGEX
  869.         x = $1.scan(/\d+/)
  870.         $game_chests[key].armors_stash[x[0].to_i] = x[1].to_i
  871.       end
  872.     end
  873.     $game_chests.explored[key] = next_event_code != 108
  874.   end
  875.   
  876. end

  877. module SceneManager
  878.   
  879.   def self.call_chest(key,st_vocab = THEO::CHEST::ST_VOCAB)
  880.     @stack.push(@scene)
  881.     @scene = Scene_Chest.new(key,st_vocab)
  882.   end
  883.   
  884. end
复制代码
阁下的心。我收下了
头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
发表于 2020-6-17 17:56:13 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

梦石
0
星屑
11806
在线时间
623 小时
注册时间
2016-8-25
回帖
1339

R考场第七期纪念奖

发表于 2020-6-17 23:33:08 | 显示全部楼层
这里建议您用变量
因为我不会脚本
每个物品的数量对应一个变量
所有变量等于0的时候执行就好了
回复

使用道具 举报

头像被屏蔽
梦石
0
星屑
5706
在线时间
922 小时
注册时间
2013-8-29
回帖
1401
发表于 2020-6-17 23:50:11 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 1 0

使用道具 举报

梦石
0
星屑
864
在线时间
299 小时
注册时间
2014-8-1
回帖
31
 楼主| 发表于 2020-6-18 15:35:52 | 显示全部楼层
chanszeman1018 发表于 2020-6-17 17:56
大哥你把帖子设成付費主题了

我不太懂,以为这个是悬赏呢,哈哈哈取消了,谢谢回答
阁下的心。我收下了
回复

使用道具 举报

梦石
0
星屑
864
在线时间
299 小时
注册时间
2014-8-1
回帖
31
 楼主| 发表于 2020-6-20 18:13:56 | 显示全部楼层
PLeaseS 发表于 2020-6-17 23:33
这里建议您用变量
因为我不会脚本
每个物品的数量对应一个变量

如果多次使用的话怎么办
阁下的心。我收下了
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部