Obligatory hard action requirements you want dropped

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
sveinung
Elite
Posts: 542
Joined: Wed Feb 20, 2013 4:50 pm

Obligatory hard action requirements you want dropped

Postby sveinung » Mon Feb 22, 2021 8:33 pm

Thanks to the obligatory hard requirement support for actions in Freeciv 3.0 you now know why that awesome rule you had planned to implement via an action enabler didn't work. It had a conflict with a hard requirement for the action it enabled. But you want that conflict gone!

List the hard requirements you want gone here and why you want it gone. Bonus points if you can show that it won't be much work. (Example: Dropping NoHome for "Home City" enablers only needed 5 lines in the auto help system.)

I don't want people to accuse me of playing favorites: The amount of work needed to drop a hard requirement varies. The amount of work to verify that a solutions someone suggest works varies too. Unit type flags are typically relatively easy to check since they can be searched for. Other requirements may have subtle interactions in areas that don't even mention the requirement.

If you didn't understand what was said above, see my explanation of hard requirements here.

User avatar
Caedo
Elite
Posts: 512
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Obligatory hard action requirements you want dropped

Postby Caedo » Mon Feb 22, 2021 11:21 pm

All the ones I've found require at least some amount of effort (more than just five lines in the autohelp), and sometimes decisions on how something should be done.
In ascending order of projected effort:

Tl;dr: Some effort, some possible info leak.
"Airlift Unit" requires the actor unit to not be transporting anything. As far as I can tell, the primary issue (that isn't ruleset authors' problem) would be making sure that, if transporting one ally's units and airlifting to a different ally's city, those transported units are allowed to enter that destination city (i.e. your two allies are also allied with each other). This could lead to info leak in the case where you don't have an embassy with either of those players.

Tl;dr: Some effort, and depending on implementation, some possible info leak or unhappy allies.
"Paradrop Unit" requires the actor to not be transporting any units. One could imagine a scenario where a strike team is launched deep into enemy territory in some kind of vehicle.
Like Airlift, this necessitates the question of whether transported units are allowed to enter the destination tile. Unlike Airlift, Paradrop is known to occasionally kill the actor unit when dropping into unknown territory, which your allies might not like if you're transporting their units.

Note that both of the above are basically no problem if the actor is only transporting units of the same player.

Tl;dr: Quite a bit of effort.
Unhardcoding the "CanOccupyCity" unit class flag.
Unfortunately, there seems to be a shocking amount of places in the code that just look for the UCF, not for whether units are capable of any "Conquer City" action. This also includes places involving auto-conquering of cities (e.g. when teleporting a unit). One option would be to just remove the flag as an obligatory requirement for "Conquer City" actions, which would change its role to "CanAutoConquerCity", but at that point we're reworking quite a bit of code.
Note: At the moment, there seem to be some places (particularly AI-wise) that assume any military unit of a CanOccupyCity class is, in fact, capable of conquering cities on demand – this is a problem in and of itself, if any ruleset author ever decides to violate that assumption.

Tl;dr: Probably not gonna happen due to required effort.
"Upgrade Unit" currently requires the target city to be domestic. One could imagine a ruleset where upgrading units is also possible in cities controlled by your allies.
Granted, flat out dropping this requirement would mean that, if ruleset authors don't enforce things like requiring an embassy for upgrades in foreign cities, there might be some info leak (as described in detail in a comment in actions.c).
Digging deeper into the code, it looks like this would probably be a change that requires quite a bit of work; not the least of which being the question of whether unit upgrade cost effects should be computed against the unit's owner, or the city's owner.


Any others ould usually require a huge amount of reworking, like "what would it take to get rid of the Settlers utyf?" or "what if animals could conquer cities?", which is way outside the scope of this.
~ A.V. L.

Ignatus
Elite
Posts: 492
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Obligatory hard action requirements you want dropped

Postby Ignatus » Tue Feb 23, 2021 12:52 pm

