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
This commit is contained in:
Danny
2025-12-21 23:49:10 +01:00
committed by GitHub
parent 9ab1319126
commit 7db8d51bf7
5 changed files with 1 additions and 43 deletions
-2
View File
@@ -73,8 +73,6 @@ export interface NukeMagnitude {
}
export interface Config {
samHittingChance(): number;
samWarheadHittingChance(): number;
spawnImmunityDuration(): Tick;
serverConfig(): ServerConfig;
gameConfig(): GameConfig;
-8
View File
@@ -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;
}
-8
View File
@@ -28,14 +28,6 @@ export class DevServerConfig extends DefaultServerConfig {
return 5 * 1000;
}
samWarheadHittingChance(): number {
return 1;
}
samHittingChance(): number {
return 1;
}
numWorkers(): number {
return 2;
}
+1 -21
View File
@@ -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
-4
View File
@@ -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;
}