fix(战斗): 调整近战英雄追击逻辑和攻击范围
- 禁用 atk_s1.prefab 中的某个节点以避免干扰 - 增加近战攻击范围的高度从 100 到 150 - 添加 meleeOvertakeSpeedGap 常量用于控制追击速度差阈值 - 实现 shouldAllowMeleeOvertake 方法,允许高速近战英雄在特定条件下超越同优先级盟友 - 条件包括:双方均为近战、优先级相同、速度足够快、盟友未进入攻击准备状态且仍在前进中
This commit is contained in:
@@ -297,7 +297,7 @@
|
||||
"node": {
|
||||
"__id__": 8
|
||||
},
|
||||
"_enabled": true,
|
||||
"_enabled": false,
|
||||
"__prefab": {
|
||||
"__id__": 12
|
||||
},
|
||||
@@ -492,7 +492,7 @@
|
||||
"_size": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 30,
|
||||
"height": 100
|
||||
"height": 150
|
||||
},
|
||||
"_id": ""
|
||||
},
|
||||
|
||||
@@ -38,6 +38,7 @@ interface MoveFacConfig {
|
||||
export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||
private readonly meleeAttackRange = HeroDisVal[HType.Melee];
|
||||
private readonly meleeMinEnemyDistanceX = 80;
|
||||
private readonly meleeOvertakeSpeedGap = 20;
|
||||
private readonly allySpacingX = 40;
|
||||
private readonly allyOverlapSpacingX = 14;
|
||||
private readonly displacementReleaseX = 10;
|
||||
@@ -309,6 +310,7 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
const allyPriority = this.getCombatPriority(attrs);
|
||||
if (allyPriority < selfPriority) return;
|
||||
const x = view.node.position.x;
|
||||
if (this.shouldAllowMeleeOvertake(selfAttrs, selfMove, attrs, allyMove, currentX, x, direction, allyPriority, selfPriority)) return;
|
||||
const spacing = this.resolveAllySpacing(selfAttrs, selfMove, currentX, direction, allyMove, x, allyPriority, selfPriority);
|
||||
if (direction > 0 && x > currentX) {
|
||||
clampedX = Math.min(clampedX, x - spacing);
|
||||
@@ -320,6 +322,35 @@ export class MoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
return clampedX;
|
||||
}
|
||||
|
||||
private shouldAllowMeleeOvertake(
|
||||
selfAttrs: HeroAttrsComp | null,
|
||||
selfMove: MoveComp | null,
|
||||
allyAttrs: HeroAttrsComp,
|
||||
allyMove: MoveComp | null,
|
||||
currentX: number,
|
||||
allyX: number,
|
||||
direction: number,
|
||||
allyPriority: number,
|
||||
selfPriority: number
|
||||
): boolean {
|
||||
if (!selfAttrs || !selfMove || !allyMove) return false;
|
||||
if ((selfAttrs.type as HType) !== HType.Melee || (allyAttrs.type as HType) !== HType.Melee) return false;
|
||||
if (allyPriority !== selfPriority) return false;
|
||||
if (selfAttrs.speed <= allyAttrs.speed + this.meleeOvertakeSpeedGap) return false;
|
||||
if (direction > 0 && allyX <= currentX) return false;
|
||||
if (direction < 0 && allyX >= currentX) return false;
|
||||
const selfTargetX = selfMove.targetX;
|
||||
const allyTargetX = allyMove.targetX;
|
||||
if (Math.abs(selfTargetX) <= 0.01 || Math.abs(allyTargetX) <= 0.01) return false;
|
||||
const selfNeedAdvance = direction > 0 ? selfTargetX > currentX + 2 : selfTargetX < currentX - 2;
|
||||
if (!selfNeedAdvance) return false;
|
||||
const allyCanAttackNow = allyAttrs.enemy_in_cast_range || Math.abs(allyTargetX - allyX) <= this.attackReadyLockX;
|
||||
if (allyCanAttackNow) return false;
|
||||
const allyStillAdvancing = direction > 0 ? allyTargetX > allyX + 2 : allyTargetX < allyX - 2;
|
||||
if (!allyStillAdvancing) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private resolveAllySpacing(
|
||||
selfAttrs: HeroAttrsComp | null,
|
||||
selfMove: MoveComp | null,
|
||||
|
||||
Reference in New Issue
Block a user