mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-26 14:04:36 +00:00
Improve mirv: give it arc
This commit is contained in:
@@ -26,7 +26,7 @@ export class MirvExecution implements Execution {
|
||||
|
||||
private nuke: Unit;
|
||||
|
||||
private mirvRange = 350;
|
||||
private mirvRange = 500;
|
||||
private warheadCount = 1000;
|
||||
// private warheadRange = 5;
|
||||
|
||||
@@ -36,6 +36,8 @@ export class MirvExecution implements Execution {
|
||||
|
||||
private targetPlayer: Player | TerraNullius;
|
||||
|
||||
private separateDst: TileRef;
|
||||
|
||||
constructor(private senderID: PlayerID, private dst: TileRef) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
@@ -55,10 +57,18 @@ export class MirvExecution implements Execution {
|
||||
return;
|
||||
}
|
||||
this.nuke = this.player.buildUnit(UnitType.MIRV, 0, spawn);
|
||||
const x = Math.floor(
|
||||
(this.mg.x(this.dst) + this.mg.x(this.mg.x(this.nuke.tile()))) / 2
|
||||
);
|
||||
const y = Math.max(0, this.mg.y(this.dst) - 500) + 50;
|
||||
this.separateDst = this.mg.ref(x, y);
|
||||
}
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const result = this.pathFinder.nextTile(this.nuke.tile(), this.dst);
|
||||
const result = this.pathFinder.nextTile(
|
||||
this.nuke.tile(),
|
||||
this.separateDst
|
||||
);
|
||||
switch (result.type) {
|
||||
case PathFindResultType.Completed:
|
||||
this.nuke.move(result.tile);
|
||||
@@ -92,15 +102,21 @@ export class MirvExecution implements Execution {
|
||||
dsts.push(potential);
|
||||
}
|
||||
console.log(`dsts: ${dsts.length}`);
|
||||
dsts.sort(
|
||||
(a, b) =>
|
||||
this.mg.manhattanDist(b, this.dst) - this.mg.manhattanDist(a, this.dst)
|
||||
);
|
||||
|
||||
for (const dst of dsts) {
|
||||
for (const [i, dst] of dsts.entries()) {
|
||||
this.mg.addExecution(
|
||||
new NukeExecution(
|
||||
UnitType.MIRVWarhead,
|
||||
this.senderID,
|
||||
dst,
|
||||
this.nuke.tile(),
|
||||
this.random.nextInt(5, 9)
|
||||
15 + Math.floor((i / this.warheadCount) * 5),
|
||||
// this.random.nextInt(5, 9),
|
||||
this.random.nextInt(0, 15)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ export class NukeExecution implements Execution {
|
||||
private senderID: PlayerID,
|
||||
private dst: TileRef,
|
||||
private src?: TileRef,
|
||||
private speed: number = 4
|
||||
private speed: number = 4,
|
||||
private waitTicks = 0
|
||||
) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
@@ -51,6 +52,13 @@ export class NukeExecution implements Execution {
|
||||
}
|
||||
this.nuke = this.player.buildUnit(this.type, 0, spawn);
|
||||
}
|
||||
if (this.waitTicks > 0) {
|
||||
this.waitTicks--;
|
||||
return;
|
||||
}
|
||||
|
||||
const r = (this.mg.y(this.dst) * this.mg.x(this.dst)) % 10;
|
||||
const s = this.speed + (this.mg.ticks() % r);
|
||||
|
||||
for (let i = 0; i < this.speed; i++) {
|
||||
const x = this.mg.x(this.nuke.tile());
|
||||
|
||||
Reference in New Issue
Block a user