refactor(技能系统): 移除未使用属性并优化目标选择逻辑

- 移除 Skill.ts 中未使用的 wfuny 属性赋值
- 将 SCastSystem 中的目标选择逻辑重构为统一方法
- 在施放技能前增加目标有效性检查,避免无效操作
- 移除 HeroAtkSystem 中未使用的导入和接口字段
- 调整 SkillSet 中技能 6008 的 ready 参数值
This commit is contained in:
walkpan
2026-03-16 19:33:24 +08:00
parent 5d24dbff29
commit a634b33f6b
4 changed files with 25 additions and 19 deletions

View File

@@ -235,7 +235,7 @@ export const SkillSet: Record<number, SkillConfig> = {
6008: { 6008: {
uuid:6008,name:"水球",sp_name:"ball_water",icon:"1126",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single, uuid:6008,name:"水球",sp_name:"ball_water",icon:"1126",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
ap:100,hit_count:2,hitcd:0.3,speed:720,with:90, ap:100,hit_count:2,hitcd:0.3,speed:720,with:90,
ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision, ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision,
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害", buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
}, },

View File

@@ -2,13 +2,11 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { FacSet } from "../common/config/GameSet"; import { FacSet } from "../common/config/GameSet";
import { Attrs } from "../common/config/HeroAttrs"; import { Attrs } from "../common/config/HeroAttrs";
import { FightSet } from "../common/config/GameSet"; import { FightSet } from "../common/config/GameSet";
import { SkillSet, DType } from "../common/config/SkillSet"; import { SkillSet } from "../common/config/SkillSet";
import { HeroAttrsComp } from "./HeroAttrsComp"; import { HeroAttrsComp } from "./HeroAttrsComp";
import { HeroViewComp } from "./HeroViewComp"; import { HeroViewComp } from "./HeroViewComp";
import { DamageQueueComp, DamageEvent } from "./DamageQueueComp"; import { DamageQueueComp, DamageEvent } from "./DamageQueueComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { mLogger } from "../common/Logger"; import { mLogger } from "../common/Logger";
@@ -17,12 +15,10 @@ import { mLogger } from "../common/Logger";
* 用于封装一次攻击计算的所有结果数据 * 用于封装一次攻击计算的所有结果数据
* @property damage - 最终造成的伤害值(已考虑所有加成和减免) * @property damage - 最终造成的伤害值(已考虑所有加成和减免)
* @property isCrit - 是否为暴击攻击 * @property isCrit - 是否为暴击攻击
* @property isDodge - 是否被闪避闪避时damage为0
*/ */
interface FinalData { interface FinalData {
damage: number; damage: number;
isCrit: boolean; isCrit: boolean;
isDodge: boolean;
} }
/** /**
* 英雄攻击系统 - 伤害处理核心系统 * 英雄攻击系统 - 伤害处理核心系统
@@ -106,7 +102,6 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
let reDate:FinalData={ let reDate:FinalData={
damage:0, damage:0,
isCrit:false, isCrit:false,
isDodge:false,
} }
if (!TAttrsComp || TAttrsComp.is_dead || TAttrsComp.is_reviving) return reDate; if (!TAttrsComp || TAttrsComp.is_dead || TAttrsComp.is_reviving) return reDate;

View File

@@ -25,6 +25,7 @@ import { GameConst } from "../common/config/GameConst";
@ecs.register('SCastSystem') @ecs.register('SCastSystem')
export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
debugMode: boolean = false; // 是否启用调试模式 debugMode: boolean = false; // 是否启用调试模式
private readonly emptyCastPlan = { skillId: 0, targets: [] as HeroViewComp[] };
filter(): ecs.IMatcher { filter(): ecs.IMatcher {
return ecs.allOf(HeroAttrsComp, HeroViewComp); return ecs.allOf(HeroAttrsComp, HeroViewComp);
@@ -39,12 +40,12 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
if (heroAttrs.is_dead || heroAttrs.is_reviving || heroAttrs.isStun() || heroAttrs.isFrost()) return; if (heroAttrs.is_dead || heroAttrs.is_reviving || heroAttrs.isStun() || heroAttrs.isFrost()) return;
heroAttrs.updateCD(this.dt); heroAttrs.updateCD(this.dt);
if (!heroAttrs.is_atking) return; if (!heroAttrs.is_atking) return;
const castSkillId = this.pickCastSkill(heroAttrs, heroView); const castPlan = this.pickCastSkill(heroAttrs, heroView);
if (castSkillId === 0) return; if (castPlan.skillId === 0 || castPlan.targets.length === 0) return;
this.castSkill(e, castSkillId, heroAttrs, heroView); this.castSkill(e, castPlan, heroAttrs, heroView);
} }
private pickCastSkill(heroAttrs: HeroAttrsComp, heroView: HeroViewComp): number { private pickCastSkill(heroAttrs: HeroAttrsComp, heroView: HeroViewComp): { skillId: number; targets: HeroViewComp[] } {
const skillCandidates = [heroAttrs.skill_id, heroAttrs.atk_id]; const skillCandidates = [heroAttrs.skill_id, heroAttrs.atk_id];
for (const s_uuid of skillCandidates) { for (const s_uuid of skillCandidates) {
if (!s_uuid) continue; if (!s_uuid) continue;
@@ -55,16 +56,15 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
if (!isMainSkill && !heroAttrs.can_atk) continue; if (!isMainSkill && !heroAttrs.can_atk) continue;
const targets = this.findTargets(heroView, heroAttrs, config); const targets = this.findTargets(heroView, heroAttrs, config);
if (targets.length === 0) continue; if (targets.length === 0) continue;
return s_uuid; return { skillId: s_uuid, targets };
} }
return 0; return this.emptyCastPlan;
} }
private castSkill(entity: ecs.Entity, s_uuid: number, heroAttrs: HeroAttrsComp, heroView: HeroViewComp) { private castSkill(entity: ecs.Entity, castPlan: { skillId: number; targets: HeroViewComp[] }, heroAttrs: HeroAttrsComp, heroView: HeroViewComp) {
const s_uuid = castPlan.skillId;
const config = SkillSet[s_uuid]; const config = SkillSet[s_uuid];
if (!config) return; if (!config) return;
const targets = this.findTargets(heroView, heroAttrs, config);
if (targets.length === 0) return;
heroView.playSkillEffect(s_uuid); heroView.playSkillEffect(s_uuid);
const isMainSkill = s_uuid === heroAttrs.skill_id; const isMainSkill = s_uuid === heroAttrs.skill_id;
@@ -75,8 +75,10 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
heroView.scheduleOnce(() => { heroView.scheduleOnce(() => {
if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return; if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return;
this.applyPrimaryEffect(entity, s_uuid, config, heroView, targets); const validTargets = this.filterValidTargets(castPlan.targets);
this.applyExtraEffects(config, targets); if (validTargets.length === 0) return;
this.applyPrimaryEffect(entity, s_uuid, config, heroView, validTargets);
this.applyExtraEffects(config, validTargets);
}, delay); }, delay);
if (isMainSkill) { if (isMainSkill) {
heroAttrs.triggerSkillCD(); heroAttrs.triggerSkillCD();
@@ -138,6 +140,16 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
} }
} }
private filterValidTargets(targets: HeroViewComp[]): HeroViewComp[] {
return targets.filter(target => {
if (!target || !target.node || !target.node.isValid) return false;
if (!target.ent) return false;
const model = target.ent.get(HeroAttrsComp);
if (!model || model.is_dead || model.is_reviving) return false;
return true;
});
}
private findTargets(caster: HeroViewComp, casterAttrs: HeroAttrsComp, config: SkillConfig): HeroViewComp[] { private findTargets(caster: HeroViewComp, casterAttrs: HeroAttrsComp, config: SkillConfig): HeroViewComp[] {
const range = casterAttrs.getCachedMaxSkillDistance() || GameConst.Battle.DEFAULT_SEARCH_RANGE; const range = casterAttrs.getCachedMaxSkillDistance() || GameConst.Battle.DEFAULT_SEARCH_RANGE;
const isEnemy = config.TGroup === TGroup.Enemy; const isEnemy = config.TGroup === TGroup.Enemy;

View File

@@ -202,7 +202,6 @@ export class Skill extends ecs.Entity {
sDataCom.Attrs[Attrs.slow_chance] = cAttrsComp.slow_chance; sDataCom.Attrs[Attrs.slow_chance] = cAttrsComp.slow_chance;
sDataCom.Attrs[Attrs.puncture] = cAttrsComp.puncture; sDataCom.Attrs[Attrs.puncture] = cAttrsComp.puncture;
sDataCom.Attrs[Attrs.puncture_dmg] = cAttrsComp.puncture_dmg; sDataCom.Attrs[Attrs.puncture_dmg] = cAttrsComp.puncture_dmg;
sDataCom.Attrs[Attrs.wfuny] = cAttrsComp.wfuny;
sDataCom.s_uuid=s_uuid sDataCom.s_uuid=s_uuid
sDataCom.fac=cAttrsComp.fac sDataCom.fac=cAttrsComp.fac