添加判断命中的方法
parent
d53bac2d5a
commit
ab98e17e8a
|
@ -108,7 +108,7 @@ end
|
|||
function Skill:Cast(func)
|
||||
self.castDoneFunc = func
|
||||
self.effectTargets = {}
|
||||
|
||||
self.targetIsHit = {}
|
||||
-- 先计算出技能的目标
|
||||
for i=1, self.effectList.size do
|
||||
-- 是否重新选择目标
|
||||
|
@ -152,7 +152,7 @@ function Skill:Cast(func)
|
|||
local chooseId = effectGroup.chooseId
|
||||
local arr = self.effectTargets[i]
|
||||
if arr and #arr > 0 then
|
||||
--效果延迟1帧生效
|
||||
-- 效果延迟1帧生效
|
||||
BattleLogic.WaitForTrigger(BattleLogic.GameDeltaTime, function()
|
||||
local effects = effectGroup.effects
|
||||
local weight = floor(chooseId % 10000 / 100)
|
||||
|
@ -162,7 +162,11 @@ function Skill:Cast(func)
|
|||
end
|
||||
-- 全部同时生效
|
||||
for j=1, count do
|
||||
if arr[j] and not arr[j]:IsRealDead() then
|
||||
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()
|
||||
-- 技能后摇
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue