fix: AD's 'AL unload' sættes til center ved Start af udkørsel med autoload-bil (stod på fra → ingen aflæsning ved salgssted); pris-% = kurven alene (v1.12.10.0)

This commit is contained in:
2026-09-23 12:00:55 +02:00
parent 448af2bbea
commit a6e17d4f36
5 changed files with 52 additions and 15 deletions
+4 -5
View File
@@ -77,7 +77,9 @@ local function getCurrentPeriod()
end
-- {price, top, percent} for varen ved stationen; nil hvis stationen ikke kan prissætte den.
-- percent = kurve-% × (effektiv ÷ stationens grundpris nu); top = den pris der svarer til 100 %.
-- percent = kurve-% (faktor nu ÷ årets højeste). Stationens `fillTypePrices` bruges IKKE som
-- reference: in-game (23/9) gav effektiv 1602 mod grundpris 505 = 317 %, fordi grundprisen
-- hverken indeholder sværhedsgrad eller prisskala. top = prisen der svarer til 100 % af kurven.
function ADPrices.getQuote(station, fillType)
if station == nil or station.getEffectiveFillTypePrice == nil then
return nil
@@ -88,10 +90,7 @@ function ADPrices.getQuote(station, fillType)
end
local fillTypeDesc = g_fillTypeManager ~= nil and g_fillTypeManager.getFillTypeByIndex ~= nil and g_fillTypeManager:getFillTypeByIndex(fillType) or nil
local factors = fillTypeDesc ~= nil and fillTypeDesc.economy ~= nil and fillTypeDesc.economy.factors or nil
local curve = ADPrices.curvePercent(factors, getCurrentPeriod())
local baseNow = station.fillTypePrices ~= nil and tonumber(station.fillTypePrices[fillType]) or nil
local stationRatio = (baseNow ~= nil and baseNow > 0) and (effective / baseNow) or 1
local percent = math.floor(curve * stationRatio + 0.5)
local percent = ADPrices.curvePercent(factors, getCurrentPeriod())
local top = percent > 0 and (effective * 100 / percent) or effective
return {price = effective, top = top, percent = percent}
end
+27
View File
@@ -568,10 +568,37 @@ local function findNearestLoadMarker(adEnv, vehicle, farmId)
return best
end
local function getSettingValue(adEnv, vehicle, settingName)
local global = adEnv.AutoDrive.settings[settingName]
if global == nil then
return nil
end
local setting = global
if global.isVehicleSpecific and vehicle.ad.settings ~= nil and vehicle.ad.settings[settingName] ~= nil then
setting = vehicle.ad.settings[settingName]
end
return setting.values ~= nil and setting.values[setting.current] or nil
end
-- AutoDrives "AL unload" (aflæsning af autoload-vogn ved målet) står som standard på FRA (0):
-- bilen ville holde ved salgsstedet uden at læsse af. "center" (1) løsner stropperne i triggeren,
-- så salgsstedet tager pallerne; left/behind/right lader UAL sætte pallerne af ved siden af.
-- Et valg brugeren selv har lavet, røres ikke.
ADRunsController.AL_UNLOAD_CENTER = 1
local function ensureAutoloadUnload(adEnv, vehicle)
if getSettingValue(adEnv, vehicle, "ALUnload") == 0 then
setSetting(adEnv, vehicle, "ALUnload", ADRunsController.AL_UNLOAD_CENTER)
Logging.info(ADRunsController.LOG_PREFIX .. "'%s': AutoDrives 'AL unload' var fra — sat til 'center' (stropper løsnes i triggeren)", tostring(vehicle:getName()))
end
end
-- Udkørsel: 1. og 2. markør = første kilde (pladsholder — kilde og mål vælges pr. tur af
-- ADOutbound), varevalg = run'ets varer vognen kan bære, rotation "kun pålæsning" (hook'en).
local function applyOutboundRunToVehicle(adEnv, run, vehicle)
local stateModule = vehicle.ad.stateModule
if hasAutoload(adEnv, vehicle) then
ensureAutoloadUnload(adEnv, vehicle)
end
stateModule:setMode(adEnv.AutoDrive.MODE_PICKUPANDDELIVER)
local firstId = run.sourceWayPointIds[1]
stateModule:setFirstMarkerByWayPointId(firstId)
+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.12.9.0</version>
<version>1.12.10.0</version>
<title>
<en>AD Smart Pickup</en>
</title>
+10 -8
View File
@@ -42,8 +42,8 @@ local station = {
}
local quote = ADPrices.getQuote(station, SUGAR)
check("P4 pris", quote.price, 470)
check("P4 top (pris ved 100 %)", math.floor(quote.top + 0.5), 627)
check("P4 procent", quote.percent, 75)
check("P4 top (pris ved 100 %)", math.floor(quote.top + 0.5), 588)
check("P4 procent = kurven alene (stationens grundpris bruges ikke: den mangler sværhedsgrad m.m.)", quote.percent, 80)
check("P4 er salgssted", ADPrices.isSellingStation(station), true)
check("P4 skjult = ikke salgssted", ADPrices.isSellingStation({isa = function() return true end, isSellingPoint = true, hideFromPricesMenu = true}), false)
check("P4 fabrik-station = ikke salgssted", ADPrices.isSellingStation({isa = function() return true end, isSellingPoint = false}), false)
@@ -59,12 +59,14 @@ check("P7 curvePercent ved top", ADPrices.curvePercent({1.0, 1.25, 0.9}, 2), 100
check("P7 flad kurve = 100", ADPrices.curvePercent({1.0, 1.01, 1.0}, 3), 100)
check("P7 ingen kurve = 100", ADPrices.curvePercent(nil, 1), 100)
check("P7 ukendt periode = 100", ADPrices.curvePercent({1.0, 1.25}, nil), 100)
-- P8: stor efterspørgsel ganger stationens egen faktor på: 500 grundpris, 700 effektiv, kurve 80 % -> 112
local demandStation = {fillTypePrices = {[SUGAR] = 500}, getEffectiveFillTypePrice = function() return 700 end}
check("P8 stor efterspørgsel > 100", ADPrices.getQuote(demandStation, SUGAR).percent, 112)
-- P9: sværhedsgraden påvirker ikke procenten (begge priser skaleres ens)
local hardStation = {fillTypePrices = {[SUGAR] = 250}, getEffectiveFillTypePrice = function() return 235 end}
check("P9 uafhængig af sværhedsgrad", ADPrices.getQuote(hardStation, SUGAR).percent, 75)
-- P8: in-game (23/9): effektiv 1602 mod fillTypePrices 505 gav 317 % — stationens grundpris indeholder
-- hverken sværhedsgrad eller prisskala, så forholdet er ubrugeligt. Procenten er kurven alene.
local demandStation = {fillTypePrices = {[SUGAR] = 505}, getEffectiveFillTypePrice = function() return 1602 end}
check("P8 procent uafhængig af stationens grundpris", ADPrices.getQuote(demandStation, SUGAR).percent, 80)
check("P8 top = pris ved 100 % af kurven", math.floor(ADPrices.getQuote(demandStation, SUGAR).top + 0.5), 2003)
-- P9: sværhedsgraden påvirker ikke procenten
local hardStation = {getEffectiveFillTypePrice = function() return 235 end}
check("P9 uafhængig af sværhedsgrad", ADPrices.getQuote(hardStation, SUGAR).percent, 80)
check("P5 fejlende station -> nil", ADPrices.getQuote({getEffectiveFillTypePrice = function() error("x") end}, SUGAR), nil)
-- P6: bedste tilbud = højeste procent, dernæst pris
+10 -1
View File
@@ -37,6 +37,7 @@ FS25_AutoDrive = {
settings = {
useFolders = {values = {false, true}, current = 1, isVehicleSpecific = false},
rotateTargets = {values = {1, 2, 3, 4}, current = 1, isVehicleSpecific = true},
ALUnload = {values = {0, 1, 2, 3, 4}, current = 1, isVehicleSpecific = true},
},
getAllVehicles = function() return vehicles end,
getAllUnits = function(vehicle) return vehicle.trailers end,
@@ -101,7 +102,7 @@ local function makeVehicle(uniqueId, name, carriable, capacity, x, z)
startAutoDrive = function(self) self.ad.stateModule.active = true; self.started = (self.started or 0) + 1 end,
getClosestWayPoint = function() return nil, 0 end,
stopAutoDrive = function(self) self.ad.stateModule.active = false; self.stopped = (self.stopped or 0) + 1 end,
ad = {stateModule = stateModule, settings = {rotateTargets = {values = {1, 2, 3, 4}, current = 1, new = 1, isVehicleSpecific = true}}},
ad = {stateModule = stateModule, settings = {rotateTargets = {values = {1, 2, 3, 4}, current = 1, new = 1, isVehicleSpecific = true}, ALUnload = {values = {0, 1, 2, 3, 4}, current = 1, new = 1, isVehicleSpecific = true}}},
}
nodePositions = nodePositions or {}
nodePositions[uniqueId] = {x = x or 0, z = z or 0}
@@ -522,6 +523,14 @@ check("Cout3 bulk-vogn: kun TMR", table.concat(bulkTractor.ad.stateModule.select
check("Cout3 UAL-vogn: kurve", table.concat(ualTractor.ad.stateModule.selectedFillTypes, ","), tostring(BASKET))
check("Cout3 rotation kun pålæsning", bulkTractor.ad.settings.rotateTargets.current, 2)
check("Cout3 startet", bulkTractor.started, 1)
-- AD's "AL unload" er slået FRA som standard (values[1] = 0): autoload-vognen ville aldrig læsse af
-- ved salgsstedet. Ved Start sættes den til "center" hvis den er fra; et brugervalg (left/right/behind) røres ikke.
check("Cout3 ALUnload sat til center for autoload-bil", ualTractor.ad.settings.ALUnload.current, 2)
check("Cout3 ALUnload rører ikke tipvogn", bulkTractor.ad.settings.ALUnload.current, 1)
ualTractor.ad.settings.ALUnload.current = 4
ualTractor.ad.stateModule.active = false
ADRunsController.startRun(adEnv, out.id)
check("Cout3 ALUnload brugervalg bevares", ualTractor.ad.settings.ALUnload.current, 4)
-- Cout4: produkter til fanen (politik slået op, sorteret på titel) og status
local list = ADRunsController.getRunProducts(adEnv, outRun)