increase shell lifetime to 1s after death of target (#354)

TITLE IS WRONG I meant 2s not 1s

Problem: two warship fight each other, if one back off he won't be hit
by the ennemy at all. he'll kill other warship, then all shells
dissapear so 0% damage are received. It's OP and unfair.
Solution: make warship's shells last 2s after its death so even if one
warship backs off he'll eventually receive some damages. 2s is enough to
get between 250-750 HP loss

---------

Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
Ilan Schemoul
2025-03-29 22:10:31 +01:00
committed by GitHub
parent 839835f958
commit 849d612314
3 changed files with 16 additions and 2 deletions
+1
View File
@@ -92,6 +92,7 @@ export interface Config {
maxPopulation(player: Player | PlayerView): number;
cityPopulationIncrease(): number;
boatAttackAmount(attacker: Player, defender: Player | TerraNullius): number;
warshipShellLifetime(): number;
boatMaxNumber(): number;
allianceDuration(): Tick;
allianceRequestCooldown(): Tick;
+4
View File
@@ -474,6 +474,10 @@ export class DefaultConfig implements Config {
return Math.floor(attacker.troops() / 5);
}
warshipShellLifetime(): number {
return 20; // in ticks (one tick is 100ms)
}
radiusPortSpawn() {
return 20;
}
+11 -2
View File
@@ -8,6 +8,8 @@ export class ShellExecution implements Execution {
private active = true;
private pathFinder: PathFinder;
private shell: Unit;
private mg: Game;
private destroyAtTick: number = -1;
constructor(
private spawn: TileRef,
@@ -18,6 +20,7 @@ export class ShellExecution implements Execution {
init(mg: Game, ticks: number): void {
this.pathFinder = PathFinder.Mini(mg, 2000, true, 10);
this.mg = mg;
}
tick(ticks: number): void {
@@ -30,13 +33,19 @@ export class ShellExecution implements Execution {
}
if (
!this.target.isActive() ||
!this.ownerUnit.isActive() ||
this.target.owner() == this.shell.owner()
this.target.owner() == this.shell.owner() ||
(this.destroyAtTick != -1 && this.mg.ticks() >= this.destroyAtTick)
) {
this.shell.delete(false);
this.active = false;
return;
}
if (this.destroyAtTick == -1 && !this.ownerUnit.isActive()) {
this.destroyAtTick =
this.mg.ticks() + this.mg.config().warshipShellLifetime();
}
for (let i = 0; i < 3; i++) {
const result = this.pathFinder.nextTile(
this.shell.tile(),