复活判定逻辑

This commit is contained in:
xiekaidong 2023-08-15 17:32:54 +08:00
parent 1ccef0858b
commit eeeadeace0

View File

@ -1402,8 +1402,10 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx)
end end
local targetType = skill:getTargetType() local targetType = skill:getTargetType()
local target local target
local targetIsSelf = false
if targetType == 1 then -- 自己 if targetType == 1 then -- 自己
target = self target = self
targetIsSelf = true
else else
target = self.battleController:getOtherSideMainUnit(self.side) target = self.battleController:getOtherSideMainUnit(self.side)
if skill:getIsNormalType() then -- 普攻要计算一下格挡 if skill:getIsNormalType() then -- 普攻要计算一下格挡
@ -1450,6 +1452,11 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx)
end end
end end
if isFinalBlock and targetIsSelf then -- 死亡判定
local otherSideTarget = self.battleController:getOtherSideMainUnit(self.side)
otherSideTarget:checkDeadStatus(target)
end
if succ then if succ then
if skill:getIsHurtType() then if skill:getIsHurtType() then
self.team:addCombo() self.team:addCombo()
@ -1740,51 +1747,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
self.team:playHurt() self.team:playHurt()
end end
else else
if self.unitEntity:getIsDead() then if self:checkDeadStatus(atker, damageOrCureType) then
if self.unitEntity:getCanRebirth() then -- 复活
self.battleController:resetTimeSpeed(true)
local mainUnit = self.team:getMainUnit()
if mainUnit then
local callback = self.actionOverCallback
if not callback then
callback = atker.actionOverCallback
end
self.actionOverCallback = nil
atker.actionOverCallback = nil
mainUnit.unitEntity:setIsRebirth()
mainUnit:playDead(function()
mainUnit:removeBuffByName(BattleConst.ATTR_NAME.REBIRTH)
local hpPercent = self.unitEntity:getHpPercent()
self.battleController:refreshHp(self.side, self.unitEntity:getHp(), hpPercent)
self.team:checkPassiveEvent(PASSIVE_EVENT.HP_LOWER_THAN, atker, hpPercent)
mainUnit:changeState(UNIT_STATE.IDLE)
mainUnit:initPosition()
if callback then
callback()
end
end)
end
return
end
if damageOrCureType == BattleConst.BUFF_NAME.BURN then
local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN)
end
if self.unitEntity:getAttrValue(BattleConst.ATTR_NAME.BLEED) > 0 then
local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_WITH_BLEED)
end
if self.actionOverCallback then -- 被反伤时死亡
self.actionOverCallback = nil
self.battleController:enterNextTeamAction()
end
self.battleController:resetTimeSpeed(true)
self.team:changeDead() -- 因为buff生效对象有可能不是当前主英雄会导致状态不对所以使用主英雄来播放动画
elseif damage < 0 then elseif damage < 0 then
self.team:playHurt() self.team:playHurt()
end end
@ -1797,6 +1760,58 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
end end
end end
function BattleUnitComp:checkDeadStatus(atker, damageOrCureType)
if self.unitEntity:getIsDead() then
if self.unitEntity:getCanRebirth() then -- 复活
self.battleController:resetTimeSpeed(true)
local mainUnit = self.team:getMainUnit()
if mainUnit then
local callback = self.actionOverCallback
if not callback then
callback = atker.actionOverCallback
end
self.actionOverCallback = nil
atker.actionOverCallback = nil
mainUnit.unitEntity:setIsRebirth()
mainUnit:playDead(function()
mainUnit:removeBuffByName(BattleConst.ATTR_NAME.REBIRTH)
local hpPercent = self.unitEntity:getHpPercent()
self.battleController:refreshHp(self.side, self.unitEntity:getHp(), hpPercent)
self.team:checkPassiveEvent(PASSIVE_EVENT.HP_LOWER_THAN, atker, hpPercent)
mainUnit:changeState(UNIT_STATE.IDLE)
mainUnit:initPosition()
if callback then
callback()
end
end)
end
return
end
if damageOrCureType == BattleConst.BUFF_NAME.BURN then
local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN)
end
if self.unitEntity:getAttrValue(BattleConst.ATTR_NAME.BLEED) > 0 then
local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_WITH_BLEED)
end
if self.actionOverCallback then -- 被反伤时死亡
self.actionOverCallback = nil
self.battleController:enterNextTeamAction()
end
self.battleController:resetTimeSpeed(true)
self.team:changeDead() -- 因为buff生效对象有可能不是当前主英雄会导致状态不对所以使用主英雄来播放动画
return true
end
return false
end
function BattleUnitComp:addBattleExp(atker, hpRealReduce) function BattleUnitComp:addBattleExp(atker, hpRealReduce)
if not atker or hpRealReduce > 0 then if not atker or hpRealReduce > 0 then
return return