From 1b6d9598a56ae650cf85837ccda1b5d6dca2c2a5 Mon Sep 17 00:00:00 2001 From: pops64 Date: Tue, 13 Nov 2018 17:23:10 -0500 Subject: [PATCH] v05.03.00050 MR Turn Fix pt2 Fixes turn manuver for MR on hills when not using the change angle function for direction change. --- base.lua | 1 + modDesc.xml | 2 +- turn.lua | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/base.lua b/base.lua index c1ea9e96c..2138c9926 100644 --- a/base.lua +++ b/base.lua @@ -51,6 +51,7 @@ function courseplay:load(savegame) -- --More Realistlitic Mod and Mass Type adjustment self.cp.useProgessiveBraking = g_modIsLoaded["FS17_fillTypeMassAdjustment_realistic"] or g_modIsLoaded["FS17_moreRealisticGameplay"] self.cp.mrAccelrator = nil -- Used when MR needs assitance breaking, Mode2 field driving, Turn Driving, Pathfinding Driving, Drive Driving + self.cp.mrHasStopped = nil -- Used in the turn manuver to stop MR on a steep grade -- Mode4/6 Pathfinding TODO Move this to its proper place self.cp.isNavigatingPathfinding = false diff --git a/modDesc.xml b/modDesc.xml index e5b0d1511..a504a63da 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,6 +1,6 @@ - 5.03.00049 + 5.03.00050 <br>CoursePlay 5</br> diff --git a/turn.lua b/turn.lua index b3269e8cf..73f1b8a78 100644 --- a/turn.lua +++ b/turn.lua @@ -464,7 +464,21 @@ function courseplay:turn(vehicle, dt) courseplay:debug( string.format( "%s:(Turn) lowering implement at turn waypoint %d", nameNum(vehicle), vehicle.cp.curTurnIndex ), 14 ) courseplay:lowerImplements( vehicle, true, true ) end - vehicle.cp.curTurnIndex = min(vehicle.cp.curTurnIndex + 1, #vehicle.cp.turnTargets); + local nextCurTurnIndex = min(vehicle.cp.curTurnIndex + 1, #vehicle.cp.turnTargets); + local changeDir = ((newTarget.turnReverse and not vehicle.cp.turnTargets[nextCurTurnIndex].turnReverse) or (not newTarget.turnReverse and vehicle.cp.turnTargets[nextCurTurnIndex].turnReverse)) + -- We are still moving and want to swicth directions STOP if using MR mod. And we haven't yet stoped + if math.abs(vehicle.lastSpeedReal) > 0.0001 and vehicle.mrIsMrVehicle and changeDir and not vehicle.cp.mrHasStopped then + allowedToDrive = false + -- We have finally stoped on direction. Set a flag to allow movement again + elseif math.abs(vehicle.lastSpeedReal) < 0.0001 and vehicle.mrIsMrVehicle and changeDir then + vehicle.cp.mrHasStopped = true; + else + -- We are now 1 index away from the direction clear the flag + if vehicle.cp.mrHasStopped then + vehicle.cp.mrHasStopped = nil + end; + vehicle.cp.curTurnIndex = nextCurTurnIndex; + end end; @@ -493,7 +507,6 @@ function courseplay:turn(vehicle, dt) if angleDifference then courseplay:debug(("%s:(Turn) Change direction when anglediff(%.2f) <= %.2f"):format(nameNum(vehicle), angleDifference, allowedAngle), 14); if angleDifference <= allowedAngle then - local changeToForward = newTarget.turnReverse; if math.abs(vehicle.lastSpeedReal) > 0.0001 and vehicle.mrIsMrVehicle then allowedToDrive = false -- This is to ensure MR brakes before changing directions to prevent runaway tractors on steep grades else @@ -747,7 +760,6 @@ function courseplay:turn(vehicle, dt) directionForce = -vehicle.cp.mrAccelrator -- The progressive breaking function returns a postive number which accelerates the tractor end end - --vehicle,dt,steeringAngleLimit,acceleration,slowAcceleration,slowAngleLimit,allowedToDrive,moveForwards,lx,lz,maxSpeed,slowDownFactor,angle if newTarget and ((newTarget.turnReverse and reversingWorkTool ~= nil) or (courseplay:onAlignmentCourse( vehicle ) and vehicle.cp.curTurnIndex < 2 )) then if math.abs(vehicle.lastSpeedReal) < 0.0001 and not g_currentMission.missionInfo.stopAndGoBraking then