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

Project1

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

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

[复制链接]

Lv5.捕梦者

梦石
0
星屑
24292
在线时间
5047 小时
注册时间
2016-3-8
帖子
1618
跳转到指定楼层
1
发表于 2020-1-3 22:59:10 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

va默认下,连续技能每一次攻击时,其命中判定是独立的,因此会造成以下图片中,左方上至下的三种情况

经过了一番修改,改成了只计算一次是否命中,只要第一次命中,所有攻击必定全中.因此会造成以上图片中,中間上至下的三种情况



问题来了,怎样改成最右面的情况?
(现在最右面的情况是改图改出来的)

Lv5.捕梦者

梦石
0
星屑
24292
在线时间
5047 小时
注册时间
2016-3-8
帖子
1618
2
 楼主| 发表于 2020-1-3 23:08:39 | 只看该作者
Game_Battler第567行附近
RUBY 代码复制
  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

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

RUBY 代码复制
  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附近
RUBY 代码复制
  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
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
13763
在线时间
5691 小时
注册时间
2011-7-18
帖子
158

开拓者

3
发表于 2020-1-4 01:27:04 | 只看该作者
可以取消全部修改然后用这个
RUBY 代码复制
  1. # 岚风雷(论坛ID:gqxastg)制作
  2. #--------------------------------------------------------------------------
  3. # 技能/物品备注 <特殊连续攻击> 或 <repeat_hit> 即可
  4. # 第一次使用(命中)成功则后续次数均成功 否则立刻中断
  5.  
  6. #==============================================================================
  7. # ■ RPG::UsableItem
  8. #==============================================================================
  9.  
  10. class RPG::UsableItem < RPG::BaseItem
  11.   #--------------------------------------------------------------------------
  12.   # ● 返回是否特殊连续攻击
  13.   #--------------------------------------------------------------------------
  14.   def repeat_hit?
  15.     /<(?:特殊连续攻击|REPEAT_HIT)>/i =~ @note ? true : false
  16.   end
  17. end
  18. #==============================================================================
  19. # ■ Game_ActionResult
  20. #==============================================================================
  21.  
  22. class Game_ActionResult
  23.   #--------------------------------------------------------------------------
  24.   # ● 定义实例变量
  25.   #--------------------------------------------------------------------------
  26.   attr_accessor :force_hit_result                # 强制命中结果
  27.   #--------------------------------------------------------------------------
  28.   # ● 判定最后是否命中
  29.   #--------------------------------------------------------------------------
  30.   alias fixed_hit_repeat_hit? hit?
  31.   def hit?
  32.     if @force_hit_result.nil?
  33.       return fixed_hit_repeat_hit?
  34.     else
  35.       @missed = false if @force_hit_result
  36.       @evaded = false if @force_hit_result
  37.       return @force_hit_result
  38.     end
  39.   end
  40. end
  41. #==============================================================================
  42. # ■ Scene_Battle
  43. #==============================================================================
  44.  
  45. class Scene_Battle < Scene_Base
  46.   #--------------------------------------------------------------------------
  47.   # ● 使用技能/物品
  48.   #--------------------------------------------------------------------------
  49.   alias fixed_hit_repeat_use_item use_item
  50.   def use_item
  51.     @last_hit = nil
  52.     fixed_hit_repeat_use_item
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 发动技能/物品
  56.   #--------------------------------------------------------------------------
  57.   alias fixed_hit_repeat_invoke_item invoke_item
  58.   def invoke_item(target, item)
  59.     return if item.repeat_hit? && @last_hit == false
  60.     target.result.force_hit_result = item.repeat_hit? ? @last_hit : nil
  61.     fixed_hit_repeat_invoke_item(target, item)
  62.     @last_hit = target.result.hit?
  63.   end
  64. 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
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-27 01:12

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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