diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 6d8edd2f4..67dcf8e6f 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -190,8 +190,8 @@ export class DefaultConfig implements Config { return { cost: (p: Player) => p.type() == PlayerType.Human && this.infiniteGold() - ? 25 - : 25_000_000, + ? 0 + : 15_000_000, territoryBound: false, }; case UnitType.MIRVWarhead: diff --git a/src/core/execution/MIRVExecution.ts b/src/core/execution/MIRVExecution.ts index d7129c008..1ad5d053e 100644 --- a/src/core/execution/MIRVExecution.ts +++ b/src/core/execution/MIRVExecution.ts @@ -9,7 +9,6 @@ import { UnitType, TerraNullius, MessageType, - AllPlayers, } from "../game/Game"; import { PathFinder } from "../pathfinding/PathFinding"; import { PathFindResultType } from "../pathfinding/AStar"; @@ -28,6 +27,7 @@ export class MirvExecution implements Execution { private nuke: Unit; + private mirvRange = 1500; private warheadCount = 350; private random: PseudoRandom; @@ -74,14 +74,16 @@ export class MirvExecution implements Execution { return; } this.nuke = this.player.buildUnit(UnitType.MIRV, 0, spawn); - const x = Math.floor(Math.floor(this.mg.width() / 2)); - const y = Math.min(this.mg.height(), 50); + 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); this.mg.displayMessage( - `⚠️⚠️⚠️ ${this.player.name()} - MIRV LAUNCH DETECTED ⚠️⚠️⚠️`, + `⚠️⚠️⚠️ ${this.player.name()} - MIRV INBOUND ⚠️⚠️⚠️`, MessageType.ERROR, - null, + this.targetPlayer.id(), ); } @@ -116,7 +118,7 @@ export class MirvExecution implements Execution { let attempts = 1000; while (attempts > 0 && dsts.length < this.warheadCount) { attempts--; - const potential = this.randomLand(dsts); + const potential = this.randomLand(this.dst, dsts); if (potential == null) { continue; } @@ -154,12 +156,18 @@ export class MirvExecution implements Execution { this.nuke.delete(false); } - randomLand(taken: TileRef[]): TileRef | null { + randomLand(ref: TileRef, taken: TileRef[]): TileRef | null { let tries = 0; while (tries < 100) { tries++; - const x = this.random.nextInt(0, this.mg.width()); - const y = this.random.nextInt(0, this.mg.height()); + const x = this.random.nextInt( + this.mg.x(ref) - this.mirvRange, + this.mg.x(ref) + this.mirvRange, + ); + const y = this.random.nextInt( + this.mg.y(ref) - this.mirvRange, + this.mg.y(ref) + this.mirvRange, + ); if (!this.mg.isValidCoord(x, y)) { continue; } @@ -168,11 +176,10 @@ export class MirvExecution implements Execution { if (!this.mg.isLand(tile)) { continue; } - const owner = this.mg.owner(tile); - if (!owner.isPlayer()) { + if (this.mg.euclideanDist(tile, ref) > this.mirvRange) { continue; } - if (owner == this.player || this.player.allianceWith(owner)) { + if (this.mg.owner(tile) != this.targetPlayer) { continue; } for (const t of taken) { diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index efa530d16..a752a7eaa 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -134,7 +134,7 @@ export class NukeExecution implements Execution { let magnitude; switch (this.type) { case UnitType.MIRVWarhead: - magnitude = { inner: 30, outer: 35 }; + magnitude = { inner: 25, outer: 30 }; break; case UnitType.AtomBomb: magnitude = { inner: 12, outer: 30 }; diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index 684f9cb59..02341d4b9 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -675,6 +675,9 @@ export class PlayerImpl implements Player { } switch (unitType) { case UnitType.MIRV: + if (!this.mg.hasOwner(targetTile)) { + return false; + } return this.nukeSpawn(targetTile); case UnitType.AtomBomb: case UnitType.HydrogenBomb: