本帖最后由 墨凌羽 于 2015-8-27 07:19 编辑
补脚本来了
Game_Party的gain_item替换成下边这个。然后在该类初始化的时候执行变量初始化操作(@max_item = 40 @item_sum = 0)其中@max_item是总的最大物品持有数。
说明:
1.物品超出没提示。想要提示自己写【大概改改map和shop就行
2.和上边限制单个物品数量上限的不冲突
#-------------------------------------------------------------------------- # ● 增加/减少物品 # include_equip : 是否包括装备 #-------------------------------------------------------------------------- def gain_item(item, amount, include_equip = false) container = item_container(item.class) return unless container if max_item_number(item) - item_number(item) < amount then amount = max_item_number(item) - item_number(item) end if @max_item - @item_sum < amount then amount = @max_item - @item_sum end @item_sum = @item_sum + amount last_number = item_number(item) new_number = last_number + amount container[item.id] = [[new_number, 0].max, max_item_number(item)].min container.delete(item.id) if container[item.id] == 0 if include_equip && new_number < 0 discard_members_equip(item, -new_number) end $game_map.need_refresh = true end
#--------------------------------------------------------------------------
# ● 增加/减少物品
# include_equip : 是否包括装备
#--------------------------------------------------------------------------
def gain_item(item, amount, include_equip = false)
container = item_container(item.class)
return unless container
if max_item_number(item) - item_number(item) < amount then
amount = max_item_number(item) - item_number(item)
end
if @max_item - @item_sum < amount then
amount = @max_item - @item_sum
end
@item_sum = @item_sum + amount
last_number = item_number(item)
new_number = last_number + amount
container[item.id] = [[new_number, 0].max, max_item_number(item)].min
container.delete(item.id) if container[item.id] == 0
if include_equip && new_number < 0
discard_members_equip(item, -new_number)
end
$game_map.need_refresh = true
end
|