层数护盾

This commit is contained in:
xiekaidong 2023-07-17 14:28:55 +08:00
parent 6249f3bd3e
commit de16d711ec
5 changed files with 38 additions and 6 deletions

View File

@ -333,6 +333,7 @@ local BUFF_NAME = {
INVALID_CONTROL = "invalid_control",
END_DMG_ADDITION_ALL_ADD = "end_dmg_addition_all_add",
END_DMG_DEC_ALL_ADD = "end_dmg_dec_all_add",
INVINCIBLE_SHIELD = "invincible_shield",
}
BattleConst.BUFF_NAME = BUFF_NAME
@ -390,7 +391,6 @@ local ATTR_NAME = {
INVALID_CONTROL = "invalid_control",
END_DMG_ADDITION_ALL = "end_dmg_addition_all",
END_DMG_DEC_ALL = "end_dmg_dec_all",
ATTR_CRIT_RED = "attr_crit_red",
ATTR_CRIT_YELLOW = "attr_crit_yellow",
ATTR_CRIT_GREEN = "attr_crit_green",
@ -416,7 +416,6 @@ local ATTR_NAME = {
ATTR_HPP_GREEN = "attr_hpp_green",
ATTR_HPP_BLUE = "attr_hpp_blue",
ATTR_HPP_PURPLE = "attr_hpp_purple",
ATTR_NORMAL_HURT_RED = "attr_normal_hurt_red",
ATTR_NORMAL_HURT_YELLOW = "attr_normal_hurt_yellow",
ATTR_NORMAL_HURT_GREEN = "attr_normal_hurt_green",
@ -437,6 +436,7 @@ local ATTR_NAME = {
ATTR_SKILL_HURTP_GREEN = "attr_skill_hurtp_green",
ATTR_SKILL_HURTP_BLUE = "attr_skill_hurtp_blue",
ATTR_SKILL_HURTP_PURPLE = "attr_skill_hurtp_purple",
INVINCIBLE_SHIELD = "invincible_shield",
}
BattleConst.ATTR_NAME = ATTR_NAME

View File

@ -1614,13 +1614,14 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
if effectType ~= EFFECT_TYPE.DIRECT then
showHurtCombo = false
end
local shieldHpBefore = self.unitEntity:getShieldHp()
local hpRealReduce = self.unitEntity:takeDamageOrCure(num)
local hpRealReduce, shieldWorkOn = self.unitEntity:takeDamageOrCure(num)
if hpRealReduce < 0 and self.side == BattleConst.SIDE_DEF then -- 实际掉血了
self:addBattleExp(atker, hpRealReduce)
end
local shieldHpDiff = self.unitEntity:getShieldHp() - shieldHpBefore
if shieldHpDiff < 0 then -- 说明护盾减少了
if shieldHpDiff < 0 or shieldWorkOn then -- 说明护盾减少了
self.team:handleShield(shieldHpDiff, self)
end
local hp = self.unitEntity:getHp()

View File

@ -116,6 +116,18 @@ local function _invalidControlOff(buffSender, target, buff, buffEffect)
return 1
end
local function _invincibleShieldOn(buffSender, buff, target, buffEffect)
local shieldNum = buff:getEffectNum()
target.team:addInvincibleShield(buffEffect)
target.unitEntity:addAttr(ATTR_NAME.INVINCIBLE_SHIELD, shieldNum, false)
return shieldNum
end
local function _invincibleShieldOff(buffSender, target, buff, buffEffect)
target.team:removeShield(buffEffect)
target.unitEntity:setAttr(ATTR_NAME.INVINCIBLE_SHIELD, 0)
return 1
end
local _handleOn = {
[BUFF_NAME.ADD_SKILL] = _addSkillOn, -- 添加技能
@ -126,6 +138,7 @@ local _handleOn = {
[BUFF_NAME.FROZEN] = _frozenOn, -- 冻结
[BUFF_NAME.LOCK] = _lockOn, -- 锁定
[BUFF_NAME.INVALID_CONTROL] = _invalidControlOn, -- 无控
[BUFF_NAME.INVINCIBLE_SHIELD] = _invincibleShieldOn, -- 层数护盾
}
local _handleOff = {
@ -137,6 +150,7 @@ local _handleOff = {
[BUFF_NAME.FROZEN] = _frozenOff, -- 冻结
[BUFF_NAME.LOCK] = _lockOff, -- 锁定
[BUFF_NAME.INVALID_CONTROL] = _invalidControlOff, -- 无控
[BUFF_NAME.INVINCIBLE_SHIELD] = _invincibleShieldOff, -- 层数护盾
}
local _handleWork = {

View File

@ -204,6 +204,12 @@ function BattleTeam:addShield(buffEffect)
end
end
function BattleTeam:addInvincibleShield(buffEffect)
if buffEffect then
table.insert(self.shieldBuffList, 1, buffEffect)
end
end
function BattleTeam:removeShield(buffEffect)
for k, v in ipairs(self.shieldBuffList) do
if v == buffEffect then
@ -221,7 +227,12 @@ function BattleTeam:handleShield(reduceShield, unit)
local needReedRefreshBuff = false
local currShieldBuff = self.shieldBuffList[1]
while currShieldBuff do
if reduceShield <= 0 and currShieldBuff.buff and currShieldBuff.buff:getName() == BattleConst.BUFF_NAME.INVINCIBLE_SHIELD then
reduceShield = currShieldBuff.result - 1
else
reduceShield = reduceShield + currShieldBuff.result
end
if reduceShield > 0 then
currShieldBuff.result = reduceShield
reduceShield = 0

View File

@ -363,7 +363,7 @@ function BattleTeamEntity:takeDamageOrCure(num)
if num < 0 then -- 是伤害的话处理一下护盾
num = self:handleShield(num)
if num >= 0 then -- 这次伤害被抵消了
return 0
return 0, true
end
end
local hpBefore = self:getHp()
@ -391,6 +391,12 @@ function BattleTeamEntity:takeDamageOrCure(num)
end
function BattleTeamEntity:handleShield(damageNum)
local invincibleShieldCount = self:getAttrValue(ATTR_NAME.INVINCIBLE_SHIELD)
if invincibleShieldCount > 0 then
self:setAttrValue(ATTR_NAME.INVINCIBLE_SHIELD, invincibleShieldCount - 1)
return 0
end
self.shieldHp = self.shieldHp + damageNum
if self.shieldHp >= 0 then
return 0