添加判断命中的方法

dev_chengFeng
gaoxin 2020-07-02 21:33:00 +08:00
parent d53bac2d5a
commit ab98e17e8a
2 changed files with 24 additions and 3 deletions

View File

@ -108,7 +108,7 @@ end
function Skill:Cast(func)
self.castDoneFunc = func
self.effectTargets = {}
self.targetIsHit = {}
-- 先计算出技能的目标
for i=1, self.effectList.size do
-- 是否重新选择目标
@ -163,6 +163,10 @@ function Skill:Cast(func)
-- 全部同时生效
for j=1, count do
if arr[j] and not arr[j]:IsRealDead() then
-- 检测是否命中
if i == 1 then
self.targetIsHit[arr[j]] = BattleUtil.CheckIsHit(self.owner, arr[j])
end
takeEffect(self.owner, arr[j], effects, self.hitTime, self)
end
end
@ -212,6 +216,11 @@ function Skill:GetMaxTargetNum()
return BattleUtil.GetMaxTargetNum(mainEffect.chooseId)
end
-- 判断是否命中
function Skill:CheckTargetIsHit(role)
return self.targetIsHit[role]
end
-- 结束技能
function Skill:EndSkill()
-- 技能后摇

View File

@ -526,6 +526,18 @@ end
-- 检测命中
function BattleUtil.CheckIsHit(atkRole, defRole)
-- 是否命中: 命中 = 自身命中率 - 对方闪避率
local isHit = false
local hitRandom = Random.Range01()
local hitCondition = clamp(atkRole:GetRoleData(RoleDataName.Hit) - defRole:GetRoleData(RoleDataName.Dodge), 0, 1)
isHit = hitRandom <= hitCondition
return isHit
end
function BattleUtil.RandomAction(rand, action)
if Random.Range01() <= rand and action then