伤害反弹

This commit is contained in:
chenxi 2023-04-24 15:11:55 +08:00
parent c02e769d4a
commit fe492541a4
3 changed files with 12 additions and 1 deletions

View File

@ -1148,6 +1148,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus)
if shieldHpDiff < 0 then -- 说明护盾减少了 if shieldHpDiff < 0 then -- 说明护盾减少了
self.team:handleShield(shieldHpDiff, self) self.team:handleShield(shieldHpDiff, self)
end end
local hp = self.unitEntity:getHp()
local x, y = self.baseObject:fastGetLocalPosition() local x, y = self.baseObject:fastGetLocalPosition()
if num < 0 then -- 伤害 if num < 0 then -- 伤害
if effectStatus == HURT_STATE_CRIT then if effectStatus == HURT_STATE_CRIT then
@ -1159,10 +1160,12 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus)
self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_MOVE_R, num, x, y) self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_MOVE_R, num, x, y)
end end
end end
if hp > 0 and self.unitEntity:getShieldRebound() then -- 伤害反弹
atker:takeDamageOrCure(self, num*self.unitEntity:getShieldRebound() // DEFAULT_FACTOR, EFFECT_TYPE.DIRECT, 0)
end
elseif num > 0 then -- 治疗 elseif num > 0 then -- 治疗
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y) self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y)
end end
local hp = self.unitEntity:getHp()
local hpPercent = self.unitEntity:getHpPercent() local hpPercent = self.unitEntity:getHpPercent()
self.battleController:refreshHp(self.side, hp, hpPercent) self.battleController:refreshHp(self.side, hp, hpPercent)
if atker:getIsCentralizedAttack() then if atker:getIsCentralizedAttack() then

View File

@ -199,6 +199,10 @@ function BattleTeamEntity:getShieldHp()
return self.shieldHp return self.shieldHp
end end
function BattleTeamEntity:getShieldRebound()
return self.attr.shield_rebound or 0
end
function BattleTeamEntity:getBlock() function BattleTeamEntity:getBlock()
return self.attr.block or 0 return self.attr.block or 0
end end

View File

@ -302,6 +302,10 @@ function BattleUnitEntity:getShieldHp()
return self.team:getShieldHp() return self.team:getShieldHp()
end end
function BattleUnitEntity:getShieldRebound()
return self.team:getShieldRebound()
end
function BattleUnitEntity:addMaxHp(num) function BattleUnitEntity:addMaxHp(num)
self.team:addMaxHp(num) self.team:addMaxHp(num)
end end