Skip to content

Commit da3cd04

Browse files
committed
Merge remote-tracking branch 'upstream/main' into ChopperSupport
2 parents 5bfb3d8 + a6f56c0 commit da3cd04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1062
-236
lines changed

config/InfoTexts.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<InfoText name="ERROR_GROUND_UNLOAD_NOT_SUPPORTED" text="errorGroundUnloadNotSupported" class="AIMessageErrorGroundUnloadNotSupported"/>
2121
<InfoText name="ERROR_CUTTER_NOT_SUPPORTED" text="errorCutterNotSupported" class="AIMessageErrorCutterNotSupported"/>
2222
<InfoText name="ERROR_AUTOMATIC_CUTTER_ATTACH_DISABLED" text="errorAutomaticCutterAttachNotActive" class="AIMessageErrorAutomaticCutterAttachNotActive" isOnlyShownOnPlayerStart="true"/>
23+
<InfoText name="ERROR_WRONG_SEASON" text="errorWrongSeason" class="AIMessageErrorWrongSeason"/>
24+
<InfoText name="ERROR_WRONG_MISSION_FRUIT_TYPE" text="errorWrongMissionFruitType" class="AIMessageErrorWrongMissionFruitType"/>
2325

2426
<InfoText name="IS_STUCK" text="isStuck"/>
2527
<InfoText name="BLOCKED_BY_OBJECT" text="blockedByObject" class="AIMessageErrorBlockedByObject"/>

config/MasterTranslations.xml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@
385385
<Text language="de"><![CDATA[Helfer %s hat die Arbeit gestoppt - automatisches Scheidwerk ankuppeln deaktiviert!]]></Text>
386386
<Text language="en"><![CDATA[AI worker %s has stopped work unexpectedly - automatic cutter attach disabled!]]></Text>
387387
</Translation>
388+
<Translation name="CP_ai_messageErrorWrongMissionFruitType">
389+
<Text language="de"><![CDATA[Helfer %s hat die Arbeit gestoppt - falsche Frucht für die Mission ausgewählt!]]></Text>
390+
<Text language="en"><![CDATA[AI worker %s has stopped work unexpectedly - wrong fill type for mission selected!]]></Text>
391+
</Translation>
388392
</Category>
389393
<Category name="AI fieldwork task descriptions">
390394
<Translation name="CP_ai_taskDescriptionAttachHeader">
@@ -443,10 +447,6 @@
443447
</Translation>
444448
</Category>
445449
<Category name="AI silo loader task descriptions">
446-
<Translation name="CP_ai_taskDescriptionUnloadingToTrailer">
447-
<Text language="de"><![CDATA[Entlädt zu einem Anhänger]]></Text>
448-
<Text language="en"><![CDATA[Unloads to a trailer]]></Text>
449-
</Translation>
450450
<Translation name="CP_ai_taskDescriptionWaitsForTrailer">
451451
<Text language="de"><![CDATA[Wartet auf einen Anhänger]]></Text>
452452
<Text language="en"><![CDATA[Waits for a trailer]]></Text>
@@ -691,6 +691,14 @@
691691
<Text language="de"><![CDATA[Arbeitsbreite. Wert: 0 - 50]]></Text>
692692
<Text language="en"><![CDATA[Work width. Value: 0 - 50]]></Text>
693693
</Translation>
694+
<Translation name="CP_vehicle_setting_levelerHeightOffset_title">
695+
<Text language="de"><![CDATA[Versatz Schildhöhe]]></Text>
696+
<Text language="en"><![CDATA[Shield height offset]]></Text>
697+
</Translation>
698+
<Translation name="CP_vehicle_setting_levelerHeightOffset_tooltip">
699+
<Text language="de"><![CDATA[Höhenversatz vom Schild zum Boden. Wert: 0 - 1]]></Text>
700+
<Text language="en"><![CDATA[Offset of the shield form the ground. Value: 0 - 1]]></Text>
701+
</Translation>
694702
<Translation name="CP_vehicle_setting_loadingShovelHeightOffset_title">
695703
<Text language="de"><![CDATA[Versatz Schaufelhöhe.]]></Text>
696704
<Text language="en"><![CDATA[Shovel hight offset.]]></Text>
@@ -1614,6 +1622,14 @@ The course is saved automatically on closing of the editor and overrides the sel
16141622
<Text language="de"><![CDATA[Schneidwerk ankuppeln deaktiviert]]></Text>
16151623
<Text language="en"><![CDATA[Cutter attaching deactivated]]></Text>
16161624
</Translation>
1625+
<Translation name="CP_infoTexts_errorWrongSeason">
1626+
<Text language="de"><![CDATA[Falsche Jahreszeit]]></Text>
1627+
<Text language="en"><![CDATA[Wrong season for fruit]]></Text>
1628+
</Translation>
1629+
<Translation name="CP_infoTexts_errorWrongMissionFruitType">
1630+
<Text language="de"><![CDATA[Falsche Frucht für Mission ausgewählt]]></Text>
1631+
<Text language="en"><![CDATA[Wrong fruit for mission selected]]></Text>
1632+
</Translation>
16171633
</Category>
16181634
<Category name="Custom field manager">
16191635
<Translation name="CP_customFieldManager_confirm_save">

