diff --git a/CTLD.lua b/CTLD.lua index b565e91..52b41bd 100644 --- a/CTLD.lua +++ b/CTLD.lua @@ -1896,8 +1896,8 @@ end -- -- Weights can be found in the ctld.spawnableCrates list -- Points can be made by hand or obtained from a Unit position by Unit.getByName("PilotName"):getPoint() --- e.g. ctld.spawnCrateAtZone("red", 500,{x=1,y=2,z=3}) -- spawn a humvee at triggerzone 1 for red side at a specified point --- e.g. ctld.spawnCrateAtZone("blue", 505,{x=1,y=2,z=3}) -- spawn a tow humvee at triggerzone1 for blue side at a specified point +-- e.g. ctld.spawnCrateAtPoint("red", 500,{x=1,y=2,z=3}) -- spawn a humvee at triggerzone 1 for red side at a specified point +-- e.g. ctld.spawnCrateAtPoint("blue", 505,{x=1,y=2,z=3}) -- spawn a tow humvee at triggerzone1 for blue side at a specified point -- -- function ctld.spawnCrateAtPoint(_side, _weight, _point, _hdg) @@ -2062,13 +2062,16 @@ function ctld.repackVehicle(_params, t) -- scan rrs table 'repackRequestsStack' end local relativePoint = ctld.getRelativePoint(playerPoint, secureDistance + (i * offset), randomHeading) -- 7 meters from the transport unit - ctld.spawnCrateStatic(PlayerTransportUnit:getCountry(), _unitId, relativePoint, _name, crateWeight, - PlayerTransportUnit:getCoalition(), mist.getHeading(PlayerTransportUnit, true)) + if ctld.unitDynamicCargoCapable(PlayerTransportUnit) == false then + ctld.spawnCrateStatic(PlayerTransportUnit:getCountry(), _unitId, relativePoint, _name, crateWeight, + PlayerTransportUnit:getCoalition(), mist.getHeading(PlayerTransportUnit, true)) + else + local _point = ctld.getPointAt6Oclock(PlayerTransportUnit, 15) + ctld.spawnCrateStatic(PlayerTransportUnit:getCountry(), _unitId, _point, _name, crateWeight, + PlayerTransportUnit:getCoalition(), mist.getHeading(PlayerTransportUnit, "dynamic")) + end end - --if ctld.isUnitInALogisticZone(repackableUnitName) == nil then - --ctld.addStaticLogisticUnit({ x = spawnRefPoint.x + 5, z = spawnRefPoint.z + 10 }, refCountry) -- create a temporary logistic unit to be able to repack the vehicle - --end repackableUnit:destroy() -- destroy repacked unit end ctld.repackRequestsStack[ii] = nil @@ -2083,7 +2086,7 @@ function ctld.repackVehicle(_params, t) -- scan rrs table 'repackRequestsStack' end -- *************************************************************** -function ctld.addStaticLogisticUnit(_point, _country) -- create a temporary logistic unit to be able to repack the vehicle +function ctld.addStaticLogisticUnit(_point, _country) -- create a temporary logistic unit with a Windsock object local dynamicLogisticUnitName = "%dynLogisticName_" .. tostring(ctld.getNextDynamicLogisticUnitIndex()) ctld.logisticUnits[#ctld.logisticUnits + 1] = dynamicLogisticUnitName local LogUnit = { @@ -2503,7 +2506,6 @@ function ctld.spawnCrate(_arguments, bypassCrateWaitTime) local _status, _err = pcall(function(_args) -- use the cargo weight to guess the type of unit as no way to add description :( local _crateType = ctld.crateLookupTable[tostring(_args[2])] - local _heli = ctld.getTransportUnit(_args[1]) if not _heli then return @@ -2531,7 +2533,6 @@ function ctld.spawnCrate(_arguments, bypassCrateWaitTime) if ctld.inLogisticsZone(_heli) == false then ctld.displayMessageToGroup(_heli, ctld.i18n_translate("You are not close enough to friendly logistics to get a crate!"), 10) - return end @@ -5907,9 +5908,20 @@ function ctld.addTransportF10MenuOptions(_unitName) ctld.spawnCrate, { _unitName, _menu.crate.weight }) end end + if ctld.unitDynamicCargoCapable(_unit) then + if ctld.vehicleCommandsPath[_unitName] == nil then + ctld.vehicleCommandsPath[_unitName] = mist.utils.deepCopy(_rootPath) + end + if ctld.enableRepackingVehicles then + ctld.updateRepackMenu(_unitName) + end + + end + + end end - + if (ctld.enabledFOBBuilding or ctld.enableCrates) and _unitActions.crates then local _crateCommands = missionCommands.addSubMenuForGroup(_groupId, ctld.i18n_translate("CTLD Commands"), _rootPath) @@ -6015,7 +6027,7 @@ function ctld.updateRepackMenu(_playerUnitName) local repackableVehicles = ctld.getUnitsInRepackRadius(_playerUnitName, ctld.maximumDistanceRepackableUnitsSearch) if repackableVehicles then ctld.logTrace("FG_ ctld.vehicleCommandsPath[_playerUnitName] = %s", ctld.p(ctld.vehicleCommandsPath[_playerUnitName])) - local RepackCommandsPath = mist.utils.deepCopy(ctld.vehicleCommandsPath[_playerUnitName]) + local RepackCommandsPath = mist.utils.deepCopy(ctld.vehicleCommandsPath[_playerUnitName]) RepackCommandsPath[#RepackCommandsPath + 1] = ctld.i18n_translate("Repack Vehicles") --ctld.logTrace("FG_ RepackCommandsPath = %s", ctld.p(RepackCommandsPath)) missionCommands.removeItemForGroup(_groupId, RepackCommandsPath) -- remove existing "Repack Vehicles" menu @@ -6023,13 +6035,12 @@ function ctld.updateRepackMenu(_playerUnitName) local menuEntries = {} --ctld.logTrace("FG_ RepackmenuPath = %s", ctld.p(RepackmenuPath)) for _, _vehicle in pairs(repackableVehicles) do - table.insert(menuEntries, { - text = ctld.i18n_translate("repack ") .. _vehicle.unit, - groupId = _groupId, - subMenuPath = RepackmenuPath, - menuFunction = ctld.repackVehicleRequest, - menuArgsTable = { _vehicle, _playerUnitName } - }) + table.insert(menuEntries, { text = ctld.i18n_translate("repack ") .. _vehicle.unit, + groupId = _groupId, + subMenuPath = RepackmenuPath, + menuFunction = ctld.repackVehicleRequest, + menuArgsTable = { _vehicle, _playerUnitName } + }) end ctld.buildPaginatedMenu(menuEntries) end