伤害公式

This commit is contained in:
puxuan 2025-10-27 10:54:15 +08:00
parent 97d8c082c7
commit 676ced2dec
9 changed files with 67 additions and 7 deletions

View File

@ -526,6 +526,8 @@ local ATTR_NAME = {
IMMUNE_REDUCTION_BENEFIT = "immune_reduction_benefit", -- 免疫减益 IMMUNE_REDUCTION_BENEFIT = "immune_reduction_benefit", -- 免疫减益
FOREVER_UNCONTROLLED = "forever_uncontrolled", -- 永久免控 FOREVER_UNCONTROLLED = "forever_uncontrolled", -- 永久免控
ATTR_NORMAL_HURTP_ALL_ADD = "attr_normal_hurtp_all", 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 BattleConst.ATTR_NAME = ATTR_NAME

View File

@ -60,6 +60,10 @@ function BattleUnitComp:getMatchType()
return self.unitEntity:getMatchType() return self.unitEntity:getMatchType()
end end
function BattleUnitComp:checkMonsterDmgAdd()
return self.battleController:checkMonsterDmgAdd()
end
function BattleUnitComp:getIsBoss() function BattleUnitComp:getIsBoss()
return self.unitEntity:getIsBoss() return self.unitEntity:getIsBoss()
end end

View File

@ -20,6 +20,10 @@ local GRID_BREAK_CONDITION = BattleConst.GRID_BREAK_CONDITION
local SIDE_ATK = BattleConst.SIDE_ATK local SIDE_ATK = BattleConst.SIDE_ATK
local SIDE_DEF = BattleConst.SIDE_DEF local SIDE_DEF = BattleConst.SIDE_DEF
function BattleBaseController:checkMonsterDmgAdd()
return true
end
function BattleBaseController:getPosInfo(posId) function BattleBaseController:getPosInfo(posId)
return ModuleManager.BattleManager:getPosInfo(posId, self:getRowCount()) return ModuleManager.BattleManager:getPosInfo(posId, self:getRowCount())
end end

View File

@ -7,6 +7,10 @@ local SIDE_ATK = BattleConst.SIDE_ATK
local SIDE_DEF = BattleConst.SIDE_DEF local SIDE_DEF = BattleConst.SIDE_DEF
-- *************各个子模块的战斗需要重写的方法 START************* -- *************各个子模块的战斗需要重写的方法 START*************
function BattleControllerPVP:checkMonsterDmgAdd()
return false
end
function BattleControllerPVP:getBoardConfig() function BattleControllerPVP:getBoardConfig()
return {} return {}
end end

View File

@ -50,10 +50,17 @@ function BattleFormula:getExpectedDamageResult(unitComp, count, targetUnitComp,
end end
BattleFormula.calculateFormula = { BattleFormula.calculateFormula = {
-- ((攻击)*技能倍率*(1+(攻击者元素伤害增加+所有伤害增加)(攻击者)- (攻击者元素伤害降低+所有伤害降低) +(受到元素伤害增加+受到所有伤害增加(受击)-受到元素伤害降低-受到所有伤害降低(受击) + 主动技能增伤) + 固定值) *暴击伤害*(1-最终造成伤害降低%+最终造成伤害增加%) -- 局内攻击*技能倍率*(1
-- +(攻击者元素伤害增加+所有伤害增加+主动技能OR普攻增伤%+BOSS或小怪增伤%)(攻击者
-- +(受到元素伤害增加+受到所有伤害增加)(受击者
-- -(攻击者元素伤害降低+所有伤害降低)(受击者
-- -(受到元素伤害降低-受到所有伤害降低)(受击者
-- +普攻或技能增伤固定值)*暴击伤害(攻击者)*(1-最终造成伤害降低%(受击者
-- +最终造成伤害增加%(攻击者))-减伤固定值(受击者)
[1] = function(unitComp, buff, targetUnit) [1] = function(unitComp, buff, targetUnit)
local skillFixedAdd = 0 local skillFixedAdd = 0
local skillPAdd = 0 local skillPAdd = 0
local monsterDmgPAdd = 0
local hostSkill = buff:getHostSkill() local hostSkill = buff:getHostSkill()
local atkMatchType = unitComp.unitEntity:getMatchType() local atkMatchType = unitComp.unitEntity:getMatchType()
if hostSkill then -- 技能伤害加成 if hostSkill then -- 技能伤害加成
@ -67,13 +74,21 @@ BattleFormula.calculateFormula = {
skillPAdd = skillPAdd + unitComp.unitEntity:getAllHurtP() skillPAdd = skillPAdd + unitComp.unitEntity:getAllHurtP()
end 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 -- 基础值(攻击 * 技能倍率) local result = unitComp.unitEntity:getAtk() * buff:getEffectNum() // DEFAULT_FACTOR -- 基础值(攻击 * 技能倍率)
result = result * (DEFAULT_FACTOR result = result * (DEFAULT_FACTOR
+ unitComp.unitEntity:getDmgAddition() -- (攻击者元素伤害增加 + 所有伤害增加) + unitComp.unitEntity:getDmgAddition() -- (攻击者元素伤害增加 + 所有伤害增加)
- unitComp.unitEntity:getDmgDec() -- (攻击者元素伤害降低 + 所有伤害降低) - unitComp.unitEntity:getDmgDec() -- (攻击者元素伤害降低 + 所有伤害降低)
+ targetUnit.unitEntity:getWeakness(atkMatchType) -- (受击者受到元素伤害增加 + 受到所有伤害增加) + targetUnit.unitEntity:getWeakness(atkMatchType) -- (受击者受到元素伤害增加 + 受到所有伤害增加)
- targetUnit.unitEntity:getDecDmg(atkMatchType) -- (受击者受到元素伤害降低 + 受到所有伤害降低) - targetUnit.unitEntity:getDecDmg(atkMatchType) -- (受击者受到元素伤害降低 + 受到所有伤害降低)
+ skillPAdd) // DEFAULT_FACTOR -- 技能增伤百分比 + skillPAdd + monsterDmgPAdd) // DEFAULT_FACTOR -- 技能增伤百分比
result = result + skillFixedAdd -- 固定值 result = result + skillFixedAdd -- 固定值
-- 暴击 -- 暴击
@ -87,6 +102,10 @@ BattleFormula.calculateFormula = {
end end
-- 最终伤害 -- 最终伤害
result = result * (DEFAULT_FACTOR - unitComp.unitEntity:getEndDmgDecAll() + unitComp.unitEntity:getEndDmgAddtionAll()) // DEFAULT_FACTOR 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 return result, hurtState
end, end,
-- 生命值*回合开始时的回血系数*(1 + 治疗效果增加) -- 生命值*回合开始时的回血系数*(1 + 治疗效果增加)

View File

@ -945,6 +945,9 @@ function BattleBaseData:initHeroData(formation)
end end
unitData.attr[BattleConst.ATTR_NAME.ATTR_MONSTER_DMG] = heroEntity:getTotalAttrValue(BattleConst.ATTR_NAME.ATTR_MONSTER_DMG) 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.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] local skillInfo = skillCfg[skillId]
if skillInfo then if skillInfo then

View File

@ -193,6 +193,18 @@ function BattleTeamEntity:getDecDmg(matchType)
return self:getAttrValue(ATTR_NAME.DEC_DMG_ALL) + self:getAttrValue(MATCH_DEC_DMG_NAME[matchType]) return self:getAttrValue(ATTR_NAME.DEC_DMG_ALL) + self:getAttrValue(MATCH_DEC_DMG_NAME[matchType])
end 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) function BattleTeamEntity:getWeakness(matchType)
return self:getAttrValue(ATTR_NAME.WEAKNESS_ALL) + self:getAttrValue(MATCH_WEAKNESS_NAME[matchType]) return self:getAttrValue(ATTR_NAME.WEAKNESS_ALL) + self:getAttrValue(MATCH_WEAKNESS_NAME[matchType])
end end
@ -340,12 +352,12 @@ end
function BattleTeamEntity:getSkillHurtP(matchType) function BattleTeamEntity:getSkillHurtP(matchType)
local skillHurtPName = GConst.MATCH_SKILL_HURTP_NAME[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 end
function BattleTeamEntity:getSkillHurtFixed(matchType) function BattleTeamEntity:getSkillHurtFixed(matchType)
local skillHurtName = GConst.MATCH_SKILL_HURT_NAME[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 end
@ -356,7 +368,7 @@ end
function BattleTeamEntity:getNormalSkillHurtFixed(matchType) function BattleTeamEntity:getNormalSkillHurtFixed(matchType)
local skillHurtName = GConst.MATCH_NORMAL_HURT_NAME[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 end
function BattleTeamEntity:getAllHurtP(matchType) function BattleTeamEntity:getAllHurtP(matchType)

View File

@ -348,6 +348,18 @@ function BattleUnitEntity:getDecDmg(matchType)
return self.team:getDecDmg(matchType or self.unitData.matchType) return self.team:getDecDmg(matchType or self.unitData.matchType)
end 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) function BattleUnitEntity:getWeakness(matchType)
return self.team:getWeakness(matchType or self.unitData.matchType) return self.team:getWeakness(matchType or self.unitData.matchType)
end end

View File

@ -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[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_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_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_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.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() self:calcPower()
end end