About Settlers, Workers (and Migrants?)... Hardcoded?

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
omero
Posts: 48
Joined: Fri Mar 31, 2023 10:43 am

About Settlers, Workers (and Migrants?)... Hardcoded?

Post by omero »

Hello.

Thus, I was trying to implement a different unit that is the military equivalent of a civilian worker. It is based on historical 'architecti' of the Romans (siege of Alesia is a famous example), but such kind of 'military' specialists are also reported in Chinese records.
Ideally (in my custom ruleset), civilian workers would be employed for roads, farming, irrigation, mining.

The military "architecti" would instead be more specialized in building watchtowers, forts, fortresses, airstrips (in later stages of a single player game)...

I might have stumbled into a "problem" or be missing something obvious.
It seems that the behaviors/actions of the settlers (migrants too), workers and engineers is somewhat hard coded. At least the part where they all are able to build bases (forts and fortresses).

In other words, can you imagine settlers/migrants building a fort/fortress along their search for a suitable destination? A bit of a stretch...

The question: Is it possible to have the 'build fort/fortress' actions NOT belonging to civilian units in v2.6?

I understand Engineers (modern times, modern techs)...
The old settlers&co., not so much.
cazfi
Elite
Posts: 3105
Joined: Tue Jan 29, 2013 6:54 pm

Re: About Settlers, Workers (and Migrants?)... Hardcoded?

Post by cazfi »

omero wrote: Wed May 17, 2023 4:16 pmThe question: Is it possible to have the 'build fort/fortress' actions NOT belonging to civilian units in v2.6?
Quick answer is that all such actions are action enablers controlled in later branches, but 2.6 had rather limited actions enablers support (just diplomat actions, IIRC).

S2_6 was branched early 2016, meaning that 3.0 became the version in active development - 2.6 development time isn't very fresh in my memory. Anyway, I'd guess that giving "Settlers" unit type flag would work for military units too (maybe some unit high in alien ruleset tech tree does)
cazfi
Elite
Posts: 3105
Joined: Tue Jan 29, 2013 6:54 pm

Re: About Settlers, Workers (and Migrants?)... Hardcoded?

Post by cazfi »

Or maybe it's enough to change requirements of the extra itself (not to require "Settlers" as builder), but I assumed that you had tested that already.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: About Settlers, Workers (and Migrants?)... Hardcoded?

Post by Ignatus »

According to what I have once found and wrote here, if you assign "Settlers" flag to a military unit, AI stops considering it for military actions. But it needs testing. Any way, I doubt AI is smart enough to order any terrain action for reasons other than if it is within an owner's city radius and the operation increases tile output.
omero
Posts: 48
Joined: Fri Mar 31, 2023 10:43 am

Re: About Settlers, Workers (and Migrants?)... Hardcoded?

Post by omero »

cazfi wrote: Wed May 17, 2023 6:13 pm Or maybe it's enough to change requirements of the extra itself (not to require "Settlers" as builder), but I assumed that you had tested that already.
ARGH! Yes... But did not catch _all_ the "bases" thus some still had their

Code: Select all

"UnitFlag", "Settlers", "Local", TRUE
In terrain.ruleset, obviously. No wonder my testing was ... failing. /facepalm
omero
Posts: 48
Joined: Fri Mar 31, 2023 10:43 am

Re: About Settlers, Workers (and Migrants?)... Hardcoded?

Post by omero »

Ignatus wrote: Wed May 17, 2023 8:53 pm According to what I have once found and wrote here, if you assign "Settlers" flag to a military unit, AI stops considering it for military actions. But it needs testing. Any way, I doubt AI is smart enough to order any terrain action for reasons other than if it is within an owner's city radius and the operation increases tile output.
Uhm... That explains many of the 'things' I am seeing happening, especially the part where AI stops handling wounded units properly. I have added a 'fishing boat' that is useful in island games and allows exploring if there is anything visible in the neighborhood before triremes. This unit was introduced as his own class and to somewhat limit it, looses hp if it does not seek harbour regularly. The AIs like them very much but ... They do not care to take them to a city in range after they are starting to loose HPs.

I will test how AI handles my Architecti unit, considering they do have atk/def stats and should be seen as military units proper (of course a human player would think twice before employing such unit to wage war).

I've made sure now that only Architecti (and Engineers) will be able to build fortifications/airbases. However, in many and many more games, I never seen an AI build even a single fort... Ever. They seem preferring 'smalpox'-ing and found a new city instead... Which kind of makes sense, since a city has more uses than ... Marking a spot on the map and AI already can "see" everything that moves around (unlike a human player)...

Thanks for that link suggestion, sir Ignatus :)
omero
Posts: 48
Joined: Fri Mar 31, 2023 10:43 am

Re: About Settlers, Workers (and Migrants?)... Hardcoded?

Post by omero »

The Architecti unit now works as intended, the Settlers, Workers (and Migrants) are no longer able to build ground fortifications (in my orxperimental ruleset). As an extra measure, I also introduced a custom UnitFlag (Groundbase) to be specifically assigned to Architecti and Engineers for such activity, similar to the custom UnitFlag (Airbase) that is used in other rulesets.

I also found the "real" cause of my initial troubles trying to prevent Settlers, Workers (and Migrants) building ground fortifications: a misplaced ";" in the reqs section of Fortress.

Code: Select all

reqs           =
    { "type", "name", "range", "present", "quiet"
      "Tech", "Ceremonial Burial", "Player", TRUE, FALSE
      "TerrainClass", "Land", "Local", TRUE, FALSE
      ;"UnitFlag", "Settlers", "Local", TRUE, FALSE
      "UnitFlag", "Groundbase", "Local", TRUE, FALSE
      "UnitClass", "Sea", "Local", FALSE, TRUE
      "CityTile", "Center", "Local", FALSE, TRUE
    }
That ";" not being at the beginning of the line caused some intensive head scratching and countless save/reload/start new game gigs.
That line was there just as a reminder but eventually unnecessary and potentially harmful. Eliminated.

I am left with one last (minor) problem: finding a more generic name for the Architecti unit.
Post Reply