查看: 3354|回复: 6

[已经解决] 转职道具

[复制链接]
梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
发表于 2019-2-10 22:06:34 | 显示全部楼层 |阅读模式

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

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

×
下面这个脚本是道具加上备注转职的,问下要是加些条件转职能实现吗,例如到一定等级才能使用这个道具转职
或者只有特定的角色使用才能转职,或者是某种职业的前提下用该道具才能转职
知道的告诉下,谢谢


  1. class RPG::Item
  2.   def transfer_index
  3.     /<TRANSFER\s*(\d+)>/ =~ note ? $1.to_i : 0
  4.   end
  5. end


  6. class Scene_ItemBase
  7.   
  8.   #--------------------------------------------------------------------------
  9.   # ● 对角色使用物品
  10.   #--------------------------------------------------------------------------
  11.   def use_item_to_actors
  12.     item_target_actors.each do |target|
  13.       item.repeats.times {
  14.         target.item_apply(user, item)
  15.         use_transfer_item(target, item.transfer_index) if item.transfer_index > 0
  16.       }
  17.     end
  18.   end
  19.   
  20.   def use_transfer_item(user, index)
  21.     user.change_class(index, true)
  22.   end
  23.   
  24. end
复制代码
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-2-11 00:28:50 | 显示全部楼层
在原脚本下面插入这个脚本
  1. #  使用方法
  2. #  物品备注中写<condition>xxx</condition> 支持多行
  3. #  用user代表使用者,s[n]和v[n]分别代表n号开关和变量
  4. #
  5. #  例 <condition>user.level > 9</condition> # 使用者等级大于9才能用
  6. #     <condition>s[1] && v[1] > 5</condition> # 1号开关开启且1号变量大于5才能用
  7. #     其他用法参考伤害公式

  8. class Game_Actor
  9.   #--------------------------------------------------------------------------
  10.   # ● 技能/物品的应用测试
  11.   #    如果使用目标的 HP 或者 MP 全满时,禁止使用恢复道具。
  12.   #--------------------------------------------------------------------------
  13.   alias item_test_for_class_transfer item_test
  14.   def item_test(user, item)
  15.     if item.transfer_index != 0
  16.       return false unless item.transfer_ok?(self)
  17.     end
  18.     item_test_for_class_transfer(user, item)
  19.   end
  20. end

  21. class RPG::Item
  22.   def transfer_ok?(user)
  23.     s = $game_switches
  24.     v = $game_variables
  25.     self.note =~ /<condition>((?:.\s?)+)<\/condition>/mi ? eval($1) : true
  26.   end
  27. end

复制代码


具体用法见注释及范例。
Project1.zip (1.43 MB, 下载次数: 75)

点评

关于楼主需要的条件,这里提供几个思路。把n换成对应的数字。①user.level > n ②user == $game_actors[n] ③user.class_id == n  发表于 2019-2-11 00:31

评分

参与人数 2星屑 +40 赞 +1 收起 理由
VIPArcher + 40 认可答案
fjm + 1 认可答案

查看全部评分

用头画头像,用脚写脚本
回复

使用道具 举报

梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
 楼主| 发表于 2019-2-11 12:21:41 | 显示全部楼层
KB.Driver 发表于 2019-2-11 00:28
在原脚本下面插入这个脚本
#  使用方法
#  物品备注中写xxx 支持多行

非常感谢,可以用了
回复

使用道具 举报

梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
 楼主| 发表于 2019-2-11 13:56:22 | 显示全部楼层
KB.Driver 发表于 2019-2-11 00:28
在原脚本下面插入这个脚本
#  使用方法
#  物品备注中写xxx 支持多行

刚才试了下战斗的时候,放全体回复技能会报错,这个可以解决吗
回复

使用道具 举报

梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2019-2-11 14:12:50 | 显示全部楼层
本帖最后由 KB.Driver 于 2019-2-11 14:25 编辑
fjm 发表于 2019-2-11 13:56
刚才试了下战斗的时候,放全体回复技能会报错,这个可以解决吗


麻烦截图发一下报错的窗口,如果有完整工程最好。
不过我大致猜到了,应该是因为RPG::Skill没有定义transfer_index方法。
你把范例工程里的222脚本换成这个

  1. #  使用方法
  2. #  物品备注中写<condition>xxx</condition> 支持多行
  3. #  用user代表使用者,s[n]和v[n]分别代表n号开关和变量
  4. #
  5. #  例 <condition>user.level > 9</condition> # 使用者等级大于9才能用
  6. #     <condition>s[1] && v[1] > 5</condition> # 1号开关开启且1号变量大于5才能用
  7. #     其他用法参考伤害公式

  8. class Game_Actor
  9.   #--------------------------------------------------------------------------
  10.   # ● 技能/物品的应用测试
  11.   #    如果使用目标的 HP 或者 MP 全满时,禁止使用恢复道具。
  12.   #--------------------------------------------------------------------------
  13.   alias item_test_for_class_transfer item_test
  14.   def item_test(user, item)
  15.     if item.is_a?(RPG::Item) && item.transfer_index != 0
  16.       return false unless item.transfer_ok?(self)
  17.     end
  18.     item_test_for_class_transfer(user, item)
  19.   end
  20. end

  21. class RPG::Item
  22.   def transfer_ok?(user)
  23.     s = $game_switches
  24.     v = $game_variables
  25.     self.note =~ /<condition>((?:.\s?)+)<\/condition>/mi ? eval($1) : true
  26.   end
  27. end
复制代码


另外,好像发现这个只对菜单中使用物品有效。
你把转职道具设置成只有菜单能用就没问题了。
用头画头像,用脚写脚本
回复

使用道具 举报

梦石
0
星屑
2245
在线时间
1015 小时
注册时间
2015-10-17
回帖
1077
 楼主| 发表于 2019-2-11 14:31:23 | 显示全部楼层
KB.Driver 发表于 2019-2-11 14:12
麻烦截图发一下报错的窗口,如果有完整工程最好。
不过我大致猜到了,应该是因为RPG::Skill没有定义trans ...

非常感谢,现在战斗时没问题了
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部