refactor(战斗系统): 统一伤害减免属性命名并优化伤害计算逻辑

- 将LDMG枚举值重命名为DAMAGE_REDUCTION以提高可读性
- 修改HeroAtkSystem中的dmgCount方法,直接接收HeroAttrsComp参数
- 在伤害计算中整合天赋系统的伤害减免效果
This commit is contained in:
2025-11-26 16:35:44 +08:00
parent df3ad88c3e
commit bbf8dbb8cb
3 changed files with 11 additions and 9 deletions

View File

@@ -158,7 +158,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]);
if (isCrit) attackerModel?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff
// 计算伤害
let damage = this.dmgCount(damageEvent,targetAttrs.Attrs);
let damage = this.dmgCount(damageEvent,targetAttrs);
if (isCrit) {
// 暴击伤害计算
// 使用施法者的暴击伤害加成属性damageEvent.Attrs 快照)
@@ -228,9 +228,10 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
* - 所有除法和乘法计算后都进行取整操作,确保游戏中的伤害值为整数
* - 元素伤害只应用于魔法伤害部分
*/
private dmgCount(damageEvent:any,TAttrs:any){
private dmgCount(damageEvent:any,TAttrsComp:HeroAttrsComp){
// 1. 获取技能配置 - 如果技能不存在直接返回0伤害
const CAttrs=damageEvent.Attrs;
const TAttrs=TAttrsComp.Attrs;
let sConf = SkillSet[damageEvent.s_uuid];
if (!sConf) return 0;
@@ -276,11 +277,12 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
// 8. 计算最终总伤害(物理伤害 + 魔法伤害)
let total = apAfter + mapAfter;
// 9. 应用最终伤害减免效果如特殊天赋、buff等提供的减免
// 9. 计算免伤
let DMG_RED = TAttrs[Attrs.DAMAGE_REDUCTION]||0+TAttrsComp.useCountValTal(Attrs.DAMAGE_REDUCTION);
// 10. 应用最终伤害减免效果如特殊天赋、buff等提供的减免
total = Math.floor(total * (1 - ((TAttrs[Attrs.DAMAGE_REDUCTION]||0)/100)));
// 10. 确保伤害值非负,返回最终伤害
// 11. 确保伤害值非负,返回最终伤害
return Math.max(0,total);
}