From 1e2b23d2de9e5dabb4e2c008fadfe1d47c284341 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 22 Nov 2024 20:49:45 -0800 Subject: [PATCH] fixed bug causing crash when capturing trade ship already captured by another destroyer --- src/core/configuration/DevConfig.ts | 12 ++++++------ src/core/execution/DestroyerExecution.ts | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index f6cfe152d..d43510abf 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -24,12 +24,12 @@ export const devConfig = new class extends DefaultConfig { return 100 } - numBots(): number { - return 0 - } - spawnNPCs(): boolean { - return false - } + // numBots(): number { + // return 0 + // } + // spawnNPCs(): boolean { + // return false + // } // boatMaxDistance(): number { // return 2000 diff --git a/src/core/execution/DestroyerExecution.ts b/src/core/execution/DestroyerExecution.ts index a2ee21fe2..6b3e12556 100644 --- a/src/core/execution/DestroyerExecution.ts +++ b/src/core/execution/DestroyerExecution.ts @@ -77,6 +77,11 @@ export class DestroyerExecution implements Execution { } this.target = ships.sort(distSortUnit(this.destroyer))[0] } + if (!this.target.isActive() || this.target.owner() == this._owner) { + // Incase another destroyer captured or destroyed target + this.target = null + return + } for (let i = 0; i < 2; i++) { const result = this.pathfinder.nextTile(this.destroyer.tile(), this.target.tile(), 5)