diff --git a/scripts/ai/jobs/CpAIJob.lua b/scripts/ai/jobs/CpAIJob.lua index 3a3654c07..acb9dbc81 100644 --- a/scripts/ai/jobs/CpAIJob.lua +++ b/scripts/ai/jobs/CpAIJob.lua @@ -94,37 +94,40 @@ function CpAIJob:start(farmId) end function CpAIJob:stop(aiMessage) - if self.isServer then - local vehicle = self.vehicleParameter:getVehicle() - vehicle:resetCpAllActiveInfoTexts() - local driveStrategy = vehicle:getCpDriveStrategy() - if not aiMessage then - self:debug("No valid ai message given!") - if driveStrategy then - driveStrategy:onFinished() - end - return - end - local releaseMessage, hasFinished, event, isOnlyShownOnPlayerStart = - g_infoTextManager:getInfoTextDataByAIMessage(aiMessage) - if releaseMessage then - self:debug("Stopped with release message %s", tostring(releaseMessage)) - end + if not self.isServer then + CpAIJob:superClass().stop(self, aiMessage) + return + end + local vehicle = self.vehicleParameter:getVehicle() + vehicle:deleteAgent() + vehicle:aiJobFinished() + vehicle:resetCpAllActiveInfoTexts() + local driveStrategy = vehicle:getCpDriveStrategy() + if not aiMessage then + self:debug("No valid ai message given!") if driveStrategy then - driveStrategy:onFinished(hasFinished) + driveStrategy:onFinished() end - if releaseMessage and not vehicle:getIsControlled() and not isOnlyShownOnPlayerStart then - --- Only shows the info text, if the vehicle is not entered. - --- TODO: Add check if passing to ad is active maybe? - vehicle:setCpInfoTextActive(releaseMessage) - end - if event then - SpecializationUtil.raiseEvent(vehicle, event) - end - vehicle:deleteAgent() - vehicle:aiJobFinished() + CpAIJob:superClass().stop(self, aiMessage) + return + end + local releaseMessage, hasFinished, event, isOnlyShownOnPlayerStart = + g_infoTextManager:getInfoTextDataByAIMessage(aiMessage) + if releaseMessage then + self:debug("Stopped with release message %s", tostring(releaseMessage)) + end + if releaseMessage and not vehicle:getIsControlled() and not isOnlyShownOnPlayerStart then + --- Only shows the info text, if the vehicle is not entered. + --- TODO: Add check if passing to ad is active maybe? + vehicle:setCpInfoTextActive(releaseMessage) end CpAIJob:superClass().stop(self, aiMessage) + if event then + SpecializationUtil.raiseEvent(vehicle, event) + end + if driveStrategy then + driveStrategy:onFinished(hasFinished) + end end --- Updates the parameter values.