tweak decomposition.

leaves will now start decomposing faster if touching certain nodes.
they'll also take longer overall to start decomposing.
This commit is contained in:
trans_soup 2023-10-19 16:18:24 +02:00
parent ae26cfad42
commit 400c27c021

View file

@ -7,20 +7,31 @@ local vec = blockgame.vector
local leaves = modname .. ":leaves" local leaves = modname .. ":leaves"
local leaves_decomposing = modname .. ":leaves_decomposing" local leaves_decomposing = modname .. ":leaves_decomposing"
-- END OF NODE NAMES
local decompose_scores = {
dirty = 50,
leaves_decomposing = 30,
}
local start_decompose_cost = 4000
blockgame.register_increasing_abm({ blockgame.register_increasing_abm({
id = modname .. ":begin_decompose", id = modname .. ":begin_decompose",
label = "decompose leaves", label = "decompose leaves",
nodenames = {leaves}, nodenames = {leaves},
neighbors = {"group:dirty", leaves_decomposing}, neighbors = {"group:dirty", leaves_decomposing},
interval = 20, interval = 30,
chance = 4, chance = 4,
rate = function (pos, node, data) rate = function (pos, node, data)
return data.value + math.random(4, 6) local score = blockgame.score_nearby_nodes(pos, 2, decompose_scores, function (gain, distance)
return math.floor(gain / (distance ^ 3))
end)
return data.value + score
end, end,
check = function (pos, node, data) check = function (pos, node, data)
return data.value >= 80 return data.value >= start_decompose_cost
end, end,
action = function (pos, node, data) action = function (pos, node, data)
-- NOTE: might wanna access the 4 from somewhere, instead of directly knowing it. -- NOTE: might wanna access the 4 from somewhere, instead of directly knowing it.
@ -30,11 +41,6 @@ blockgame.register_increasing_abm({
end, end,
}) })
local decompose_scores = {
dirty = 50,
leaves_decomposing = 30,
}
local decompose_cost = 30000 local decompose_cost = 30000
local average_leaves_per_dirt = 4 local average_leaves_per_dirt = 4
@ -53,7 +59,6 @@ blockgame.register_increasing_abm({
end) end)
score = score + bonus score = score + bonus
return data.value + score return data.value + score
end, end,
check = function (pos, node, data) check = function (pos, node, data)