Bug #2481
openAI: hunters don't attack
0%
Description
dai_hunter_manage() skips a target when !unit_attack_unit_at_tile_result(...) holds. That function returns enum unit_attack_result, and ATT_OK is 0, so the test is true exactly when the hunter can attack the target, and the hunter considers only targets it cannot attack.
In practice no hunter takes a target. eval_hunter_want() runs the same code on a virtual unit, so the AI never builds a unit to hunt with either (only hard and cheating levels build hunters; the others have H_TARGETS). That is every Hunter-role unit: in classic Horsemen, Chariot, Knights, Dragoons, Cavalry, Armor, Frigate, Ironclad, Destroyer and Submarine; civ2civ3 has Elephants and Crusaders in place of the Chariot.
The check came in with osdn #46176 (Dec 2022, against a segfault when nothing on the tile could be attacked) and is in 2.6.8, 3.0.5, 3.1.0 and every 3.2 release.
Attached patch compares with ATT_OK. A tile with nothing to attack, which the check was added for, is still skipped. main and S3_3 share one patch; S3_2 has its own for aihunt.c. Might collide with #2461
Files