From 22caa9c5d2bd658cffd5d196610eef64aaefdbef Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 12 Jun 2025 10:13:44 -0700 Subject: [PATCH] favor transport ships, no reload penalty (#1153) ## Description: People were able to get transport ships across by distracting enemy warships with their own warship. This change has warships prioritize enemy transport ships over warships. It also allows warships to reload instantly after shooting a transport ship. This prevent cheesing where players send out many transport ships with little to no troops to distract the warship. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: --- src/core/execution/WarshipExecution.ts | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/core/execution/WarshipExecution.ts b/src/core/execution/WarshipExecution.ts index 969eec2e0..ad8a6159a 100644 --- a/src/core/execution/WarshipExecution.ts +++ b/src/core/execution/WarshipExecution.ts @@ -120,19 +120,7 @@ export class WarshipExecution implements Execution { const { unit: unitA, distSquared: distA } = a; const { unit: unitB, distSquared: distB } = b; - // Prioritize Warships - if ( - unitA.type() === UnitType.Warship && - unitB.type() !== UnitType.Warship - ) - return -1; - if ( - unitA.type() !== UnitType.Warship && - unitB.type() === UnitType.Warship - ) - return 1; - - // Then favor Transport Ships over Trade Ships + // Prioritize Transport Ships above all other units if ( unitA.type() === UnitType.TransportShip && unitB.type() !== UnitType.TransportShip @@ -144,6 +132,18 @@ export class WarshipExecution implements Execution { ) return 1; + // Then prioritize Warships. + if ( + unitA.type() === UnitType.Warship && + unitB.type() !== UnitType.Warship + ) + return -1; + if ( + unitA.type() !== UnitType.Warship && + unitB.type() === UnitType.Warship + ) + return 1; + // If both are the same type, sort by distance (lower `distSquared` means closer) return distA - distB; })[0]?.unit; @@ -152,7 +152,10 @@ export class WarshipExecution implements Execution { private shootTarget() { const shellAttackRate = this.mg.config().warshipShellAttackRate(); if (this.mg.ticks() - this.lastShellAttack > shellAttackRate) { - this.lastShellAttack = this.mg.ticks(); + if (this.warship.targetUnit()?.type() !== UnitType.TransportShip) { + // Warships don't need to reload when attacking transport ships. + this.lastShellAttack = this.mg.ticks(); + } this.mg.addExecution( new ShellExecution( this.warship.tile(),