查看: 3377|回复: 3

【仿宝可梦】连续招式的命中机制

[复制链接]
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
发表于 2020-1-3 22:59:10 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 alexncf125 于 2024-1-5 19:35 编辑

va默认下,连续技能每一次攻击时,其命中判定是独立的,因此会造成以下图片中,左方上至下的三种情况
230130c824tpp5tixtijt8.png
经过了一番修改,改成了只计算一次是否命中,只要第一次命中,所有攻击必定全中.因此会造成以上图片中,中間上至下的三种情况



问题来了,怎样改成最右面的情况?
(现在最右面的情况是改图改出来的)
梦石
0
星屑
29901
在线时间
5734 小时
注册时间
2016-3-8
回帖
1653
 楼主| 发表于 2020-1-3 23:08:39 | 显示全部楼层
Game_Battler第567行附近
[pre lang="ruby"]  #--------------------------------------------------------------------------
  # ● 計算技能/物品的成功幾率
  #--------------------------------------------------------------------------
  def item_hit(user, item)
    rate = item.success_rate * 0.01         # 獲取成功幾率
    rate *= user.hit if item.physical?      # 物理攻擊:計算成功幾率的乘積
    if item.is_a?(RPG::Skill) and item.id == 3
      if $game_variables[1] == 1
        return 1
      end
      if $game_variables[1] == 2
        return 0
      end
    end
    return rate                             # 返回計算后的成功幾率
  end[/pre]
[pre lang="ruby"]  #--------------------------------------------------------------------------
  # ● 計算技能/物品的閃避幾率
  #--------------------------------------------------------------------------
  def item_eva(user, item)
    if item.is_a?(RPG::Skill) and item.id == 3
      if $game_variables[1] == 1
        return 0
      end
      if $game_variables[1] == 2
        return 1
      end
    end
    return eva if item.physical?            # 是物理攻擊則返回閃避幾率
    return mev if item.magical?             # 是魔法攻擊則返回閃避魔法幾率
    return 0
  end[/pre]
[pre lang="ruby"]
  #--------------------------------------------------------------------------
  # ● 應用技能/物品的效果
  #--------------------------------------------------------------------------
  def item_apply(user, item)
    @result.clear
    @result.used = item_test(user, item)
    @result.missed = (@result.used && rand >= item_hit(user, item))
    @result.evaded = (!@result.missed && rand < item_eva(user, item))
    if item.is_a?(RPG::Skill) and item.id == 3
      if @result.hit?
        $game_variables[1] = 1
      else
        $game_variables[1] = 2
      end
    end
    if @result.hit?
      unless item.damage.none?
        @result.critical = (rand < item_cri(user, item))
        make_damage_value(user, item)
        execute_damage(user)
      end
      item.effects.each {|effect| item_effect_apply(user, item, effect) }
      item_user_effect(user, item)
    end
  end[/pre]


Scene_Battle第615附近
[pre lang="ruby"]
  #--------------------------------------------------------------------------
  # ● 戰斗行動結束時的處理
  #--------------------------------------------------------------------------
  def process_action_end
    @subject.on_action_end
    refresh_status
    @log_window.display_auto_affected_status(@subject)
    @log_window.wait_and_clear
    @log_window.display_current_state(@subject)
    @log_window.wait_and_clear
    $game_variables[1] = 0
    BattleManager.judge_win_loss
  end[/pre]
回复

使用道具 举报

梦石
0
星屑
17038
在线时间
6058 小时
注册时间
2011-7-18
回帖
152

开拓者

发表于 2020-1-4 01:27:04 | 显示全部楼层
可以取消全部修改然后用这个
[pre lang="ruby"]# 岚风雷(论坛ID:gqxastg)制作
#--------------------------------------------------------------------------
# 技能/物品备注 <特殊连续攻击> 或 <repeat_hit> 即可
# 第一次使用(命中)成功则后续次数均成功 否则立刻中断

#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● 返回是否特殊连续攻击
  #--------------------------------------------------------------------------
  def repeat_hit?
    /<(?:特殊连续攻击|REPEAT_HIT)>/i =~ @note ? true : false
  end
end
#==============================================================================
# ■ Game_ActionResult
#==============================================================================

class Game_ActionResult
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :force_hit_result                # 强制命中结果
  #--------------------------------------------------------------------------
  # ● 判定最后是否命中
  #--------------------------------------------------------------------------
  alias fixed_hit_repeat_hit? hit?
  def hit?
    if @force_hit_result.nil?
      return fixed_hit_repeat_hit?
    else
      @missed = false if @force_hit_result
      @evaded = false if @force_hit_result
      return @force_hit_result
    end
  end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 使用技能/物品
  #--------------------------------------------------------------------------
  alias fixed_hit_repeat_use_item use_item
  def use_item
    @last_hit = nil
    fixed_hit_repeat_use_item
  end
  #--------------------------------------------------------------------------
  # ● 发动技能/物品
  #--------------------------------------------------------------------------
  alias fixed_hit_repeat_invoke_item invoke_item
  def invoke_item(target, item)
    return if item.repeat_hit? && @last_hit == false
    target.result.force_hit_result = item.repeat_hit? ? @last_hit : nil
    fixed_hit_repeat_invoke_item(target, item)
    @last_hit = target.result.hit?
  end
end[/pre]

点评

这个完美解决了我的问题!谢谢!  发表于 2020-1-4 02:10

评分

参与人数 3星屑 +50 赞 +2 收起 理由
Cupidk爱呗茶 + 1 塞糖
VIPArcher + 50 认可答案
alexncf125 + 1 认可答案

查看全部评分

这里岚风·雷,任饭、PM理性粉、UT/DR原作粉、(Trans)Furry自萌,半吊子技术一枚_(:з」∠)_    游戏制作交流工(liao)作(tian)室欢迎来玩!
【无偿/有偿】RGSS3(VA)脚本定制 + 合作招募/同好交友    修正Firefox/火狐浏览器的代码框复制问题(油猴脚本)
Click→←Click
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部