Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. Read more...

Feature #873418

Allow attacking part of a stack by actionenabler

Added by Edward Cree 6 months ago. Updated 5 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

In my Aviation ruleset for 3.0, I have unit flags and actionenabler rules to determine whether units can attack each of ground, sea and air units. (I didn't use Unreachable and targets=, because units in cities are always reachable and I didn't want bombers to be able to bomb fighters in cities.) See https://github.com/ec429/fc-aviation/blob/04f5a70ec153270194eb4c971614ee3d5b71a272/aviation/game.ruleset#L330 for my current actionenabler rules implementing this.

Unfortunately, the result of this is that a mixed stack of (say) ground and air units can neither be attacked by an AntiGround nor an AntiAir unit, because there is always something in the stack that cannot be attacked. Confusingly, the "Choose a strategy" dialogue box nonetheless offers an "Attack" option, which when selected produces an "illegal action" message (and loss of a move fragment).

I would like a way for the attack in this case to only interact with that subset of the stack for which the actionenabler says yes; so the strongest attackable unit in the stack defends, and if stack-kill is on, a defender loss only destroys the attackable units (not the entire stack). Of course if there are no attackable units in the stack, then the game would behave as it does currently.

History

#1 Updated by Alexandro Ignatiev 6 months ago

That is the behaviour of stack targeted (ATK_UNITS) actions: you must be enabled to perform them to each single unit on a tile, that sometimes results in a failed move (btw can you set the Illegal_Action_Move_Cost effect to 0 for this case?). The reasoning of why "Attack" is one is in Feature #672612. Probably we need some new target kind ATK_SOME_UNITS to handle the case, that will unhardcode the "Unreachable" mechanism.

#2 Updated by Lexxie L 5 months ago

FCW has solved this by using NeverProtects and NeverBlocked utype flags.

It can be a little bit of a logic-puzzle to figure it out: but it is now possible to specify any and all possible combinations for reachability/pure unreachability/unreachable-but-not-blocking, through a thoughtful combination of:
1. "Unreachable"
2. "NeverProtects"
3. "NeverBlocked"
4. targets = "",...

#3 Updated by Edward Cree 5 months ago

Lexxie L wrote:

FCW has solved this by using NeverProtects and NeverBlocked utype flags.

Hmm sounds nice, but does that actually solve my problem? I'm not using Unreachable because cities override it and (as mentioned) I don't want bombers flattening a city to take out the fighters that are sitting there waiting to intercept.

So NeverProtects would need to work on an actionenabler level, not just on a hardcoded-Unreachable level. But if it did, then yes I think that would give me what I need (and from my initial exploration of the source, seems like it'd be a lot easier to implement than a whole new action target kind. Just figuring out the information-leak stuff in action_prob_vs_units_full() is doing my head in).

A related question is, what happens if you try to conquer a city that contains only planes? Will you be able (either because of NeverProtects or because of DoesntOccupyTile) to march your troops in and destroy the planes without fighting them? That's the behaviour I'd like (better still would be if the planes evacuated to random adjacent tiles, so you could fly them to other cities/bases if they had enough fuel left), but my guess is that instead you'll need to kill the planes (by attacking the city with fighters) before you can conquer, because MaxUnitsOnTile counts everything (not just units that occupy the tile).

#4 Updated by Alexandro Ignatiev 5 months ago

Edward Cree wrote:

A related question is, what happens if you try to conquer a city that contains only planes? Will you be able (either because of NeverProtects or because of DoesntOccupyTile) to march your troops in and destroy the planes without fighting them? That's the behaviour I'd like (better still would be if the planes evacuated to random adjacent tiles, so you could fly them to other cities/bases if they had enough fuel left), but my guess is that instead you'll need to kill the planes (by attacking the city with fighters) before you can conquer, because MaxUnitsOnTile counts everything (not just units that occupy the tile).

Currently, you must "fight" each unit in a city to conquer it, even Diplomats, see Feature #864356. DoesntOccupyTile has nothing to do with it, it just allows enemy cities to place workers on tiles with your units with this flag. And stacks in cities never bounce around like you described except one case: when a player who is not allied with the city owner captures them and nothing protects them from being captured. You may try implementing some dirty hack based on this fact ;)

Also available in: Atom PDF