Question: Implementing unit resource requirements.

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
NotAnyoneSpecial
Posts: 19
Joined: Wed Feb 27, 2013 10:08 am

Question: Implementing unit resource requirements.

Post 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.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Question: Implementing unit resource requirements.

Post 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)
Elefant
Hardened
Posts: 212
Joined: Sat May 28, 2022 3:55 am

Re: Question: Implementing unit resource requirements.

Post by Elefant »

Or you could have something like action enablers, but they allow the construction of the targeted building or unit.
Civ 3 tileset: viewtopic.php?t=92953
3d Irrlicht desktop client development: viewtopic.php?t=92289&start=20
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Question: Implementing unit resource requirements.

Post 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.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Question: Implementing unit resource requirements.

Post 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.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Question: Implementing unit resource requirements.

Post 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.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: Question: Implementing unit resource requirements.

Post 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.
nef
Elite
Posts: 324
Joined: Mon Jun 25, 2018 5:01 pm

Re: Question: Implementing unit resource requirements.

Post 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.
Post Reply