diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index d4b827a3..76a737e1 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -1402,8 +1402,10 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx) end local targetType = skill:getTargetType() local target + local targetIsSelf = false if targetType == 1 then -- 自己 target = self + targetIsSelf = true else target = self.battleController:getOtherSideMainUnit(self.side) if skill:getIsNormalType() then -- 普攻要计算一下格挡 @@ -1450,6 +1452,11 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx) end end + if isFinalBlock and targetIsSelf then -- 死亡判定 + local otherSideTarget = self.battleController:getOtherSideMainUnit(self.side) + otherSideTarget:checkDeadStatus(target) + end + if succ then if skill:getIsHurtType() then self.team:addCombo() @@ -1740,51 +1747,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d self.team:playHurt() end else - 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生效对象有可能不是当前主英雄,会导致状态不对,所以使用主英雄来播放动画 + if self:checkDeadStatus(atker, damageOrCureType) then elseif damage < 0 then self.team:playHurt() end @@ -1797,6 +1760,58 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d 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) if not atker or hpRealReduce > 0 then return