Skip to content

Commit

Permalink
Release 2.0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Iwan1803 authored Dec 23, 2021
2 parents 664b8d4 + f655cc0 commit 1589c0f
Show file tree
Hide file tree
Showing 30 changed files with 458 additions and 65 deletions.
11 changes: 2 additions & 9 deletions modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,20 @@
<description>
<en>
<![CDATA[This mod can be used to create a network of routes for vehicles to drive autonomously. Once setup you can tell a tractor which is standing anywhere close to the network to drive to any point, such as the shop, field 1 or to a sell point.
Changelog 2.0.0.0:
]]>
</en>
<de>
<![CDATA[Dieser Mod erlaubt es ein Netzwerk von Routen aufzuzeichnen, um dann ein Fahrzeug von jedem beliebigen Punkt zu speziell definierten Zielen, wie zum Beispiel der eigenen Farm, Feld 1 oder auch zu jedem Verkaufspunkt fahren zu lassen.
Changelog 2.0.0.0:
]]>
</de>
<it>
<![CDATA[Questa mod può essere usata per creare una rete di percorsi per permettere ai veicoli di guidare autonomamente. Una volta effettuata la configurazione puoi dire a un veicolo di guidare tramite la rete verso un qualsiasi punto, come il negozio, il campo 1 o un punto vendita.
Log delle modifiche 2.0.0.0:
]]>
</it>
<fr>
<![CDATA[Ce mod peut être utilisé pour créer un réseau de routes permettant aux véhicules de conduire de manière autonome. Une fois la configuration effectuée, vous pouvez indiquer à un tracteur situé près du réseau de se rendre à n’importe quel point, tel que le magasin, le champ 1 ou un point de vente.
Créer, ajouter, modifier, supprimer vos routes ou points de destination à l'aide de l'éditeur intégré très pratique !
Différents modes d'utilisation ont été ajoutés depuis les premières versions, et peuvent être combinés à l'utilisation du bien connu "Courseplay".
Changelog 2.0.0.0:
]]>
</fr>
<es>
Expand All @@ -38,7 +30,7 @@ Changelog 2.0.0.0:
<![CDATA[Этот мод может быть использован для создания сети маршрутов для транспортных средств для автономного вождения. После настройки вы можете указать трактору, стоящему где-угодно рядом с сетью, проехать в любую точку, например, в магазин, поле №1 или в точку продажи.]]>
</ru>
</description>
<version>2.0.0.1</version>
<version>2.0.0.2</version>
<multiplayer supported="true" />
<iconFilename>icon.dds</iconFilename>
<extraSourceFiles>
Expand Down Expand Up @@ -98,6 +90,7 @@ Changelog 2.0.0.0:
<action name="ADToggleHudExtension" category="VEHICLE" ignoreComboMask="false" />
<action name="ADToggleAutomaticUnloadTarget" category="VEHICLE" ignoreComboMask="false" />
<action name="ADToggleAutomaticPickupTarget" category="VEHICLE" ignoreComboMask="false" />
<action name="ADRepairVehicle" category="VEHICLE" ignoreComboMask="false" />
</actions>

<inputBinding>
Expand Down
2 changes: 1 addition & 1 deletion register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- Author: Stephan
-- Email: [email protected]
-- Date: 17.12.2021
-- Version: 2.0.0.0
-- Version: 2.0.0.2

-- #############################################################################

Expand Down
26 changes: 19 additions & 7 deletions scripts/AutoDrive.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AutoDrive = {}
AutoDrive.version = "2.0.0.1"
AutoDrive.version = "2.0.0.2"

AutoDrive.directory = g_currentModDirectory

Expand All @@ -14,7 +14,8 @@ AutoDrive.experimentalFeatures.telemetryOutput = false
AutoDrive.experimentalFeatures.enableRoutesManagerOnDediServer = false
AutoDrive.experimentalFeatures.detectGrasField = true
AutoDrive.experimentalFeatures.colorAssignmentMode = false
AutoDrive.experimentalFeatures.DrawAlternativ = false
AutoDrive.experimentalFeatures.UTurn = true
AutoDrive.experimentalFeatures.FoldImplements = false

