Project1

标题: 【简易坑爹系列】多背包脚本 [打印本页]

作者: 英顺的马甲    时间: 2016-5-25 14:39
标题: 【简易坑爹系列】多背包脚本
本帖最后由 英顺的马甲 于 2016-6-18 00:41 编辑

其实我也不记得以前有没有发布过了
先附上个简易脚本,插入Game_Party之后,Main之前的任何位置
RUBY 代码复制
  1. #===============================================================================
  2. # ● 【简易坑爹系列】多背包脚本
  3. #===============================================================================
  4. class GameBag
  5.   # 背包判定条件
  6.   def self.identifier
  7.     # 若需要以别的条件来判定背包请更改下面的脚本
  8.     #===========================================
  9.     $game_variables[1] # 以一号开关来判定
  10.     #===========================================
  11.     # 若需要以别的条件来判定背包请更改上面的脚本
  12.   end
  13.   # 将当前背包复制到缓存背包
  14.   def self.push
  15.     ObjectSpace.each_object(GameBag) do |bag|
  16.       bag.cache = (bag.data[GameBag.identifier]||{}).clone
  17.     end
  18.   end
  19.   # 将缓存背包复制到当前背包
  20.   def self.pull
  21.     ObjectSpace.each_object(GameBag) do |bag|
  22.       bag.data[GameBag.identifier] = bag.cache.clone
  23.     end
  24.   end
  25.   # 将当前背包叠加到缓存背包
  26.   def self.merge
  27.     ObjectSpace.each_object(GameBag) do |bag|
  28.       (bag.data[GameBag.identifier] || {}).each do |k, v|
  29.         bag.cache[k] = [bag.cache[k] + v, 99].min
  30.       end
  31.     end
  32.   end
  33.   # 清空当前背包
  34.   def self.clear
  35.     ObjectSpace.each_object(GameBag) do |bag|
  36.       bag.data.delete(GameBag.identifier)
  37.     end
  38.   end
  39.   # 清空缓存背包
  40.   def self.drop
  41.     ObjectSpace.each_object(GameBag) do |bag|
  42.       bag.cache.clear
  43.     end
  44.   end
  45.   # 初始化
  46.   def initialize
  47.     @data = {}
  48.     @cache = {}
  49.   end
  50.   # 不需要理会
  51.   def method_missing(meth, *args)
  52.     begin
  53.       (@data[GameBag.identifier] ||= {}).__send__(meth, *args)
  54.     rescue Exception
  55.       raise $!, $!.message, caller
  56.     end
  57.   end
  58.   attr_accessor :data
  59.   attr_accessor :cache
  60. end
  61. $ORIG_MULTIBAG_PARTY = Game_Party.clone unless $ORIG_MULTIBAG_PARTY
  62. class Game_Party < $ORIG_MULTIBAG_PARTY
  63.   def initialize
  64.     super
  65.     @items = GameBag.new
  66.     @armors = GameBag.new
  67.     @weapons = GameBag.new
  68.   end
  69. end
再附上个简易截图范例       
作者: 无忧谷主幻    时间: 2016-5-25 18:48
为何我照着做,结果却崩了
Project1.zip (202.55 KB, 下载次数: 95)








欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1