From 9962a725d10ad2f4a58e68e8a2cc0383524d8d32 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sun, 22 Mar 2026 21:30:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8A=80=E8=83=BD):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=8D=87=E7=BA=A7=E9=85=8D=E7=BD=AE=E5=92=8C?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 SkillUpList 中的 buff_max 字段更正为 buff_hp - 移除 add_hp 和 add_shield 方法的 isValue 参数,改为直接使用数值 - 在 SCastSystem 中应用技能升级加成计算 AP、命中次数和 buff 值 - 为 HeroAttrsComp 添加 add_hp_max 和 add_ap 方法,替换原有的通用 buff 处理逻辑 - 简化伤害和技能效果应用逻辑,确保属性计算正确 --- assets/script/game/common/config/SkillSet.ts | 2 +- assets/script/game/hero/HeroAtkSystem.ts | 2 +- assets/script/game/hero/HeroAttrsComp.ts | 63 +++++--------------- assets/script/game/hero/SCastSystem.ts | 21 +++++-- 4 files changed, 33 insertions(+), 55 deletions(-) diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index c4161097..a4e9c352 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -150,7 +150,7 @@ export interface SkillConfig { } export const SkillUpList = { - 6001:{ap:0,hit_count:0,buff_ap:0,buff_max:0,bck:0,frz:0,crt:0,num:0} + 6001:{ap:0,hit_count:0,buff_ap:0,buff_hp:0,bck:0,frz:0,crt:0,num:0} } /****** diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 90bcdd38..b26967ac 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -139,7 +139,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd if (damage <= 0) return reDate; // TAttrsComp.hp -= damage; // 应用伤害到数据层 - TAttrsComp.add_hp(-damage, true); // 使用 add_hp 以触发 dirty_hp 和 UI 更新 + TAttrsComp.add_hp(-damage); // 使用 add_hp 以触发 dirty_hp 和 UI 更新 // 受击者产生击退效果 // if (damage > 0 && targetView) { diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 9f1420ae..33774450 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -80,19 +80,9 @@ export class HeroAttrsComp extends ecs.Comp { } /*******************基础属性管理********************/ - add_hp(value:number,isValue:boolean){ + add_hp(value:number){ const oldHp = this.hp; let addValue = value; - if(!isValue){ - addValue = value * this.hp_max / 100; - } - - // ✅ 数据层只负责数据修改,不调用视图层 - // let heroView = this.ent.get(HeroViewComp); - // if(heroView && addValue > 0){ - // heroView.health(addValue); - // } - this.hp += addValue; this.hp = Math.max(0, Math.min(this.hp, this.hp_max)); this.dirty_hp = true; // ✅ 仅标记需要更新 @@ -101,13 +91,9 @@ export class HeroAttrsComp extends ecs.Comp { } return addValue; } - - add_shield(value:number,isValue:boolean){ + add_shield(value:number){ const oldShield = this.shield; let addValue = value; - if(!isValue){ - addValue = value * this.hp_max / 100; - } this.shield += addValue; this.shield_max += addValue; if (this.shield < 0) this.shield = 0; @@ -117,44 +103,23 @@ export class HeroAttrsComp extends ecs.Comp { mLogger.log(this.debugMode, 'HeroAttrs', ` 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`); } } - // ==================== BUFF 管理 ==================== - /** - * 添加 buff 效果 - * @param buffConf buff 配置 - */ - addBuff(buffConf: BuffConf) { - this.applyAttrChange(buffConf.buff, buffConf.value); - if (this.debugMode) { - mLogger.log(this.debugMode, 'HeroAttrs', `属性:${buffConf.buff}, 值:${buffConf.value}`); - } + add_hp_max(value:number){ + this.hp_max+=value + this.hp+=value + this.dirty_hp = true; // ✅ 仅标记需要更新 + return value } - + + add_ap(value:number){ + this.ap +=value + return value + } + + toFrost(time: number=1) { this.frost_end_time += FightSet.FROST_TIME*time; } - /** - * 通用属性修改应用 - * @param attr 属性名 - * @param value 变化值 - */ - private applyAttrChange(attr: Attrs, value: number,) { - const mappedAttr = attr === Attrs.hp ? Attrs.hp_max : (attr === Attrs.shield ? Attrs.shield_max : attr); - if (mappedAttr !== Attrs.ap && mappedAttr !== Attrs.hp_max && mappedAttr !== Attrs.shield_max) return; - if (mappedAttr === Attrs.ap) { - this.ap = Math.max(0, this.ap + value); - return; - } - if (mappedAttr === Attrs.hp_max) { - this.hp_max = Math.max(1, this.hp_max + value); - if (this.hp > this.hp_max) this.hp = this.hp_max; - this.dirty_hp = true; - return; - } - this.shield_max = Math.max(0, this.shield_max + value); - this.shield = Math.max(0, Math.min(this.shield + value, this.shield_max)); - this.dirty_shield = true; - } updateCD(dt: number){ for (const key in this.skills) { const skill = this.skills[key]; diff --git a/assets/script/game/hero/SCastSystem.ts b/assets/script/game/hero/SCastSystem.ts index b9b402b3..f7602e00 100644 --- a/assets/script/game/hero/SCastSystem.ts +++ b/assets/script/game/hero/SCastSystem.ts @@ -7,6 +7,7 @@ import { Skill } from "../skill/Skill"; import { smc } from "../common/SingletonModuleComp"; import { GameConst } from "../common/config/GameConst"; import { HType } from "../common/config/heroSet"; +import { Attrs } from "../common/config/HeroAttrs"; /** * ==================== 自动施法系统 ==================== @@ -173,20 +174,32 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate */ private applyFriendlySkillEffects(_s_uuid: number, _skillLv: number, config: SkillConfig, _heroView: HeroViewComp, _cAttrsComp: HeroAttrsComp, targets: HeroViewComp[], _targetPos: Vec3 | null) { const kind = config.kind ?? SkillKind.Support; + const sUp=SkillUpList[_skillLv] + const sAp =config.ap+sUp.ap*_skillLv; + const sHit=config.hit_count+sUp.hit_count*_skillLv for (const target of targets) { if (!target.ent) continue; const model = target.ent.get(HeroAttrsComp); if (!model || model.is_dead) continue; if (kind === SkillKind.Heal && config.ap !== 0) { - const addHp = model.add_hp(config.ap, false); + const addHp = model.add_hp(sAp*_cAttrsComp.ap); target.health(addHp); - } else if (kind === SkillKind.Shield && config.ap !== 0) { - model.add_shield(config.ap, false); + } else if (kind === SkillKind.Shield && sAp !== 0) { + model.add_shield(sAp*_cAttrsComp.ap); } if (!config.buffs || config.buffs.length === 0) continue; for (const buffConf of config.buffs) { if (!buffConf) continue; - model.addBuff(buffConf); + const sBuffAp=buffConf.value+sUp.buff_ap + const sBuffHp=buffConf.value+sUp.buff_hp + switch (buffConf.buff){ + case Attrs.ap: + model.add_ap(sBuffAp) + break + case Attrs.hp_max: + model.add_hp_max(sBuffHp) + break + } } } }