Ticket #42960

firepower of ship not reduced when attacking from city

Open Date: 2021-10-01 04:06 Last Update: 2021-11-22 23:09

Reporter:
Owner:
Type:
Status:
Closed
Component:
MileStone:
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
Fixed
File:
3

Details

It is an old rule that when a ship attacks a land unit, both firepowers are reduced to 1.
Problem is, GNAPATCH#3830 (github commit here) seems to have unintentionally caused a rule change: after this commit, the firepowers are not reduced when the ship attacks from a city.

This has strategic implications, as it makes ships useful as fire-back city defenders against land assaults.

To reproduce, open attached savegame, take the Spanish, activate the Cruiser in Barcelona, and inspect the chance to win against the Austrian Mech. Inf.
If you do this in 2.5, the chance is 50%; if you do it in 3.0.0-beta2, the chance is 98%.

The easiest fix would be to just add a hard-coded check for the attacker-in-city case.
Alternatively, since the patch originally introduced the offending check !can_exist_at_tile(unit_type(defender), unit_tile(attacker)) with the sole purpose to handle the attacker-ship-offshore/defender-ship-in-city case, maybe replace it with a simple literal check for defender-in-city, and refrain from considering the attacker tile altogether.

In any case, the discussion in GNAPATCH#3830 makes it clear that formulating this via tile nativity is very confusing. And the rationale behind this rule is hard to generalize -- it makes sense for classic, but is it the right thing to do in other rulesets? Maybe this should not be hard coded. Currently there is a "FirePower1" bonus to reduce defender firepower, maybe something similar can be added to also reduce attacker firepower. In that case, the logic that the classic ruleset needs to express becomes quite simple: reduce both firepowers to 1 when a Sea unit attacks a Land unit, irrespective of terrain (since classic Land units cannot defend on oceanic terrain anyway).

Ticket History (3/14 Histories)

2021-10-01 04:06 Updated by: log65536
  • New Ticket "firepower of ship not reduced when attacking from city" created
2021-10-01 08:37 Updated by: log65536
Comment

A reminder that any rule change here should also update the Combat section of helpdata.txt, which in the meantime has been edited to reflect GNAPATCH#3830.

(Edited, 2021-10-01 08:38 Updated by: log65536)
2021-10-01 10:19 Updated by: cazfi
Comment

Reply To log65536

the sole purpose to handle the attacker-ship-offshore/defender-ship-in-city case, maybe replace it with a simple literal check for defender-in-city, and refrain from considering the attacker tile altogether.

I don't think there need to be a city involved. Ships can bombard units on shore anywhere.
Yeah, that seems hairy to resolve correctly.
2021-10-01 15:42 Updated by: log65536
Comment

cazfi への返信

Reply To log65536

the sole purpose to handle the attacker-ship-offshore/defender-ship-in-city case, maybe replace it with a simple literal check for defender-in-city, and refrain from considering the attacker tile altogether.

I don't think there need to be a city involved. Ships can bombard units on shore anywhere.

The non-city case is handled by the first clause of the check (!is_native_tile(unit_type(attacker), unit_tile(defender)) i.e. non-native-attack). The second clause (!can_exist_at_tile(unit_type(defender), unit_tile(attacker))) has any effect only when a city is involved (since non-native attack where "defender can_exist_at_tile of attacker" is only possible in the attacker-ship-offshore/defender-ship-in-city and attacker-ship-in-city/defender-land-unit-on-land-tile cases; of those we only want the former case to be rejected for reduction of firepower).

Yeah, that seems hairy to resolve correctly.

The counter-intuitive stuff is the second clause, thus my suggestion to simplify it with a simple check for a city.

2021-10-01 15:59 Updated by: log65536
Comment

Now come to think of it more carefully, you are right, the second clause also takes effect in the attacker-ship-offshore/defender-helicopter-on-land case, therefore the second clause cannot be replaced by a city check. A city check should be in addition to it. I forgot that Helicopters are not Unreachable.

2021-10-01 15:59 Updated by: cazfi
Comment

No, I read the code so that the main reason of that check is to distinguish between a land unit on shore, and a helicopter unit above land (in classic ruleset - in custom rulesets it may apply to other units native to both land and sea)

2021-10-01 16:09 Updated by: log65536
Comment

Writing at the same time - this was nice :)

2021-11-08 08:17 Updated by: cazfi
  • Resolution Update from None to Accepted
  • Milestone Update from (None) to 2.6.6 (closed)
Comment

Do you think the attached patches do the right thing? They *add* the check for the possibility that the attacker is in a city (or transport) on non-native terrain.

2021-11-21 07:14 Updated by: cazfi
Comment

The patch has the issue that when a ship attacks against a Helicopter from a city, it's considered land bombardment.

1) I conclude that correct behavior in all situations is not possible without additional information from the rulesets -> fix to that not possible in d3f branches (S2_6 & S3_0)
2) I think that the patch here is the least bad solution for S2_6 & S3_0 - it handles typical attack against land units always correctly. So I still plan to push the patch.

2021-11-21 07:22 Updated by: cazfi
Comment

Reply To cazfi

1) I conclude that correct behavior in all situations is not possible without additional information from the rulesets -> fix to that not possible in d3f branches (S2_6 & S3_0)

2021-11-22 23:09 Updated by: cazfi
  • Status Update from Open to Closed
  • Owner Update from (None) to cazfi
  • Resolution Update from Accepted to Fixed

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login