Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/ai/strategies/AIDriveStrategyUnloadCombine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,16 @@ function AIDriveStrategyUnloadCombine:onBlockingVehicle(blockingVehicle, isBack)
-- with an offset from the combine that makes sure we are clear. Use the trailer's root node (and not
-- the tractor's) as when we reversing, it is easier when the trailer remains on the same side of the combine
local dx, _, _ = localToLocal(referenceObject.rootNode, blockingVehicle:getAIDirectionNode(), 0, 0, 0)
local xOffset = self.vehicle.size.width / 2 + blockingVehicle:getCpDriveStrategy():getWorkWidth() / 2 + 2
-- articulated harvesters can stand bent, with the rear part sticking out sideways from
-- the direction node - make sure the offset also clears the widest component, not just
-- the work width around the front part
local maxComponentOffset = 0
for _, component in pairs(blockingVehicle.components) do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the existing VehicleSizeScanner here?

local cdx, _, _ = localToLocal(component.node, blockingVehicle:getAIDirectionNode(), 0, 0, 0)
maxComponentOffset = math.max(maxComponentOffset, math.abs(cdx) + blockingVehicle.size.width / 2)
end
local xOffset = self.vehicle.size.width / 2 +
math.max(blockingVehicle:getCpDriveStrategy():getWorkWidth() / 2, maxComponentOffset) + 2
xOffset = dx > 0 and xOffset or -xOffset
self:setNewState(self.states.MOVING_AWAY_FROM_OTHER_VEHICLE)
self.state.properties.vehicle = blockingVehicle
Expand Down