From de16d711ec39335c77b8bcb8c5c198f2bf56f6ca Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Mon, 17 Jul 2023 14:28:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=82=E6=95=B0=E6=8A=A4=E7=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 4 ++-- .../module/battle/component/battle_unit_comp.lua | 5 +++-- .../module/battle/helper/battle_buff_special.lua | 14 ++++++++++++++ lua/app/module/battle/team/battle_team.lua | 13 ++++++++++++- .../userdata/battle/team/battle_team_entity.lua | 8 +++++++- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 36f91dd6..534996b4 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -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 diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 80f1010a..7d0c26a7 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -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() diff --git a/lua/app/module/battle/helper/battle_buff_special.lua b/lua/app/module/battle/helper/battle_buff_special.lua index 5237ba9a..c823fa8c 100644 --- a/lua/app/module/battle/helper/battle_buff_special.lua +++ b/lua/app/module/battle/helper/battle_buff_special.lua @@ -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 = { diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 9c390010..24704b49 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -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 - reduceShield = reduceShield + currShieldBuff.result + 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 diff --git a/lua/app/userdata/battle/team/battle_team_entity.lua b/lua/app/userdata/battle/team/battle_team_entity.lua index 66648c1d..cded5c2c 100644 --- a/lua/app/userdata/battle/team/battle_team_entity.lua +++ b/lua/app/userdata/battle/team/battle_team_entity.lua @@ -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