fixed bug causing crash when capturing trade ship already captured by another destroyer

This commit is contained in:
Evan
2024-11-22 20:49:45 -08:00
parent a2a6654bf5
commit 1e2b23d2de
2 changed files with 11 additions and 6 deletions
+6 -6
View File
@@ -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
+5
View File
@@ -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)