Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Changelog 8.1.0.3
<sourceFile filename="scripts/ai/controllers/CombineController.lua"/>
<sourceFile filename="scripts/ai/controllers/MotorController.lua"/>
<sourceFile filename="scripts/ai/controllers/VineCutterController.lua"/>
<sourceFile filename="scripts/ai/controllers/VineyardToolController.lua"/>
<sourceFile filename="scripts/ai/controllers/WearableController.lua"/>
<sourceFile filename="scripts/ai/controllers/SoilSamplerController.lua"/>
<sourceFile filename="scripts/ai/controllers/TrailerController.lua"/>
Expand Down
15 changes: 15 additions & 0 deletions scripts/ai/controllers/VineyardToolController.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- Lowers and raises vineyard tools without AI markers.
--- These are not in the AI implement list of giants, so lowering all implements
--- at the start of the work would not turn them on.
---@class VineyardToolController : ImplementController
VineyardToolController = CpObject(ImplementController)

function VineyardToolController:onLowering()
self:debug('Lowering vineyard tool without AI markers')
self.implement:aiImplementStartLine()
end

function VineyardToolController:onRaising()
self:debug('Raising vineyard tool without AI markers')
self.implement:aiImplementEndLine()
end
3 changes: 3 additions & 0 deletions scripts/ai/strategies/AIDriveStrategyFieldWorkCourse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ function AIDriveStrategyFieldWorkCourse:initializeImplementControllers(vehicle)
self:addImplementController(vehicle, SoilSamplerController, nil, defaultDisabledStates, CpUtil.getSoilSamplerSpecName())
self:addImplementController(vehicle, StumpCutterController, StumpCutter, defaultDisabledStates)
self:addImplementController(vehicle, TreePlanterController, TreePlanter, {})
for _, tool in ipairs(AIUtil.getVineyardToolsWithoutAIMarkers(vehicle)) do
self:appendImplementController(VineyardToolController(vehicle, tool), {})
end

end

Expand Down
31 changes: 31 additions & 0 deletions scripts/ai/util/AIUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,37 @@ function AIUtil.hasValidUniversalTrailerAttached(vehicle)
return spec.isAutoloadAvailable and not spec.autoloadDisabled
end

--- Is this a vineyard tool with work areas?
--- Giants leaves out the AI markers on some of them, for example on the row spreading
--- configuration of the Kuhn Accura 1200, as the built in helper can't work in vineyards.
function AIUtil.isVineyardTool(object)
if object.getAIIsVineyardTool and object:getAIIsVineyardTool() and WorkWidthUtil.hasWorkAreas(object) then
return true
end
return false
end

--- Checks if a vineyard tool with work areas is attached.
function AIUtil.hasVineyardToolAttached(vehicle)
for _, childVehicle in pairs(vehicle:getChildVehicles()) do
if AIUtil.isVineyardTool(childVehicle) then
return true
end
end
return false
end

--- Gets all vineyard tools, that are not in the AI implement list of giants, as they have no AI markers.
function AIUtil.getVineyardToolsWithoutAIMarkers(vehicle)
local tools = {}
for _, childVehicle in pairs(vehicle:getChildVehicles()) do
if AIUtil.isVineyardTool(childVehicle) and not childVehicle:getCanImplementBeUsedForAI() then
table.insert(tools, childVehicle)
end
end
return tools
end

--- Checks if cutter on an trailer is attached.
function AIUtil.hasCutterOnTrailerAttached(vehicle)
local trailer = AIUtil.getImplementWithSpecialization(vehicle, DynamicMountAttacher)
Expand Down
2 changes: 2 additions & 0 deletions scripts/specializations/CpAIFieldWorker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ function CpAIFieldWorker:getCanStartCpFieldWork()
AIUtil.hasImplementWithSpecialization(self, Cutter) or
AIUtil.hasChildVehicleWithSpecialization(self, VineCutter) or
AIUtil.hasChildVehicleWithSpecialization(self, VinePrepruner) or
--- Vineyard tools may come without AI markers, the giants fieldworker can't use them anyway.
AIUtil.hasVineyardToolAttached(self) or
--- This also allows the use of stump cutters, that work like a mulcher.
AIUtil.hasChildVehicleWithSpecialization(self, Plow) or
--- A few mowers can't be used by the giants fieldworker
Expand Down