From 7db8d51bf79db9106dc44923c852f5843551dad8 Mon Sep 17 00:00:00 2001 From: Danny <21205085+Lavodan@users.noreply.github.com> Date: Sun, 21 Dec 2025 23:49:10 +0100 Subject: [PATCH] Remove RNG from SAM launchers (#2665) ## Description: SAMs will now always hit their target instead of missing sometimes. Describe the PR. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: Lavodan --- src/core/configuration/Config.ts | 2 -- src/core/configuration/DefaultConfig.ts | 8 -------- src/core/configuration/DevConfig.ts | 8 -------- src/core/execution/SAMLauncherExecution.ts | 22 +--------------------- tests/util/TestConfig.ts | 4 ---- 5 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index 8d12e7450..a352e2765 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -73,8 +73,6 @@ export interface NukeMagnitude { } export interface Config { - samHittingChance(): number; - samWarheadHittingChance(): number; spawnImmunityDuration(): Tick; serverConfig(): ServerConfig; gameConfig(): GameConfig; diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index cd0f0544a..85d1ec466 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -251,14 +251,6 @@ export class DefaultConfig implements Config { return this._isReplay; } - samHittingChance(): number { - return 0.8; - } - - samWarheadHittingChance(): number { - return 0.5; - } - traitorDefenseDebuff(): number { return 0.5; } diff --git a/src/core/configuration/DevConfig.ts b/src/core/configuration/DevConfig.ts index b600ba183..09c0adaa6 100644 --- a/src/core/configuration/DevConfig.ts +++ b/src/core/configuration/DevConfig.ts @@ -28,14 +28,6 @@ export class DevServerConfig extends DefaultServerConfig { return 5 * 1000; } - samWarheadHittingChance(): number { - return 1; - } - - samHittingChance(): number { - return 1; - } - numWorkers(): number { return 2; } diff --git a/src/core/execution/SAMLauncherExecution.ts b/src/core/execution/SAMLauncherExecution.ts index c669b42fd..4d0362c51 100644 --- a/src/core/execution/SAMLauncherExecution.ts +++ b/src/core/execution/SAMLauncherExecution.ts @@ -186,18 +186,6 @@ export class SAMLauncherExecution implements Execution { this.mg = mg; } - private isHit(type: UnitType, random: number): boolean { - if (type === UnitType.AtomBomb) { - return true; - } - - if (type === UnitType.MIRVWarhead) { - return random < this.mg.config().samWarheadHittingChance(); - } - - return random < this.mg.config().samHittingChance(); - } - tick(ticks: number): void { if (this.mg === null || this.player === null) { throw new Error("Not initialized"); @@ -279,15 +267,7 @@ export class SAMLauncherExecution implements Execution { ? UnitType.MIRVWarhead : target?.unit.type(); if (type === undefined) throw new Error("Unknown unit type"); - const random = this.pseudoRandom.next(); - const hit = this.isHit(type, random); - if (!hit) { - this.mg.displayMessage( - `Missile failed to intercept ${type}`, - MessageType.SAM_MISS, - this.sam.owner().id(), - ); - } else if (mirvWarheadTargets.length > 0) { + if (mirvWarheadTargets.length > 0) { const samOwner = this.sam.owner(); // Message diff --git a/tests/util/TestConfig.ts b/tests/util/TestConfig.ts index c5f514ab0..57d50558a 100644 --- a/tests/util/TestConfig.ts +++ b/tests/util/TestConfig.ts @@ -13,10 +13,6 @@ export class TestConfig extends DefaultConfig { private _proximityBonusPortsNb: number = 0; private _defaultNukeSpeed: number = 4; - samHittingChance(): number { - return 1; - } - radiusPortSpawn(): number { return 1; }