fix: æg-paller tælles kun for nærmeste spawner — tomt hønsehus så naboernes paller (hus 1+2 blev aldrig hentet) (v1.28.1.0)

This commit is contained in:
2026-09-26 11:29:49 +02:00
parent 6fd917caca
commit cb68c81a3f
3 changed files with 53 additions and 2 deletions
+27 -1
View File
@@ -256,6 +256,31 @@ end
-- Liter af varen på paller der står ved fabrikkens spawner (pallespawneren tømmer lageret
-- ud på jorden løbende, så det er dér varen fysisk er).
-- Alle andre pallespawnere der kan lave varen (stalde med spawner for fillType, fabrikkers
-- pallespawner): {{x, z}, ...}. Står bygningerne tættere end PALLET_RADIUS (hønsehuse på række),
-- tilhører en palle den nærmeste spawner — ellers tæller et tomt hus naboernes paller med.
local function findRivalSpawners(fillType)
local rivals = {}
local placeables = g_currentMission ~= nil and g_currentMission.placeableSystem ~= nil and g_currentMission.placeableSystem.placeables or {}
for _, placeable in pairs(placeables) do
local husbandrySpawners = getHusbandryPalletSpawners(placeable)
local productionPoint = getProductionPoint(placeable)
local node = firstSpawnerNode(husbandrySpawners ~= nil and husbandrySpawners[fillType] or nil)
or firstSpawnerNode(productionPoint ~= nil and productionPoint.palletSpawner or nil)
local x, z = getNodePosition(node)
if x ~= nil then table.insert(rivals, {x = x, z = z}) end
end
return rivals
end
local function isNearestSpawner(rivals, sx, sz, x, z)
local own = distance2(sx, sz, x, z)
for _, rival in ipairs(rivals) do
if distance2(rival.x, rival.z, x, z) < own then return false end
end
return true
end
local function getPalletsNearSpawner(placeable, fillType, farmId, spawnerNode)
local productionPoint = getProductionPoint(placeable)
local spawner = productionPoint ~= nil and productionPoint.palletSpawner or nil
@@ -264,6 +289,7 @@ local function getPalletsNearSpawner(placeable, fillType, farmId, spawnerNode)
if sx == nil then
return 0
end
local rivals = cacheGet("palletSpawners", fillType, 10000, function() return findRivalSpawners(fillType) end)
local vehicles = g_currentMission ~= nil and g_currentMission.vehicleSystem ~= nil and g_currentMission.vehicleSystem.vehicles or {}
local total, count = 0, 0
local radius2 = ADSources.PALLET_RADIUS * ADSources.PALLET_RADIUS
@@ -271,7 +297,7 @@ local function getPalletsNearSpawner(placeable, fillType, farmId, spawnerNode)
if isPalletVehicle(vehicle) and (vehicle.getOwnerFarmId == nil or vehicle:getOwnerFarmId() == farmId) then
local palletFillType, level = getPalletContent(vehicle)
local x, z = getNodePosition(vehicle.rootNode)
if palletFillType == fillType and x ~= nil and distance2(sx, sz, x, z) <= radius2 then
if palletFillType == fillType and x ~= nil and distance2(sx, sz, x, z) <= radius2 and isNearestSpawner(rivals, sx, sz, x, z) then
total = total + level
count = count + 1
end
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="107">
<author>masterdraco</author>
<version>1.28.0.0</version>
<version>1.28.1.0</version>
<title>
<en>AD Smart Pickup</en>
</title>