Hello. I'm trying to simulate the civ3 or civ4 "if the resource is present on any one of my cities connected by a road to city X, then city X also have that resource available". I don't seem to find that it is possible on effects.ruleset.
I checked https://freeciv.fandom.com/wiki/Editing_Effects and https://freeciv.fandom.com/wiki/Requirements.
Would something like this be possible without using lua? I'm against using it, since the AI probably couldn't handle that properly.
If not, something like this would be great to have
"Extra", "Stone", "ConnectedPath"
Example:
[unit_chariot]
name = _("Chariot")
class = "Big Land"
reqs= {
"type","name","range"
"Tech","The Wheel","Player"
"Extra", "Horse", "ConnectedPath", TRUE
}
...
Of course, currently we have Traderoute, but that would mean that i would have to create a domestic traderoute every time i want to get access to a certain resource that is outside the city.
Thank you in advance.
Checking if an resource is available on any road connected city
-
- Posts: 4
- Joined: Sat Nov 23, 2024 1:24 pm
Re: Checking if an resource is available on any road connected city
Currently, it is not available as a normal game feature; I have tried to work on it but I am currently mostly out of the project. Well, you will need to write in Lua some pathfinder to detect what city is connected to what, there are such algorithms on the web. Then you can place some special extras on center tiles of cities that are connected to a resource, and then you can make reqs based on that extra:
[pre]
[unit_chariot]
name = _("Chariot")
class = "Big Land"
reqs= {
"type","name","range"
"Tech","The Wheel","Player"
"Extra", "HorseConnected", "City"
}
[/pre]
Then you revise these extras placing on "turn_begin", "city_change_hands", "city_built" and "city_destroyed" signals. Surely, you can place the original "Horse" extras instead, but then you have to remember where the extras are native and where you have placed them, that requires some knowing of "_freeciv_state_dump()" builtin function quirks. AI won't understand what to do but probably we can grant it the extras for free as a handicap.
[pre]
[unit_chariot]
name = _("Chariot")
class = "Big Land"
reqs= {
"type","name","range"
"Tech","The Wheel","Player"
"Extra", "HorseConnected", "City"
}
[/pre]
Then you revise these extras placing on "turn_begin", "city_change_hands", "city_built" and "city_destroyed" signals. Surely, you can place the original "Horse" extras instead, but then you have to remember where the extras are native and where you have placed them, that requires some knowing of "_freeciv_state_dump()" builtin function quirks. AI won't understand what to do but probably we can grant it the extras for free as a handicap.
-
- Posts: 4
- Joined: Sat Nov 23, 2024 1:24 pm
Re: Checking if an resource is available on any road connected city
Thank you Ignatus for the response. I really hope something like this will be implemented, since it's a basic feature since civ3. And thank you for the effort on giving a solution. Yeah, the graphs theory from my programming lessons back in the day would be just what i needed if i wanted to implement this using lua. Unfortunately, i want to keep this simple, since i doubt the AI would keep up with this feature if it was developed using lua.Ignatus wrote: ↑Mon Dec 30, 2024 3:21 pm Currently, it is not available as a normal game feature; I have tried to work on it but I am currently mostly out of the project. Well, you will need to write in Lua some pathfinder to detect what city is connected to what, there are such algorithms on the web. Then you can place some special extras on center tiles of cities that are connected to a resource, and then you can make reqs based on that extra:
[pre]
[unit_chariot]
name = _("Chariot")
class = "Big Land"
reqs= {
"type","name","range"
"Tech","The Wheel","Player"
"Extra", "HorseConnected", "City"
}
[/pre]
Then you revise these extras placing on "turn_begin", "city_change_hands", "city_built" and "city_destroyed" signals. Surely, you can place the original "Horse" extras instead, but then you have to remember where the extras are native and where you have placed them, that requires some knowing of "_freeciv_state_dump()" builtin function quirks. AI won't understand what to do but probably we can grant it the extras for free as a handicap.
At the moment, i will probably check if the resource is in the traderoute or owned by the player. It's a pain to duplicate effects, but it is what it is.
Thanks again.
Re: Checking if an resource is available on any road connected city
Largely inspired by your former (proposed, unfinished) patches, I'm working on "access areas" idea: RM #1324 It's both very far from what you proposed, but hopefully also providing the most important functionalities of your dreams as ruleset author.