From f43e0a75e50d673d30df9872d8fc55eaf55dd28a Mon Sep 17 00:00:00 2001 From: walkpan Date: Tue, 30 Dec 2025 22:41:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(HeroSkills):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=86=B7=E5=8D=B4=E6=97=B6=E9=97=B4=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用技能配置中的hset属性代替数组索引判断攻击类型 添加速度加成下限保护防止除零错误 简化条件判断并移除冗余代码 --- assets/script/game/hero/HeroSkills.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/assets/script/game/hero/HeroSkills.ts b/assets/script/game/hero/HeroSkills.ts index 26d09e8d..45ef40ce 100644 --- a/assets/script/game/hero/HeroSkills.ts +++ b/assets/script/game/hero/HeroSkills.ts @@ -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; } -} \ No newline at end of file +}