查看: 3504|回复: 3

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

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

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

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

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

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



问题来了,怎样改成最右面的情况?
(现在最右面的情况是改图改出来的)
梦石
0
星屑
30103
在线时间
5741 小时
注册时间
2016-3-8
回帖
1662
 楼主| 发表于 2020-1-3 23:08:39 | 显示全部楼层
Game_Battler第567行附近
  1.   #--------------------------------------------------------------------------
  2.   # ● 計算技能/物品的成功幾率
  3.   #--------------------------------------------------------------------------
  4.   def item_hit(user, item)
  5.     rate = item.success_rate * 0.01         # 獲取成功幾率
  6.     rate *= user.hit if item.physical?      # 物理攻擊:計算成功幾率的乘積
  7.     if item.is_a?(RPG::Skill) and item.id == 3
  8.       if $game_variables[1] == 1
  9.         return 1
  10.       end
  11.       if $game_variables[1] == 2
  12.         return 0
  13.       end
  14.     end
  15.     return rate                             # 返回計算后的成功幾率
  16.   end
复制代码
  1.   #--------------------------------------------------------------------------
  2.   # ● 計算技能/物品的閃避幾率
  3.   #--------------------------------------------------------------------------
  4.   def item_eva(user, item)
  5.     if item.is_a?(RPG::Skill) and item.id == 3
  6.       if $game_variables[1] == 1
  7.         return 0
  8.       end
  9.       if $game_variables[1] == 2
  10.         return 1
  11.       end
  12.     end
  13.     return eva if item.physical?            # 是物理攻擊則返回閃避幾率
  14.     return mev if item.magical?             # 是魔法攻擊則返回閃避魔法幾率
  15.     return 0
  16.   end
复制代码

  1.   #--------------------------------------------------------------------------
  2.   # ● 應用技能/物品的效果
  3.   #--------------------------------------------------------------------------
  4.   def item_apply(user, item)
  5.     @result.clear
  6.     @result.used = item_test(user, item)
  7.     @result.missed = (@result.used && rand >= item_hit(user, item))
  8.     @result.evaded = (!@result.missed && rand < item_eva(user, item))
  9.     if item.is_a?(RPG::Skill) and item.id == 3
  10.       if @result.hit?
  11.         $game_variables[1] = 1
  12.       else
  13.         $game_variables[1] = 2
  14.       end
  15.     end
  16.     if @result.hit?
  17.       unless item.damage.none?
  18.         @result.critical = (rand < item_cri(user, item))
  19.         make_damage_value(user, item)
  20.         execute_damage(user)
  21.       end
  22.       item.effects.each {|effect| item_effect_apply(user, item, effect) }
  23.       item_user_effect(user, item)
  24.     end
  25.   end
复制代码



Scene_Battle第615附近

  1.   #--------------------------------------------------------------------------
  2.   # ● 戰斗行動結束時的處理
  3.   #--------------------------------------------------------------------------
  4.   def process_action_end
  5.     @subject.on_action_end
  6.     refresh_status
  7.     @log_window.display_auto_affected_status(@subject)
  8.     @log_window.wait_and_clear
  9.     @log_window.display_current_state(@subject)
  10.     @log_window.wait_and_clear
  11.     $game_variables[1] = 0
  12.     BattleManager.judge_win_loss
  13.   end
复制代码
回复

使用道具 举报

梦石
0
星屑
17289
在线时间
6068 小时
注册时间
2011-7-18
回帖
153

开拓者

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

  5. #==============================================================================
  6. # ■ RPG::UsableItem
  7. #==============================================================================

  8. class RPG::UsableItem < RPG::BaseItem
  9.   #--------------------------------------------------------------------------
  10.   # ● 返回是否特殊连续攻击
  11.   #--------------------------------------------------------------------------
  12.   def repeat_hit?
  13.     /<(?:特殊连续攻击|REPEAT_HIT)>/i =~ @note ? true : false
  14.   end
  15. end
  16. #==============================================================================
  17. # ■ Game_ActionResult
  18. #==============================================================================

  19. class Game_ActionResult
  20.   #--------------------------------------------------------------------------
  21.   # ● 定义实例变量
  22.   #--------------------------------------------------------------------------
  23.   attr_accessor :force_hit_result                # 强制命中结果
  24.   #--------------------------------------------------------------------------
  25.   # ● 判定最后是否命中
  26.   #--------------------------------------------------------------------------
  27.   alias fixed_hit_repeat_hit? hit?
  28.   def hit?
  29.     if @force_hit_result.nil?
  30.       return fixed_hit_repeat_hit?
  31.     else
  32.       @missed = false if @force_hit_result
  33.       @evaded = false if @force_hit_result
  34.       return @force_hit_result
  35.     end
  36.   end
  37. end
  38. #==============================================================================
  39. # ■ Scene_Battle
  40. #==============================================================================

  41. class Scene_Battle < Scene_Base
  42.   #--------------------------------------------------------------------------
  43.   # ● 使用技能/物品
  44.   #--------------------------------------------------------------------------
  45.   alias fixed_hit_repeat_use_item use_item
  46.   def use_item
  47.     @last_hit = nil
  48.     fixed_hit_repeat_use_item
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 发动技能/物品
  52.   #--------------------------------------------------------------------------
  53.   alias fixed_hit_repeat_invoke_item invoke_item
  54.   def invoke_item(target, item)
  55.     return if item.repeat_hit? && @last_hit == false
  56.     target.result.force_hit_result = item.repeat_hit? ? @last_hit : nil
  57.     fixed_hit_repeat_invoke_item(target, item)
  58.     @last_hit = target.result.hit?
  59.   end
  60. end
复制代码

点评

这个完美解决了我的问题!谢谢!  发表于 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.

在本版发帖返回顶部