查看: 2797|回复: 2

物品的能否使用判定

[复制链接]
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
发表于 2020-8-17 14:42:53 | 显示全部楼层 |阅读模式

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

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

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

在地图上因全部角色都滿血而无法使用的药水,
怎么到战斗中就会变得即使滿血也能被使用了!
我明明都已经把Game_Battler內def item_test(user, item)的
return true if $game_party.in_battle注释了,难道不是这句?
梦石
0
星屑
42345
在线时间
6022 小时
注册时间
2006-11-10
回帖
6975
发表于 2020-8-18 09:49:53 | 显示全部楼层
这个是在道具的伤害结算里判断的, 判断角色的HPSP状态都没发生变化, 且道具不带公共事件的时候, 会返回 false, 菜单中会根据这个返回值判断是否可以使用药品(技能也是如此)

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

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

使用道具 举报

梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 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 魔改成以下的样子


  1.   #------------------------------------------------- -------------------------
  2.   # ● 角色“确定”
  3.   #------------------------------------------------- -------------------------
  4.   def on_actor_ok

  5.     #[url]https://rpg.blue/forum.php?mod=viewthread&tid=411480[/url]
  6.     #当在菜单对我方使用了一个包含了行动限制状态的道具时角色会进入行动限制的状态,
  7.     #此时若我方全部人员都被限制了行动,则道具显示变成灰色,
  8.     #但是光标仍然留在选择道具的目标窗口,此时如果再点击一次确定键就会报错。
  9.     #将【Scene_ItemBase】的第65行改成 if user and item_usable?

  10.     if item_target_actors && item_usable? #~这里用不用加 item_target_actors (?,还是直接 if item_usable?
  11.       BattleManager.actor.input.target_index = @actor_window.index
  12.       @actor_window.hide
  13.       @skill_window.hide
  14.       @item_window.hide
  15.       next_command
  16.     else
  17.       BattleManager.actor.input.target_index = @actor_window.index #~这句是有什么用途的? 要不要删去??
  18.       @actor_window.activate
  19.       Sound.play_buzzer
  20.     end
  21.   end
  22.   #------------------------------------------------- -------------------------
  23.   # ● 获取物品的使用目标数组
  24.   #------------------------------------------------- -------------------------
  25.   def item_target_actors
  26.     item = @item_window.item
  27.     if !item.for_friend?
  28.       []
  29.     elsif item.for_all?
  30.       $game_party.members
  31.     else
  32.       [$game_party.members[@actor_window.index]]
  33.     end
  34.   end
  35.   #------------------------------------------------- -------------------------
  36.   # ● 判定物品是否可以使用
  37.   #------------------------------------------------- -------------------------
  38.   def item_usable?
  39.     item = @item_window.item
  40.     item_target_actors.any? do |target|
  41.       target.usable?(item) && item_effects_valid?
  42.     end
  43.   end
  44.   #------------------------------------------------- -------------------------
  45.   # ● 判定物品的效果是否有效
  46.   #------------------------------------------------- -------------------------
  47.   def item_effects_valid?
  48.     item = @item_window.item
  49.     item_target_actors.any? do |target|
  50.       target.item_test(target, item) #~ 在【Scene_ItemBase】中是 target.item_test(user, item)
  51.                                          #~ 我改成 target.item_test(target, item) 是不是不对?
  52.     end
  53.   end
复制代码

以上是魔改自【Scene_ItemBase】的


  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
复制代码


星潟的脚本
  1. #==============================================================================
  2. # ■ RGSS3 无法使用时角色脸图半透明化&文本显示 Ver1.00 by 星潟
  3. #------------------------------------------------------------------------------
  4. # 物品画面和技能画面中使用物品时,如果无法对某个角色使用
  5. # 该角色的脸图会半透明
  6. # 并且显示一个文本。
  7. # 一般情况下只支持默认使用物品系统。
  8. #==============================================================================
  9. module T_UNUSE_ITEM
  10.   
  11.   #无法使用时在脸图上显示的文字。
  12.   
  13.   WORD = "-不可用-"
  14.   
  15.   #修改文字y坐标。
  16.   #0~3为较合适的范围。(可以使用小数)
  17.   
  18.   LINE = 3
  19.   
  20. end
  21. class Game_Temp
  22.   attr_accessor :temp_unuse_item
  23.   attr_accessor :temp_unuse_actor
  24. end
  25. class Window_Base < Window
  26.   #--------------------------------------------------------------------------
  27.   # 顔グラフィック描写
  28.   #--------------------------------------------------------------------------
  29.   alias draw_actor_face_unuse_inv_face draw_actor_face
  30.   def draw_actor_face(actor, x, y, enabled = true)
  31.    
  32.     #使用不可メッセージの表示フラグを設定
  33.    
  34.     flag = false
  35.    
  36.     #本来の表示フラグが有効であり
  37.     #なおかつ、使用者情報及びアイテム情報が存在する場合は
  38.     #アイテム情報にあるアイテムの使用可否を以て
  39.     #使用不可メッセージと顔グラフィックの表示フラグを変更する。
  40.    
  41.     if $game_temp.temp_unuse_item != nil && !actor.item_test($game_temp.temp_unuse_actor, $game_temp.temp_unuse_item)
  42.       
  43.       enabled = false
  44.    
  45.       flag = true
  46.       
  47.     end
  48.    
  49.     #本来の処理を実行する。
  50.    
  51.     draw_actor_face_unuse_inv_face(actor, x, y, enabled)
  52.    
  53.     #使用不可メッセージを描写。
  54.    
  55.     draw_text(x, y + line_height * T_UNUSE_ITEM::LINE, 96, line_height, T_UNUSE_ITEM::WORD, 1) if flag
  56.    
  57.   end
  58. end
  59. class Scene_Base
  60.   #--------------------------------------------------------------------------
  61.   # 終了
  62.   #--------------------------------------------------------------------------
  63.   alias terminate_unuse_inv_face terminate
  64.   def terminate
  65.    
  66.     #アイテムの情報を消去する。
  67.    
  68.     $game_temp.temp_unuse_item = nil
  69.    
  70.     #使用者の情報を消去する。
  71.    
  72.     $game_temp.temp_unuse_actor = nil
  73.    
  74.     #本来の処理を実行する。
  75.    
  76.     terminate_unuse_inv_face
  77.   end
  78. end
  79. class Scene_ItemBase < Scene_MenuBase
  80.   #--------------------------------------------------------------------------
  81.   # アイテムの決定
  82.   #--------------------------------------------------------------------------
  83.   alias determine_item_unuse_inv_face determine_item
  84.   def determine_item
  85.    
  86.     #アイテムの情報を記録する。
  87.    
  88.     $game_temp.temp_unuse_item = item
  89.    
  90.     #使用者の情報を記録する。
  91.    
  92.     $game_temp.temp_unuse_actor = user
  93.    
  94.     #本来の処理を実行する。
  95.    
  96.     determine_item_unuse_inv_face
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # サブウィンドウの表示
  100.   #--------------------------------------------------------------------------
  101.   alias show_sub_window_unuse_inv_face show_sub_window
  102.   def show_sub_window(window)
  103.    
  104.     #サブウィンドウをリフレッシュし、顔グラフィックを変更しておく。
  105.    
  106.     window.refresh
  107.    
  108.     #本来の処理を実行する。
  109.    
  110.     show_sub_window_unuse_inv_face(window)
  111.   end
  112. end
复制代码

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部