config/VehicleConfigurations.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,16 @@ You can define the following custom settings:
361361

362362
<Vehicle name="torion1914.xml"
363363
turnRadius = "12"
364+
/>
365+
<vehicle name="torion1511.xml"
366+
turnRadius = "9"
364367
/>
365368
<Vehicle name="wheelLoaderShovel.xml"
366369
shovelMovingToolIx = "1"
367370
/>
371+
<Vehicle name="overtippingBucket.xml"
372+
shovelMovingToolIx = "1"
373+
/>
368374

369375
<!--[DLC]-->
370376

@@ -549,4 +555,30 @@ You can define the following custom settings:
549555
disablePipeMovingToolCorrection = "true"
550556
unloadOffsetX = "-3.56"
551557
/>
558+
559+
<!--Mod: FS22_lizardHTB6000-->
560+
<Vehicle name="HTB6000.xml"
561+
shovelMovingToolIx = "1"
562+
/>
563+
564+
<!--Mod: FS22_Liebherr_Xpower-->
565+
<Vehicle name="highTipShovel.xml"
566+
shovelMovingToolIx = "1"
567+
/>
568+
569+
<!--Mod: FS22_bresselUndLadeHighTipShovelPack-->
570+
<Vehicle name="bresselUndLadeL67.xml"
571+
shovelMovingToolIx = "1"
572+
/>
573+
574+
<!--Mod: FS22_bresselUndLadeHighTipShovelPack-->
575+
<Vehicle name="bresselUndLadeL71.xml"
576+
shovelMovingToolIx = "1"
577+
/>
578+
579+
<!--Mod: FS22_bresselUndLadeHighTipShovelPack-->
580+
<Vehicle name="bresselUndLadeL71.xml"
581+
shovelMovingToolIx = "1"
582+
/>
583+
552584
</VehicleConfigurations>

config/VehicleSettingsSetup.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
<Setting classType="AIParameterSettingList" name="loadingShovelHeightOffset" min="-1" max="1" incremental="0.1" default="0" unit="2"
8080
isVisible="isLoadingShovelOffsetSettingVisible" isDisabled="isLoadingShovelOffsetSettingDisabled"
8181
onChangeCallback="onCpLoadingShovelOffsetSettingChanged" vehicleConfiguration="loadingShovelOffset"/>
82+
<Setting classType="AIParameterSettingList" name="levelerHeightOffset" min="0" max="0.5" incremental="0.05" default="0" unit="2" precision="3"
83+
isVisible="isLevelerHeightOffsetSettingVisible" isDisabled="isLevelerHeightOffsetSettingDisabled" />
8284
</SettingSubTitle>
8385

8486
<SettingSubTitle title="combine" isVisible="areCombineSettingsVisible">

modDesc.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
22
<modDesc descVersion="76">
3-
<version>7.3.1.2</version>
3+
<version>7.3.1.3</version>
44
<author>Pops64</author>
55
<title>
66
<en>CoursePlay - Chopper Support</en>
@@ -276,6 +276,7 @@ Changelog 7.1.0.0:
276276

277277
<sourceFile filename="scripts/ai/AIUtil.lua"/>
278278
<sourceFile filename="scripts/ai/ImplementUtil.lua"/>
279+
<sourceFile filename="scripts/ai/PathfinderController.lua"/>
279280
<sourceFile filename="scripts/ai/ProximityController.lua"/>
280281
<sourceFile filename="scripts/ai/FieldWorkerProximityController.lua"/>
281282
<sourceFile filename="scripts/ai/CollisionAvoidanceController.lua"/>

scripts/CpObject.lua

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,47 @@ function CpObject(base, init)
5959
end
6060
return false
6161
end
62+
c.__tostring = function (self)
63+
-- Default tostring function for printing all attributes and assigned functions.
64+
local str = '[ '
65+
for attribute, value in pairs(self) do
66+
str = str .. string.format('%s: %s ', attribute, value)
67+
end
68+
str = str .. ']'
69+
return str
70+
end
71+
6272
setmetatable(c, mt)
6373
return c
6474
end
6575

