fix: kobling regnes som fremme når AD hænger ved sidste waypoint tæt på Connect (v1.62.13)
This commit is contained in:
@@ -30,6 +30,7 @@ ADHitch.TICK_MS = 250
|
||||
ADHitch.ROUTE_WAIT_MS = 10000 -- pause ved almindelige markører midt i en tur
|
||||
ADHitch.ROOMY_ATTACH_DISTANCE = 3 -- m: koblingsrækkevidde når spillets egen ikke rækker
|
||||
ADHitch.CREPT_EXTRA_DISTANCE = 8 -- m: ekstra ankomstafstand når traktoren har bakket hen til vognen
|
||||
ADHitch.STUCK_ARRIVE_MS = 4000 -- AD holder stille ved sidste waypoint tæt på markøren så længe -> fremme
|
||||
|
||||
-- ---- ren logik ----
|
||||
|
||||
@@ -136,6 +137,16 @@ function ADHitch.step(job, state, dt, succeeded)
|
||||
job.elapsed = job.elapsed + dt
|
||||
if state.adActive then
|
||||
job.seenActive = true
|
||||
-- AD bliver aldrig færdig når krogen rammer trækøjet før traktorens midte når markøren (in-game 4/10):
|
||||
-- stille ved sidste waypoint inden for ankomstafstanden et stykke tid = fremme; adapteren stopper AD
|
||||
if state.atLastWaypoint and state.speed <= ADHitch.STILL_SPEED and state.distance <= arriveDistanceOf(state) then
|
||||
job.stuckMs = (job.stuckMs or 0) + dt
|
||||
if job.stuckMs >= ADHitch.STUCK_ARRIVE_MS then
|
||||
job.state, job.stopAd = "acting", true
|
||||
end
|
||||
else
|
||||
job.stuckMs = 0
|
||||
end
|
||||
elseif ADHitch.hasArrived(state) then
|
||||
job.state = "acting"
|
||||
elseif state.distance > arriveDistanceOf(state) and (job.seenActive or job.elapsed >= ADHitch.START_GRACE_MS) then
|
||||
@@ -196,8 +207,15 @@ local function vehicleState(adEnv, vehicle, markerId)
|
||||
distance = math.min(distance, math.sqrt((x - wayPoint.x) ^ 2 + (z - wayPoint.z) ^ 2))
|
||||
end
|
||||
end
|
||||
local atLastWaypoint = false
|
||||
local dpm = vehicle.ad ~= nil and vehicle.ad.drivePathModule or nil
|
||||
if dpm ~= nil and dpm.getWayPoints ~= nil then
|
||||
local ok, wayPoints, current = pcall(dpm.getWayPoints, dpm)
|
||||
atLastWaypoint = ok and type(wayPoints) == "table" and type(current) == "number" and #wayPoints > 0 and current >= #wayPoints
|
||||
end
|
||||
return {
|
||||
adActive = module ~= nil and module:isActive(),
|
||||
atLastWaypoint = atLastWaypoint,
|
||||
distance = distance,
|
||||
speed = vehicle.getLastSpeed ~= nil and vehicle:getLastSpeed() or 0,
|
||||
}
|
||||
@@ -536,6 +554,11 @@ function ADHitch.tick(adEnv, dt)
|
||||
local state = vehicleState(adEnv, vehicle, job.markerId)
|
||||
state.arriveDistance = ADHitch.arriveDistanceFor(job.action, job.crept)
|
||||
ADHitch.step(job, state, elapsed, succeeded)
|
||||
if job.stopAd then
|
||||
job.stopAd = nil
|
||||
if vehicle.stopAutoDrive ~= nil then pcall(vehicle.stopAutoDrive, vehicle) end
|
||||
Logging.info(ADHitch.LOG_PREFIX .. "'%s' holdt stille ved sidste waypoint %.1f m fra '%s' — AutoDrive stoppet, kobler", vehicleName(vehicle), state.distance, tostring(job.markerName))
|
||||
end
|
||||
if job.state == "done" then
|
||||
finish(vehicle, job, true, detail, adEnv)
|
||||
elseif job.state == "failed" then
|
||||
|
||||
Reference in New Issue
Block a user