From a634b33f6b9d954836aad6cfda1f1e9dcf08be00 Mon Sep 17 00:00:00 2001 From: walkpan Date: Mon, 16 Mar 2026 19:33:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8A=80=E8=83=BD=E7=B3=BB=E7=BB=9F):?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=B9=B6=E4=BC=98=E5=8C=96=E7=9B=AE=E6=A0=87=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 Skill.ts 中未使用的 wfuny 属性赋值 - 将 SCastSystem 中的目标选择逻辑重构为统一方法 - 在施放技能前增加目标有效性检查,避免无效操作 - 移除 HeroAtkSystem 中未使用的导入和接口字段 - 调整 SkillSet 中技能 6008 的 ready 参数值 --- assets/script/game/common/config/SkillSet.ts | 2 +- assets/script/game/hero/HeroAtkSystem.ts | 7 +--- assets/script/game/hero/SCastSystem.ts | 34 +++++++++++++------- assets/script/game/skill/Skill.ts | 1 - 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index 1d24d75b..d7f48b0c 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -235,7 +235,7 @@ export const SkillSet: Record = { 6008: { 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, - 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%攻击的伤害", }, diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index 4107491d..65cefe02 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -2,13 +2,11 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec import { FacSet } from "../common/config/GameSet"; import { Attrs } from "../common/config/HeroAttrs"; import { FightSet } from "../common/config/GameSet"; -import { SkillSet, DType } from "../common/config/SkillSet"; +import { SkillSet } from "../common/config/SkillSet"; import { HeroAttrsComp } from "./HeroAttrsComp"; import { HeroViewComp } from "./HeroViewComp"; import { DamageQueueComp, DamageEvent } from "./DamageQueueComp"; import { smc } from "../common/SingletonModuleComp"; -import { oops } from "db://oops-framework/core/Oops"; -import { GameEvent } from "../common/config/GameEvent"; import { mLogger } from "../common/Logger"; @@ -17,12 +15,10 @@ import { mLogger } from "../common/Logger"; * 用于封装一次攻击计算的所有结果数据 * @property damage - 最终造成的伤害值(已考虑所有加成和减免) * @property isCrit - 是否为暴击攻击 - * @property isDodge - 是否被闪避(闪避时damage为0) */ interface FinalData { damage: number; isCrit: boolean; - isDodge: boolean; } /** * 英雄攻击系统 - 伤害处理核心系统 @@ -106,7 +102,6 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd let reDate:FinalData={ damage:0, isCrit:false, - isDodge:false, } if (!TAttrsComp || TAttrsComp.is_dead || TAttrsComp.is_reviving) return reDate; diff --git a/assets/script/game/hero/SCastSystem.ts b/assets/script/game/hero/SCastSystem.ts index 75441289..27e0a619 100644 --- a/assets/script/game/hero/SCastSystem.ts +++ b/assets/script/game/hero/SCastSystem.ts @@ -25,6 +25,7 @@ import { GameConst } from "../common/config/GameConst"; @ecs.register('SCastSystem') export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { debugMode: boolean = false; // 是否启用调试模式 + private readonly emptyCastPlan = { skillId: 0, targets: [] as HeroViewComp[] }; filter(): ecs.IMatcher { 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; heroAttrs.updateCD(this.dt); if (!heroAttrs.is_atking) return; - const castSkillId = this.pickCastSkill(heroAttrs, heroView); - if (castSkillId === 0) return; - this.castSkill(e, castSkillId, heroAttrs, heroView); + const castPlan = this.pickCastSkill(heroAttrs, heroView); + if (castPlan.skillId === 0 || castPlan.targets.length === 0) return; + 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]; for (const s_uuid of skillCandidates) { if (!s_uuid) continue; @@ -55,16 +56,15 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (!isMainSkill && !heroAttrs.can_atk) continue; const targets = this.findTargets(heroView, heroAttrs, config); 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]; if (!config) return; - const targets = this.findTargets(heroView, heroAttrs, config); - if (targets.length === 0) return; heroView.playSkillEffect(s_uuid); const isMainSkill = s_uuid === heroAttrs.skill_id; @@ -75,8 +75,10 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate heroView.scheduleOnce(() => { if (!heroView.node || !heroView.node.isValid || heroAttrs.is_dead) return; - this.applyPrimaryEffect(entity, s_uuid, config, heroView, targets); - this.applyExtraEffects(config, targets); + const validTargets = this.filterValidTargets(castPlan.targets); + if (validTargets.length === 0) return; + this.applyPrimaryEffect(entity, s_uuid, config, heroView, validTargets); + this.applyExtraEffects(config, validTargets); }, delay); if (isMainSkill) { 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[] { const range = casterAttrs.getCachedMaxSkillDistance() || GameConst.Battle.DEFAULT_SEARCH_RANGE; const isEnemy = config.TGroup === TGroup.Enemy; diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index 859df3a5..fc562dea 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -202,7 +202,6 @@ export class Skill extends ecs.Entity { sDataCom.Attrs[Attrs.slow_chance] = cAttrsComp.slow_chance; sDataCom.Attrs[Attrs.puncture] = cAttrsComp.puncture; sDataCom.Attrs[Attrs.puncture_dmg] = cAttrsComp.puncture_dmg; - sDataCom.Attrs[Attrs.wfuny] = cAttrsComp.wfuny; sDataCom.s_uuid=s_uuid sDataCom.fac=cAttrsComp.fac