Skip to content
Open
Changes from 1 commit
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
71 changes: 41 additions & 30 deletions src/core/execution/SAMLauncherExecution.ts

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were planning on making mirv warheads have the same logic as regular nukes anyways?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't working, unless do you mean that we change there movement speed? (I would advise not unless we want them to be launched directly from the silo)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we can change their movement stpeed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we change the movement speed then we need to have the MIRV warheads launch directly from the silo

Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@
const rangeSquared = range * range;

// Look beyond the SAM range so it can preshot nukes
const detectionRange = this.mg.config().maxSamRange() * 2;
const detectionRange = 1200;
const nukes = this.mg.nearbyUnits(
samTile,
detectionRange,
[UnitType.AtomBomb, UnitType.HydrogenBomb],
[UnitType.AtomBomb, UnitType.HydrogenBomb, UnitType.MIRVWarhead],
({ unit }) => {
if (!isUnit(unit) || unit.targetedBySAM()) return false;
if (unit.owner() === this.sam.owner()) return false;
Expand Down Expand Up @@ -271,35 +271,39 @@

this.pseudoRandom ??= new PseudoRandom(this.sam.id());

const mirvWarheadTargets = this.mg.nearbyUnits(
this.sam.tile(),
this.MIRVWarheadSearchRadius,
UnitType.MIRVWarhead,
({ unit }) => {
if (!isUnit(unit)) return false;
if (unit.owner() === this.player) return false;

// After game-over in team games, SAMs also target teammate MIRVs (aftergame fun)
const nukeOwner = unit.owner();
if (this.player.isFriendly(nukeOwner)) {
if (
this.mg.getWinner() === null ||
!this.player.isOnSameTeam(nukeOwner)
) {
return false;
let mirvWarheadTargets = this.mg

Check failure on line 274 in src/core/execution/SAMLauncherExecution.ts

View workflow job for this annotation

GitHub Actions / 🔍 ESLint

'mirvWarheadTargets' is never reassigned. Use 'const' instead. (prefer-const)

Check failure on line 274 in src/core/execution/SAMLauncherExecution.ts

View workflow job for this annotation

GitHub Actions / 🔍 ESLint

'mirvWarheadTargets' is never reassigned. Use 'const' instead. (prefer-const)
.nearbyUnits(
this.sam.tile(),
this.MIRVWarheadSearchRadius,
UnitType.MIRVWarhead,
({ unit }) => {
if (!isUnit(unit)) return false;
if (unit.owner() === this.player) return false;

// After game-over in team games, SAMs also target teammate MIRVs (aftergame fun)
const nukeOwner = unit.owner();
if (this.player.isFriendly(nukeOwner)) {
if (
this.mg.getWinner() === null ||
!this.player.isOnSameTeam(nukeOwner)
) {
return false;
}
}
}

const dst = unit.targetTile();
return (
this.sam !== null &&
dst !== undefined &&
this.mg.manhattanDist(dst, this.sam.tile()) <
this.MIRVWarheadProtectionRadius
);
},
);

const dst = unit.targetTile();
return (
this.sam !== null &&
dst !== undefined &&
this.mg.manhattanDist(dst, this.sam.tile()) <
this.mg.config().samRange(this.sam.level())
);
},
)
.filter((v, i) => {
return i <= (this.sam?.level() ?? Infinity);
});
console.log(mirvWarheadTargets.length);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
let target: Target | null = null;
if (mirvWarheadTargets.length === 0) {
target = this.targetingSystem.getSingleTarget(ticks);
Expand All @@ -325,7 +329,14 @@
{ count: mirvWarheadTargets.length },
);

mirvWarheadTargets.forEach(({ unit: u }) => {
mirvWarheadTargets.forEach(({ unit: u }, i) => {
if (this.sam !== null && i > 0) {
if (this.sam.isInCooldown()) {
return;
}
this.sam.launch();
}

// Delete warheads
u.delete();
});
Expand Down
Loading