mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-21 20:51:15 +00:00
merge with main again
This commit is contained in:
@@ -687,7 +687,7 @@ export class DefaultConfig implements Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
structureMinDist(): number {
|
structureMinDist(): number {
|
||||||
return 18;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
shellLifetime(): number {
|
shellLifetime(): number {
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ export class DefensePostExecution implements Execution {
|
|||||||
this.target = null;
|
this.target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Reconsider how/if defense posts target ships.
|
||||||
|
return;
|
||||||
|
|
||||||
const ships = this.mg
|
const ships = this.mg
|
||||||
.nearbyUnits(
|
.nearbyUnits(
|
||||||
this.post.tile(),
|
this.post.tile(),
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ export class SAMLauncherExecution implements Execution {
|
|||||||
private mg: Game;
|
private mg: Game;
|
||||||
private active: boolean = true;
|
private active: boolean = true;
|
||||||
|
|
||||||
private target: Unit = null;
|
|
||||||
private warheadTargets: Unit[] = [];
|
|
||||||
|
|
||||||
private searchRangeRadius = 80;
|
private searchRangeRadius = 80;
|
||||||
// As MIRV go very fast we have to detect them very early but we only
|
// As MIRV go very fast we have to detect them very early but we only
|
||||||
// shoot the one targeting very close (MIRVWarheadProtectionRadius)
|
// shoot the one targeting very close (MIRVWarheadProtectionRadius)
|
||||||
@@ -119,7 +116,7 @@ export class SAMLauncherExecution implements Execution {
|
|||||||
this.pseudoRandom = new PseudoRandom(this.sam.id());
|
this.pseudoRandom = new PseudoRandom(this.sam.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.warheadTargets = this.mg
|
const mirvWarheadTargets = this.mg
|
||||||
.nearbyUnits(
|
.nearbyUnits(
|
||||||
this.sam.tile(),
|
this.sam.tile(),
|
||||||
this.MIRVWarheadSearchRadius,
|
this.MIRVWarheadSearchRadius,
|
||||||
@@ -136,8 +133,9 @@ export class SAMLauncherExecution implements Execution {
|
|||||||
this.MIRVWarheadProtectionRadius,
|
this.MIRVWarheadProtectionRadius,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.warheadTargets.length == 0) {
|
let target: Unit | null = null;
|
||||||
this.target = this.getSingleTarget();
|
if (mirvWarheadTargets.length == 0) {
|
||||||
|
target = this.getSingleTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -147,16 +145,14 @@ export class SAMLauncherExecution implements Execution {
|
|||||||
this.sam.setCooldown(false);
|
this.sam.setCooldown(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSingleTarget = this.target && !this.target.targetedBySAM();
|
const isSingleTarget = target && !target.targetedBySAM();
|
||||||
if (
|
if (
|
||||||
(isSingleTarget || this.warheadTargets.length > 0) &&
|
(isSingleTarget || mirvWarheadTargets.length > 0) &&
|
||||||
!this.sam.isCooldown()
|
!this.sam.isCooldown()
|
||||||
) {
|
) {
|
||||||
this.sam.setCooldown(true);
|
this.sam.setCooldown(true);
|
||||||
const type =
|
const type =
|
||||||
this.warheadTargets.length > 0
|
mirvWarheadTargets.length > 0 ? UnitType.MIRVWarhead : target.type();
|
||||||
? UnitType.MIRVWarhead
|
|
||||||
: this.target.type();
|
|
||||||
const random = this.pseudoRandom.next();
|
const random = this.pseudoRandom.next();
|
||||||
const hit = this.isHit(type, random);
|
const hit = this.isHit(type, random);
|
||||||
if (!hit) {
|
if (!hit) {
|
||||||
@@ -166,31 +162,25 @@ export class SAMLauncherExecution implements Execution {
|
|||||||
this.sam.owner().id(),
|
this.sam.owner().id(),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (this.warheadTargets.length > 0) {
|
if (mirvWarheadTargets.length > 0) {
|
||||||
// Message
|
// Message
|
||||||
this.mg.displayMessage(
|
this.mg.displayMessage(
|
||||||
`${this.warheadTargets.length} MIRV warheads intercepted`,
|
`${mirvWarheadTargets.length} MIRV warheads intercepted`,
|
||||||
MessageType.SUCCESS,
|
MessageType.SUCCESS,
|
||||||
this.sam.owner().id(),
|
this.sam.owner().id(),
|
||||||
);
|
);
|
||||||
// Delete warheads
|
// Delete warheads
|
||||||
// Delete warheads safely
|
mirvWarheadTargets.forEach((u) => u.delete());
|
||||||
this.warheadTargets.forEach((u) => {
|
|
||||||
if (u.isActive()) {
|
|
||||||
u.delete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.target.setTargetedBySAM(true);
|
target.setTargetedBySAM(true);
|
||||||
this.mg.addExecution(
|
this.mg.addExecution(
|
||||||
new SAMMissileExecution(
|
new SAMMissileExecution(
|
||||||
this.sam.tile(),
|
this.sam.tile(),
|
||||||
this.sam.owner(),
|
this.sam.owner(),
|
||||||
this.sam,
|
this.sam,
|
||||||
this.target,
|
target,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
this.warheadTargets = [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ export class UnitImpl implements Unit {
|
|||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
throw new Error("tile cannot be null");
|
throw new Error("tile cannot be null");
|
||||||
}
|
}
|
||||||
|
this.mg.removeUnit(this);
|
||||||
this._lastTile = this._tile;
|
this._lastTile = this._tile;
|
||||||
this._tile = tile;
|
this._tile = tile;
|
||||||
this.mg.removeUnit(this);
|
|
||||||
this.mg.addUnit(this);
|
this.mg.addUnit(this);
|
||||||
this.mg.addUpdate(this.toUpdate());
|
this.mg.addUpdate(this.toUpdate());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user