fix(战斗): 修正护盾计算并重构技能效果处理

- 修复护盾计算错误,将百分比加成基数从 shield_max 改为 hp_max
- 增加护盾和最大护盾值的非负检查
- 引入 SkillKind 枚举明确技能类型,重构 SCastSystem 中的技能效果处理逻辑
- 将治疗和护盾效果从 Buff 系统剥离,直接作用于 HeroAttrsComp
- 清理未使用的导入和日志输出
This commit is contained in:
panw
2026-03-13 09:52:43 +08:00
parent 6170f47ca6
commit 3b545e3bff
3 changed files with 39 additions and 23 deletions

View File

@@ -2,12 +2,10 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { Vec3 } from "cc";
import { HeroAttrsComp } from "./HeroAttrsComp";
import { HeroViewComp } from "./HeroViewComp";
import { BuffsList, SkillConfig, SkillSet, TGroup, TType } from "../common/config/SkillSet";
import { BuffsList, SkillConfig, SkillKind, SkillSet, TGroup, TType } from "../common/config/SkillSet";
import { Skill } from "../skill/Skill";
import { smc } from "../common/SingletonModuleComp";
import { GameConst } from "../common/config/GameConst";
import { mLogger } from "../common/Logger";
import { Attrs } from "../common/config/HeroAttrs";
/**
* ==================== 自动施法系统 ====================
@@ -72,14 +70,8 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
const delay = GameConst.Battle.SKILL_CAST_DELAY;
heroView.scheduleOnce(() => {
if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return;
// 优先判断是否有ap伤害物理/魔法伤害)
if (config.ap > 0) {
this.createSkillEntity(s_uuid, heroView, targets[0].node.position);
}
// 接着应用buff效果包括治疗、护盾等已转换为buff的逻辑
if ((config.buffs && config.buffs.length > 0) || (config.debuffs && config.debuffs.length > 0)) {
this.applySupportSkill(entity, config, targets);
}
this.applyPrimaryEffect(entity, s_uuid, config, heroView, targets);
this.applyExtraEffects(config, targets);
}, delay);
if (isMainSkill) {
heroAttrs.triggerSkillCD();
@@ -96,16 +88,31 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
skill.load(caster.node.position.clone(), parent, s_uuid, targetPos.clone(), caster, 0);
}
private applySupportSkill(casterEntity: ecs.Entity, config: SkillConfig, targets: HeroViewComp[]) {
const casterAttrs = casterEntity.get(HeroAttrsComp);
if (!casterAttrs) return;
private applyPrimaryEffect(casterEntity: ecs.Entity, s_uuid: number, config: SkillConfig, heroView: HeroViewComp, targets: HeroViewComp[]) {
const kind = config.kind ?? SkillKind.Damage;
if (kind === SkillKind.Damage) {
if (config.ap > 0) {
this.createSkillEntity(s_uuid, heroView, targets[0].node.position);
}
return;
}
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) {
model.add_hp(config.ap, false);
} else if (kind === SkillKind.Shield && config.ap !== 0) {
model.add_shield(config.ap, false);
}
}
}
// 统一通过 Buff 系统应用效果
private applyExtraEffects(config: SkillConfig, targets: HeroViewComp[]) {
for (const target of targets) {
if (!target.ent) continue;
const model = target.ent.get(HeroAttrsComp);
if (!model || model.is_dead) continue;
if (config.buffs) {
for (const buffId of config.buffs) {
const buffConf = BuffsList[buffId];
@@ -115,7 +122,6 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
}
}
// 应用 Debuff 效果
if (config.debuffs) {
for (const buffId of config.debuffs) {
const buffConf = BuffsList[buffId];
@@ -125,7 +131,6 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
}
}
}
mLogger.log(this.debugMode, "SCastSystem", `[SCastSystem] ${casterAttrs.hero_name} 施放 ${config.name}`);
}
private findTargets(caster: HeroViewComp, casterAttrs: HeroAttrsComp, config: SkillConfig): HeroViewComp[] {