mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:40:43 +00:00
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:
@@ -74,8 +74,6 @@ export interface NukeMagnitude {
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
samHittingChance(): number;
|
||||
samWarheadHittingChance(): number;
|
||||
spawnImmunityDuration(): Tick;
|
||||
serverConfig(): ServerConfig;
|
||||
gameConfig(): GameConfig;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -28,14 +28,6 @@ export class DevServerConfig extends DefaultServerConfig {
|
||||
return 5 * 1000;
|
||||
}
|
||||
|
||||
samWarheadHittingChance(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
samHittingChance(): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
numWorkers(): number {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user