feat: bedste foder først — lavere foder kun når truget er nødlidende (≥75 % fri); forsynings-traktorer uden noget at hente holder ved Wait (v1.14.0.0)
This commit is contained in:
@@ -292,6 +292,7 @@ local function findBestSource(markerStations, fillTypes, farmId)
|
||||
end
|
||||
return {
|
||||
markerIndex = choice.marker.markerIndex,
|
||||
markerId = choice.marker.id,
|
||||
markerName = choice.marker.name,
|
||||
group = choice.marker.group,
|
||||
level = choice.level,
|
||||
@@ -592,11 +593,15 @@ function ADSmartPickup.findSupplyPickup(adEnv, driver, ingredients, targetWayPoi
|
||||
local allMarkers = adEnv.ADGraphManager:getMapMarkers()
|
||||
local markerStations = collectMarkerStations(adEnv, allMarkers, farmId, target.owningPlaceable)
|
||||
local loadCapacity = getLoadCapacity(adEnv, driver)
|
||||
for _, need in ipairs(ADSupplyPlanner.rankNeeds(getTargetNeeds(target, ingredients, farmId, demand), loadCapacity)) do
|
||||
local choice = findBestSource(markerStations, {need.fillType}, farmId)
|
||||
local ranked = ADSupplyPlanner.rankNeeds(getTargetNeeds(target, ingredients, farmId, demand), loadCapacity)
|
||||
-- bedste foder først: lavere foder kun når truget er nødlidende (ADSupplyPlanner.isFoodAllowed)
|
||||
local bestFood = ADSupplyPlanner.bestFoodPriority ~= nil and ADSupplyPlanner.bestFoodPriority(ranked) or nil
|
||||
for _, need in ipairs(ranked) do
|
||||
local choice = (ADSupplyPlanner.isFoodAllowed == nil or ADSupplyPlanner.isFoodAllowed(need, bestFood)) and findBestSource(markerStations, {need.fillType}, farmId) or nil
|
||||
if choice ~= nil then
|
||||
return {
|
||||
markerIndex = choice.markerIndex,
|
||||
markerId = choice.markerId,
|
||||
markerName = choice.markerName,
|
||||
group = choice.group,
|
||||
level = choice.level,
|
||||
@@ -691,6 +696,25 @@ function ADSmartPickup.choosePickup(adEnv, driver)
|
||||
|
||||
local choice = ADSmartPickup.findSupplyPickup(adEnv, driver, ingredients)
|
||||
if choice == nil then
|
||||
-- Traktor i et forsynings-run uden noget (tilladt) at hente: hold ved Wait og prøv igen, i stedet
|
||||
-- for at falde tilbage til mappe-logikken (den henter hvad som helst, fx ensilage i et halvfuldt trug).
|
||||
local run = ADRunsController ~= nil and ADRunsController.getRunForVehicle(driver) or nil
|
||||
if run ~= nil and (run.kind or "supply") == "supply" and ADOutbound ~= nil and ADOutbound.holdSupplyVehicle ~= nil then
|
||||
local replan = function()
|
||||
local list = ADSmartPickup.getIngredientsFor(adEnv, driver)
|
||||
local next = list ~= nil and ADSmartPickup.findSupplyPickup(adEnv, driver, list) or nil
|
||||
if next == nil then
|
||||
return nil
|
||||
end
|
||||
applySupplyChoice(driver, list, next)
|
||||
activePickups[driver] = {station = next.station, fillTypes = next.fillTypes, markerName = next.markerName, fillType = next.fillType}
|
||||
return next.markerId
|
||||
end
|
||||
local held = ADOutbound.holdSupplyVehicle(adEnv, driver, run, {"intet at hente (bedste foder mangler, truget ikke nødlidende)"}, replan)
|
||||
if held ~= nil then
|
||||
return held
|
||||
end
|
||||
end
|
||||
return ADSmartPickup.findLeastFilledPickup(adEnv, driver)
|
||||
end
|
||||
applySupplyChoice(driver, ingredients, choice)
|
||||
@@ -855,14 +879,16 @@ local function installHook(adEnv)
|
||||
activePickups[driver] = nil
|
||||
return originalGetNextPickup(self, driver, forcedSkip)
|
||||
end
|
||||
activePickups[driver] = {station = choice.station, fillTypes = choice.fillTypes, markerName = choice.markerName, fillType = choice.fillType or choice.fillTypes[1]}
|
||||
activePickups[driver] = choice.station ~= nil and {station = choice.station, fillTypes = choice.fillTypes, markerName = choice.markerName, fillType = choice.fillType or choice.fillTypes[1]} or nil
|
||||
|
||||
-- hold AutoDrives egen rotations-tilstand konsistent med vores valg
|
||||
self.pickups[choice.group] = self.pickups[choice.group] or {}
|
||||
self.pickups[choice.group].lastTarget = choice.markerIndex
|
||||
self.pickups[choice.group].lastVehicle = driver
|
||||
|
||||
logChoiceOnce(driver, choice)
|
||||
if choice.level ~= nil then
|
||||
logChoiceOnce(driver, choice) -- et hold ved Wait logges af ADOutbound
|
||||
end
|
||||
return choice.markerIndex
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user