From cc57eef1b318519f69fba6c147d032bd189f1a4e Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 2 Feb 2026 15:55:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=8B=B1=E9=9B=84=E5=B1=9E=E6=80=A7):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E5=B1=80=E5=B1=9E=E6=80=A7=E5=8A=A0?= =?UTF-8?q?=E6=88=90=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整全局属性加成配置,将攻击力加成值设为1,生命上限加成值设为100,并确保加成仅对英雄生效。在属性初始化时强制重算受全局属性影响的属性,并确保英雄初始状态为满血满蓝。 --- .../script/game/common/SingletonModuleComp.ts | 4 ++-- assets/script/game/hero/HeroAttrsComp.ts | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index ab8ce538..91fecf9f 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -144,8 +144,8 @@ export class SingletonModuleComp extends ecs.Comp { // 全局属性加成 {attrIndex: [value, count]} global_attrs: Record = { - [Attrs.AP]: [1, 100], // 攻击力 - [Attrs.HP_MAX]: [1, 10000], // 生命上限 + [Attrs.AP]: [1, 0], // 攻击力 + [Attrs.HP_MAX]: [100, 100], // 生命上限 [Attrs.DEF]: [1, 0], // 防御 [Attrs.SPEED]: [1, 0], // 速度 [Attrs.CRITICAL]: [1, 0], // 暴击率 diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index f7549f7c..04e66575 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -213,6 +213,19 @@ export class HeroAttrsComp extends ecs.Comp { this.addBuff(buffConf); } } + + // 3. 应用全局属性加成 (强制重算受影响的属性) + if (this.fac === 0 && smc.global_attrs) { + for (const key in smc.global_attrs) { + const attrIndex = Number(key); + this.recalculateSingleAttr(attrIndex); + } + } + + // 4. 初始化状态值 (确保满状态) + this.hp = this.Attrs[Attrs.HP_MAX]; + this.mp = this.Attrs[Attrs.MP_MAX]; + smc.updateHeroInfo(this); } /*******************基础属性管理********************/ @@ -370,10 +383,13 @@ export class HeroAttrsComp extends ecs.Comp { } } - // 全局属性加成 - if (smc.global_attrs[attrIndex]) { + // 全局属性加成 (只对英雄生效,怪物不生效) + // this.fac === 0 代表英雄 (FacSet.HERO) + if (this.fac === 0 && smc.global_attrs && smc.global_attrs[attrIndex]) { const [val, count] = smc.global_attrs[attrIndex]; - totalRatio += val * count; + const globalAdd = val * count; + totalRatio += globalAdd; + // console.log(`[HeroAttrs] 全局加成: ${this.hero_name} Attr=${attrIndex} Val=${val} Count=${count} Add=${globalAdd}%`); } // 4. 根据属性类型计算最终值