I think, the best goal of the mentioned is paradropping in a tank (well, unhardcoding the UCF is also necessary but it really needs a lot of attention). The leak of diplomatic states between allies hardly is a problem, so just check the cargo and say _("Can't paradrop %s with %s's %s aboard into this territory due to diplimatical reasons."). For sure, you must own the toplevel unit to paradrop. Really, aside of the hard reqs question, there should be a ruleset control around what happens if you get into a peaceful territory, as well as can you paradrop into an unknown tile or an unseen tile with terrain remembered to be unsuitable, and is it really plausible that a worker of a nation at peace with you will put your cool paratrooper down seeing him in the sky above...

My own idea:
Allow capturing a transporting unit. As long as we can't capture a caravel full of caravans, the piracy is just boring.

sveinung
Elite
Posts: 542
Joined: Wed Feb 20, 2013 4:50 pm

Re: Obligatory hard action requirements you want dropped

Postby sveinung » Tue Feb 23, 2021 8:14 pm

Caedo wrote:Tl;dr: Quite a bit of effort.
Unhardcoding the "CanOccupyCity" unit class flag.
Unfortunately, there seems to be a shocking amount of places in the code that just look for the UCF, not for whether units are capable of any "Conquer City" action. This also includes places involving auto-conquering of cities (e.g. when teleporting a unit). One option would be to just remove the flag as an obligatory requirement for "Conquer City" actions, which would change its role to "CanAutoConquerCity", but at that point we're reworking quite a bit of code.

Working on it. It may not look that way but a lot of my recent work on Freeciv has been aimed at it. Today I spent most of my Freeciv-time working on making it possible for ruleup to cut out unused crap from the ruleset so the output of the ruleset upgrade code for splitting Paradrop Unit could be readable enough for me to send in my patch that splits Paradrop Unit so one CanOccupyCity reference can move to the ruleset - as a hard obligatory requirement at first. The next big CanOccupyCity related task I have started to work on - mostly planning - is to handle the Lua API (that currently decides if Lua teleport move can occupy based on the flag) in a backwards compatible way that allows dropping the hard coded reference to CanOccupyCity for 3.2.

Caedo wrote:Note: At the moment, there seem to be some places (particularly AI-wise) that assume any military unit of a CanOccupyCity class is, in fact, capable of conquering cities on demand – this is a problem in and of itself, if any ruleset author ever decides to violate that assumption.

Paches welcome (from any reader)! Since I'm currently in the CanOccupyCity "area" mentally I would probably be quick to review them. If you use utype_can_do_action_result() in the 3.1 patches you won't delay generalized actions. Feel free to use utype_can_do_action() if you don't want to create a separate 3.0 patch.

User avatar
Caedo
Elite
Posts: 512
Joined: Sun Feb 10, 2013 10:21 pm
Location: Stuttgart, Germany

Re: Obligatory hard action requirements you want dropped

Postby Caedo » Thu Feb 25, 2021 4:59 pm

sveinung wrote:Paches welcome (from any reader)! Since I'm currently in the CanOccupyCity "area" mentally I would probably be quick to review them. If you use utype_can_do_action_result() in the 3.1 patches you won't delay generalized actions. Feel free to use utype_can_do_action() if you don't want to create a separate 3.0 patch.

I made a patch for the AI and advisor stuff in hrm#921005 (can't reassign the ticket or change its status tho). As far as grep can tell, this only leaves the Paradrop and Lua API stuff you mentioned above.

Ignatus wrote:My own idea:
Allow capturing a transporting unit. As long as we can't capture a caravel full of caravans, the piracy is just boring.

I've thought about that too, and I really like the idea, but I figure we should probably put that off until after we've figured out how transported units defending their transport works. I mean, when you've got a capturable transport full of capturable cargo, sure, everything's obviously gonna work, but boarding an enemy ship is gonna get significantly harder when they've got a score of legionnaires on board.
~ A.V. L.

Ignatus
Elite
Posts: 492
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Obligatory hard action requirements you want dropped

Postby Ignatus » Thu Feb 25, 2021 7:28 pm

Caedo wrote:I've thought about that too, and I really like the idea, but I figure we should probably put that off until after we've figured out how transported units defending their transport works. I mean, when you've got a capturable transport full of capturable cargo, sure, everything's obviously gonna work, but boarding an enemy ship is gonna get significantly harder when they've got a score of legionnaires on board.

