refactor(HeroSkills): 优化技能冷却时间计算逻辑
使用技能配置中的hset属性代替数组索引判断攻击类型 添加速度加成下限保护防止除零错误 简化条件判断并移除冗余代码
This commit is contained in:
@@ -145,16 +145,11 @@ export class HeroSkillsComp extends ecs.Comp {
|
||||
const skill = this.getSkill(s_uuid);
|
||||
if (!skill) return;
|
||||
|
||||
// 普通攻击(skills[0])受 AS 影响,其余技能受 SS 影响
|
||||
const isNormalAttack = s_uuid === this.skills[0]?.s_uuid;
|
||||
const speedAttr = isNormalAttack ? Attrs.AS : Attrs.SS;
|
||||
const speedBonus = attrsCom.Attrs[speedAttr] / 100; // 100 表示 100% 提速
|
||||
const speedMultiplier = 1 / (1 + speedBonus); // 提速 100% => cd 减半
|
||||
|
||||
skill.cd = skill.cd_max * speedMultiplier;
|
||||
if (skill) {
|
||||
skill.cd = skill.cd_max;
|
||||
}
|
||||
const speedAttr = skill.hset === HSSet.atk ? Attrs.AS : Attrs.SS;
|
||||
const rawSpeed = attrsCom.Attrs?.[speedAttr] ?? 0;
|
||||
const speedBonus = Math.max(-0.9, rawSpeed / 100);
|
||||
const speedMultiplier = 1 / (1 + speedBonus);
|
||||
skill.cd = Math.max(0, skill.cd_max * speedMultiplier);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,4 +269,4 @@ export class HeroSkillsComp extends ecs.Comp {
|
||||
setMaxAuto(on: boolean) {
|
||||
this.max_auto = on;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user