76+
---@class CpObjectUtil
77+
CpObjectUtil = {
78+
BUILDER_API_NIL = "nil"
79+
}
80+
81+
--- Registers a builder api for a class.
82+
--- The attributes are set as private variables with "_" before the variable name
83+
--- and the builder functions are named like the attribute.
84+
--- Nil values have to be replaced with CpObjectUtil.BUILDER_API_NIL !!
85+
---@param class table
86+
---@param attributesToDefault table<attributeName, any>
87+
function CpObjectUtil.registerBuilderAPI(class, attributesToDefault)
88+
for attributeName, default in pairs(attributesToDefault) do
89+
if default == CpObjectUtil.BUILDER_API_NIL then
90+
default = nil
91+
end
92+
--- Applies the default value to the private variable
93+
class["_" .. attributeName] = default
94+
--- Creates the builder functions/ setters with the public variable name
95+
class[attributeName] = function(self, value)
96+
self["_" .. attributeName] = value
97+
return self
98+
end
99+
end
100+
end
101+
102+
66103
--- Object that holds a value temporarily. You can tell when to set the value and how long it should keep that
67104
--- value, in milliseconds. Great for timers.
68105
---@class CpTemporaryObject

scripts/CpSettingsUtil.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ CpSettingsUtil = {}
3535
- isExpertModeOnly(bool): is the setting visible in the expert version?, default = false
3636
3737
- generateValuesFunction(string): dynamically adds value, when the setting is created.
38-
- min (int): min value
39-
- max (int): max value
38+
- min (float): min value
39+
- max (float): max value
4040
- incremental (float): increment (optional), default "1"
41+
- precision (float): optional rounding precision
4142
- text(string): string to format the setting value with in the gui element.
4243
- unit (int) : 1 == km/h, 2 == meters, 3 == ha (optional), 4 = percent (%), 5 = degrees (°)
4344
@@ -89,9 +90,10 @@ function CpSettingsUtil.init()
8990
schema:register(XMLValueType.BOOL, key.."#isExpertModeOnly", "Is enabled in simple mode?", false) -- optional
9091

9192
schema:register(XMLValueType.STRING, key .. "#generateValuesFunction", "Function to generate values.")
92-
schema:register(XMLValueType.INT, key.."#min", "Setting min value")
93-
schema:register(XMLValueType.INT, key.."#max", "Setting max value")
93+
schema:register(XMLValueType.FLOAT, key.."#min", "Setting min value")
94+
schema:register(XMLValueType.FLOAT, key.."#max", "Setting max value")
9495
schema:register(XMLValueType.FLOAT, key.."#incremental", "Setting incremental", 1) -- optional
96+
schema:register(XMLValueType.FLOAT, key.."#precision", "Setting precision", 2) -- optional
9597
schema:register(XMLValueType.STRING, key.."#text", "Setting text") -- optional
9698
schema:register(XMLValueType.INT, key .. "#unit", "Setting value unit (km/h, m ...)") --optional
9799

@@ -205,6 +207,7 @@ function CpSettingsUtil.loadSettingsFromSetup(class, filePath)
205207
settingParameters.min = xmlFile:getValue(baseKey.."#min")
206208
settingParameters.max = xmlFile:getValue(baseKey.."#max")
207209
settingParameters.incremental = MathUtil.round(xmlFile:getValue(baseKey.."#incremental"), 3)
210+
settingParameters.precision = xmlFile:getValue(baseKey.."#precision", 2)
208211
settingParameters.textStr = xmlFile:getValue(baseKey.."#text")
209212
settingParameters.unit = xmlFile:getValue(baseKey.."#unit")
210213

scripts/ai/AIDriveStrategyBunkerSilo.lua

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,11 @@ function AIDriveStrategyBunkerSilo.new(customMt)
4747
AIDriveStrategyCourse.initStates(self, AIDriveStrategyBunkerSilo.myStates)
4848
self.state = self.states.DRIVING_TO_SILO
4949

50-
-- course offsets dynamically set by the AI and added to all tool and other offsets
51-
self.aiOffsetX, self.aiOffsetZ = 0, 0
5250
self.debugChannel = CpDebug.DBG_SILO
53-
---@type ImplementController[]
54-
self.controllers = {}
5551
self.silo = nil
5652
self.siloController = nil
5753
self.drivingForwardsIntoSilo = true
5854
self.turnNode = CpUtil.createNode("turnNode", 0, 0, 0)
59-
6055

