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

Commit

Permalink
6.01.00153: fixed reaching loading point
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasGaertner committed Mar 27, 2019
1 parent 92f43c3 commit 5682970
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
5 changes: 2 additions & 3 deletions AIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,9 @@ function AIDriver:getRecordedSpeed()
return speed
end

-- TODO: review this whole fillpoint/filltrigger mess.
-- TODO: review this whole fillpoint/filltrigger thing.
function AIDriver:isNearFillPoint()
-- TODO: like above, we may have some better indication of this
return self.ppc:getCurrentWaypointIx() >= 1 and self.ppc:getCurrentWaypointIx() <= 3 or self.vehicle.cp.tipperLoadMode > 0
return self.course:havePhysicallyPassedWaypoint(self.vehicle.cp.DirectionNode,#self.course.waypoints) and self.ppc:getCurrentWaypointIx() <= 3;
end

function AIDriver:getIsInFilltrigger()
Expand Down
5 changes: 5 additions & 0 deletions Waypoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,11 @@ function Course:getWaypointLocalPosition(node, ix)
return dx, dz
end

function Course:havePhysicallyPassedWaypoint(node, ix)
local _, dz = self:getWaypointLocalPosition(node, ix)
return dz < 0;
end

function Course:getWaypointAngleDeg(ix)
return self.waypoints[math.min(#self.waypoints, ix)].angle
end
Expand Down
10 changes: 8 additions & 2 deletions helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ function courseplay:fillTypesMatch(vehicle, fillTrigger, workTool,onlyCheckThisF
end
end
if matchInThisUnit and selectedFillTypeIsNotInMyFillUnit then
courseplay.debugVehicle(19,vehicle,'fillTypesMatch(324): return true')
return true;
end
end
Expand All @@ -331,14 +332,19 @@ function courseplay:fillTypesMatch(vehicle, fillTrigger, workTool,onlyCheckThisF
else
courseplay.debugVehicle(19,vehicle,'fillTypesMatch: selectedFillType:%d',selectedFillType)
if fillTrigger.source then
return fillTrigger.source.providedFillTypes[selectedFillType] or false;
local result = fillTrigger.source.providedFillTypes[selectedFillType] or false;
courseplay.debugVehicle(19,vehicle,'fillTypesMatch(337): return %s',tostring(result))
return result;
elseif fillTrigger.sourceObject ~= nil then
local fillType = fillTrigger.sourceObject:getFillUnitFillType(1)
return fillType == selectedFillType;
local result = fillType == selectedFillType;
courseplay.debugVehicle(19,vehicle,'fillTypesMatch(342): return %s',tostring(result))
return result;
end
end
end
end
courseplay.debugVehicle(19,vehicle,'fillTypesMatch(348): return false')
return false;
end;

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="40">
<version>6.01.00152</version>
<version>6.01.00153</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay SIX</br>
Expand Down
9 changes: 1 addition & 8 deletions toolManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ function courseplay:load_tippers(vehicle, allowedToDrive)

if (vehicle.cp.tipperLoadMode == 0 or vehicle.cp.tipperLoadMode == 3) and not driveOn then
--if vehicle.cp.ppc:haveJustPassedWaypoint(1) and currentTrailer.cp.currentSiloTrigger == nil then --vehicle.cp.ppc:haveJustPassedWaypoint(1) doesn't work here
if courseplay:havePhysicallyPassedWaypoint(vehicle,1) and currentTrailer.cp.currentSiloTrigger == nil then
if vehicle.cp.driver.course:havePhysicallyPassedWaypoint(vehicle.cp.DirectionNode, 1) and currentTrailer.cp.currentSiloTrigger == nil then
--- We must be on an loading point at a field so we stop under wp1 and wait for trailer to be filled up
vehicle.cp.tipperLoadMode = 2;
elseif currentTrailer.cp.currentSiloTrigger then
Expand Down Expand Up @@ -1892,10 +1892,3 @@ function courseplay:getAIMarkerWidth(object, logPrefix)
end
end
end

function courseplay:havePhysicallyPassedWaypoint(vehicle,index)
local cx, cz = vehicle.Waypoints[index].cx, vehicle.Waypoints[index].cz; --TODO Tommi convert this to the ppc, course, waypoint, no idea stuff
local _,dy,_ = getWorldTranslation(vehicle.cp.DirectionNode);
local _,_,tz = worldToLocal(vehicle.cp.DirectionNode,cx,dy,cz)
return tz < 0
end
1 change: 1 addition & 0 deletions triggers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ end;
-- Adding easy access to SiloTrigger
--------------------------------------------------
local SiloTrigger_TriggerCallback = function(self, triggerId, otherActorId, onEnter, onLeave, onStay, otherShapeId)
courseplay:debug(' SiloTrigger_TriggerCallback',2);
local trailer = g_currentMission.nodeToObject[otherShapeId];
if trailer ~= nil then
-- Make sure cp table is present in the trailer.
Expand Down

0 comments on commit 5682970

Please sign in to comment.