"Capture units" is an action versus units, as long as it's so we won't be able to capture a transport with a single Diplomat on board if he is not capturable, so I don't see any problem with removing the hard req. Changing this behaviour with some desk fight possible or at least throwing the defenseless diplo to the sharks is another question.

sveinung
Elite
Posts: 542
Joined: Wed Feb 20, 2013 4:50 pm

Re: Obligatory hard action requirements you want dropped

Postby sveinung » Tue Mar 23, 2021 11:29 am

Ignatus wrote:"Capture units" is an action versus units, as long as it's so we won't be able to capture a transport with a single Diplomat on board if he is not capturable, so I don't see any problem with removing the hard req.

I investigated this. Capturing an occupied transport still causes a crash. Patches that avoid the crash without breaking something else and removes the hard requirement welcome.

Caedo wrote:Unhardcoding the "CanOccupyCity" unit class flag.

Now osdn #41831

bard
Veteran
Posts: 119
Joined: Fri Jun 14, 2013 2:00 pm

Re: Obligatory hard action requirements you want dropped

Postby bard » Sun Jul 04, 2021 6:01 pm

I'm testing action enablers in v3.0, and I'm loving the new possibility to fine tune the attack and bombard actions, but there is something I'm being unable to implement:
Is it possible to make units that can bombard non-native terrain, but they can not attack it? For example, a ship (native to ocean) that can attack other ships, cannot attack land units, but can bombard them. I guess it would need to unhardcode something related to "AttackNonNative" flag, but I'm not sure what.

My first attempt was:
action = "Attack"
target_reqs =
{ "type", "name", "range", "present"
"UnitState", "OnNativeTile", "Local", TRUE
}

But that means the target must be on a tile native to the target. I can't find a way to check if the target tile is native to the attacker.

Ignatus
Elite
Posts: 492
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Obligatory hard action requirements you want dropped

Postby Ignatus » Sun Jul 04, 2021 9:27 pm

bard wrote:My first attempt was:
action = "Attack"
target_reqs =
{ "type", "name", "range", "present"
"UnitState", "OnNativeTile", "Local", TRUE
}

But that means the target must be on a tile native to the target. I can't find a way to check if the target tile is native to the attacker.

Yes, we don't have a way to test such a thing with our current enabler system. All you can do is put unit type or class in actor_reqs and filter its native terrains by target_reqs (e.g. "TerrainClass", "Local", "Land", TRUE;
"TerrainType", "Mountains", "Local", FALSE)

bard
Veteran
Posts: 119
Joined: Fri Jun 14, 2013 2:00 pm

Re: Obligatory hard action requirements you want dropped

Postby bard » Mon Jul 05, 2021 2:53 am

Ignatus wrote:Yes, we don't have a way to test such a thing with our current enabler system. All you can do is put unit type or class in actor_reqs and filter its native terrains by target_reqs (e.g. "TerrainClass", "Local", "Land", TRUE;
"TerrainType", "Mountains", "Local", FALSE)

Thank you very much, your suggestion seems to get what I wanted.

By creating a new attack enabler linked to a new unit flag:

Code: Select all

[actionenabler_attack_only_sea]
action = "Attack"
actor_reqs    =
    { "type",          "name",             "range", "present"
      "UnitFlag",      "Only_Sea_Attack",  "Local", TRUE
      "UnitFlag",      "NonMil",           "Local", FALSE
      "MinMoveFrags",  "1",                "Local", TRUE
      "DiplRel",       "War",              "Local", TRUE
    }
target_reqs    =
    { "type",         "name",         "range", "present"
      "TerrainClass", "Oceanic",      "Local", TRUE
    }

And adding this to all other attack enablers:

Code: Select all

actor_reqs    =
      "UnitFlag",      "Only_Sea_Attack",  "Local", FALSE
    }


I thought this kind of rule would require to unhardcode the unit flag "Only_Native_Attack" (or the class flag "AttackNonNative"), in a similar way as "Marine" and "AttFromNonNative", but it seems I was wrong. I withdraw my request.