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. 根据属性类型计算最终值