increase shell lifetime to 1s after death of target

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
This commit is contained in:
ilan schemoul
2025-03-27 00:46:50 +01:00
parent f188af6029
commit b2a1e758f9
3 changed files with 16 additions and 2 deletions
+1
View File
@@ -88,6 +88,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
@@ -470,6 +470,10 @@ export class DefaultConfig implements Config {
return Math.floor(attacker.troops() / 5);
}
warshipShellLifetime(): number {
return 20; // in ticks (one tick is 100ms)
}
attackAmount(attacker: Player, defender: Player | TerraNullius) {
if (attacker.type() == PlayerType.Bot) {
return attacker.troops() / 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(),