AutoDrive.dynamicChaseDistance = true
AutoDrive.smootherDriving = true
Expand Down Expand Up @@ -118,7 +119,8 @@ AutoDrive.actions = {
{"ADParkVehicle", false, 0},
{"AD_devAction", false, 0},
{"ADRefuelVehicle", false, 0},
{"ADToggleHudExtension", true, 1}
{"ADToggleHudExtension", true, 1},
{"ADRepairVehicle", false, 0}
}

AutoDrive.colors = {
Expand Down Expand Up @@ -150,8 +152,9 @@ AutoDrive.fuelFillTypes = {
"AIR"
}

AutoDrive.nonFillableFillTypes = {
"AIR" -- this fillType should not be transported
AutoDrive.nonFillableFillTypes = { -- these fillTypes should not be transported
"AIR",
"SILAGE_ADDITIVE"
}

AutoDrive.seedFillTypes = {
Expand Down Expand Up @@ -285,6 +288,7 @@ function AutoDrive:loadMap(name)
BaseMission.draw = Utils.appendedFunction(BaseMission.draw, AutoDrive.drawBaseMission)
PlaceableHotspot.getCategory = Utils.overwrittenFunction(PlaceableHotspot.getCategory, AutoDrive.PlaceableHotspotGetCategory)
InGameMenuAIFrame.setMapSelectionItem = Utils.overwrittenFunction(InGameMenuAIFrame.setMapSelectionItem, AutoDrive.InGameMenuAIFrameSetMapSelectionItem)
MapHotspot.getRenderLast = Utils.overwrittenFunction(MapHotspot.getRenderLast, AutoDrive.MapHotspotGetRenderLast)
end

function AutoDrive:onAIFrameOpen()
Expand All @@ -295,6 +299,7 @@ end
function AutoDrive:onAIFrameClose()
AutoDrive.aiFrameOpen = false
AutoDrive.aiFrame = nil
AutoDrive.aiFrameVehicle = nil
end

function AutoDrive:refreshContextInputAIFrame()
Expand All @@ -312,15 +317,15 @@ function AutoDrive:drawBaseMission()
AutoDrive:drawRouteOnMap()
if AutoDrive.aiFrameVehicle ~= nil then
AutoDrive.Hud:drawHud(AutoDrive.aiFrameVehicle)
else
elseif g_currentMission.controlledVehicle ~= nil then
AutoDrive.Hud:drawHud(g_currentMission.controlledVehicle)
end
end
end

function AutoDrive:PlaceableHotspotGetCategory()
if self.isADMarker then
return MapHotspot.CATEGORY_AI
return MapHotspot.CATEGORY_PLAYER
end
return PlaceableHotspot.CATEGORY_MAPPING[self.placeableType]
end
Expand All @@ -337,6 +342,13 @@ function AutoDrive:InGameMenuAIFrameSetMapSelectionItem(superFunc, hotspot)
return superFunc(self, hotspot)
end

function AutoDrive:MapHotspotGetRenderLast(superFunc)
if self.isADMarker then
return true
end
return superFunc(self)
end

function AutoDrive.drawRouteOnMap()
if AutoDrive.aiFrame == nil then
return
Expand Down
18 changes: 10 additions & 8 deletions scripts/Hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -723,21 +723,23 @@ function AutoDriveHud:mouseEvent(vehicle, posX, posY, isDown, isUp, button)

AutoDrive.handleWayPointSection(vehicle, button, isUp)
else
vehicle.ad.selectedNodeId = nil
vehicle.ad.nodeToMoveId = nil
vehicle.ad.hoveredNodeId = nil
vehicle.ad.newcreated = nil
vehicle.ad.sectionWayPoints = {}
AutoDrive.resetMouseSelections(vehicle)
end
else
AutoDrive.resetMouseSelections(vehicle)
end

AutoDrive.mouseWheelActive = AutoDrive.mouseWheelActive or (AutoDrive.pullDownListExpanded ~= 0)
end

function AutoDrive.resetMouseSelections(vehicle)
if vehicle ~= nil and vehicle.ad ~= nil then
vehicle.ad.selectedNodeId = nil
vehicle.ad.nodeToMoveId = nil
vehicle.ad.hoveredNodeId = nil
vehicle.ad.newcreated = nil
vehicle.ad.sectionWayPoints = {}
vehicle.ad.sectionWayPoints = {}
end

AutoDrive.mouseWheelActive = AutoDrive.mouseWheelActive or (AutoDrive.pullDownListExpanded ~= 0)
end

function AutoDrive.handleWayPointSection(vehicle, button, isUp)
Expand Down
49 changes: 49 additions & 0 deletions scripts/Manager/GraphManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ function ADGraphManager:createDebugMarkers(updateMap)
end
local count1 = 1
local count2 = 1
local count3 = 1
local mapMarkerCounter = #self:getMapMarkers() + 1
for i, wp in pairs(network) do
-- mark wayPoint without outgoing connection
Expand Down Expand Up @@ -1078,6 +1079,28 @@ function ADGraphManager:createDebugMarkers(updateMap)
end
end
end

-- mark wayPoint without outgoing connection
if wp.out ~= nil then
for _, wp_out in pairs(wp.out) do
local missingIncoming = self:checkForMissingIncoming(wp, self:getWayPointById(wp_out))
if missingIncoming then
local debugMapMarkerName = "3_" .. tostring(count3)

-- create the mapMarker
local mapMarker = {}
mapMarker.name = debugMapMarkerName
mapMarker.group = ADGraphManager.debugGroupName
mapMarker.markerIndex = mapMarkerCounter
mapMarker.id = wp.id
mapMarker.isADDebug = true
self:setMapMarker(mapMarker)

count3 = count3 + 1
mapMarkerCounter = mapMarkerCounter + 1
end
end
end
end
end
if shouldUpdateMap == true then
Expand Down Expand Up @@ -1105,6 +1128,32 @@ function ADGraphManager:checkForWrongReverseStart(wp_ref, wp_current, wp_ahead)
return reverseStart
end

function ADGraphManager:checkForMissingIncoming(wp_current)
local ret = false

if wp_current == nil then
return ret
end
local reverseFound = false
if wp_current.incoming ~= nil and #wp_current.incoming == 0 then

-- search for a possible reverse connection
for _, wp in pairs(self.wayPoints) do
if wp.out ~= nil and wp_current.id ~= nil then
if table.contains(wp.out, wp_current.id) then
reverseFound = true
break
end
end
end
if not reverseFound then
-- the waypoint has no incoming connection
ret = true
end
end
return ret
end

function ADGraphManager:toggleWayPointAsSubPrio(wayPointId)
local wayPoint = self:getWayPointById(wayPointId)
if wayPoint ~= nil then
Expand Down
23 changes: 20 additions & 3 deletions scripts/Manager/InputManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ ADInputManager.actionsToInputs = {
ADRefuelVehicle = "input_refuelVehicle",
ADToggleHudExtension = "input_toggleHudExtension",
ADToggleAutomaticUnloadTarget = "input_toggleAutomaticUnloadTarget",
ADToggleAutomaticPickupTarget = "input_toggleAutomaticPickupTarget"
ADToggleAutomaticPickupTarget = "input_toggleAutomaticPickupTarget",
ADRepairVehicle = "input_repairVehicle"
}


Expand Down Expand Up @@ -95,7 +96,8 @@ ADInputManager.inputsToIds = {
input_bunkerUnloadType = 29,
input_refuelVehicle = 30,
input_toggleAutomaticUnloadTarget = 31,
input_toggleAutomaticPickupTarget = 32
input_toggleAutomaticPickupTarget = 32,
input_repairVehicle = 33
}

ADInputManager.idsToInputs = {}
Expand Down Expand Up @@ -491,7 +493,7 @@ function ADInputManager:input_bunkerUnloadType(vehicle)
end

function ADInputManager:input_refuelVehicle(vehicle)
AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_VEHICLEINFO, "ADInputManager:input_refuelVehicle ")
AutoDrive.debugPrint(vehicle, AutoDrive.DC_VEHICLEINFO, "ADInputManager:input_refuelVehicle ")
local refuelDestination = ADTriggerManager.getClosestRefuelDestination(vehicle, true)
if refuelDestination ~= nil and refuelDestination >= 1 then
-- vehicle.ad.stateModule:setFirstMarker(refuelDestination)
Expand All @@ -511,3 +513,18 @@ function ADInputManager:input_refuelVehicle(vehicle)
AutoDriveMessageEvent.sendMessageOrNotification(vehicle, ADMessagesManager.messageTypes.ERROR, "$l10n_AD_Driver_of; %s $l10n_AD_No_Refuel_Station; %s", 5000, vehicle.ad.stateModule:getName(), refuelFillTypeTitle)
end
end

function ADInputManager:input_repairVehicle(vehicle)
AutoDrive.debugPrint(vehicle, AutoDrive.DC_VEHICLEINFO, "ADInputManager:input_repairVehicle ")
local repairDestinationMarkerNodeID = AutoDrive:getClosestRepairTrigger(vehicle)
if repairDestinationMarkerNodeID ~= nil then
if vehicle.ad.stateModule:isActive() then
self:input_start_stop(vehicle) --disable if already active
end
vehicle.ad.onRouteToRepair = true
vehicle.ad.stateModule:setMode(AutoDrive.MODE_DRIVETO)
self:input_start_stop(vehicle)
else
AutoDriveMessageEvent.sendMessageOrNotification(vehicle, ADMessagesManager.messageTypes.ERROR, "$l10n_AD_Driver_of; %s $l10n_AD_No_Repair_Station;", 5000, vehicle.ad.stateModule:getName())
end
end
4 changes: 3 additions & 1 deletion scripts/Modules/PathFinderModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1981,8 +1981,10 @@ function PathFinderModule:checkSlopeAngle(x1, z1, x2, z2)
local lengthMiddle = MathUtil.vector3Length(worldPosMiddle.x - x2, terrain3 - terrain2, worldPosMiddle.z - z2)
local angleBetween = math.atan(math.abs(terrain1 - terrain2) / length)
local angleBetweenCenter = math.atan(math.abs(terrain3 - terrain2) / lengthMiddle)

local waterY = g_currentMission.environmentAreaSystem:getWaterYAtWorldPosition(worldPosMiddle.x, terrain3, worldPosMiddle.z) or -200

local belowGroundLevel = terrain1 < g_currentMission.waterY - 0.5 or terrain2 < g_currentMission.waterY - 0.5 or terrain3 < g_currentMission.waterY - 0.5
local belowGroundLevel = terrain1 < waterY - 0.5 or terrain2 < waterY - 0.5 or terrain3 < waterY - 0.5

if belowGroundLevel then
if self.vehicle ~= nil and self.vehicle.ad ~= nil and self.vehicle.ad.debug ~= nil and AutoDrive.debugVehicleMsg ~= nil then
Expand Down
3 changes: 3 additions & 0 deletions scripts/Modules/TaskModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ function ADTaskModule:RefuelIfNeeded()
end

function ADTaskModule:hasToRepair()
if self.vehicle.ad.onRouteToRepair then
return true
end
if not AutoDrive.getSetting("autoRepair", self.vehicle) then
return false
end
Expand Down
2 changes: 1 addition & 1 deletion scripts/Modules/TrailerModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function ADTrailerModule:updateLoad(dt)
-- update load delay timer
self.loadDelayTimer:timer(self.lastFillLevel >= self.fillLevel and self.trigger == self, ADTrailerModule.LOAD_DELAY_TIME, dt)

if self.trigger == nil and not fillUnitFull then
if self.trigger == nil and (not fillUnitFull or self.fillUnits > 1) then

AutoDrive.debugPrint(self.vehicle, AutoDrive.DC_TRAILERINFO, "ADTrailerModule:updateLoad search for load self.trigger %s", tostring(self.trigger))

Expand Down
Loading

0 comments on commit 1589c0f

Please sign in to comment.