修复 伤害错误

This commit is contained in:
panw
2025-03-26 16:57:15 +08:00
parent 8b33abb973
commit 63e182e214
3 changed files with 6 additions and 56 deletions

View File

@@ -31,8 +31,8 @@ export class SkillSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
if(this.checkSkill(skill)){
if(skill.atk_count < 1){
skill.atk_count++;
console.log("技能命中目标",skill.target.hero_name);
this.applySkillEffect(skill.caster,skill.target,SkillSet[skill.s_uuid],skill);
// console.log("技能命中目标",skill.caster,skill.target,SkillSet[skill.s_uuid]);
this.applySkillEffect(skill.caster,skill.target,SkillSet[skill.s_uuid]);
}
}
this.processDamageQueue();
@@ -63,10 +63,9 @@ export class SkillSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
return isInRange;
}
/** 应用技能效果 */
private applySkillEffect(casterView:HeroViewComp, targetView: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet],skill:SkillCom) {
private applySkillEffect(casterView:HeroViewComp, targetView: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]) {
// 直接计算伤害(包含防御减免)
const damageResult = this.calculateDamage(casterView, casterView, config);
const damageResult = this.calculateDamage(casterView, targetView, config);
// 将施法者传入applyDamage方法
this.applyDamage(targetView,damageResult);
// 播放技能特效
@@ -83,24 +82,11 @@ private calculateDamage(caster: HeroViewComp, target: HeroViewComp, config: type
ignoreDefense: false,
canCrit: true,
}
// 计算延迟时间
if (config.AnimType === AnimType.parabolic) {
const sourcePos = caster.node.position;
const targetPos = target.node.position;
// 计算距离除以速度得到时间
const distance = Math.abs(targetPos.x - sourcePos.x);
result.delay = distance / config.speed;
}
const sourceView = caster;
let final = sourceView.ap * config.ap / 100;
let final = caster.ap * config.ap / 100;
// 伤害浮动±10%
const damageFloat = 0.9 + Math.random() * 0.2; // 0.9~1.1
final *= damageFloat;
final = Math.round(final);
result.value = Math.max(1, final); // 确保最小伤害为1
result.isCrit = false;
return result;