查看: 2706|回复: 2

物品的能否使用判定

[复制链接]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 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
星屑
42235
在线时间
6017 小时
注册时间
2006-11-10
回帖
6966
发表于 2020-8-18 09:49:53 | 显示全部楼层
这个是在道具的伤害结算里判断的, 判断角色的HPSP状态都没发生变化, 且道具不带公共事件的时候, 会返回 false, 菜单中会根据这个返回值判断是否可以使用药品(技能也是如此)

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

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

使用道具 举报

梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2020-8-18 12:52:05 | 显示全部楼层
本帖最后由 alexncf125 于 2020-8-19 08:31 编辑

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

[pre lang="ruby"]
  #------------------------------------------------- -------------------------
  # ● 角色“确定”
  #------------------------------------------------- -------------------------
  def on_actor_ok

    #[url]https://rpg.blue/forum.php?mod=viewthread&tid=411480

    #当在菜单对我方使用了一个包含了行动限制状态的道具时角色会进入行动限制的状态,
    #此时若我方全部人员都被限制了行动,则道具显示变成灰色,
    #但是光标仍然留在选择道具的目标窗口,此时如果再点击一次确定键就会报错。
    #将【Scene_ItemBase】的第65行改成 if user and item_usable?

    if item_target_actors && item_usable? #~这里用不用加 item_target_actors (?,还是直接 if item_usable?
      BattleManager.actor.input.target_index = @actor_window.index
      @actor_window.hide
      @skill_window.hide
      @item_window.hide
      next_command
    else
      BattleManager.actor.input.target_index = @actor_window.index #~这句是有什么用途的? 要不要删去??
      @actor_window.activate
      Sound.play_buzzer
    end
  end
  #------------------------------------------------- -------------------------
  # ● 获取物品的使用目标数组
  #------------------------------------------------- -------------------------
  def item_target_actors
    item = @item_window.item
    if !item.for_friend?
      []
    elsif item.for_all?
      $game_party.members
    else
      [$game_party.members[@actor_window.index]]
    end
  end
  #------------------------------------------------- -------------------------
  # ● 判定物品是否可以使用
  #------------------------------------------------- -------------------------
  def item_usable?
    item = @item_window.item
    item_target_actors.any? do |target|
      target.usable?(item) && item_effects_valid?
    end
  end
  #------------------------------------------------- -------------------------
  # ● 判定物品的效果是否有效
  #------------------------------------------------- -------------------------
  def item_effects_valid?
    item = @item_window.item
    item_target_actors.any? do |target|
      target.item_test(target, item) #~ 在【Scene_ItemBase】中是 target.item_test(user, item)
                                         #~ 我改成 target.item_test(target, item) 是不是不对?
    end
  end[/pre]
以上是魔改自【Scene_ItemBase】的

[pre lang="ruby"]
  #------------------------------------------------- -------------------------
  # ● 获取物品的使用目标数组
  #------------------------------------------------- -------------------------
  def item_target_actors
    if !item.for_friend?
      []
    elsif item.for_all?
      $game_party.members
    else
      [$game_party.members[@actor_window.index]]
    end
  end
  #------------------------------------------------- -------------------------
  # ● 判定物品是否可以使用
  #------------------------------------------------- -------------------------
  def item_usable?
    user.usable?(item) && item_effects_valid?
  end
  #------------------------------------------------- -------------------------
  # ● 判定物品的效果是否有效
  #------------------------------------------------- -------------------------
  def item_effects_valid?
    item_target_actors.any? do |target|
      target.item_test(user, item)
    end
  end[/pre]
总体来说,我把【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
复制代码


星潟的脚本[pre lang="ruby"]#==============================================================================
# ■ RGSS3 无法使用时角色脸图半透明化&文本显示 Ver1.00 by 星潟
#------------------------------------------------------------------------------
# 物品画面和技能画面中使用物品时,如果无法对某个角色使用
# 该角色的脸图会半透明
# 并且显示一个文本。
# 一般情况下只支持默认使用物品系统。
#==============================================================================
module T_UNUSE_ITEM
  
  #无法使用时在脸图上显示的文字。
  
  WORD = "-不可用-"
  
  #修改文字y坐标。
  #0~3为较合适的范围。(可以使用小数)
  
  LINE = 3
  
end
class Game_Temp
  attr_accessor :temp_unuse_item
  attr_accessor :temp_unuse_actor
end
class Window_Base < Window
  #--------------------------------------------------------------------------
  # 顔グラフィック描写
  #--------------------------------------------------------------------------
  alias draw_actor_face_unuse_inv_face draw_actor_face
  def draw_actor_face(actor, x, y, enabled = true)
   
    #使用不可メッセージの表示フラグを設定
   
    flag = false
   
    #本来の表示フラグが有効であり
    #なおかつ、使用者情報及びアイテム情報が存在する場合は
    #アイテム情報にあるアイテムの使用可否を以て
    #使用不可メッセージと顔グラフィックの表示フラグを変更する。
   
    if $game_temp.temp_unuse_item != nil && !actor.item_test($game_temp.temp_unuse_actor, $game_temp.temp_unuse_item)
      
      enabled = false
   
      flag = true
      
    end
   
    #本来の処理を実行する。
   
    draw_actor_face_unuse_inv_face(actor, x, y, enabled)
   
    #使用不可メッセージを描写。
   
    draw_text(x, y + line_height * T_UNUSE_ITEM::LINE, 96, line_height, T_UNUSE_ITEM::WORD, 1) if flag
   
  end
end
class Scene_Base
  #--------------------------------------------------------------------------
  # 終了
  #--------------------------------------------------------------------------
  alias terminate_unuse_inv_face terminate
  def terminate
   
    #アイテムの情報を消去する。
   
    $game_temp.temp_unuse_item = nil
   
    #使用者の情報を消去する。
   
    $game_temp.temp_unuse_actor = nil
   
    #本来の処理を実行する。
   
    terminate_unuse_inv_face
  end
end
class Scene_ItemBase < Scene_MenuBase
  #--------------------------------------------------------------------------
  # アイテムの決定
  #--------------------------------------------------------------------------
  alias determine_item_unuse_inv_face determine_item
  def determine_item
   
    #アイテムの情報を記録する。
   
    $game_temp.temp_unuse_item = item
   
    #使用者の情報を記録する。
   
    $game_temp.temp_unuse_actor = user
   
    #本来の処理を実行する。
   
    determine_item_unuse_inv_face
  end
  #--------------------------------------------------------------------------
  # サブウィンドウの表示
  #--------------------------------------------------------------------------
  alias show_sub_window_unuse_inv_face show_sub_window
  def show_sub_window(window)
   
    #サブウィンドウをリフレッシュし、顔グラフィックを変更しておく。
   
    window.refresh
   
    #本来の処理を実行する。
   
    show_sub_window_unuse_inv_face(window)
  end
end[/pre]

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部