Skip to content
Merged
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
18 changes: 9 additions & 9 deletions scripts/ai/tasks/CpAITaskFieldWork.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ function CpAITaskFieldWork:start()
self:debug("Field work task started.")
local spec = self.vehicle.spec_aiFieldWorker
spec.isActive = true
self.vehicle:raiseAIEvent("onAIFieldWorkerStart", "onAIImplementStart")
if self.isServer then
self.vehicle:updateAIFieldWorkerImplementData()
if self.vehicle:getAINeedsTrafficCollisionBox() and (AIFieldWorker.TRAFFIC_COLLISION ~= nil and
if self.vehicle:getAINeedsTrafficCollisionBox() and (AIFieldWorker.TRAFFIC_COLLISION ~= nil and
(AIFieldWorker.TRAFFIC_COLLISION ~= 0 and spec.aiTrafficCollision == nil)) then

spec.aiTrafficCollision = clone(AIFieldWorker.TRAFFIC_COLLISION, true, false, true)
Expand All @@ -84,23 +83,23 @@ function CpAITaskFieldWork:start()
spec.driveStrategies = {}
end
local cpDriveStrategy
if self.startPosition and g_vineScanner:hasVineNodesCloseBy(self.startPosition.x, self.startPosition.z) then
if self.startPosition and g_vineScanner:hasVineNodesCloseBy(self.startPosition.x, self.startPosition.z) then
--- Checks if there are any vine nodes close to the starting point.
self:debug('Found a vine course, install CP vine fieldwork drive strategy for it')
cpDriveStrategy = AIDriveStrategyVineFieldWorkCourse(self, self.job)
elseif AIUtil.hasChildVehicleWithSpecialization(self.vehicle, Plow) then
self:debug('Found a plow, install CP plow drive strategy for it')
cpDriveStrategy = AIDriveStrategyPlowCourse(self, self.job)
else
local combine = AIUtil.getImplementOrVehicleWithSpecialization(self.vehicle, Combine)
local combine = AIUtil.getImplementOrVehicleWithSpecialization(self.vehicle, Combine)
local pipe = combine and SpecializationUtil.hasSpecialization(Pipe, combine.specializations)
if combine and pipe then
if combine and pipe then
-- Default harvesters with a pipe.
self:debug('Found a combine with pipe, install CP combine drive strategy for it')
cpDriveStrategy = AIDriveStrategyCombineCourse(self, self.job)
cpSpec.combineDriveStrategy = cpDriveStrategy
end
if not cpDriveStrategy then
if not cpDriveStrategy then
self:debug('Installing default CP fieldwork drive strategy')
cpDriveStrategy = AIDriveStrategyFieldWorkCourse(self, self.job)
end
Expand All @@ -110,19 +109,20 @@ function CpAITaskFieldWork:start()
--- Only the last driving strategy can stop the helper, while it is running.
table.insert(spec.driveStrategies, cpDriveStrategy)
end
self.vehicle:raiseAIEvent("onAIFieldWorkerStart", "onAIImplementStart")
CpAITask.start(self)
end

function CpAITaskFieldWork:stop(wasJobStopped)
if self.waitingForRefillingActive then
if self.waitingForRefillingActive then
local cpSpec = self.vehicle.spec_cpAIFieldWorker
cpSpec.driveStrategy:raiseControllerEvent(
AIDriveStrategyCourse.onStopRefillingEvent)
end
if self.isServer then
if self.isServer then
self:debug("Field work task stopped.")
self.vehicle:stopFieldWorker()
self.vehicle:cpBrakeToStop()
end
CpAITask.stop(self, wasJobStopped)
end
end
Loading