diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index 73a0ee8bb..5f6eb89ea 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -20,9 +20,9 @@ export class SAMLauncherExecution implements Execution { private target: Unit = null; - private searchRange = 100; + private searchRangeRadius = 75; - private missileAttackRate = 100; // 10 seconds + private missileAttackRate = 75; // 7.5 seconds private lastMissileAttack = 0; private pseudoRandom: PseudoRandom; @@ -63,10 +63,16 @@ export class SAMLauncherExecution implements Execution { const nukes = this.mg .units(UnitType.AtomBomb, UnitType.HydrogenBomb) - .filter( - (u) => - this.mg.manhattanDist(u.tile(), this.post.tile()) < this.searchRange, - ) + .filter((u) => { + // (x - center_x)² + (y - center_y)² < radius² + const x = this.mg.x(u.tile()); + const y = this.mg.y(u.tile()); + const centerX = this.mg.x(this.post.tile()); + const centerY = this.mg.y(this.post.tile()); + const isInRange = + (x - centerX) ** 2 + (y - centerY) ** 2 < this.searchRangeRadius ** 2; + return isInRange; + }) .filter((u) => u.owner() !== this.player) .filter((u) => !u.owner().isAlliedWith(this.player)); diff --git a/src/core/execution/SAMMissileExecution.ts b/src/core/execution/SAMMissileExecution.ts index 10252b552..9a110c3be 100644 --- a/src/core/execution/SAMMissileExecution.ts +++ b/src/core/execution/SAMMissileExecution.ts @@ -23,10 +23,8 @@ export class SAMMissileExecution implements Execution { private target: Unit, private mg: Game, private pseudoRandom: number, - private speed: number = 6, - // Regular atom bomb or warhead of MIRV + private speed: number = 12, private hittingChance: number = 0.75, - private hittingChanceHydrogen: number = 0.1, ) {} init(mg: Game, ticks: number): void { @@ -45,10 +43,13 @@ export class SAMMissileExecution implements Execution { this.active = false; return; } + // Mirv warheads are too fast, and mirv shouldn't be stopped ever + const nukesWhitelist = [UnitType.AtomBomb, UnitType.HydrogenBomb]; if ( !this.target.isActive() || !this.ownerUnit.isActive() || - this.target.owner() == this.SAMMissile.owner() + this.target.owner() == this.SAMMissile.owner() || + !nukesWhitelist.includes(this.target.type()) ) { this.SAMMissile.delete(false); this.active = false; @@ -63,22 +64,7 @@ export class SAMMissileExecution implements Execution { switch (result.type) { case PathFindResultType.Completed: this.active = false; - let hit = false; - if ( - this.target.type() == UnitType.HydrogenBomb && - this.pseudoRandom < this.hittingChanceHydrogen - ) { - hit = true; - } else if ( - [UnitType.MIRVWarhead, UnitType.AtomBomb].includes( - this.target.type(), - ) && - this.pseudoRandom < this.hittingChance - ) { - hit = true; - } - - if (hit) { + if (this.pseudoRandom < this.hittingChance) { this.target.delete(); this.mg.displayMessage( @@ -88,7 +74,7 @@ export class SAMMissileExecution implements Execution { ); } else { this.mg.displayMessage( - `Missile failed to intercept ${this.target.type()}`, + `Missile failed to target ${this.target.type()}`, MessageType.ERROR, this._owner.id(), );