fix(战斗): 修正护盾计算并重构技能效果处理
- 修复护盾计算错误,将百分比加成基数从 shield_max 改为 hp_max - 增加护盾和最大护盾值的非负检查 - 引入 SkillKind 枚举明确技能类型,重构 SCastSystem 中的技能效果处理逻辑 - 将治疗和护盾效果从 Buff 系统剥离,直接作用于 HeroAttrsComp - 清理未使用的导入和日志输出
This commit is contained in:
@@ -40,6 +40,13 @@ export enum DTType {
|
||||
range = 1,
|
||||
}
|
||||
|
||||
export enum SkillKind {
|
||||
Damage = 0,
|
||||
Heal = 1,
|
||||
Shield = 2,
|
||||
Support = 3
|
||||
}
|
||||
|
||||
/**
|
||||
* 攻击距离类型分类
|
||||
* 用于AI决策和技能配置规范化
|
||||
@@ -179,6 +186,7 @@ export interface SkillConfig {
|
||||
DAnm:number, // 命中后动画ID
|
||||
RType:RType, // 技能运行类型(直线/贝塞尔/固定起点/固定终点)
|
||||
EType:EType, // 结束条件(动画结束/时间结束/距离结束/碰撞/次数结束)
|
||||
kind?:SkillKind, // 主效果类型
|
||||
buffs:number[], // 对施法者的buff配置列表(Buff UUID 列表)
|
||||
debuffs:number[], // 对目标的debuff配置列表(Buff UUID 列表)
|
||||
call_hero?:number, // 召唤技能召唤英雄id(可选)
|
||||
@@ -221,25 +229,25 @@ export const SkillSet: Record<number, SkillConfig> = {
|
||||
uuid:6100,name:"治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Self,TType:TType.LowestHP,act:"atk",DTType:DTType.single,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[10301],debuffs:[],info:"治疗自己,回复30%最大生命值",
|
||||
kind:SkillKind.Heal,buffs:[],debuffs:[],info:"治疗自己,回复30%最大生命值",
|
||||
},
|
||||
6101:{
|
||||
uuid:6101,name:"魔法盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,TType:TType.LowestHP,act:"atk",DTType:DTType.single,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[10302],debuffs:[],info:"获得30%最大生命值的护盾,持续60秒",
|
||||
kind:SkillKind.Shield,buffs:[],debuffs:[],info:"获得30%最大生命值的护盾,持续60秒",
|
||||
},
|
||||
6102:{
|
||||
uuid:6102,name:"强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,TType:TType.HighestAP,act:"atk",DTType:DTType.single,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[10001],debuffs:[],info:"增加目标10%攻击力,持续30秒",
|
||||
kind:SkillKind.Support,buffs:[10001],debuffs:[],info:"增加目标10%攻击力,持续30秒",
|
||||
},
|
||||
6103:{
|
||||
uuid:6103,name:"群体强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,TType:TType.HighestAP,act:"atk",DTType:DTType.range,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[10011],debuffs:[],info:"增加目标10%攻击力,持续30秒",
|
||||
kind:SkillKind.Support,buffs:[10011],debuffs:[],info:"增加目标10%攻击力,持续30秒",
|
||||
},
|
||||
// ========== 怪物基础技能 ========== 6200-6299
|
||||
6201: {
|
||||
|
||||
@@ -141,9 +141,12 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
const oldShield = this.shield;
|
||||
let addValue = value;
|
||||
if(!isValue){
|
||||
addValue = value * this.shield_max / 100;
|
||||
addValue = value * this.hp_max / 100;
|
||||
}
|
||||
this.shield += addValue;
|
||||
this.shield_max += addValue;
|
||||
if (this.shield < 0) this.shield = 0;
|
||||
if (this.shield_max < 0) this.shield_max = 0;
|
||||
this.dirty_shield = true; // 标记护盾需要更新
|
||||
mLogger.log(this.debugMode, 'HeroAttrs', ` 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`);
|
||||
}
|
||||
|
||||
@@ -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[] {
|
||||
|
||||
Reference in New Issue
Block a user