赞 | 6 |
VIP | 4 |
好人卡 | 58 |
积分 | 5 |
经验 | 58579 |
最后登录 | 2024-6-30 |
在线时间 | 1478 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 508
- 在线时间
- 1478 小时
- 注册时间
- 2011-9-17
- 帖子
- 1316
|
本帖最后由 iisnow 于 2011-10-28 09:48 编辑
刚刚自己写的脚本:
试试吧!可能背包总格子方面还没有考虑,要考虑的话,我就去稍微改一下好了- module ITEM_APART
-
- MAX = 999 # 默认最多携带量
-
- end
- # 用法说明:在物品的描述后加@再加上最大叠加数即可:
- # 例如:己方单体 HP 回复。@50
- class Game_Party
-
- include ITEM_APART
- def initialize
- # 建立角色序列
- @actors = []
- # 初始化金钱与步数
- @gold = 0
- @steps = 0
- # 生成物品、武器、防具的所持数 hash
- @items = {}
- @weapons = {}
- @armors = {}
- @limt = [] # 生成个物品可叠加数
- get_limit
- end
-
- def gain_item(item_id, n)
- # 更新 hash 的个数数据
- if item_id > 0
- @items[item_id] = [[item_number(item_id) + n, 0].max ,MAX].min
- end
- end
-
- def limt(id)
- return @limt[id]
- end
-
- def get_limit
- for i in 1...$data_items.size
- @limt[i] = $data_items[i].description.split("@")[1].to_i
- end
- end
-
- end
- class Window_Item < Window_Selectable
-
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # 添加报务
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- if $game_party.item_number(i) > $game_party.limt(i)
- part_num = $game_party.item_number(i) / $game_party.limt(i)
- if $game_party.item_number(i) % $game_party.limt(i) != 0
- part_num += 1
- end
- for p in 0...part_num
- @data.push($data_items[i])
- end
- end
- end
- end
- # 在战斗中以外添加武器、防具
- unless $game_temp.in_battle
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- @data.push($data_armors[i])
- end
- end
- end
- # 如果项目数不是 0 就生成位图、重新描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
-
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- if @data[index + 1] == item
- number = $game_party.limt(item.id)
- else
- number = $game_party.item_number(item.id) % $game_party.limt(item.id)
- if number == 0
- number = $game_party.limt(item.id)
- end
- end
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- if item.is_a?(RPG::Item) and
- $game_party.item_can_use?(item.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
- end
-
- end
-
复制代码 大致是这个样子:
可能还要改改那个描述显示,加上:
description.split("@")[0]
就可以了 |
|