查看: 2822|回复: 6

[已经解决] 求教一下设计一个不能吃药的角色问题

[复制链接]
梦石
0
星屑
2019
在线时间
940 小时
注册时间
2015-10-26
回帖
293

开拓者

发表于 2018-11-28 21:13:19 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 踢腿水上飘 于 2018-11-29 06:41 编辑

我想设计一个不能对其使用恢复道具的角色
本来我的思路是在
[pre lang="ruby"]  def item_test(user, item)
    return false if item.for_dead_friend? != dead?
    return true if $game_party.in_battle
    return true if item.for_opponent?
    return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
    return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
    return true if item_has_any_valid_effects?(user, item)
    return false
  end[/pre]
里面插入一行
[pre lang="ruby"]    return false if self ==  $game_actors[2][/pre]

结果发现战斗是还是可以对该角色使用恢复道具,只不过是不会产生效果罢了,离目标还差一点
如何才能做到直接不让对他用药?
梦石
8
星屑
4809
在线时间
1568 小时
注册时间
2014-1-9
回帖
373

开拓者

发表于 2018-11-28 21:32:10 | 显示全部楼层
[pre lang="ruby"]class Game_Actor
  alias hawkeye_no_recovery_item_item_conditions_met? item_conditions_met?
  def item_conditions_met?(item)
    hawkeye_no_recovery_item_item_conditions_met?(item) && !(/<禁用恢复道具>/ =~ actor.note && /<恢复道具>/ =~ item.note)
  end
end[/pre]

使用方法:在恢复道具的备注区写<恢复道具>,在禁用恢复道具的角色的备注区写<禁用恢复道具>
回复

使用道具 举报

梦石
0
星屑
2019
在线时间
940 小时
注册时间
2015-10-26
回帖
293

开拓者

 楼主| 发表于 2018-11-29 06:41:43 | 显示全部楼层
余音·魔眼 发表于 2018-11-28 21:32
class Game_Actor
  alias hawkeye_no_recovery_item_item_conditions_met? item_conditions_met?
  def it ...

你这个和我的方法效果一样啊,在战斗中还是可以给她用药,只是用了药也没效果而已~
回复

使用道具 举报

梦石
0
星屑
7427
在线时间
948 小时
注册时间
2017-9-27
回帖
566
发表于 2018-11-29 09:28:57 | 显示全部楼层
我觉得你应该在“选择使用物品的目标”这一步上做筛选。
回复

使用道具 举报

梦石
8
星屑
4809
在线时间
1568 小时
注册时间
2014-1-9
回帖
373

开拓者

发表于 2018-11-30 17:18:59 | 显示全部楼层
[pre lang="ruby"]class Game_Actor
  alias hawkeye_no_recovery_item_item_test item_test
  def item_test(user, item)
    return false if /<禁用恢复道具>/ =~ actor.note && /<恢复道具>/ =~ item.note
    hawkeye_no_recovery_item_item_test(user, item)
  end
end
class Window_BattleItem
  alias hawkeye_no_recovery_item_enable? enable?
  def enable?(item)
    actor = BattleManager.actor.actor
    hawkeye_no_recovery_item_enable?(item) && !(/<禁用恢复道具>/ =~ actor.note && /<恢复道具>/ =~ item.note)
  end
end[/pre]

点评

不知道你有没有插入什么其他脚本,反正我测试了是好的。  发表于 2018-12-6 21:16
还是一样呀  发表于 2018-12-3 20:08
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部