本帖最后由 英顺的马甲 于 2015-1-1 14:31 编辑
这样就每个人都有一个背包了,
效果是背包根据队伍的第一个成员而定
脚本未经测试效果未知class Game_Party def item_number(id) @items[@actors[0].id] ? (@items[@actors[0].id].include?(id) ? @items[@actors[0].id][id] : 0) : 0 end def weapon_number(id) @weapons[@actors[0].id] ? (@weapons[@actors[0].id].include?(id) ? @weapons[@actors[0].id][id] : 0) : 0 end def armor_number(id) @armors[@actors[0].id] ? (@armors[@actors[0].id].include?(id) ? @armors[@actors[0].id][id] : 0) : 0 end def gain_item(id, n) @items[@actors[0].id] = {} unless @items[@actors[0].id] if item_id > 0 @items[@actors[0].id][id] = [[item_number(id) + n, 0].max, 99].min end end def gain_weapon(id, n) @weapons[@actors[0].id] = {} unless @weapons[@actors[0].id] if id > 0 @weapons[@actors[0].id][id] = [[weapon_number(id) + n, 0].max, 99].min end end def gain_armor(id, n) @armors[@actors[0].id] = {} unless @armors[@actors[0].id] if id > 0 @armors[@actors[0].id][id] = [[armor_number(id) + n, 0].max, 99].min end end end
class Game_Party
def item_number(id)
@items[@actors[0].id] ? (@items[@actors[0].id].include?(id) ? @items[@actors[0].id][id] : 0) : 0
end
def weapon_number(id)
@weapons[@actors[0].id] ? (@weapons[@actors[0].id].include?(id) ? @weapons[@actors[0].id][id] : 0) : 0
end
def armor_number(id)
@armors[@actors[0].id] ? (@armors[@actors[0].id].include?(id) ? @armors[@actors[0].id][id] : 0) : 0
end
def gain_item(id, n)
@items[@actors[0].id] = {} unless @items[@actors[0].id]
if item_id > 0
@items[@actors[0].id][id] = [[item_number(id) + n, 0].max, 99].min
end
end
def gain_weapon(id, n)
@weapons[@actors[0].id] = {} unless @weapons[@actors[0].id]
if id > 0
@weapons[@actors[0].id][id] = [[weapon_number(id) + n, 0].max, 99].min
end
end
def gain_armor(id, n)
@armors[@actors[0].id] = {} unless @armors[@actors[0].id]
if id > 0
@armors[@actors[0].id][id] = [[armor_number(id) + n, 0].max, 99].min
end
end
end
以下是第二种实现方法(同样未经测试):
class Bag def initialize @data = {} end def [](id) return nil unless @data[$game_party.actors[0].id] return @data[$game_party.actors[0].id][id] end def []=(id, n) @data = {} unless @data[$game_party.actors[0].id] @data[$game_party.actors[0].id][id] = n end end class Game_Party alias multi_bag_init initialize unless defined?(multi_bag_init) def initialize multi_bag_init @items = Bag.new @weapons = Bag.new @armor = Bag.new end end
class Bag
def initialize
@data = {}
end
def [](id)
return nil unless @data[$game_party.actors[0].id]
return @data[$game_party.actors[0].id][id]
end
def []=(id, n)
@data = {} unless @data[$game_party.actors[0].id]
@data[$game_party.actors[0].id][id] = n
end
end
class Game_Party
alias multi_bag_init initialize unless defined?(multi_bag_init)
def initialize
multi_bag_init
@items = Bag.new
@weapons = Bag.new
@armor = Bag.new
end
end
从第二种方法可以简单实现更多种多背包,比如说让背包根据一号变量而定,(其实第一种方法也能做到)
class Bag def initialize @data = {} end def [](id) return nil unless @data[$game_variables[1]] return @data[$game_variables[1]][id] end def []=(id, n) @data = {} unless @data[$game_variables[1]] @data[$game_variables[1]][id] = n end end class Game_Party alias multi_bag_init initialize unless defined?(multi_bag_init) def initialize multi_bag_init @items = Bag.new @weapons = Bag.new @armor = Bag.new end end
class Bag
def initialize
@data = {}
end
def [](id)
return nil unless @data[$game_variables[1]]
return @data[$game_variables[1]][id]
end
def []=(id, n)
@data = {} unless @data[$game_variables[1]]
@data[$game_variables[1]][id] = n
end
end
class Game_Party
alias multi_bag_init initialize unless defined?(multi_bag_init)
def initialize
multi_bag_init
@items = Bag.new
@weapons = Bag.new
@armor = Bag.new
end
end
理论上只要你会一些脚本你就能从第二种方法中延伸出各种各样的多重背包。 |