diff --git a/resources/lang/en.json b/resources/lang/en.json index 516d9645ab..d824972b17 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -771,6 +771,8 @@ "received_gold_from_conquest": "Conquered {name}, received {gold} gold", "conquered_no_gold": "Conquered {name} (didn't play, no gold awarded)", "missile_intercepted": "Missile intercepted {unit}", + "interceptor_destroyed": "Interceptor destroyed, retargeting {unit}", + "interceptor_destroyed_attacker": "{unit} survived interception, will re-attempt interception, if possible", "mirv_warheads_intercepted": "{count, plural, one {{count} MIRV warhead intercepted} other {{count} MIRV warheads intercepted}}", "sent_troops_to_player": "Sent {troops} troops to {name}", "received_troops_from_player": "Received {troops} troops from {name}", diff --git a/src/core/configuration/Config.ts b/src/core/configuration/Config.ts index 55fbab613a..242610d7bd 100644 --- a/src/core/configuration/Config.ts +++ b/src/core/configuration/Config.ts @@ -139,6 +139,7 @@ export interface Config { safeFromPiratesCooldownMax(): number; defensePostRange(): number; SAMCooldown(): number; + samRefireDelayTicks(): number; SiloCooldown(): number; minDistanceBetweenPlayers(): number; defensePostDefenseBonus(): number; diff --git a/src/core/configuration/DefaultConfig.ts b/src/core/configuration/DefaultConfig.ts index 2195371a32..15ea543a79 100644 --- a/src/core/configuration/DefaultConfig.ts +++ b/src/core/configuration/DefaultConfig.ts @@ -203,6 +203,11 @@ export class DefaultConfig implements Config { SAMCooldown(): number { return 75; } + samRefireDelayTicks(): number { + // Beta testing: adjust this constant to tune the delay before a SAM can + // refire at a nuke whose interceptor was destroyed. 0 = instant refire. + return 0; + } SiloCooldown(): number { return 75; } diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index 2bf2055b71..41e6a105a1 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -322,8 +322,7 @@ export class NukeExecution implements Execution { type === UnitType.AtomBomb || type === UnitType.HydrogenBomb || type === UnitType.MIRVWarhead || - type === UnitType.MIRV || - type === UnitType.SAMMissile + type === UnitType.MIRV ) { continue; } diff --git a/src/core/execution/SAMMissileExecution.ts b/src/core/execution/SAMMissileExecution.ts index 657166a80e..22df4ad882 100644 --- a/src/core/execution/SAMMissileExecution.ts +++ b/src/core/execution/SAMMissileExecution.ts @@ -17,6 +17,7 @@ export class SAMMissileExecution implements Execution { private SAMMissile: Unit | undefined; private mg: Game; private speed: number = 0; + private refireDelayRemaining: number | null = null; constructor( private spawn: TileRef, @@ -39,6 +40,31 @@ export class SAMMissileExecution implements Execution { {}, ); if (!this.SAMMissile.isActive()) { + // Interceptor was destroyed (e.g. by nuke blast) — allow SAMs to re-target this nuke after delay + if (this.target.isActive()) { + this.refireDelayRemaining ??= this.mg.config().samRefireDelayTicks(); + if (this.refireDelayRemaining > 0) { + this.refireDelayRemaining--; + return; + } + this.target.setTargetedBySAM(false); + // Notify defender their interceptor was destroyed + this.mg.displayMessage( + "events_display.interceptor_destroyed", + MessageType.SAM_MISS, + this._owner.id(), + undefined, + { unit: this.target.type() }, + ); + // Notify attacker their nuke survived interception + this.mg.displayMessage( + "events_display.interceptor_destroyed_attacker", + MessageType.SAM_MISS, + this.target.owner().id(), + undefined, + { unit: this.target.type() }, + ); + } this.active = false; return; }