Bug #1242
openchoosing unit to attack not checking action enablers
0%
Description
Version 3.1.4
Context - testing my custom ruleset with wild animals, I changed the action
enablers so that land animals (which have AttackNonNative flag) cannot attack
ocean tiles. Testing this with edited game with animal on a coast tile, a
Caravel on adjacent ocean tile and Workers on adjacent land tile - animal fails
to attack either one. When Caravel sails off from that adjacent tile, then
animal attacks Workers.
Problem is in aiunit.c routine dai_rampage_want() - it returns a higher "want"
value for the Caravel, so find_rampage_target() tries to attack the Caravel,
but is prevented by the action enabler.
Found similar problem with Kraken unit (unitclass:Sea,
has AttackNonNative flag), and action enabler which prevents them attacking land
tiles. With an adjacent Trireme and adjacent Catapult, fails to attack either one,
when Catapult moves away, then Kraken attacks Trireme.
To reproduce, I hacked up a copy of the civ2civ3 ruleset, called kraken ruleset,
with changed files game.ruleset, units.ruleset, nations.ruleset and
terrain.ruleset. Using submarine graphic for the Kraken to avoid needing a tilespec
file. Also saved an edited game with the Kraken, Trireme & Catapult situation.
Unzip the krakenZip.zip, put the 2 files in the resulting krakenZip directory
into ~/.freeciv/3.1 and put kraken.sav.xz in ~/.freeciv/saves,
and should be able to load that saved game.
Files
Updated by Dean Brown 5 days ago
- File 1242_3_1_patch.diff 1242_3_1_patch.diff added
- File 1242_main_patch.diff 1242_main_patch.diff added
Patch for main and 3.1, fixes problem with barbarians.
I was also able to reproduce the same bug, but not involving barbarians.
Tried adding similar fix to combat.c routine can_unit_attack_tile(),
but it caused something bad to happen, got error msg -
1: Lost connection to server: server disconnected.
The code in combat.c is beyond my comprehension, so I shouldn't mess with it,
but there is an issue there with ignoring action enablers.