fix: AD der hænger ved markmarkøren stoppes, så marken går i gang (1.62.221)
In-game F36: AutoDrive stod stille ét vejpunkt før markmarkøren (461/462) og blev ved med at være aktiv; moden ventede på at AD stoppede, så Courseplay blev aldrig startet. Stille 15 s ved et af de sidste to vejpunkter inden for 30 m af markøren = fremme. Review: ikke mens den læsser ved et påfyldningssted tæt på marken; stillSince nulstilles ved spillerpause.
This commit is contained in:
@@ -2122,7 +2122,8 @@ function ADFieldWork.follow(adEnv, assignment)
|
||||
elseif assignment.phase == "driving" then
|
||||
local px, pz = vehiclePosition(vehicle)
|
||||
local target = info ~= nil and adEnv.ADGraphManager:getWayPointById(info.markerId) or nil
|
||||
local arrived = target ~= nil and math.sqrt((target.x - px) ^ 2 + (target.z - pz) ^ 2) <= ADFieldWork.ARRIVE_DISTANCE
|
||||
local targetDistance = target ~= nil and math.sqrt((target.x - px) ^ 2 + (target.z - pz) ^ 2) or math.huge
|
||||
local arrived = targetDistance <= ADFieldWork.ARRIVE_DISTANCE
|
||||
local stateModule = vehicle.ad ~= nil and vehicle.ad.stateModule or nil
|
||||
local firstMarker = stateModule ~= nil and stateModule.getFirstMarker ~= nil and stateModule:getFirstMarker() or nil
|
||||
local otherTarget = assignment.drive ~= nil and firstMarker ~= nil and firstMarker.id ~= nil and firstMarker.id ~= assignment.drive.first
|
||||
@@ -2135,20 +2136,50 @@ function ADFieldWork.follow(adEnv, assignment)
|
||||
return ADFieldWork.release(assignment)
|
||||
elseif pause == "wait" then
|
||||
-- spilleren har slået AD fra og kører den fri af en anden: vent på ham (in-game 11/10)
|
||||
assignment.playerPaused, assignment.since = true, now()
|
||||
assignment.playerPaused, assignment.since, assignment.stillSince = true, now(), nil
|
||||
return
|
||||
elseif pause == "clear" then
|
||||
assignment.playerPaused = nil
|
||||
elseif pause == "resume" and assignment.drive == nil then
|
||||
assignment.playerPaused = nil
|
||||
elseif pause == "resume" then
|
||||
assignment.playerPaused, assignment.since = nil, now()
|
||||
assignment.playerPaused, assignment.since, assignment.stillSince = nil, now(), nil
|
||||
assignment.startX, assignment.startZ = vehiclePosition(vehicle)
|
||||
local d = assignment.drive
|
||||
startAd(adEnv, vehicle, d.mode, d.first, d.second, d.fillType)
|
||||
log(assignment.fieldId, "'%s': spilleren steg af — kører videre til %s", ADRuns.vehicleLabel(vehicle), tostring(info ~= nil and info.markerName or "?"))
|
||||
return
|
||||
end
|
||||
-- AD hænger ved markmarkøren (aktiv, stille ved et af de sidste vejpunkter): stop den, så marken går i gang
|
||||
if isAdActive(vehicle) then
|
||||
local speed = vehicle.getLastSpeed ~= nil and vehicle:getLastSpeed() or 0
|
||||
local wpLeft = nil
|
||||
local dpm = vehicle.ad ~= nil and vehicle.ad.drivePathModule or nil
|
||||
if dpm ~= nil and dpm.getWayPoints ~= nil then
|
||||
local okWp, wayPoints, current = pcall(dpm.getWayPoints, dpm)
|
||||
if okWp and type(wayPoints) == "table" and type(current) == "number" then wpLeft = #wayPoints - current end
|
||||
end
|
||||
if speed > ADFieldJobs.STALL_SPEED then
|
||||
assignment.stillSince = nil
|
||||
elseif assignment.stillSince == nil then
|
||||
assignment.stillSince = now()
|
||||
end
|
||||
local stillMs = assignment.stillSince ~= nil and now() - assignment.stillSince or 0
|
||||
-- påfyldning tæt på marken (LOAD): står den ved påfyldningsstedet, læsser den — det er ikke at hænge
|
||||
local refillPoint = assignment.drive ~= nil and assignment.drive.second ~= nil and adEnv.ADGraphManager:getWayPointById(assignment.drive.second) or nil
|
||||
if refillPoint ~= nil and math.sqrt((refillPoint.x - px) ^ 2 + (refillPoint.z - pz) ^ 2) <= ADFieldJobs.STALL_ARRIVE_M then
|
||||
stillMs = 0
|
||||
end
|
||||
if ADFieldJobs.stalledAtTarget({adActive = true, speed = speed, wpLeft = wpLeft, distance = targetDistance, stillMs = stillMs}) then
|
||||
log(assignment.fieldId, "'%s' holdt stille %.0f s ved %s (%.0f m, %s vejpunkt(er) tilbage) — AutoDrive stoppes, arbejdet starter",
|
||||
ADRuns.vehicleLabel(vehicle), stillMs / 1000, tostring(info ~= nil and info.markerName or "?"), targetDistance, tostring(wpLeft))
|
||||
assignment.stillSince = nil
|
||||
stopAd(vehicle)
|
||||
assignment.since = now() - 2001
|
||||
end
|
||||
return
|
||||
end
|
||||
assignment.stillSince = nil
|
||||
if not isAdActive(vehicle) and now() - assignment.since > 2000 then
|
||||
local x, z = vehiclePosition(vehicle)
|
||||
local wayPoint = info ~= nil and adEnv.ADGraphManager:getWayPointById(info.markerId) or nil
|
||||
|
||||
Reference in New Issue
Block a user