| 赞 | 5 |
| VIP | |
| 好人卡 | |
| 积分 | 39 |
| 经验 | |
| 最后登录 | 2026-8-3 |
| 在线时间 | 1899 小时 |
- 梦石
- 0
- 星屑
- 3850
- 在线时间
- 1899 小时
- 注册时间
- 2010-6-19
- 回帖
- 917
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
下面这个脚本已经添加了装备等级显示,如何给装备添加上等级限制。
[pre lang="ruby"]#==============================================================================
# ■ Fenlei_Command
#------------------------------------------------------------------------------
# 物品分类
#==============================================================================
class Fenlei_Command < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(22, 276+28, 365, 50)
self.contents = Bitmap.new(width - 32, height - 32)
@commands = ["", "", "", "",""]
# @commands = ["平时物品", "战斗物品", "武器装备", "宠物道具","任务道具"]
@item_max = 5
@column_max = 5
self.opacity = 0
self.z = 300
refresh
self.index = 0
# 更改窗口皮肤
self.windowskin = RPG::Cache.windowskin('物品皮肤/分类')
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
w = contents.text_size(@commands).width
x = i * 94
self.contents.font.color = normal_color
self.contents.draw_text(x, 0, w, 32, @commands)
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
# y = index * 32
self.contents.draw_text(0, y, 128, 32, @commands[index])
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(@commands[self.index])
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 34
# 计算光标坐标
x = @index % @column_max * (cursor_width+29)
# 更新国标矩形
self.cursor_rect.set(x-3, 0, cursor_width+26, 22)
end
end
#==============================================================================
# ■ Actor_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Actor_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(actor)
super(8, 326, 420, 270)
@column_max = 6
self.opacity = 0
self.z = 300
@actor = actor
refresh
self.index = -1
# 更改窗口皮肤
self.windowskin = RPG::Cache.windowskin('物品皮肤/物品')
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
end
#--------------------------------------------------------------------------
# ● 项目列表设置
# command : 选中的命令
#--------------------------------------------------------------------------
def set_item(command)
refresh
case command
# 平时物品
when 0
for i in 1...$data_items.size
# 选项在0-2时不显示11号属性的物品
if ($data_items.occasion == 0 or $data_items.occasion == 2) and $game_party.item_number(i) > 0 and $data_items.element_set.include?(11) == false
@data.push($data_items)
end
end
# 战斗物品
when 1
for i in 1...$data_items.size
if ($data_items.occasion == 1 and $game_party.item_number(i) > 0)
@data.push($data_items)
end
end
# 武器装备
when 2
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
@data.push(nil)
# 宠物道具
when 3
for i in 1...$data_items.size
# 显示11号和12号属性的物品
if $data_items.element_set.include?(11) or $data_items.element_set.include?(12) and $game_party.item_number(i) > 0
@data.push($data_items)
end
end
# 任务道具
when 4
for i in 1...$data_items.size
if $data_items.occasion == 3 and $game_party.item_number(i) > 0
# 不显示11号和12号属性的物品
unless $data_items.element_set.include?(11) or $data_items.element_set.include?(12)
@data.push($data_items)
end
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 59.5, row_max * 61)
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 按类型检索项目数
#--------------------------------------------------------------------------
def item_number
return @item_max
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
return if item.nil?
case item
when RPG::Item
number = $game_party.item_number(item.id)
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 = @actor.can_equip?(item) ? normal_color : disabled_color
####################################################
end
x = index % 6 * 59.5
y = (index / 6) * 60
rect = Rect.new(x, y, self.width - 59.5, 60)
bitmap = RPG::Cache.icon(item.icon_name)
opacity = 255
self.contents.blt(x, y , bitmap, Rect.new(0, 0, 59.5, 60), opacity)
self.contents.font.size = 18
# 字体加粗
self.contents.font.bold = true
self.contents.draw_text(x-4, y-7, 23, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
# 当没有物品时
if item == nil
# 关闭帮助窗口
@help_window.visible = false
else
# 打开帮助窗口
@help_window.visible = true
# 显示描述内容
@help_window.set_text(item)
#校正帮助窗口位置
@help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
end
end
#--------------------------------------------------------------------------
# ● 获取开头行
#--------------------------------------------------------------------------
def top_row
# 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
return self.oy / 60
end
#--------------------------------------------------------------------------
# ● 设置开头行
# row : 显示开头的行
#--------------------------------------------------------------------------
def top_row=(row)
# row 未满 0 的场合更正为 0
if row < 0
row = 0
end
# row 超过 row_max - 1 的情况下更正为 row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
self.oy = row * 60
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的行数
#--------------------------------------------------------------------------
def page_row_max
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
return (self.height) / 61
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的项目数
#--------------------------------------------------------------------------
def page_item_max
# 将行数 page_row_max 乘上列数 @column_max
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = 61
# 计算光标坐标
x = @index % @column_max * (cursor_width-1.5)
y = @index / @column_max * 60 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, 61)
end
end
# ■装备判断
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# 处理角色的类。本类在 Game_Actors 类 ($game_actors)
# 的内部使用、Game_Party 类请参考 ($game_party) 。
#==============================================================================
# 判断能否装备。
class Game_Actor < Game_Battler
def can_equip?(equip)
if equip.is_a?(RPG::Weapon)
set = $data_classes[@class_id].weapon_set
else
set = $data_classes[@class_id].armor_set
end
# 装备为无时返回
return true if equip.nil?
# 穿戴装备
return set.include?(equip.id)
end
end
# 装备等级限制
module RPG
class Weapon
def level
return 1 if @description.split(/★/)[1] == nil
return @description.split(/★/)[1]
end
def description
return @description.split(/★/)[0]
end
end
class Armor
def level
return 1 if @description.split(/★/)[1] == nil
return @description.split(/★/)[1]
end
def description
return @description.split(/★/)[0]
end
end
end[/pre] |
|