Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
v05.03.00050 MR Turn Fix pt2
Browse files Browse the repository at this point in the history
Fixes turn manuver for MR on hills when not using the change angle function for direction change.
  • Loading branch information
pops64 committed Nov 13, 2018
1 parent 36eae5a commit 1b6d959
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="39">
<version>5.03.00049</version>
<version>5.03.00050</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay 5</br>
Expand Down
18 changes: 15 additions & 3 deletions turn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1b6d959

Please sign in to comment.