设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2349|回复: 2
打印 上一主题 下一主题

物品的能否使用判定

[复制链接]

Lv5.捕梦者

梦石
0
星屑
26102
在线时间
5263 小时
注册时间
2016-3-8
帖子
1652
跳转到指定楼层
1
发表于 2020-8-17 14:42:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 alexncf125 于 2024-1-25 13:16 编辑

在地图上因全部角色都滿血而无法使用的药水,
怎么到战斗中就会变得即使滿血也能被使用了!
我明明都已经把Game_Battler內def item_test(user, item)的
return true if $game_party.in_battle注释了,难道不是这句?

Lv5.捕梦者

梦石
0
星屑
39642
在线时间
5741 小时
注册时间
2006-11-10
帖子
6634
2
发表于 2020-8-18 09:49:53 | 只看该作者
这个是在道具的伤害结算里判断的, 判断角色的HPSP状态都没发生变化, 且道具不带公共事件的时候, 会返回 false, 菜单中会根据这个返回值判断是否可以使用药品(技能也是如此)

而战斗中没有调用这个值进行是否是无效用的判断, 毕竟战斗流程是先选择指令再后继执行结算的, 你选择指令的时候没掉血, 开打后怪物速度快先攻击就掉血了, 这个时候如果预先吃药就马上拉回血量咯, 有这样的战略意义存在,所以战斗中不禁满血恢复

因为手头没有VA, 所以不能指出是哪句,自己研究看看吧
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
26102
在线时间
5263 小时
注册时间
2016-3-8
帖子
1652
3
 楼主| 发表于 2020-8-18 12:52:05 | 只看该作者
本帖最后由 alexncf125 于 2020-8-19 08:31 编辑
[url=forum.php?mod=redirect&goto=findpost&pid=2900424&ptid=482902]灯笼菜刀王发表于2020-8-18 09:49[/ url]
这个是在道具的伤害结算里判断的, 判断角色的HPSP状态都没发生变化, 且道具不带公共事件的时候, 会返回 fal ...

研究完一阵子,现在除注释了【Game_Battler】中 item_test 内那句 return true if $game_party.in_battle 外
我还把【Scene_Battle】那段 def on_actor_ok 魔改成以下的样子

RUBY 代码复制
  1. #------------------------------------------------- -------------------------
  2.   # ● 角色“确定”
  3.   #------------------------------------------------- -------------------------
  4.   def on_actor_ok
  5.  
  6.     #[url]https://rpg.blue/forum.php?mod=viewthread&tid=411480[/url]
  7.     #当在菜单对我方使用了一个包含了行动限制状态的道具时角色会进入行动限制的状态,
  8.     #此时若我方全部人员都被限制了行动,则道具显示变成灰色,
  9.     #但是光标仍然留在选择道具的目标窗口,此时如果再点击一次确定键就会报错。
  10.     #将【Scene_ItemBase】的第65行改成 if user and item_usable?
  11.  
  12.     if item_target_actors && item_usable? #~这里用不用加 item_target_actors (?,还是直接 if item_usable?
  13.       BattleManager.actor.input.target_index = @actor_window.index
  14.       @actor_window.hide
  15.       @skill_window.hide
  16.       @item_window.hide
  17.       next_command
  18.     else
  19.       BattleManager.actor.input.target_index = @actor_window.index #~这句是有什么用途的? 要不要删去??
  20.       @actor_window.activate
  21.       Sound.play_buzzer
  22.     end
  23.   end
  24.   #------------------------------------------------- -------------------------
  25.   # ● 获取物品的使用目标数组
  26.   #------------------------------------------------- -------------------------
  27.   def item_target_actors
  28.     item = @item_window.item
  29.     if !item.for_friend?
  30.       []
  31.     elsif item.for_all?
  32.       $game_party.members
  33.     else
  34.       [$game_party.members[@actor_window.index]]
  35.     end
  36.   end
  37.   #------------------------------------------------- -------------------------
  38.   # ● 判定物品是否可以使用
  39.   #------------------------------------------------- -------------------------
  40.   def item_usable?
  41.     item = @item_window.item
  42.     item_target_actors.any? do |target|
  43.       target.usable?(item) && item_effects_valid?
  44.     end
  45.   end
  46.   #------------------------------------------------- -------------------------
  47.   # ● 判定物品的效果是否有效
  48.   #------------------------------------------------- -------------------------
  49.   def item_effects_valid?
  50.     item = @item_window.item
  51.     item_target_actors.any? do |target|
  52.       target.item_test(target, item) #~ 在【Scene_ItemBase】中是 target.item_test(user, item)
  53.                                          #~ 我改成 target.item_test(target, item) 是不是不对?
  54.     end
  55.   end

以上是魔改自【Scene_ItemBase】的

RUBY 代码复制
  1. #------------------------------------------------- -------------------------
  2.   # ● 获取物品的使用目标数组
  3.   #------------------------------------------------- -------------------------
  4.   def item_target_actors
  5.     if !item.for_friend?
  6.       []
  7.     elsif item.for_all?
  8.       $game_party.members
  9.     else
  10.       [$game_party.members[@actor_window.index]]
  11.     end
  12.   end
  13.   #------------------------------------------------- -------------------------
  14.   # ● 判定物品是否可以使用
  15.   #------------------------------------------------- -------------------------
  16.   def item_usable?
  17.     user.usable?(item) && item_effects_valid?
  18.   end
  19.   #------------------------------------------------- -------------------------
  20.   # ● 判定物品的效果是否有效
  21.   #------------------------------------------------- -------------------------
  22.   def item_effects_valid?
  23.     item_target_actors.any? do |target|
  24.       target.item_test(user, item)
  25.     end
  26.   end

总体来说,我把【Scene_ItemBase】的 user 换成了 item_target_actors.any? do |target| 的 target
和 item 换成了 @item_window.item 后,搬到【Scene_Battle】去了,也不知这样改有没有什么问题,大大能指点一下么?

另外如果我想搭配星泻的脚本使用,
是不是加上以下这段就可行了??


  1. class Scene_Battle < Scene_Base
  2.   alias on_item_ok_unuse_inv_face on_item_ok
  3.   def on_item_ok
  4.     $game_temp.temp_unuse_item = @item_window.item
  5.     item_target_actors.any? do |target|
  6.       $game_temp.temp_unuse_actor = target
  7.     end
  8.     on_item_ok_unuse_inv_face
  9.   end
  10. end
复制代码

星潟的脚本

回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-6-4 19:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表