| 赞 | 0  | 
 
| VIP | 0 | 
 
| 好人卡 | 7 | 
 
| 积分 | 1 | 
 
| 经验 | 43463 | 
 
| 最后登录 | 2017-9-10 | 
 
| 在线时间 | 1019 小时 | 
 
 
 
 
 
Lv1.梦旅人 
	- 梦石
 - 0 
 
        - 星屑
 - 50 
 
        - 在线时间
 - 1019 小时
 
        - 注册时间
 - 2012-4-25
 
        - 帖子
 - 799
 
 
 
 | 
	
 本帖最后由 lirn 于 2012-6-26 16:47 编辑  
-   @result.missed = (@result.used && (rand+1) >= (item_hit(user,item)-item_eva(user,item)))
 
 -     @result.evaded = false
 
  复制代码 我稍微改了一下,普通攻击,技能尚未测试,大概做到了命中减回避大于100就必中,50大概是半中,25%的话每10次大概都有2-3次MISS。 
 
为什么RAND后面要加1?,命中与回避相同的的时候,HIT-EVA应该=0吧。 
 
 
出现问题了……防御也MISS了……似乎技能是必然MISS,即使对方回避率为0……错在哪里? 
 
 
==================================================================== 
 
问题是大概是找到了,物理系技能返回的是回避,物理技能返回的是魔法回避,这些技能对自己也有的命中与回避也有影响,但不知道必中的类型是哪个,也不知道-   def item_hit(user, item)
 
 -     rate = item.success_rate * 0.01         # 取得成功率
 
 -     rate *= user.hit if item.physical?      # 物理攻击:计算命中率的乘积
 
 -     rate *= user.hit if item.magical?
 
 -     return rate                             # 返回计算后的命中率
 
 -   end
 
  复制代码 在这个公式当中出现了问题,比如说技能成功率为50%,命中200,回避100,那么实际的计算公式是200*0.5-100=0,而不是(200-100)*0.5=50. 
 
 
于是乎,改成这样,暂时还没发现问题- #--------------------------------------------------------------------------
 
 -   # ● 计算技能/物品的命中率
 
 -   #--------------------------------------------------------------------------
 
 -   def item_hit(user, item)
 
 -        rate = item.success_rate * 0.01         # 取得成功率
 
 -     rate *= (user.hit-eva) if item.physical?      # 物理攻击:计算命中率的乘积
 
 -     rate *= (user.hit-mev) if item.magical?  #魔法攻击:计算命中率的乘积
 
 -       return rate                             # 返回计算后的命中率
 
 -   end
 
  复制代码 
-   #--------------------------------------------------------------------------
 
 -   # ● 应用技能/物品的效果
 
 -   #--------------------------------------------------------------------------
 
 -   def item_apply(user, item)
 
 -     @result.clear
 
 -     @result.used = item_test(user, item)
 
 -     @result.missed = (@result.used && rand >= item_hit(user, item))  # 命中判定
 
 -     @result.evaded = false
 
  复制代码 |   
 
 
 
 |