查看: 1498|回复: 0

利用开关禁止使用道具

[复制链接]

…あたしは天

梦石
0
星屑
2308
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2014-5-21 15:49:06 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 taroxd 于 2014-10-2 21:04 编辑

[pre lang="ruby" line="1"]

#--------------------------------------------------------------------------
# ● require Taroxd基础设置
#    使用方法:技能/道具备注以下内容
#    <unusable x> 或 <usable -x> :当 x 号开关开启时,技能/道具禁止使用
#    <usable x> 或 <unusable -x> :当 x 号开关关闭时,技能/道具禁止使用
#--------------------------------------------------------------------------

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● 获取开关 ID 构成的数组
  #--------------------------------------------------------------------------
  def unusable_switches
    @unusable_switches ||=
    @note.scan(/<(UN)?USABLE\s+(-*\d+)>/i).map {|(un, id)|
      un ? id.to_i : -id.to_i }.uniq
  end
end

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 检查技能/物品的使用条件
  #--------------------------------------------------------------------------
  id_ok = ->(id) { (id > 0) ^ $game_switches[id.abs] }
  ok = ->(old, item) { old && item.unusable_switches.all?(&id_ok) }
  def_with :usable_item_conditions_met?, ok
end[/pre]

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

在本发帖返回顶部