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

Project1

 找回密码
 注册会员
搜索
查看: 1911|回复: 5

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

[复制链接]

Lv2.观梦者

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

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

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

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

如题,楼主做了一款小沙盒,可以自由摆放家具可以收回。用了仓库系统,把家具柜子设定为仓库了,可以储藏东西,问题来了,我想根据仓库里有无物品再收回,仓库里有东西就不能收回家具(事件),没东西就可以收回
RUBY 代码复制
  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.  
  22.   使用方法 :
  23.   本脚本放在插件脚本之下,main之上
  24.  
  25.   在使用脚本打开仓库前,使用以下事件注释:
  26.   <item: id, 数量>
  27.   <weapon: id, 数量>
  28.   <armor: id, 数量>
  29.  
  30.   解释 :
  31.   id >> 物品/武器/护甲id
  32.   数量 >> 数量多少
  33.  
  34.   使用以上注释后, 使用脚本 :
  35.   open_chest
  36.  
  37.   对于自定义名称的仓库, 则可以 :
  38.   open_chest("小仓库")
  39.   open_chest("Eric的宝箱")
  40.  
  41.   注意 : 所有事件中的所有注释都会读取一次,请确保在使用脚本之前使用了注释。
  42.  
  43.   使用规定 :
  44.   署名脚本作者, TheoAllen. 你可以自由编辑此脚本,只要你不声明你是脚本的原作者
  45.   如果你想用此脚本于商业游戏,请和我共享收益.别忘了给我一份免费的游戏拷贝.
  46.  
  47. =end
  48. # =============================================================================
  49. # 设定 :
  50. # =============================================================================
  51. module THEO
  52.   module CHEST
  53.     # =========================================================================
  54.     # Vocabs
  55.     # -------------------------------------------------------------------------
  56.       AMOUNT_VOCAB  = "数量 :"       # 数量.
  57.       ALL_VOCAB     = "全部"         # 全部类别.
  58.       INV_VOCAB     = "背包"         # 背包.
  59.       ST_VOCAB      = "库存"         # 库存.
  60.     # =========================================================================
  61.  
  62.     # =========================================================================
  63.       TRIGGER_GAIN_ALL  = :CTRL
  64.     # -------------------------------------------------------------------------
  65.     # 全部取出的按钮. 如果你设定为 :CTRL, 则在玩家按下CTRL和确定键 (z)后会取出
  66.     # 全部物品
  67.     # =========================================================================
  68.  
  69.     # =========================================================================
  70.       SHOW_AMOUNT_MIN   = 10
  71.     # -------------------------------------------------------------------------
  72.     # 显示窗口数量的最小值.
  73.     # =========================================================================
  74.  
  75.   end
  76. end
  77. # =============================================================================
  78. # 设定结束 (除非清除你在干什么,否则以下内容勿动)
  79. # =============================================================================
  80. module THEO
  81.   module CHEST
  82.   module REGEXP
  83.  
  84.     ITEM_REGEX   = /<(?:ITEM|item):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
  85.     WEAPON_REGEX = /<(?:WEAPON|weapon):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
  86.     ARMOR_REGEX  = /<(?:ARMOR|armor):[ ]*[ ]*(\d+\s*,\s*\d*)>/i
  87.  
  88.   end
  89.   end
  90. end
  91.  
  92. class Scene_Chest < Scene_MenuBase
  93.  
  94.   include THEO::CHEST
  95.  
  96.   def initialize(key,st_vocab)
  97.     $game_party.init_chest_cursors
  98.     @last_active = :stash
  99.     @key = key
  100.     @st_vocab = st_vocab
  101.   end
  102.  
  103.   def start
  104.     super
  105.     create_header_windows
  106.     create_footer_window
  107.     create_main_windows
  108.     create_amount_window
  109.     prepare
  110.   end
  111.  
  112.   def create_header_windows
  113.     create_help_window
  114.     create_category_window
  115.   end
  116.  
  117.   def create_main_windows
  118.     create_inventory_window
  119.     create_stash_window
  120.   end
  121.  
  122.   def create_help_window
  123.     @help = Window_Help.new
  124.     @help.viewport = @viewport
  125.   end
  126.  
  127.   def create_category_window
  128.     @category = Window_ChestCategory.new
  129.     @category.viewport = @viewport
  130.     @category.y = @help.height
  131.     @category.set_handler(:ok, method(:on_category_ok))
  132.     @category.set_handler(:cancel, method(:return_scene))
  133.   end
  134.  
  135.   def create_footer_window
  136.     create_inv_footer
  137.     create_st_footer
  138.   end
  139.  
  140.   def create_inv_footer
  141.     if $imported[:Theo_LimInventory]
  142.       x = 0
  143.       y = Graphics.height - 48
  144.       w = Graphics.width/2
  145.       @inv_footer = Window_ChestFreeSlot.new(x,y,w)
  146.       @inv_footer.viewport = @viewport
  147.     else
  148.       @inv_footer = Window_ChestFooter.new(INV_VOCAB,$game_party,0)
  149.       @inv_footer.viewport = @viewport
  150.     end
  151.   end
  152.  
  153.   def create_st_footer
  154.     @st_footer = Window_ChestFooter.new(@st_vocab,$game_chests[@key],1)
  155.     @st_footer.viewport = @viewport
  156.   end
  157.  
  158.   def create_inventory_window
  159.     x = 0
  160.     y = @help.height + @category.height
  161.     w = Graphics.width/2
  162.     h = Graphics.height - y - @inv_footer.height
  163.     @inventory = Window_Inventory.new(x,y,w,h)
  164.     @inventory.viewport = @viewport
  165.     @inventory.set_handler(:ok, method(:item_inventory_ok))
  166.     @inventory.set_handler(:cancel, method(:on_inventory_cancel))
  167.     @inventory.help_window = @help
  168.     @category.item_window = @inventory
  169.   end
  170.  
  171.   def create_stash_window
  172.     x = Graphics.width / 2
  173.     y = @inventory.y
  174.     w = x
  175.     h = @inventory.height
  176.     @stash = Window_Stash.new(x,y,w,h,@key)
  177.     @stash.viewport = @viewport
  178.     @stash.set_handler(:ok, method(:item_stash_ok))
  179.     @stash.set_handler(:cancel, method(:on_stash_cancel))
  180.     @stash.help_window = @help
  181.     @category.stash_window = @stash
  182.   end
  183.  
  184.   def create_amount_window
  185.     @amount = Window_ChestAmount.new
  186.     @amount.viewport = @viewport
  187.     @amount.inv_window = @inv_footer if $imported[:Theo_LimInventory]
  188.   end
  189.  
  190.   # for future plan ~
  191.   def refresh_all_footers
  192.     @inv_footer.refresh
  193.     @st_footer.refresh
  194.   end
  195.  
  196.   def prepare
  197.     unselect_all
  198.     @category.show
  199.     @category.activate
  200.     @item_phase = false
  201.     deactivate_item_windows
  202.     hide_amount
  203.   end
  204.  
  205.   def deactivate_item_windows
  206.     @inventory.deactivate
  207.     @stash.deactivate
  208.   end
  209.  
  210.   def on_category_ok
  211.     @category.deactivate
  212.     activate_itemlist
  213.     @item_phase = true
  214.   end
  215.  
  216.   def item_inventory_ok
  217.     unless @inventory.item
  218.       @inventory.activate
  219.       return
  220.     end
  221.     if @inventory.item_number < SHOW_AMOUNT_MIN
  222.       store_items(1)
  223.       @inventory.activate
  224.       refresh_itemlist
  225.     else
  226.       @last_active = :inventory
  227.       input_amount(@inventory)
  228.     end
  229.   end
  230.  
  231.   def item_stash_ok
  232.     unless @stash.item
  233.       @stash.activate
  234.       return
  235.     end
  236.     if @stash.item_number < SHOW_AMOUNT_MIN
  237.       gain_items(1)
  238.       @stash.activate
  239.       refresh_itemlist
  240.     else
  241.       @last_active = :stash
  242.       input_amount(@stash)
  243.     end
  244.   end
  245.  
  246.   def on_stash_cancel
  247.     @last_active = :stash
  248.     memorize_st
  249.     prepare
  250.   end
  251.  
  252.   def on_inventory_cancel
  253.     @last_active = :inventory
  254.     memorize_inv
  255.     prepare
  256.   end
  257.  
  258.   def input_amount(window)
  259.     memorize_all
  260.     if window.equal?(@stash)
  261.       @inventory.unselect
  262.     else
  263.       @stash.unselect
  264.     end
  265.     @amount.open
  266.     @amount.item_window = window
  267.     deactivate_item_windows
  268.   end
  269.  
  270.   def hide_amount
  271.     Sound.play_cancel
  272.     @amount.close
  273.     @amount.reset_amount
  274.   end
  275.  
  276.   def update
  277.     super
  278.     @amount.mode = @last_active
  279.     @inv_footer.mode = @last_active if $imported[:Theo_LimInventory]
  280.     select_item_phase if @item_phase
  281.     input_amount_phase if @amount.open?
  282.   end
  283.  
  284.   def select_item_phase
  285.     gain_all_items if trigger_gain_all_item?
  286.     switch_window if Input.repeat?(:RIGHT) || Input.repeat?(:LEFT)
  287.   end
  288.  
  289.   def input_amount_phase
  290.     activate_itemlist if Input.trigger?(:B)
  291.     if @amount.item_window.equal?(@stash) && Input.trigger?(:C)
  292.       gain_items(@amount.amount)
  293.     elsif @amount.item_window.equal?(@inventory) && Input.trigger?(:C)
  294.       store_items(@amount.amount)
  295.     end
  296.   end
  297.  
  298.   def switch_window
  299.     if @inventory.active
  300.       switch_stash
  301.     elsif @stash.active
  302.       switch_inventory
  303.     end
  304.   end
  305.  
  306.   def switch_inventory
  307.     memorize_st
  308.     @stash.deactivate
  309.     @stash.unselect
  310.     @inventory.activate
  311.     inv_select
  312.   end
  313.  
  314.   def switch_stash
  315.     @stash.activate
  316.     st_select
  317.     memorize_inv
  318.     @inventory.deactivate
  319.     @inventory.unselect
  320.   end
  321.  
  322.   def gain_all_items
  323.     if @stash.active
  324.       @stash.data.each do |item|
  325.         gain_items(@stash.item_number(item),item)
  326.       end
  327.       @stash.select(0)
  328.     else
  329.       @inventory.data.each do |item|
  330.         store_items(@inventory.item_number(item),item)
  331.       end
  332.       @inventory.select(0)
  333.     end
  334.     refresh_itemlist
  335.     refresh_all_footers
  336.   end
  337.  
  338.   def trigger_gain_all_item?
  339.     Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL) && Input.trigger?(:C)
  340.   end
  341.  
  342.   def gain_items(amount, item = @stash.item)
  343.     if $imported[:Theo_LimInventory]
  344.       amount = [[amount,0].max,$game_party.inv_max_item(item)].min
  345.     end
  346.     $game_party.gain_item(item,amount)
  347.     $game_chests[@key].lose_item(item,amount)
  348.     on_amount_confirm if @amount.open?
  349.   end
  350.  
  351.   def store_items(amount, item = @inventory.item)
  352.     $game_chests[@key].gain_item(item,amount)
  353.     $game_party.lose_item(item,amount)
  354.     on_amount_confirm if @amount.open?
  355.   end
  356.  
  357.   def refresh_itemlist
  358.     @stash.refresh   
  359.     @inventory.refresh
  360.   end
  361.  
  362.   def on_amount_confirm
  363.     Sound.play_ok
  364.     refresh_itemlist
  365.     unselect_all
  366.     activate_itemlist
  367.   end
  368.  
  369.   def activate_itemlist
  370.     hide_amount
  371.     case @last_active
  372.     when :stash
  373.       activate_stash
  374.     when :inventory
  375.       activate_inventory
  376.     end
  377.     @item_phase = true
  378.   end
  379.  
  380.   def activate_inventory
  381.     @inventory.activate
  382.     @stash.unselect
  383.     inv_select
  384.   end
  385.  
  386.   def activate_stash
  387.     @stash.activate
  388.     @inventory.unselect
  389.     st_select
  390.   end
  391.  
  392.   def memorize_inv
  393.     $game_party.last_inv = @inventory.index
  394.   end
  395.  
  396.   def memorize_st
  397.     $game_party.last_st = @stash.index
  398.   end
  399.  
  400.   def inv_select
  401.     @inventory.index = [[$game_party.last_inv,@inventory.item_max-1].min,0].max
  402.   end
  403.  
  404.   def st_select
  405.     @stash.index = [[$game_party.last_st,@stash.item_max-1].min,0].max
  406.   end
  407.  
  408.   def unselect_all
  409.     @inventory.unselect
  410.     @stash.unselect
  411.   end
  412.  
  413.   def memorize_all
  414.     memorize_inv
  415.     memorize_st
  416.   end
  417.  
  418. end
  419.  
  420. if $imported[:Theo_LimInventory]
  421. class Window_ChestFreeSlot < Window_FreeSlot
  422.   attr_accessor :item
  423.   attr_accessor :mode
  424.  
  425.   def initialize(x,y,w)
  426.     @add_number = 0
  427.     @mode = :stash
  428.     super(x,y,w)
  429.   end
  430.  
  431.   def add_number=(number)
  432.     temp = @add_number
  433.     @add_number = number
  434.     refresh if temp != number
  435.   end
  436.  
  437.   def draw_inv_slot(x,y,width = contents.width,align = 2)
  438.     item_size = @item.nil? ? 0 : @item.inv_size
  439.     item_size = -item_size if @mode == :inventory
  440.     txt = sprintf("%d/%d",$game_party.total_inv_size + @add_number *
  441.     item_size, $game_party.inv_max)
  442.     color = Theo::LimInv::NearMaxed_Color
  443.     near_max = ($game_party.total_inv_size + @add_number * item_size).to_f /
  444.       $game_party.inv_max >= (100 - Theo::LimInv::NearMaxed_Percent)/100.0
  445.     if near_max
  446.       change_color(text_color(color))
  447.     else
  448.       change_color(normal_color)
  449.     end
  450.     draw_text(x,y,width,line_height,txt,align)
  451.     change_color(normal_color)
  452.   end
  453.  
  454. end
  455. end
  456.  
  457. class Window_ChestCategory < Window_ItemCategory
  458.   attr_reader :stash_window
  459.  
  460.   def col_max
  461.     return 4
  462.   end
  463.  
  464.   def update
  465.     super
  466.     @stash_window.category = current_symbol if @stash_window
  467.   end
  468.  
  469.   def make_command_list
  470.     add_command(THEO::CHEST::ALL_VOCAB, :all)
  471.     add_command(Vocab::item,     :item)
  472.     add_command(Vocab::weapon,   :weapon)
  473.     add_command(Vocab::armor,    :armor)
  474.   end
  475.  
  476.   def stash_window=(stash_window)
  477.     @stash_window = stash_window
  478.     update
  479.   end
  480.  
  481. end
  482.  
  483. class Window_Inventory < Window_ItemList
  484.   attr_reader :data
  485.  
  486.   def col_max
  487.     return 1
  488.   end
  489.  
  490.   def current_item_enabled?
  491.     return true
  492.   end
  493.  
  494.   def include?(item)
  495.     case @category
  496.     when :item
  497.       item.is_a?(RPG::Item) && !item.key_item?
  498.     when :weapon
  499.       item.is_a?(RPG::Weapon)
  500.     when :armor
  501.       item.is_a?(RPG::Armor)
  502.     when :all
  503.       item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
  504.     else
  505.       false
  506.     end
  507.   end
  508.  
  509.   def draw_item(index)
  510.     item = @data[index]
  511.     if item
  512.       rect = item_rect(index)
  513.       rect.width -= 4
  514.       draw_item_name(item, rect.x, rect.y, true,contents.width)
  515.       draw_item_number(rect, item)
  516.     end
  517.   end
  518.  
  519.   def item_number(item = @data[index])
  520.     $game_party.item_number(item)
  521.   end
  522.  
  523.   def process_ok
  524.     return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
  525.     super
  526.   end
  527.  
  528. end
  529.  
  530. class Window_Stash < Window_ItemList
  531.   attr_reader :data
  532.  
  533.   def initialize(x, y, width, height, key)
  534.     @key = key
  535.     super(x,y,width,height)
  536.     @category = :none
  537.     @data = []
  538.   end
  539.  
  540.   def col_max
  541.     return 1
  542.   end
  543.  
  544.   def current_item_enabled?
  545.     enable?(item)
  546.   end
  547.  
  548.   def enable?(item)
  549.     return true unless $imported[:Theo_LimInventory]
  550.     return $game_party.inv_max_item(item) > 0
  551.   end
  552.  
  553.   def include?(item)
  554.     case @category
  555.     when :item
  556.       item.is_a?(RPG::Item) && !item.key_item?
  557.     when :weapon
  558.       item.is_a?(RPG::Weapon)
  559.     when :armor
  560.       item.is_a?(RPG::Armor)
  561.     when :all
  562.       item.is_a?(RPG::Armor) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Item)
  563.     else
  564.       false
  565.     end
  566.   end
  567.  
  568.   def make_item_list
  569.     @data = $game_chests[@key].all_items.select {|item| include?(item) }
  570.     @data.push(nil) if include?(nil)
  571.   end
  572.  
  573.   def draw_item(index)
  574.     item = @data[index]
  575.     if item
  576.       rect = item_rect(index)
  577.       rect.width -= 4
  578.       draw_item_name(item, rect.x, rect.y, enable?(item),contents.width)
  579.       draw_item_number(rect, item)
  580.     end
  581.   end
  582.  
  583.   def draw_item_number(rect, item)
  584.     draw_text(rect, sprintf(":%2d", $game_chests[@key].item_number(item)), 2)
  585.   end
  586.  
  587.   def item_number(item = @data[index])
  588.     $game_chests[@key].item_number(item)
  589.   end
  590.  
  591.   def process_ok
  592.     return if Input.press?(THEO::CHEST::TRIGGER_GAIN_ALL)
  593.     super
  594.   end
  595.  
  596. end
  597.  
  598. class Window_ChestAmount < Window_Base  
  599.   attr_accessor :item_window
  600.   attr_accessor :mode
  601.   attr_reader   :amount
  602.  
  603.   def initialize
  604.     super(0,0,window_width,window_height)
  605.     self.openness = 0
  606.     @mode = :stash
  607.     reset_amount
  608.     update_position
  609.     refresh
  610.   end
  611.  
  612.   def inv_window=(window)
  613.     @inv_window = window
  614.   end
  615.  
  616.   def reset_amount
  617.     @amount = 0
  618.     refresh
  619.   end
  620.  
  621.   def open
  622.     super
  623.     reset_amount
  624.   end
  625.  
  626.   def update_position
  627.     self.x = (Graphics.width / 2) - (self.width / 2)
  628.     self.y = (Graphics.height / 2) - (self.height / 2)
  629.   end
  630.  
  631.   def refresh
  632.     contents.clear
  633.     draw_text(0,0,contents.width,24,THEO::CHEST::AMOUNT_VOCAB,)
  634.     draw_text(0,0,contents.width,24,@amount,2)
  635.   end
  636.  
  637.   def window_width
  638.     return 200
  639.   end
  640.  
  641.   def window_height
  642.     return 24+24
  643.   end
  644.  
  645.   def update
  646.     super
  647.     if @inv_window
  648.       @inv_window.add_number = @amount
  649.       @inv_window.item = @item_window.item if @item_window
  650.     end
  651.     if open?
  652.       increment if Input.repeat?(:RIGHT)
  653.       decrement if Input.repeat?(:LEFT)
  654.       ten_increment if Input.repeat?(:UP)
  655.       ten_decrement if Input.repeat?(:DOWN)
  656.     end
  657.   end
  658.  
  659.   def increment
  660.     change_amount(1)
  661.   end
  662.  
  663.   def decrement
  664.     change_amount(-1)
  665.   end
  666.  
  667.   def ten_increment
  668.     change_amount(10)
  669.   end
  670.  
  671.   def ten_decrement
  672.     change_amount(-10)
  673.   end
  674.  
  675.   def change_amount(modifier)
  676.     @amount = [[@amount+modifier,0].max,max_amount].min
  677.     refresh
  678.   end
  679.  
  680.   def show
  681.     super
  682.     reset_amount
  683.   end
  684.  
  685.   def max_amount
  686.     if $imported[:Theo_LimInventory]
  687.       if @mode == :inventory
  688.         @item_window.item_number rescue 0
  689.       elsif @mode == :stash
  690.         [@item_window.item_number,$game_party.inv_max_item(@item_window.item)].min
  691.       end
  692.     else
  693.       @item_window.item_number rescue 0
  694.     end
  695.   end
  696.  
  697. end
  698.  
  699. class Window_ChestFooter < Window_Base
  700.  
  701.   include THEO::CHEST
  702.  
  703.   def initialize(vocab,object,x)
  704.     w = Graphics.width/2
  705.     h = fitting_height(1)
  706.     y = Graphics.height - h
  707.     x = (Graphics.width/2) * x
  708.     @vocab = vocab
  709.     super(x,y,w,h)
  710.     @object = object
  711.     refresh
  712.   end
  713.  
  714.   def refresh
  715.     contents.clear
  716.     cx = text_size(@vocab).width
  717.     draw_text(0,0,contents.width,line_height,@vocab,1)
  718.   end
  719.  
  720. end
  721.  
  722. module DataManager
  723.  
  724.   class << self
  725.     alias pre_create_chest create_game_objects
  726.     alias pre_chest_save_contents make_save_contents
  727.     alias pre_extract_chests extract_save_contents
  728.   end
  729.  
  730.   def self.create_game_objects
  731.     pre_create_chest
  732.     create_chest_object
  733.   end
  734.  
  735.   def self.create_chest_object
  736.     $game_chests = Game_Chest.new
  737.   end
  738.  
  739.   def self.make_save_contents
  740.     contents = pre_chest_save_contents
  741.     contents[:chest] = $game_chests
  742.     contents
  743.   end
  744.  
  745.   def extract_save_contents(contents)
  746.     pre_extract_chests(contents)
  747.     $game_chests = contents[:chest]
  748.   end
  749.  
  750. end
  751.  
  752. class Game_Chest
  753.  
  754.   def initialize
  755.     @data = {}
  756.     @explored = {}
  757.   end
  758.  
  759.   def[](key)
  760.     (@data[key] ||= Game_Stash.new)
  761.   end
  762.  
  763.   def explored
  764.     @explored
  765.   end
  766.  
  767. end
  768.  
  769. class Game_Stash
  770.   attr_accessor :items_stash
  771.   attr_accessor :weapons_stash
  772.   attr_accessor :armors_stash
  773.  
  774.   def initialize
  775.     @items_stash = {}
  776.     @weapons_stash = {}
  777.     @armors_stash = {}
  778.   end
  779.  
  780.   def refresh
  781.     evaluate(@items_stash)
  782.     evaluate(@weapons_stash)
  783.     evaluate(@armors_stash)
  784.   end
  785.  
  786.   def evaluate(stash)
  787.     stash.keys.each do |key|
  788.       stash.delete(key) if stash[key] <= 0
  789.     end
  790.   end
  791.  
  792.   def items
  793.     @items_stash.keys.collect {|id| $data_items[id] }
  794.   end
  795.  
  796.   def weapons
  797.     @weapons_stash.keys.collect {|id| $data_weapons[id] }
  798.   end
  799.  
  800.   def armors
  801.     @armors_stash.keys.collect {|id| $data_armors[id] }
  802.   end
  803.  
  804.   def all_items
  805.     items + weapons + armors
  806.   end
  807.  
  808.   def item_number(item)
  809.     if item.is_a?(RPG::Item)
  810.       return @items_stash[item.id] ||= 0
  811.     elsif item.is_a?(RPG::Weapon)
  812.       return @weapons_stash[item.id] ||= 0
  813.     elsif item.is_a?(RPG::Armor)
  814.       return @armors_stash[item.id] ||= 0
  815.     end
  816.     refresh
  817.   end
  818.  
  819.   def gain_item(item, amount)
  820.     return unless item
  821.     stash = pick_stash(item)
  822.     stash[item.id] = 0 if stash[item.id].nil?
  823.     stash[item.id] += amount
  824.     refresh
  825.   end
  826.  
  827.   def lose_item(item,amount)
  828.     gain_item(item,-amount)
  829.   end
  830.  
  831.   def pick_stash(item)
  832.     if item.is_a?(RPG::Item)
  833.       return @items_stash
  834.     elsif item.is_a?(RPG::Weapon)
  835.       return @weapons_stash
  836.     elsif item.is_a?(RPG::Armor)
  837.       return @armors_stash
  838.     end
  839.   end
  840.  
  841. end
  842.  
  843. class Game_Party
  844.   attr_accessor :last_inv
  845.   attr_accessor :last_st
  846.  
  847.   alias pre_chest_init initialize
  848.   def initialize
  849.     pre_chest_init
  850.     init_chest_cursors
  851.   end
  852.  
  853.   def init_chest_cursors
  854.     @last_inv   = 0
  855.     @last_st = 0
  856.   end
  857.  
  858. end
  859.  
  860. class Game_Interpreter
  861.  
  862.   def open_chest(st_vocab = THEO::CHEST::ST_VOCAB,key = [@map_id,@event_id])
  863.     if st_vocab.is_a?(Numeric)
  864.       key = st_vocab
  865.       st_vocab = THEO::CHEST::ST_VOCAB
  866.     end
  867.     SceneManager.call_chest(key,st_vocab)
  868.   end
  869.  
  870.   alias pre_chest_command_108 command_108
  871.   def command_108
  872.     pre_chest_command_108
  873.     read_chest_comments
  874.   end
  875.  
  876.   def read_chest_comments
  877.     map = @map_id
  878.     event = @event_id
  879.     key = [map,event]
  880.     return if $game_chests.explored[key]
  881.     @comments.each do |comment|
  882.       case comment
  883.       when THEO::CHEST::REGEXP::ITEM_REGEX
  884.         x = $1.scan(/\d+/)
  885.         $game_chests[key].items_stash[x[0].to_i] = x[1].to_i
  886.       when THEO::CHEST::REGEXP::WEAPON_REGEX
  887.         x = $1.scan(/\d+/)
  888.         $game_chests[key].weapons_stash[x[0].to_i] = x[1].to_i
  889.       when THEO::CHEST::REGEXP::ARMOR_REGEX
  890.         x = $1.scan(/\d+/)
  891.         $game_chests[key].armors_stash[x[0].to_i] = x[1].to_i
  892.       end
  893.     end
  894.     $game_chests.explored[key] = next_event_code != 108
  895.   end
  896.  
  897. end
  898.  
  899. module SceneManager
  900.  
  901.   def self.call_chest(key,st_vocab = THEO::CHEST::ST_VOCAB)
  902.     @stack.push(@scene)
  903.     @scene = Scene_Chest.new(key,st_vocab)
  904.   end
  905.  
  906. end
阁下的心。我收下了
头像被屏蔽

Lv4.逐梦者 (禁止发言)

梦石
0
星屑
5701
在线时间
922 小时
注册时间
2013-8-29
帖子
1468
发表于 2020-6-17 17:56:13 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
11194
在线时间
607 小时
注册时间
2016-8-25
帖子
1393

R考场第七期纪念奖

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

使用道具 举报

头像被屏蔽

Lv4.逐梦者 (禁止发言)

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

使用道具 举报

Lv2.观梦者

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

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

使用道具 举报

Lv2.观梦者

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

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-28 20:51

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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