| 赞 | 189 |
| VIP | |
| 好人卡 | |
| 积分 | 96 |
| 经验 | |
| 最后登录 | 2026-5-4 |
| 在线时间 | 5074 小时 |
- 梦石
- 0
- 星屑
- 9557
- 在线时间
- 5074 小时
- 注册时间
- 2013-6-21
- 回帖
- 3459
  
|
发表于 2015-2-2 20:15:50
|
显示全部楼层
顺手写了一个,未测试。
插入到Main前,此脚本可能造成脚本冲突。
用法为在需要等级限制的装备的说明处,写上%lvl[最低等级],例如,如果想让布衣的最低装备等级为10,则再布衣的说明处写%lvl[10](位置任意)
注意,当使用事件指令【变更装备】时,具有等级限制的装备仍然可以强制被装备到角色身上。
[pre lang="Ruby"]module RPG
class Weapon
Regex_Lvl_Need = /%lvl\[(\d+)\]/
unless method_defined? :rb_description_20150202
alias rb_description_20150202 description
def description
return rb_description_20150202.gsub(Regex_Lvl_Need, "")
end
end
def level_need
Regex_Lvl_Need =~ @description
return $1.to_i
end
end
class Armor
Regex_Lvl_Need = /%lvl\[(\d+)\]/
unless method_defined? :rb_description_20150202
alias rb_description_20150202 description
def description
return rb_description_20150202.gsub(Regex_Lvl_Need, "")
end
end
def level_need
Regex_Lvl_Need =~ @description
return $1.to_i
end
end
end
class Game_Actor < Game_Battler
def can_equip?(equipment)
return true if equipment.nil?
return self.level >= equipment.level_need
end
end
class Window_EquipItem < Window_Selectable
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
opacity = @actor.can_equip?(item) ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.font.color = @actor.can_equip?(item) ? normal_color : disabled_color
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
def update_help
text = @actor.can_equip?(self.item) ? "" : sprintf("(角色需要达到LV%d)", self.item.level_need)
@help_window.set_text(self.item == nil ? "" : self.item.description + text)
end
end
class Scene_Equip
def update_item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活右侧窗口
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品窗口现在选择的装备数据
item = @item_window.item
unless @actor.can_equip?(item)
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏装备 SE
$game_system.se_play($data_system.equip_se)
# 变更装备
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
# 激活右侧窗口
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# 再生成右侧窗口、物品窗口的内容
@right_window.refresh
@item_window.refresh
return
end
end
end
[/pre]
|
|