6156
self.isStuckTimer = Timer.new(self.isStuckMs)
6257
self.driveIntoSiloAttempts = 0
@@ -177,7 +172,7 @@ function AIDriveStrategyBunkerSilo:setAllStaticParameters()
177172
else
178173
self:startDrivingTemporaryOutOfSilo()
179174
end
180-
elseif self.siloController:hasNearbyUnloader() and self:isDrivingToParkPositionAllowed() then
175+
elseif self.state == self.states.DRIVING_INTO_SILO and self.siloController:hasNearbyUnloader() and self:isDrivingToParkPositionAllowed() then
181176
self:debug("Found an unloader nearby and is stuck, so immediately leave the silo.")
182177
self:startDrivingOutOfSilo()
183178
end
@@ -292,15 +287,11 @@ end
292287
function AIDriveStrategyBunkerSilo:update(dt)
293288
AIDriveStrategyBunkerSilo:superClass().update(self, dt)
294289
self:updateImplementControllers(dt)
295-
296290
if CpDebug:isChannelActive(self.debugChannel, self.vehicle) then
297-
if self.course then
298-
-- TODO_22 check user setting
299-
if self.course:isTemporary() then
300-
self.course:draw()
301-
elseif self.ppc:getCourse():isTemporary() then
302-
self.ppc:getCourse():draw()
303-
end
291+
if self.course and self.course:isTemporary() then
292+
self.course:draw()
293+
elseif self.ppc:getCourse():isTemporary() then
294+
self.ppc:getCourse():draw()
304295
end
305296
if self.siloEndDetectionMarker ~= nil then
306297
DebugUtil.drawDebugNode(self.siloEndDetectionMarker, "siloEndDetectionMarker", false, 1)

scripts/ai/AIDriveStrategyCourse.lua

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ function AIDriveStrategyCourse:setAIVehicle(vehicle, jobParameters)
111111
self:initializeImplementControllers(vehicle)
112112
self.ppc = PurePursuitController(vehicle)
113113
self.ppc:registerListeners(self, 'onWaypointPassed', 'onWaypointChange')
114+
115+
self.pathfinderController = PathfinderController(vehicle)
116+
self.pathfinderController:registerListeners(self, self.onPathfindingFinished, self.onPathfindingRetry)
117+
114118
self.storage = vehicle.spec_cpAIWorker
115119

116120
self.settings = vehicle:getCpSettings()
@@ -428,8 +432,9 @@ function AIDriveStrategyCourse:getCurrentCourse()
428432
return self.ppc:getCourse() or self.course
429433
end
430434

431-
function AIDriveStrategyCourse:update()
435+
function AIDriveStrategyCourse:update(dt)
432436
self.ppc:update()
437+
self.pathfinderController:update(dt)
433438
self:updatePathfinding()
434439
self:updateInfoTexts()
435440
end
@@ -579,6 +584,24 @@ end
579584
function AIDriveStrategyCourse:onWaypointPassed(ix, course)
580585
end
581586

587+
--- Pathfinding has finished
588+
---@param controller PathfinderController
589+
---@param success boolean
590+
---@param course Course|nil
591+
---@param goalNodeInvalid boolean|nil
592+
function AIDriveStrategyCourse:onPathfindingFinished(controller, success, course, goalNodeInvalid)
593+
-- override
594+
end
595+
596+
--- Pathfinding failed, but a retry attempt is leftover.
597+
---@param controller PathfinderController
598+
---@param lastContext PathfinderControllerContext
599+
---@param wasLastRetry boolean
600+
---@param currentRetryAttempt number
601+
function AIDriveStrategyCourse:onPathfindingRetry(controller, lastContext, wasLastRetry, currentRetryAttempt)
602+
-- override
603+
end
604+
582605
------------------------------------------------------------------------------------------------------------------------
583606
--- Pathfinding
584607
---------------------------------------------------------------------------------------------------------------------------

scripts/ai/AIDriveStrategyDriveToFieldWorkStart.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function AIDriveStrategyDriveToFieldWorkStart:start(course, startIx, jobParamete
8484
nVehicles > 1 and jobParameters.laneOffset:getValue() or 0,
8585
course:getWorkWidth() / nVehicles)
8686
local implement = AIUtil.getImplementWithSpecialization(self.vehicle, Cutter)
87-
if self:giantsPreFoldHeaderWithWheelsFix(implement) then
87+
if self.settings.foldImplementAtEnd:getValue() then
8888
self.vehicle:prepareForAIDriving()
89+
end
90+
if self:giantsPreFoldHeaderWithWheelsFix(implement) then
8991
self:giantsPostFoldHeaderWithWheelsFix(implement)
90-
else
91-
self.vehicle:prepareForAIDriving()
9292
end
9393
self:startCourseWithPathfinding(course, startIx)
9494
end
@@ -130,7 +130,7 @@ function AIDriveStrategyDriveToFieldWorkStart:getDriveData(dt, vX, vY, vZ)
130130
elseif self.state == self.states.PREPARE_TO_DRIVE then
131131
self:setMaxSpeed(0)
132132
local isReadyToDrive, blockingVehicle = self.vehicle:getIsAIReadyToDrive()
133-
if isReadyToDrive then
133+
if isReadyToDrive or not self.settings.foldImplementAtEnd:getValue() then
134134
self.state = self.states.DRIVING_TO_WORK_START
135135
self:debug('Ready to drive to work start')
136136
else

0 commit comments

Comments
 (0)