Project

General

Profile

Actions

Bug #1242

open

choosing unit to attack not checking action enablers

Added by Dean Brown 5 days ago. Updated 5 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
AI
Target version:
-
Start date:
02/18/2025
Due date:
% Done:

0%

Estimated time:

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

krakenZip.zip (113 KB) krakenZip.zip Dean Brown, 02/18/2025 07:06 AM
kraken.sav.xz (9.27 KB) kraken.sav.xz Dean Brown, 02/18/2025 07:07 AM
1242_3_1_patch.diff (1.06 KB) 1242_3_1_patch.diff Dean Brown, 02/18/2025 07:17 AM
1242_main_patch.diff (1.08 KB) 1242_main_patch.diff Dean Brown, 02/18/2025 07:17 AM

Updated by Dean Brown 5 days ago

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.

Actions

Also available in: Atom PDF