From 676ced2decf1ab97c9719d15b74eb5f744e7b62f Mon Sep 17 00:00:00 2001 From: puxuan <413323644@qq.com> Date: Mon, 27 Oct 2025 10:54:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=A4=E5=AE=B3=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 2 ++ .../battle/component/battle_unit_comp.lua | 4 ++++ .../controller/battle_base_controller.lua | 4 ++++ .../controller/battle_controller_pvp.lua | 4 ++++ .../module/battle/helper/battle_formula.lua | 23 +++++++++++++++++-- lua/app/userdata/battle/battle_base_data.lua | 3 +++ .../battle/team/battle_team_entity.lua | 18 ++++++++++++--- .../battle/team/battle_unit_entity.lua | 12 ++++++++++ lua/app/userdata/hero/hero_entity.lua | 4 ++-- 9 files changed, 67 insertions(+), 7 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 485a19b9..178b90a8 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -526,6 +526,8 @@ local ATTR_NAME = { IMMUNE_REDUCTION_BENEFIT = "immune_reduction_benefit", -- 免疫减益 FOREVER_UNCONTROLLED = "forever_uncontrolled", -- 永久免控 ATTR_NORMAL_HURTP_ALL_ADD = "attr_normal_hurtp_all", + ATTR_NORMAL_HURT = "attr_normal_hurt", -- 通用个人普攻伤害增加(固定值) 普攻增伤 + ATTR_SKILL_HURT = "attr_skill_hurt", -- 通用个人普攻伤害增加(固定值) 普攻增伤 } 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 de466a6c..797c145a 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -60,6 +60,10 @@ function BattleUnitComp:getMatchType() return self.unitEntity:getMatchType() end +function BattleUnitComp:checkMonsterDmgAdd() + return self.battleController:checkMonsterDmgAdd() +end + function BattleUnitComp:getIsBoss() return self.unitEntity:getIsBoss() end diff --git a/lua/app/module/battle/controller/battle_base_controller.lua b/lua/app/module/battle/controller/battle_base_controller.lua index 26419d7a..043dd52c 100644 --- a/lua/app/module/battle/controller/battle_base_controller.lua +++ b/lua/app/module/battle/controller/battle_base_controller.lua @@ -20,6 +20,10 @@ local GRID_BREAK_CONDITION = BattleConst.GRID_BREAK_CONDITION local SIDE_ATK = BattleConst.SIDE_ATK local SIDE_DEF = BattleConst.SIDE_DEF +function BattleBaseController:checkMonsterDmgAdd() + return true +end + function BattleBaseController:getPosInfo(posId) return ModuleManager.BattleManager:getPosInfo(posId, self:getRowCount()) end diff --git a/lua/app/module/battle/controller/battle_controller_pvp.lua b/lua/app/module/battle/controller/battle_controller_pvp.lua index 522de4b0..5780b32f 100644 --- a/lua/app/module/battle/controller/battle_controller_pvp.lua +++ b/lua/app/module/battle/controller/battle_controller_pvp.lua @@ -7,6 +7,10 @@ local SIDE_ATK = BattleConst.SIDE_ATK local SIDE_DEF = BattleConst.SIDE_DEF -- *************各个子模块的战斗需要重写的方法 START************* +function BattleControllerPVP:checkMonsterDmgAdd() + return false +end + function BattleControllerPVP:getBoardConfig() return {} end diff --git a/lua/app/module/battle/helper/battle_formula.lua b/lua/app/module/battle/helper/battle_formula.lua index aafbcc9b..94473385 100644 --- a/lua/app/module/battle/helper/battle_formula.lua +++ b/lua/app/module/battle/helper/battle_formula.lua @@ -50,10 +50,17 @@ function BattleFormula:getExpectedDamageResult(unitComp, count, targetUnitComp, end BattleFormula.calculateFormula = { - -- ((攻击)*技能倍率*(1+(攻击者元素伤害增加+所有伤害增加)(攻击者)- (攻击者元素伤害降低+所有伤害降低) +(受到元素伤害增加+受到所有伤害增加(受击)-受到元素伤害降低-受到所有伤害降低(受击) + 主动技能增伤) + 固定值) *暴击伤害*(1-最终造成伤害降低%+最终造成伤害增加%) + -- 局内攻击*技能倍率*(1 + -- +(攻击者元素伤害增加+所有伤害增加+主动技能OR普攻增伤%+BOSS或小怪增伤%)(攻击者 + -- +(受到元素伤害增加+受到所有伤害增加)(受击者 + -- -(攻击者元素伤害降低+所有伤害降低)(受击者 + -- -(受到元素伤害降低-受到所有伤害降低)(受击者 + -- +普攻或技能增伤固定值)*暴击伤害(攻击者)*(1-最终造成伤害降低%(受击者 + -- +最终造成伤害增加%(攻击者))-减伤固定值(受击者) [1] = function(unitComp, buff, targetUnit) local skillFixedAdd = 0 local skillPAdd = 0 + local monsterDmgPAdd = 0 local hostSkill = buff:getHostSkill() local atkMatchType = unitComp.unitEntity:getMatchType() if hostSkill then -- 技能伤害加成 @@ -67,13 +74,21 @@ BattleFormula.calculateFormula = { skillPAdd = skillPAdd + unitComp.unitEntity:getAllHurtP() end + if unitComp:checkMonsterDmgAdd() and unitComp:getSide() == BattleConst.SIDE_ATK then + if unitComp.unitEntity:getIsBoss() then + monsterDmgPAdd = unitComp.unitEntity:getBossHurtP() + else + monsterDmgPAdd = unitComp.unitEntity:getMonsterHurtP() + end + end + local result = unitComp.unitEntity:getAtk() * buff:getEffectNum() // DEFAULT_FACTOR -- 基础值(攻击 * 技能倍率) result = result * (DEFAULT_FACTOR + unitComp.unitEntity:getDmgAddition() -- (攻击者元素伤害增加 + 所有伤害增加) - unitComp.unitEntity:getDmgDec() -- (攻击者元素伤害降低 + 所有伤害降低) + targetUnit.unitEntity:getWeakness(atkMatchType) -- (受击者受到元素伤害增加 + 受到所有伤害增加) - targetUnit.unitEntity:getDecDmg(atkMatchType) -- (受击者受到元素伤害降低 + 受到所有伤害降低) - + skillPAdd) // DEFAULT_FACTOR -- 技能增伤百分比 + + skillPAdd + monsterDmgPAdd) // DEFAULT_FACTOR -- 技能增伤百分比 result = result + skillFixedAdd -- 固定值 -- 暴击 @@ -87,6 +102,10 @@ BattleFormula.calculateFormula = { end -- 最终伤害 result = result * (DEFAULT_FACTOR - unitComp.unitEntity:getEndDmgDecAll() + unitComp.unitEntity:getEndDmgAddtionAll()) // DEFAULT_FACTOR + result = result - targetUnit.unitEntity:getDmgDecFixed() // DEFAULT_FACTOR -- 固定值 + if result <= 0 then + result = 1 + end return result, hurtState end, -- 生命值*回合开始时的回血系数*(1 + 治疗效果增加) diff --git a/lua/app/userdata/battle/battle_base_data.lua b/lua/app/userdata/battle/battle_base_data.lua index 847cb194..41722e71 100644 --- a/lua/app/userdata/battle/battle_base_data.lua +++ b/lua/app/userdata/battle/battle_base_data.lua @@ -945,6 +945,9 @@ function BattleBaseData:initHeroData(formation) end unitData.attr[BattleConst.ATTR_NAME.ATTR_MONSTER_DMG] = heroEntity:getTotalAttrValue(BattleConst.ATTR_NAME.ATTR_MONSTER_DMG) unitData.attr[BattleConst.ATTR_NAME.ATTR_BOSS_DMG] = heroEntity:getTotalAttrValue(BattleConst.ATTR_NAME.ATTR_BOSS_DMG) + unitData.attr[BattleConst.ATTR_NAME.DMGDEC] = heroEntity:getTotalAttrValue(BattleConst.ATTR_NAME.DMGDEC) + unitData.attr[BattleConst.ATTR_NAME.ATTR_NORMAL_HURT] = heroEntity:getTotalAttrValue(BattleConst.ATTR_NAME.ATTR_NORMAL_HURT) + unitData.attr[BattleConst.ATTR_NAME.ATTR_SKILL_HURT] = heroEntity:getTotalAttrValue(BattleConst.ATTR_NAME.ATTR_SKILL_HURT) local skillInfo = skillCfg[skillId] if skillInfo then diff --git a/lua/app/userdata/battle/team/battle_team_entity.lua b/lua/app/userdata/battle/team/battle_team_entity.lua index 95967ba0..e3f8f58b 100644 --- a/lua/app/userdata/battle/team/battle_team_entity.lua +++ b/lua/app/userdata/battle/team/battle_team_entity.lua @@ -193,6 +193,18 @@ function BattleTeamEntity:getDecDmg(matchType) return self:getAttrValue(ATTR_NAME.DEC_DMG_ALL) + self:getAttrValue(MATCH_DEC_DMG_NAME[matchType]) end +function BattleTeamEntity:getDmgDecFixed() + return self:getAttrValue(ATTR_NAME.DMGDEC) +end + +function BattleTeamEntity:getBossHurtP() + return self:getAttrValue(ATTR_NAME.ATTR_BOSS_DMG) +end + +function BattleTeamEntity:getMonsterHurtP() + return self:getAttrValue(ATTR_NAME.ATTR_MONSTER_DMG) +end + function BattleTeamEntity:getWeakness(matchType) return self:getAttrValue(ATTR_NAME.WEAKNESS_ALL) + self:getAttrValue(MATCH_WEAKNESS_NAME[matchType]) end @@ -340,12 +352,12 @@ end function BattleTeamEntity:getSkillHurtP(matchType) local skillHurtPName = GConst.MATCH_SKILL_HURTP_NAME[matchType] - return self:getAttrValue(ATTR_NAME.SKILL_HURTP) + self:getAttrValue(skillHurtPName) + return self:getAttrValue(ATTR_NAME.SKILL_HURTP) + self:getAttrValue(skillHurtPName) + self:getAttrValue(ATTR_NAME.SKILL_HURTP) end function BattleTeamEntity:getSkillHurtFixed(matchType) local skillHurtName = GConst.MATCH_SKILL_HURT_NAME[matchType] - return self:getAttrValue(skillHurtName) + return self:getAttrValue(skillHurtName) + self:getAttrValue(BattleConst.ATTR_NAME.ATTR_SKILL_HURT) end @@ -356,7 +368,7 @@ end function BattleTeamEntity:getNormalSkillHurtFixed(matchType) local skillHurtName = GConst.MATCH_NORMAL_HURT_NAME[matchType] - return self:getAttrValue(skillHurtName) + return self:getAttrValue(skillHurtName) + self:getAttrValue(BattleConst.ATTR_NAME.ATTR_NORMAL_HURT) end function BattleTeamEntity:getAllHurtP(matchType) diff --git a/lua/app/userdata/battle/team/battle_unit_entity.lua b/lua/app/userdata/battle/team/battle_unit_entity.lua index 2b2c3c57..ef1fd639 100644 --- a/lua/app/userdata/battle/team/battle_unit_entity.lua +++ b/lua/app/userdata/battle/team/battle_unit_entity.lua @@ -348,6 +348,18 @@ function BattleUnitEntity:getDecDmg(matchType) return self.team:getDecDmg(matchType or self.unitData.matchType) end +function BattleUnitEntity:getDmgDecFixed() + return self.team:getDmgDecFixed() +end + +function BattleUnitEntity:getBossHurtP() + return self.team:getBossHurtP() +end + +function BattleUnitEntity:getMonsterHurtP() + return self.team:getMonsterHurtP() +end + function BattleUnitEntity:getWeakness(matchType) return self.team:getWeakness(matchType or self.unitData.matchType) end diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index fd7c8ac6..6fcab37a 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -144,8 +144,8 @@ function HeroEntity:_updateAllAttr() self.allAttr[ATTR_NAME.DMGDEC] = (self.allAttr[ATTR_NAME.DMGDEC] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_DMGDEC_ALL) self.allAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_CRIT_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_CRIT_ALL) self.allAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_CRIT_TIME_ALL) - self.allAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_NORMAL_HURTP_ALL) - self.allAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_SKILL_HURTP_ALL) + self.allAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_NORMAL_HURTP_ALL) + self:getGlobalAttrByType(GConst.ATTR_PERSIONAL.ATTR_NORMAL_HURTP) + self.allAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] = (self.allAttr[GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()]] or 0) + self:getGlobalAttrByType(GConst.ATTR_ALL.ATTR_SKILL_HURTP_ALL) + self:getGlobalAttrByType(GConst.ATTR_PERSIONAL.ATTR_SKILL_HURTP) self:calcPower() end