There is two bugs that prevent any ancient tree variation from spawning at the world generation, in this function:
function Landscaper:_get_tree_size(tree_type, value)
local size_determiner = self._tree_size_determiners[tree_type]
local quantized = size_determiner.quantizer:quantize_down(value)
local size = size_determiner.size_map[quantized]
if size == 'large' then
local rng = self._rng
if rng:get_int(1, 100) <= size_determiner.ancient_percentage then
return ancient
end
end
return size
end
First bug is that size_determiner.ancient_percentage is always being -1. This will make the rng never enter the if condition.
The reason why it is always -1 is because in the function Landscaper:_parse_tree_sizes(tree_variants) there is this piece of code in a loop:
if tree_size == 'ancient' then
size_determiner.ancient_percentage = threshold.percentage
else
size_determiner.ancient_percentage = -1
table.insert(thresholds, threshold)
size_map[threshold] = tree_size
end
Which will always resets the value back to -1, because the āancientā tree size is not the last call. As soon as another type (small, medium or large) is called, the condition falls into the else statement and the value goes back to -1.
The second bug is that even if we hard code a value there (like 50 to have a 50% chance), when the condition is met an error happens cause it is trying to return the non existent variable ancient, while it should return the string āancientā
I fixed the second bug by changing that return ancient to return āancientā
And the first bug at function Landscaper:_parse_tree_sizes(tree_variants) by changing the:
if tree_size == 'ancient' then
size_determiner.ancient_percentage = threshold.percentage
else
size_determiner.ancient_percentage = -1
table.insert(thresholds, threshold)
size_map[threshold] = tree_size
end
To this:
if not size_determiner.ancient_percentage then
size_determiner.ancient_percentage = -1
end
if tree_size == 'ancient' then
size_determiner.ancient_percentage = threshold.percentage
else
table.insert(thresholds, threshold)
size_map[threshold] = tree_size
end
hmm⦠iām not sure if this is a ābugā, as iām pretty sure awhile back the team said they removed them until the ancient trees had more of a purpose⦠could be wrong though, paging @sdee
From the point of view that the ancient trees looks almost the same (just bulkier) yeah. But if we are trying to add one ourselves to our biomes (or even changing/adding to the default biomes), there is no way to add ancient trees without changing those codes.
No, that is the big tree, you can simple plant a sapling and that is the biggest size it reaches.
The ancient tree has (should had) a rare chance to appear, in the temperate it should be 10%. But with this bug it canāt even if you bump it to 100%.
@8BitCrab is correct; we removed the ancient trees from world generation till we had a better reason for using them (also, because Tom felt they didnāt look quite right yet). But thereās a chance that the fact that the ancient tree isnāt used is causing the code to atrophy.
Thatās ok, there is still other ways to have rarer trees using json alone. I just thought that you guys didnāt noticed that the ancient tree feature was not working.