Project1

标题: 如何在一定条件下禁用某种物品 [打印本页]

作者: 造小梦    时间: 2019-2-14 11:50
标题: 如何在一定条件下禁用某种物品
就是当某个物品使用X次时就不能再使用了,这需要脚本吗?求大佬指点
作者: 百里_飞柳    时间: 2019-2-14 13:22
如果这个物品全局只能获得一个的话,可以通过调用公共事件来变更一个特定的变量,然后当变量加到指定值时,失去该物品,也可以重新获得一个不可使用的物品
作者: KB.Driver    时间: 2019-2-14 13:40
RUBY 代码复制
  1. #==============================================================================
  2. # ■ 自定义物品/技能使用条件 by Calendar99
  3. #------------------------------------------------------------------------------
  4. #  使用方法
  5. #  物品/技能备注中写<condition>xxx</condition> xxx为条件,支持多行
  6. #  condition也可以换成使用条件或者条件
  7. #  用user代表使用者,s[n]和v[n]分别代表n号开关和变量
  8. #
  9. #  例 <condition>user.level > 9</condition>   # 使用者等级大于9才能用
  10. #     <使用条件>s[1] && v[1] > 5</使用条件>    # 1号开关开启且1号变量大于5才能用
  11. #     <条件>s[1] && v[1] > 5</条件>    # 1号开关开启且1号变量大于5才能用
  12. #     其他用法参考伤害公式
  13. #==============================================================================
  14. class RPG::UsableItem
  15.   TAG = "(?:condition|(?:使用)?条件)"
  16.   #--------------------------------------------------------------------------
  17.   # ● [追加]自定义条件是否满足
  18.   #--------------------------------------------------------------------------
  19.   def condition_ok?(user)
  20.     s = $game_switches
  21.     v = $game_variables
  22.     self.note =~ /<#{TAG}>((?:.\s?)+)<\/#{TAG}>/mi ? eval($1) : true
  23.   end
  24. end
  25.  
  26. class Game_Actor
  27.   #--------------------------------------------------------------------------
  28.   # ● [别名修改]技能/物品的应用测试
  29.   #--------------------------------------------------------------------------
  30.   alias item_test_for_eval_condition item_test
  31.   def item_test(user, item)
  32.     return false unless item.condition_ok?(self) # self为使用者
  33.     item_test_for_eval_condition(user, item)
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● [别名修改]判定技能/使用物品是否可用
  37.   #--------------------------------------------------------------------------
  38.   alias usable_for_eval_condition usable?
  39.   def usable?(item)
  40.     return false unless extra_condition_met?(item)
  41.     usable_for_eval_condition(item)
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● [追加]判定技能/使用物品是否可用的额外条件
  45.   #--------------------------------------------------------------------------
  46.   def extra_condition_met?(item)
  47.     item.is_a?(RPG::UsableItem) && item.condition_ok?(self) # self为使用者
  48.   end
  49. end
  50.  
  51. class Window_BattleItem < Window_ItemList
  52.   #--------------------------------------------------------------------------
  53.   # ● [别名修改]查询使用列表中是否含有此物品
  54.   #--------------------------------------------------------------------------
  55.   alias include_for_eval_condition include?
  56.   def include?(item)
  57.     original_usable = BattleManager.actor.usable_for_eval_condition(item)
  58.     include_for_eval_condition(item) || original_usable
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● [子类覆盖]查询此物品是否可用
  62.   #--------------------------------------------------------------------------
  63.   def enable?(item)
  64.     BattleManager.actor.usable?(item)
  65.   end
  66. end


物品特殊效果启动公共事件,在里面将变量1的值+1

物品备注写
RUBY 代码复制
  1. <condition>
  2. v[1] < 1 # 1号变量小于1才能用
  3. </condition>

作者: 造小梦    时间: 2019-2-14 15:37
KB.Driver 发表于 2019-2-14 13:40
#==============================================================================
# ■ 自定义物品/技能 ...

感谢大佬!




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1