It would be nice to be able to modify how often and where a special appears. As of now, as far as I'm concerned, every special just spawns randomly anywhere on the defined terrain in more or less equal numbers.
My intention is to introduce certain specials that are rarer like uranium or that only appear if the tile is adjacent to water for seals for example.
Specials frequency and location
Re: Specials frequency and location
Yes, improving support for that is something to look at.
I don't know if anyone has actually tested it, but there's been talk about a trick you might be able to do with current version: list same resource multiple times for the same terrain. That doesn't affect the overall amount of the resources, but their relative frequency.
I don't know if anyone has actually tested it, but there's been talk about a trick you might be able to do with current version: list same resource multiple times for the same terrain. That doesn't affect the overall amount of the resources, but their relative frequency.
-
- Hardened
- Posts: 171
- Joined: Sun Dec 31, 2017 3:41 am
Re: Specials frequency and location
Can restrict seals to tiles adjacent to water by using lua script. Should also do Ivory.
Code: Select all
function coast_only(tile, resource, replace_resource)
isOK = false
for t in tile:square_iterate(1) do
class = t.terrain:class_name()
if class == "Oceanic" then
isOK = true
break;
end
end -- for tile:square_iterate
if not isOK then
tile:remove_extra(resource)
tile:create_extra(replace_resource)
end
end
function coasts_only_callback()
for tile in whole_map_iterate() do
local resource = "Ivory"
if tile:has_extra(resource) then
coast_only(tile, resource, "Furs")
end
resource = "Seals"
if tile:has_extra(resource) then
coast_only(tile, resource, "Oil")
end
end -- for whole_map_iterate
return false
end
signal.connect("map_generated", "coasts_only_callback")
Last edited by Dino the Dinosore on Sun Jan 09, 2022 4:02 am, edited 2 times in total.
Re: Specials frequency and location
Tested it and you are right!cazfi wrote:Yes, improving support for that is something to look at.
I don't know if anyone has actually tested it, but there's been talk about a trick you might be able to do with current version: list same resource multiple times for the same terrain. That doesn't affect the overall amount of the resources, but their relative frequency.
resources = "Buffalo", "Buffalo", "Buffalo", "Buffalo", "Buffalo", "Buffalo", "Buffalo", "Buffalo", "Buffalo", "Horses"
Counted on a map 39 buffalos and 3 horses so almost a perfect 10:1 ratio.
-
- Hardened
- Posts: 171
- Joined: Sun Dec 31, 2017 3:41 am
Re: Specials frequency and location
I spoke too soon about my code testing OK - seeing some weird things. And just noticed in the chat log a bunch of assert failures -
Guess I should file a ticket. edit.remove_extra(tile, resource) seems to trigger it.in dbv_isset() [../../freeciv-3.0.0/utility/bitvector.c::122]: assertion 'pdbv->vec != ((void*)0)' failed.
Please report this message at https://osdn.net/projects/freeciv/ticket/
Re: Specials frequency and location
Thanks. Should be fixed in 3.0.0. Meanwhile, if it bothers you, you may try to do the resource removal in the beginning of the first turn (the problem was that things are not properly initialized at the time 'map_generated' signal gets emitted).Dino the Dinosore wrote:I spoke too soon about my code testing OK - seeing some weird things. And just noticed in the chat log a bunch of assert failures -Guess I should file a ticket. edit.remove_extra(tile, resource) seems to trigger it.in dbv_isset() [../../freeciv-3.0.0/utility/bitvector.c::122]: assertion 'pdbv->vec != ((void*)0)' failed.
Please report this message at https://osdn.net/projects/freeciv/ticket/
This script might cause fairness issues. Player start positions have already been assigned with the assumption that those resources are there.
-
- Hardened
- Posts: 171
- Joined: Sun Dec 31, 2017 3:41 am
Re: Specials frequency and location
Thanks. Good point about fairness issues - I edited my code in previous post to replace the resource with another one.