Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
1 change: 1 addition & 0 deletions src/core/configuration/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export interface Config {
safeFromPiratesCooldownMax(): number;
defensePostRange(): number;
SAMCooldown(): number;
samRefireDelayTicks(): number;
SiloCooldown(): number;
minDistanceBetweenPlayers(): number;
defensePostDefenseBonus(): number;
Expand Down
5 changes: 5 additions & 0 deletions src/core/configuration/DefaultConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/execution/NukeExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
26 changes: 26 additions & 0 deletions src/core/execution/SAMMissileExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down
Loading