Fix Frenzy.EXE: use tile coordinates instead of pixel positions for HIVE frenzy radius check

This commit is contained in:
Dejvino
2026-11-14 23:11:36 +01:00
parent 3cf17a9a5f
commit 7ef629d5df
3 changed files with 303 additions and 58 deletions
+29
View File
@@ -204,3 +204,32 @@ TEST(unit/reset_rearms_everything)
EXPECT(nodeOnline[N_AIRLK]); // the old root-online bug
EXPECT(!nodeOnline[N_JUNC] && !nodeOnline[N_DOOR] && !nodeOnline[N_HIVE]);
}
// Enemies outside the hive sphere of influence should not be impacted by frenzy
TEST(unit/frenzy_hive_sphere_influence)
{
// HIVE node is at tile (35, 4), FRENZY_RADIUS = 6 tiles.
// Sphere covers tiles within 6 tiles of (35, 4).
// (12, 2) is ~23 tiles from HIVE — outside the frenzy sphere.
// (20, 12) is ~17 tiles from HIVE — outside the frenzy sphere.
// (32, 10) is ~3.6 tiles from HIVE — inside the frenzy sphere.
// (33, 5) is ~2.2 tiles from HIVE — inside the frenzy sphere.
freshScenario();
// Droid at (12, 2) — outside HIVE frenzy sphere (default droid position)
// Unit 2 is already a droid at (12, 2) from freshScenario()
// Enemy droid at (20, 12) — outside HIVE frenzy sphere (default droid at unit 3)
// Unit 3 is already a droid at (20, 12) from freshScenario()
frenzyT = 300; // activate Frenzy.EXE
// With frenzy active: droid at (12,2) should NOT target droid at (20,12)
// because the enemy is outside the HIVE sphere of influence.
// Without the fix, this would incorrectly target the enemy.
EXPECT_EQ(acquireTarget(2), -1);
// Without frenzy: droid at (12,2) should target droid at (20,12)
// since it's within range and LOS, and not marine.
frenzyT = 0;
// Note: may or may not acquire target depending on LOS, but the key test
// is that with frenzy + outside sphere, target is rejected.
}