feat(技能系统): 扩展Buff运行类型并修复治疗与护盾配置

- 扩展BuffRunType枚举,新增Permanent和Timed类型,明确区分永久、定时和间隔效果
- 在HeroAttrsComp中重构addBuff方法,根据配置智能解析运行类型
- 为治疗(10301)和护盾(10302)配置显式添加runType: Permanent,确保逻辑一致性
- 修复定时Buff的持续时间处理,避免time为0时使用默认值1
This commit is contained in:
panw
2026-03-13 10:41:47 +08:00
parent 3ee57a5711
commit 887ba6064c
2 changed files with 17 additions and 15 deletions

View File

@@ -48,8 +48,9 @@ export enum SkillKind {
}
export enum BuffRunType {
Attr = 0,
Interval = 1
Permanent = 0,
Timed = 1,
Interval = 2
}
/**
@@ -329,9 +330,9 @@ export const BuffsList: Record<number, BuffConf> = {
// ========== 治疗与护盾 (转换自原 SType) ========== 10300 - 10399
// 治疗 (基于攻击力百分比)
10301: { uuid: 10301, name: "治疗", icon: "1292", buff: Attrs.hp, BType: BType.RATIO, value: 30, time: 0, chance: 1, info: "回复30%最大生命值" },
10301: { uuid: 10301, name: "治疗", icon: "1292", buff: Attrs.hp, BType: BType.RATIO, value: 30, time: 0, chance: 1, runType: BuffRunType.Permanent, info: "回复30%最大生命值" },
// 护盾 (基于攻击力百分比)
10302: { uuid: 10302, name: "护盾", icon: "1255", buff: Attrs.shield, BType: BType.RATIO, value: 30, time: 0, chance: 1, info: "获得30%最大生命值护盾" },
10302: { uuid: 10302, name: "护盾", icon: "1255", buff: Attrs.shield, BType: BType.RATIO, value: 30, time: 0, chance: 1, runType: BuffRunType.Permanent, info: "获得30%最大生命值护盾" },
10311: { uuid: 10311, name: "持续治疗", icon: "1292", buff: Attrs.hp, BType: BType.RATIO, value: 5, time: 5, interval: 1, chance: 1, runType: BuffRunType.Interval, info: "每秒回复5%最大生命值持续5秒" },
10312: { uuid: 10312, name: "流血", icon: "10211", buff: Attrs.hp, BType: BType.RATIO, value: -4, time: 5, interval: 1, chance: 1, isDebuff: true, runType: BuffRunType.Interval, info: "每秒损失4%最大生命值持续5秒" },

View File

@@ -1,6 +1,4 @@
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { Attrs, BType } from "../common/config/HeroAttrs";
import { BuffConf, BuffRunType, SkillDisVal, SkillRange } from "../common/config/SkillSet";
import { HeroInfo, HType } from "../common/config/heroSet";
@@ -9,12 +7,7 @@ import { smc } from "../common/SingletonModuleComp";
import { HeroViewComp } from "./HeroViewComp";
import { _decorator } from "cc";
const { property } = _decorator;
interface talTrigger{
value:number
count:number
}
interface ActiveBuffState {
id: number
attr: Attrs
@@ -180,7 +173,8 @@ export class HeroAttrsComp extends ecs.Comp {
*/
addBuff(buffConf: BuffConf) {
const normalized = this.normalizeBuffValue(buffConf);
if (buffConf.runType === BuffRunType.Interval) {
const runType = this.resolveRunType(buffConf);
if (runType === BuffRunType.Interval) {
const interval = buffConf.interval && buffConf.interval > 0 ? buffConf.interval : 1;
const remain = buffConf.time > 0 ? buffConf.time : interval;
this.INTERVAL_EFFECTS.push({
@@ -195,10 +189,11 @@ export class HeroAttrsComp extends ecs.Comp {
});
return;
}
if (buffConf.time <= 0) {
if (runType === BuffRunType.Permanent) {
this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType);
return;
}
const duration = buffConf.time > 0 ? buffConf.time : 1;
const targetList = buffConf.isDebuff ? this.DEBUFFS : this.BUFFS;
const attrKey = buffConf.buff as unknown as number; // 强制转换 key 类型以适配 Record
@@ -213,12 +208,18 @@ export class HeroAttrsComp extends ecs.Comp {
sourceUuid: buffConf.uuid,
value: normalized.value,
BType: normalized.BType,
time: buffConf.time
time: duration
});
this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType);
mLogger.log(this.debugMode, 'HeroAttrs', `添加Buff: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}, 时间:${buffConf.time}`);
mLogger.log(this.debugMode, 'HeroAttrs', `添加Buff: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}, 时间:${duration}`);
}
private resolveRunType(buffConf: BuffConf): BuffRunType {
if (buffConf.runType !== undefined) return buffConf.runType;
if (buffConf.interval && buffConf.interval > 0) return BuffRunType.Interval;
return buffConf.time > 0 ? BuffRunType.Timed : BuffRunType.Permanent;
}
private normalizeBuffValue(buffConf: BuffConf): { value: number; BType: BType } {