diff --git a/assets/script/game/hero/SCastSystem.ts b/assets/script/game/hero/SCastSystem.ts index f38e5e25..ad204684 100644 --- a/assets/script/game/hero/SCastSystem.ts +++ b/assets/script/game/hero/SCastSystem.ts @@ -69,8 +69,9 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (typeof selfEid !== "number") continue; return { skillId: s_uuid, isFriendly: true, targetPos: null, targetEids: [selfEid] }; } - if (!target) continue; - return { skillId: s_uuid, isFriendly: false, targetPos: target.node.position.clone(), targetEids: [] }; + if (!target || !heroView.node || !target.node) continue; + const targetPos = this.buildEnemyCastTargetPos(heroView, target, maxRange); + return { skillId: s_uuid, isFriendly: false, targetPos, targetEids: [] }; } return this.emptyCastPlan; } @@ -212,4 +213,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if (type === HType.Mid) return 360; return this.meleeCastRange; } + + private buildEnemyCastTargetPos(caster: HeroViewComp, target: HeroViewComp, castRange: number): Vec3 { + const casterPos = caster.node.position; + const targetPos = target.node.position; + const direction = targetPos.x >= casterPos.x ? 1 : -1; + return new Vec3(casterPos.x + direction * castRange, casterPos.y, casterPos.z); + } }