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

Project1

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

[已经解决] 请问如何让“速度”影响命中率、回避率、必杀率和反击率

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
353 小时
注册时间
2010-12-27
帖子
68
跳转到指定楼层
1
发表于 2015-5-25 21:24:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
请问如何让“速度”影响命中率、回避率、必杀率和反击率,谢谢!

Lv1.梦旅人

梦石
0
星屑
135
在线时间
450 小时
注册时间
2015-2-25
帖子
365
2
发表于 2015-5-26 10:53:28 | 只看该作者
  1. class BattlerBase
  2.   def hit;  xparam(0);  end    # 命中機率      
  3.   def eva;  xparam(1);  end    # 閃避機率   
  4.   def cri;  xparam(2);  end    # 必殺機率
  5.   def cev;  xparam(3);  end    # 閃避必殺機率   
  6.   def cnt;  xparam(6);  end    # 反擊機率   
  7. end
复制代码
把xparam(x)改成你要的算式 比如
RUBY 代码复制
  1. agi
RUBY 代码复制
  1. agi*10
RUBY 代码复制
  1. [agi*10,100].max
RUBY 代码复制
  1. [[10+agi/2,100].max,50].min




以下的是戰鬥中命中,閃避等的計算,設定算式時須參考一下(或者不改上面的,直接改下面的,改起來會比較簡單..分別在於上面的是角色/敵人的能力值,下面的是實際作用時的算法)
  1.     (@result.used && rand >= item_hit(user, item))   #命中
  2.     ([email protected] && rand < item_eva(user, item))   #閃避
  3.     (rand < item_cri(user, item))       #必殺
  4.     rand < target.item_cnt(@subject, item)    #反擊
复制代码
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.     return rate                             # 返回計算后的成功幾率
  8.   end
  9.   #--------------------------------------------------------------------------
  10.   # ● 計算技能/物品的閃避幾率
  11.   #--------------------------------------------------------------------------
  12.   def item_eva(user, item)
  13.     return eva if item.physical?            # 是物理攻擊則返回閃避幾率
  14.     return mev if item.magical?             # 是魔法攻擊則返回閃避魔法幾率
  15.     return 0
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 計算技能/物品的必殺幾率
  19.   #--------------------------------------------------------------------------
  20.   def item_cri(user, item)
  21.     item.damage.critical ? user.cri * (1 - cev) : 0
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 計算技能/物品的反擊幾率
  25.   #--------------------------------------------------------------------------
  26.   def item_cnt(user, item)
  27.     return 0 unless item.physical?          # 攻擊類型不是物理攻擊
  28.     return 0 unless opposite?(user)         # 隊友無法反擊
  29.     return cnt                              # 返回反擊幾率
  30.   end

点评

谢谢~~  发表于 2015-5-26 11:10

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-1 05:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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