From a7b3209ad7cb6c98537c656846beb0ce543b5bab Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 4 Feb 2025 19:50:18 -0800 Subject: [PATCH] Improve mirv: give it arc --- src/core/execution/MIRVExecution.ts | 24 ++++++++++++++++++++---- src/core/execution/NukeExecution.ts | 10 +++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/core/execution/MIRVExecution.ts b/src/core/execution/MIRVExecution.ts index 5ac288fb5..e7f8af2f9 100644 --- a/src/core/execution/MIRVExecution.ts +++ b/src/core/execution/MIRVExecution.ts @@ -26,7 +26,7 @@ export class MirvExecution implements Execution { private nuke: Unit; - private mirvRange = 350; + private mirvRange = 500; private warheadCount = 1000; // private warheadRange = 5; @@ -36,6 +36,8 @@ export class MirvExecution implements Execution { private targetPlayer: Player | TerraNullius; + private separateDst: TileRef; + constructor(private senderID: PlayerID, private dst: TileRef) {} init(mg: Game, ticks: number): void { @@ -55,10 +57,18 @@ export class MirvExecution implements Execution { return; } this.nuke = this.player.buildUnit(UnitType.MIRV, 0, spawn); + const x = Math.floor( + (this.mg.x(this.dst) + this.mg.x(this.mg.x(this.nuke.tile()))) / 2 + ); + const y = Math.max(0, this.mg.y(this.dst) - 500) + 50; + this.separateDst = this.mg.ref(x, y); } for (let i = 0; i < 4; i++) { - const result = this.pathFinder.nextTile(this.nuke.tile(), this.dst); + const result = this.pathFinder.nextTile( + this.nuke.tile(), + this.separateDst + ); switch (result.type) { case PathFindResultType.Completed: this.nuke.move(result.tile); @@ -92,15 +102,21 @@ export class MirvExecution implements Execution { dsts.push(potential); } console.log(`dsts: ${dsts.length}`); + dsts.sort( + (a, b) => + this.mg.manhattanDist(b, this.dst) - this.mg.manhattanDist(a, this.dst) + ); - for (const dst of dsts) { + for (const [i, dst] of dsts.entries()) { this.mg.addExecution( new NukeExecution( UnitType.MIRVWarhead, this.senderID, dst, this.nuke.tile(), - this.random.nextInt(5, 9) + 15 + Math.floor((i / this.warheadCount) * 5), + // this.random.nextInt(5, 9), + this.random.nextInt(0, 15) ) ); } diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index 5db9fa619..2b6ac9361 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -28,7 +28,8 @@ export class NukeExecution implements Execution { private senderID: PlayerID, private dst: TileRef, private src?: TileRef, - private speed: number = 4 + private speed: number = 4, + private waitTicks = 0 ) {} init(mg: Game, ticks: number): void { @@ -51,6 +52,13 @@ export class NukeExecution implements Execution { } this.nuke = this.player.buildUnit(this.type, 0, spawn); } + if (this.waitTicks > 0) { + this.waitTicks--; + return; + } + + const r = (this.mg.y(this.dst) * this.mg.x(this.dst)) % 10; + const s = this.speed + (this.mg.ticks() % r); for (let i = 0; i < this.speed; i++) { const x = this.mg.x(this.nuke.tile());