查看: 2428|回复: 1

[已经解决] (新人)求教如何弄装备上限等级

[复制链接]
梦石
0
星屑
50
在线时间
23 小时
注册时间
2015-2-1
回帖
4
发表于 2015-2-2 17:41:57 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
比如:10级才能装备布衣
梦石
0
星屑
9557
在线时间
5074 小时
注册时间
2013-6-21
回帖
3459

开拓者贵宾剧作品鉴家

发表于 2015-2-2 20:15:50 | 显示全部楼层
顺手写了一个,未测试。
插入到Main前,此脚本可能造成脚本冲突。
用法为在需要等级限制的装备的说明处,写上%lvl[最低等级],例如,如果想让布衣的最低装备等级为10,则再布衣的说明处写%lvl[10](位置任意)
注意,当使用事件指令【变更装备】时,具有等级限制的装备仍然可以强制被装备到角色身上。
  1. module RPG
  2.   class Weapon
  3.     Regex_Lvl_Need = /%lvl\[(\d+)\]/
  4.     unless method_defined? :rb_description_20150202
  5.       alias rb_description_20150202 description
  6.       def description
  7.         return rb_description_20150202.gsub(Regex_Lvl_Need, "")
  8.       end
  9.     end
  10.     def level_need
  11.       Regex_Lvl_Need =~ @description
  12.       return $1.to_i
  13.     end
  14.   end
  15.   class Armor
  16.     Regex_Lvl_Need = /%lvl\[(\d+)\]/
  17.     unless method_defined? :rb_description_20150202
  18.       alias rb_description_20150202 description
  19.       def description
  20.         return rb_description_20150202.gsub(Regex_Lvl_Need, "")
  21.       end
  22.     end
  23.     def level_need
  24.       Regex_Lvl_Need =~ @description
  25.       return $1.to_i
  26.     end
  27.   end
  28. end

  29. class Game_Actor < Game_Battler
  30.   def can_equip?(equipment)
  31.     return true if equipment.nil?
  32.     return self.level >= equipment.level_need
  33.   end
  34. end

  35. class Window_EquipItem < Window_Selectable
  36.   def draw_item(index)
  37.     item = @data[index]
  38.     x = 4 + index % 2 * (288 + 32)
  39.     y = index / 2 * 32
  40.     case item
  41.     when RPG::Weapon
  42.       number = $game_party.weapon_number(item.id)
  43.     when RPG::Armor
  44.       number = $game_party.armor_number(item.id)
  45.     end
  46.     bitmap = RPG::Cache.icon(item.icon_name)
  47.     opacity = @actor.can_equip?(item) ? 255 : 128
  48.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  49.     self.contents.font.color = @actor.can_equip?(item) ? normal_color : disabled_color
  50.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  51.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  52.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  53.   end
  54.   def update_help
  55.     text = @actor.can_equip?(self.item) ? "" : sprintf("(角色需要达到LV%d)", self.item.level_need)
  56.     @help_window.set_text(self.item == nil ? "" : self.item.description + text)
  57.   end
  58. end

  59. class Scene_Equip
  60.   def update_item
  61.     # 按下 B 键的情况下
  62.     if Input.trigger?(Input::B)
  63.       # 演奏取消 SE
  64.       $game_system.se_play($data_system.cancel_se)
  65.       # 激活右侧窗口
  66.       @right_window.active = true
  67.       @item_window.active = false
  68.       @item_window.index = -1
  69.       return
  70.     end
  71.     # 按下 C 键的情况下
  72.     if Input.trigger?(Input::C)
  73.       # 获取物品窗口现在选择的装备数据
  74.       item = @item_window.item
  75.       unless @actor.can_equip?(item)
  76.         $game_system.se_play($data_system.buzzer_se)
  77.         return
  78.       end
  79.       # 演奏装备 SE
  80.       $game_system.se_play($data_system.equip_se)
  81.       # 变更装备
  82.       @actor.equip(@right_window.index, item == nil ? 0 : item.id)
  83.       # 激活右侧窗口
  84.       @right_window.active = true
  85.       @item_window.active = false
  86.       @item_window.index = -1
  87.       # 再生成右侧窗口、物品窗口的内容
  88.       @right_window.refresh
  89.       @item_window.refresh
  90.       return
  91.     end
  92.   end
  93. end
复制代码

点评

谢谢  发表于 2015-2-16 15:12
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部