Page 1 of 1

Question: Implementing unit resource requirements.

Posted: Thu Jun 23, 2022 11:31 pm
by NotAnyoneSpecial
Hello everyone, I've been following this project for a decade now and I was a long time fan. I would like to kindly ask is it now possible to implement civ3 or civ4 style resource requirements or trade networks. And if not can this be implemented in lua somehow to make up for it, I know lua is powerful but I know little else about it. Like for example, is it possible to plant a improvement on a tile with coal to get coal available for your civilization and enable/disable coal power and steam ships? Or make Iron a requirement for Legions and so on.

Re: Question: Implementing unit resource requirements.

Posted: Fri Jun 24, 2022 10:53 am
by cazfi
As units do not support generic requirement vectors, the only way I see to do something like that is to have a resource requirement for a building (those do support requirement vectors), and then to make that building requirement of the unit.

E.g. one could only build stables if there's horses around, and only cities with stables could build horsemen.

Units are lagging behind other concepts in this lack of requirement vectors. Should look in to making some progress with them (i.e. to check what are the current blockers against implementing it)

Re: Question: Implementing unit resource requirements.

Posted: Fri Jun 24, 2022 2:51 pm
by Elefant
Or you could have something like action enablers, but they allow the construction of the targeted building or unit.

Re: Question: Implementing unit resource requirements.

Posted: Fri Jun 24, 2022 5:02 pm
by cazfi
As I assumed, there's moderate size dependency chain for internal changes to be made to the freeciv engine before unit type requirement vectors can be exposed to the ruleset interface. Good news is that I now have some of those changes in development already. There's a fair chance that we have it available by freeciv-3.2.

Re: Question: Implementing unit resource requirements.

Posted: Sat Jun 25, 2022 10:51 am
by Ignatus
Elefant wrote: Fri Jun 24, 2022 2:51 pm Or you could have something like action enablers, but they allow the construction of the targeted building or unit.
Action enablers with city as actor are planned a good while ago, but I don't know if there is somebody developing them for 3.2 release.

Re: Question: Implementing unit resource requirements.

Posted: Sat Jun 25, 2022 12:20 pm
by cazfi
Ignatus wrote: Sat Jun 25, 2022 10:51 am
Elefant wrote: Fri Jun 24, 2022 2:51 pm Or you could have something like action enablers, but they allow the construction of the targeted building or unit.
Action enablers with city as actor are planned a good while ago, but I don't know if there is somebody developing them for 3.2 release.
As that work has not started yet, and the time 3.2 development was planned to stay on master is already 3/4 gone, it's unlikely that they are coming to 3.2.

Re: Question: Implementing unit resource requirements.

Posted: Sun Jun 26, 2022 11:48 am
by cazfi
btw. We don't even need to decide if we go for requirement vectors for units, or implement this via city-actor action enablers, yet. We need to work towards less hardcoded code behavior (especially AI) first, in either case.

Re: Question: Implementing unit resource requirements.

Posted: Mon Jun 27, 2022 12:55 pm
by nef
NotAnyoneSpecial wrote: Thu Jun 23, 2022 11:31 pm I would like to kindly ask is it now possible to implement civ3 or civ4 style resource requirements or trade networks. And if not can this be implemented in lua somehow to make up for it, ... . Like for example, is it possible to plant a improvement on a tile with coal to get coal available for your civilization and enable/disable coal power and steam ships? Or make Iron a requirement for Legions and so on.
You could use Lua to grant a root_req tech that enables the unit creation. The tech could be dependant on existing techs - like iron working. Another possibility is to get Lua to automatically upgrade a freshly created unit based on whatever criteria is available to Lua (e.g. phalanx to legion). For city improvements one could use Lua to create an extra on the city centre tile(s).

If you`re not comfortable with Lua I can work something up for you but it might take a couple of weeks. The real problem is trade. fc3.x has 'goods' but I have not tried it yet.