mirror of
https://github.com/ciribob/DCS-CTLD.git
synced 2026-08-11 19:57:28 +00:00
Compare commits
178 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82e87bf866 | |||
| e59bc50e6c | |||
| c12c0b242d | |||
| 659268d3f5 | |||
| 041a9ab6af | |||
| 8d73c966db | |||
| af3e4fab17 | |||
| 97e7c72144 | |||
| 65336fdab8 | |||
| 61db3e9f93 | |||
| a1da0ea1c4 | |||
| 782940265d | |||
| b5cd8929f3 | |||
| 1826d28a86 | |||
| 359bf1418d | |||
| e3424c6af5 | |||
| 1ac3b3f8a9 | |||
| e13e630830 | |||
| 7bfed7ef55 | |||
| 8bfaba399f | |||
| 4dada3d24d | |||
| 74b40fe3cb | |||
| aa8bc78b27 | |||
| 7286a6a010 | |||
| c8bb41648c | |||
| 08635622b0 | |||
| 42e8549649 | |||
| 5c48a9d756 | |||
| f3983c6a90 | |||
| 1c66408127 | |||
| 3ac2b3b22c | |||
| c576268d87 | |||
| 35f52d543a | |||
| c608d00d15 | |||
| d2789f554a | |||
| fcef6a66d1 | |||
| dd71451194 | |||
| 807e81e389 | |||
| 33d8810ebb | |||
| 87e8a31f31 | |||
| e4a0fff931 | |||
| ca5bf76c78 | |||
| f8659c5de6 | |||
| 9a0cc8eeee | |||
| a706890cb6 | |||
| 815684dd77 | |||
| 0ccb2ba7bb | |||
| 1e471df264 | |||
| cc8b916870 | |||
| cd62d0c60a | |||
| a35e023752 | |||
| f71e7f3213 | |||
| a468faefec | |||
| 99f2c7aec0 | |||
| 7db8e2d772 | |||
| 026099bd12 | |||
| 82a330e61a | |||
| b3470250e4 | |||
| bbde4ae62b | |||
| 540a316754 | |||
| 574217d931 | |||
| 1fce52088d | |||
| 4d704a489e | |||
| da80f9ea06 | |||
| 93260908c4 | |||
| 3c261e8dc2 | |||
| 7b7eb62bf0 | |||
| 951ee37903 | |||
| 3a7ab50834 | |||
| 9a69d4b52c | |||
| 0345d16150 | |||
| d071fba20f | |||
| 1a32ce6b57 | |||
| 85275ad84b | |||
| 819ba2de53 | |||
| 8f34ad3902 | |||
| 16f366d039 | |||
| 2524320096 | |||
| e6b8c9ba14 | |||
| a5b47503be | |||
| aaa25dcd41 | |||
| e834dd1395 | |||
| 774e499759 | |||
| 0a1f4de471 | |||
| f9cd8b8b51 | |||
| 3eef8d9a5d | |||
| e1b9e1d7d8 | |||
| ca976f4387 | |||
| 91f74b73ed | |||
| f8df243043 | |||
| 29b19d5262 | |||
| 48aca9d488 | |||
| 12741d0532 | |||
| 6df583b9f1 | |||
| ca99c58f98 | |||
| 879272a2e8 | |||
| 267156e04e | |||
| 6fa12ca46f | |||
| eb22f5dc67 | |||
| 601805abb0 | |||
| e0e4279f20 | |||
| 9023c571ba | |||
| 72aab26e43 | |||
| aef146a6d8 | |||
| d8db662dc5 | |||
| e4f13f98b1 | |||
| c1aba95b6f | |||
| d50bcfccd9 | |||
| f0f095e274 | |||
| 69f04dfd57 | |||
| 546f3feaae | |||
| 23e83bf53a | |||
| ee07423588 | |||
| 96d801c342 | |||
| b1818d9fb3 | |||
| 2bc6e76516 | |||
| 61a1fd42ee | |||
| 954a6b0fad | |||
| 159915a6ac | |||
| d029e2479b | |||
| 251467fee4 | |||
| f3a9b44388 | |||
| f0adb72c49 | |||
| ecc47bb247 | |||
| 0c74729837 | |||
| ef1d3d57e5 | |||
| b69f20eb6b | |||
| d80a70c0ee | |||
| 80fe5d59b0 | |||
| 3eaa08b74e | |||
| f83365ec63 | |||
| 0b3b1ea1f8 | |||
| 888d949234 | |||
| 75c9d0bf68 | |||
| 7517eaf188 | |||
| 1181fcfff7 | |||
| 9def2f1a3a | |||
| 9c25240c43 | |||
| 8a17ff52aa | |||
| d125cdbe80 | |||
| 8dcaa3e0bb | |||
| baf1231141 | |||
| d1d9b55769 | |||
| ff06dcecf7 | |||
| dcdf6438a1 | |||
| 4d0062dee3 | |||
| c618f4b282 | |||
| b390d5dabf | |||
| f4b81fd101 | |||
| 78aa8a010e | |||
| 6996769cec | |||
| 0d9c01283c | |||
| fa1553a83e | |||
| 4db3c71728 | |||
| 0180cf33d2 | |||
| c51a3d80ca | |||
| 9eb4fc66b5 | |||
| 8f2a335609 | |||
| c5bae34ed1 | |||
| 6fc9f146ae | |||
| b6232d3c15 | |||
| 111fd73b94 | |||
| 61d9e206b2 | |||
| 08ebd7e82d | |||
| f152f58a97 | |||
| 38e86bead3 | |||
| b0d8f8b5c7 | |||
| a58efad985 | |||
| 0793d3bda5 | |||
| c397bad107 | |||
| 791ee4e63e | |||
| 5aa37c52a4 | |||
| fb26645996 | |||
| 3a3bcaf568 | |||
| fb804b4a22 | |||
| 665bdddbdd | |||
| 6beaedb79a | |||
| 9c2f982d03 |
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Lua.diagnostics.globals": [
|
||||||
|
"ctld"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
--[[
|
--[[ ! IMPORTANT : You must must use the version of MIST supplied in the CTLD pack to correctly manage dynamic spwans
|
||||||
|
|
||||||
Combat Troop and Logistics Drop
|
Combat Troop and Logistics Drop
|
||||||
|
|
||||||
Allows Huey, Mi-8 and C130 to transport troops internally and Helicopters to transport Logistic / Vehicle units to the field via sling-loads
|
Allows Huey, Mi-8 and C130 to transport troops internally and Helicopters to transport Logistic / Vehicle units to the field via sling-loads
|
||||||
@@ -11,6 +12,9 @@
|
|||||||
See https://github.com/ciribob/DCS-CTLD for a user manual and the latest version
|
See https://github.com/ciribob/DCS-CTLD for a user manual and the latest version
|
||||||
|
|
||||||
Contributors:
|
Contributors:
|
||||||
|
- FullGas1 - https://github.com/FullGas1 (i18n concept, FR and SP translations)
|
||||||
|
- Rex (VEAF) - https://github.com/RexAttaque (code, testing, JTAC)
|
||||||
|
- Zip (VEAF) - https://github.com/davidp57 (project management, code, testing)
|
||||||
- Steggles - https://github.com/Bob7heBuilder
|
- Steggles - https://github.com/Bob7heBuilder
|
||||||
- mvee - https://github.com/mvee
|
- mvee - https://github.com/mvee
|
||||||
- jmontleon - https://github.com/jmontleon
|
- jmontleon - https://github.com/jmontleon
|
||||||
@@ -20,7 +24,6 @@
|
|||||||
- Proxy404 - https://github.com/Proxy404
|
- Proxy404 - https://github.com/Proxy404
|
||||||
- atcz - https://github.com/atcz
|
- atcz - https://github.com/atcz
|
||||||
- marcos2221- https://github.com/marcos2221
|
- marcos2221- https://github.com/marcos2221
|
||||||
- FullGas1 - https://github.com/FullGas1 (i18n concept, FR and SP translations)
|
|
||||||
|
|
||||||
Add [issues](https://github.com/ciribob/DCS-CTLD/issues) to the GitHub repository if you want to report a bug or suggest a new feature.
|
Add [issues](https://github.com/ciribob/DCS-CTLD/issues) to the GitHub repository if you want to report a bug or suggest a new feature.
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@ end
|
|||||||
ctld.Id = "CTLD - "
|
ctld.Id = "CTLD - "
|
||||||
|
|
||||||
--- Version.
|
--- Version.
|
||||||
ctld.Version = "1.5.2"
|
ctld.Version = "1.6.1"
|
||||||
|
|
||||||
-- To add debugging messages to dcs.log, change the following log levels to `true`; `Debug` is less detailed than `Trace`
|
-- To add debugging messages to dcs.log, change the following log levels to `true`; `Debug` is less detailed than `Trace`
|
||||||
ctld.Debug = false
|
ctld.Debug = false
|
||||||
@@ -611,6 +614,7 @@ ctld.aircraftTypeTable = {
|
|||||||
--"Mirage-F1DDA",
|
--"Mirage-F1DDA",
|
||||||
--"Su-25T",
|
--"Su-25T",
|
||||||
--"Yak-52",
|
--"Yak-52",
|
||||||
|
"C-130J-30",
|
||||||
|
|
||||||
--%%%%% WARBIRDS %%%%%
|
--%%%%% WARBIRDS %%%%%
|
||||||
--"Bf-109K-4",
|
--"Bf-109K-4",
|
||||||
@@ -808,6 +812,7 @@ ctld.logisticUnits = {
|
|||||||
ctld.vehicleTransportEnabled = {
|
ctld.vehicleTransportEnabled = {
|
||||||
"76MD", -- the il-76 mod doesnt use a normal - sign so il-76md wont match... !!!! GRR
|
"76MD", -- the il-76 mod doesnt use a normal - sign so il-76md wont match... !!!! GRR
|
||||||
"Hercules",
|
"Hercules",
|
||||||
|
"C-130J-30",
|
||||||
--"CH-47Fbl1",
|
--"CH-47Fbl1",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,7 +822,10 @@ ctld.vehicleTransportEnabled = {
|
|||||||
-- We will also use this to make modifications to the menu and other checks and messages
|
-- We will also use this to make modifications to the menu and other checks and messages
|
||||||
ctld.dynamicCargoUnits = {
|
ctld.dynamicCargoUnits = {
|
||||||
"CH-47Fbl1",
|
"CH-47Fbl1",
|
||||||
--"UH-1H",
|
"UH-1H",
|
||||||
|
"Mi-8MT",
|
||||||
|
"Mi-24P",
|
||||||
|
"C-130J-30"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- ************** Maximum Units SETUP for UNITS ******************
|
-- ************** Maximum Units SETUP for UNITS ******************
|
||||||
@@ -866,6 +874,7 @@ ctld.unitLoadLimits = {
|
|||||||
--["Mirage-F1DDA"] = 1,
|
--["Mirage-F1DDA"] = 1,
|
||||||
--["Su-25T"] = 1,
|
--["Su-25T"] = 1,
|
||||||
--["Yak-52"] = 1,
|
--["Yak-52"] = 1,
|
||||||
|
["C-130J-30"] = 80
|
||||||
|
|
||||||
--%%%%% WARBIRDS %%%%%
|
--%%%%% WARBIRDS %%%%%
|
||||||
--["Bf-109K-4"] = 1,
|
--["Bf-109K-4"] = 1,
|
||||||
@@ -888,6 +897,7 @@ ctld.internalCargoLimits = {
|
|||||||
-- Remove the -- below to turn on options
|
-- Remove the -- below to turn on options
|
||||||
["Mi-8MT"] = 2,
|
["Mi-8MT"] = 2,
|
||||||
["CH-47Fbl1"] = 8,
|
["CH-47Fbl1"] = 8,
|
||||||
|
["C-130J-30"] = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -916,6 +926,7 @@ ctld.unitActions = {
|
|||||||
["Hercules"] = { crates = true, troops = true },
|
["Hercules"] = { crates = true, troops = true },
|
||||||
["SK-60"] = { crates = true, troops = true },
|
["SK-60"] = { crates = true, troops = true },
|
||||||
["UH-60L"] = { crates = true, troops = true },
|
["UH-60L"] = { crates = true, troops = true },
|
||||||
|
["C-130J-30"] = { crates = true, troops = true },
|
||||||
--["T-45"] = {crates=true, troops=true},
|
--["T-45"] = {crates=true, troops=true},
|
||||||
|
|
||||||
--%%%%% CHOPPERS %%%%%
|
--%%%%% CHOPPERS %%%%%
|
||||||
@@ -1924,19 +1935,24 @@ function ctld.spawnCrateAtPoint(_side, _weight, _point, _hdg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
function ctld.getSecureDistanceFromUnit(_unitName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
function ctld.getSecureDistanceFromUnit(_unitOrName) -- return a distance between the center of unitName, to be sure not touch the unitName
|
||||||
local rotorDiameter = 0 --19 -- meters -- õk for UH & CH47
|
local rotorDiameter = 19 -- meters -- ok for UH & CH47
|
||||||
if Unit.getByName(_unitName) then
|
local unit = _unitOrName
|
||||||
local unitUserBox = Unit.getByName(_unitName):getDesc().box
|
if type(unit) == "string" then
|
||||||
local SecureDistanceFromUnit = 0
|
unit = Unit.getByName(_unitOrName)
|
||||||
|
end
|
||||||
|
local secureDistanceFromUnit = rotorDiameter
|
||||||
|
if unit then
|
||||||
|
local unitUserBox = unit:getDesc().box
|
||||||
|
if unitUserBox then
|
||||||
if math.abs(unitUserBox.max.x) >= math.abs(unitUserBox.min.x) then
|
if math.abs(unitUserBox.max.x) >= math.abs(unitUserBox.min.x) then
|
||||||
SecureDistanceFromUnit = math.abs(unitUserBox.max.x) + (rotorDiameter/2)
|
secureDistanceFromUnit = math.abs(unitUserBox.max.x) + (rotorDiameter/2)
|
||||||
else
|
else
|
||||||
SecureDistanceFromUnit = math.abs(unitUserBox.min.x) + (rotorDiameter/2)
|
secureDistanceFromUnit = math.abs(unitUserBox.min.x) + (rotorDiameter/2)
|
||||||
end
|
end
|
||||||
return SecureDistanceFromUnit
|
|
||||||
end
|
end
|
||||||
return nil
|
end
|
||||||
|
return secureDistanceFromUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ***************************************************************
|
-- ***************************************************************
|
||||||
@@ -2603,7 +2619,7 @@ function ctld.spawnCrate(_arguments, bypassCrateWaitTime)
|
|||||||
|
|
||||||
if ctld.unitDynamicCargoCapable(_heli) then
|
if ctld.unitDynamicCargoCapable(_heli) then
|
||||||
_model_type = "dynamic"
|
_model_type = "dynamic"
|
||||||
_point = ctld.getPointAt6Oclock(_heli, 15)
|
_point = ctld.getPointAt6Oclock(_heli, ctld.getSecureDistanceFromUnit(_heli))
|
||||||
_position = "6"
|
_position = "6"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2618,9 +2634,18 @@ function ctld.spawnCrate(_arguments, bypassCrateWaitTime)
|
|||||||
-- add to move table
|
-- add to move table
|
||||||
ctld.crateMove[_name] = _name
|
ctld.crateMove[_name] = _name
|
||||||
|
|
||||||
|
local refPoint = _heli:getPoint()
|
||||||
|
local refLat, refLon = coord.LOtoLL(refPoint)
|
||||||
|
local unitPos = _heli:getPosition()
|
||||||
|
local refHeading = math.deg(math.atan2(unitPos.x.z, unitPos.x.x))
|
||||||
|
|
||||||
|
local destLat, destLon, destAlt = coord.LOtoLL(_point)
|
||||||
|
|
||||||
|
local relativePos, forma = ctld.tools.getRelativeBearing(refLat, refLon, refHeading, destLat, destLon, 'clock')
|
||||||
|
|
||||||
ctld.displayMessageToGroup(_heli,
|
ctld.displayMessageToGroup(_heli,
|
||||||
ctld.i18n_translate("A %1 crate weighing %2 kg has been brought out and is at your %3 o'clock ",
|
ctld.i18n_translate("A %1 crate weighing %2 kg has been brought out and is at your %3 o'clock ",
|
||||||
_crateType.desc, _crateType.weight, _position), 20)
|
_crateType.desc, _crateType.weight, relativePos), 20)
|
||||||
else
|
else
|
||||||
env.info("Couldn't find crate item to spawn")
|
env.info("Couldn't find crate item to spawn")
|
||||||
end
|
end
|
||||||
@@ -3894,7 +3919,7 @@ function ctld.getClosestCrate(_heli, _crates, _type)
|
|||||||
local _shortestDistance = -1
|
local _shortestDistance = -1
|
||||||
local _distance = 0
|
local _distance = 0
|
||||||
local _minimumDistance = 5 -- prevents dynamic cargo crates from unpacking while in cargo hold
|
local _minimumDistance = 5 -- prevents dynamic cargo crates from unpacking while in cargo hold
|
||||||
local _maxDistance = 20 -- prevents onboard dynamic cargo crates from unpacking requested by other helo
|
local _maxDistance = 75 -- prevents onboard dynamic cargo crates from unpacking requested by other helo
|
||||||
for _, _crate in pairs(_crates) do
|
for _, _crate in pairs(_crates) do
|
||||||
if (_crate.details.unit == _type or _type == nil) then
|
if (_crate.details.unit == _type or _type == nil) then
|
||||||
_distance = _crate.dist
|
_distance = _crate.dist
|
||||||
@@ -4219,12 +4244,11 @@ function ctld.dropSlingCrate(_args)
|
|||||||
local _position = "12"
|
local _position = "12"
|
||||||
if ctld.unitDynamicCargoCapable(_heli) then
|
if ctld.unitDynamicCargoCapable(_heli) then
|
||||||
_model_type = "dynamic"
|
_model_type = "dynamic"
|
||||||
_point = ctld.getPointAt6Oclock(_heli, 15)
|
_point = ctld.getPointAt6Oclock(_heli, ctld.getSecureDistanceFromUnit(_heli))
|
||||||
_position = "6"
|
_position = "6"
|
||||||
end
|
end
|
||||||
ctld.displayMessageToGroup(_heli,
|
ctld.displayMessageToGroup(_heli,
|
||||||
ctld.i18n_translate("%1 crate has been safely unhooked and is at your %2 o'clock", _crate.desc,
|
ctld.i18n_translate("%1 crate has been safely unhooked and is at your %2 o'clock", _crate.desc, _position), 10)
|
||||||
_position), 10)
|
|
||||||
elseif _heightDiff > 7.5 and _heightDiff <= 40.0 then
|
elseif _heightDiff > 7.5 and _heightDiff <= 40.0 then
|
||||||
ctld.displayMessageToGroup(_heli,
|
ctld.displayMessageToGroup(_heli,
|
||||||
ctld.i18n_translate("%1 crate has been safely dropped below you", _crate.desc), 10)
|
ctld.i18n_translate("%1 crate has been safely dropped below you", _crate.desc), 10)
|
||||||
@@ -5746,7 +5770,7 @@ function ctld.unitDynamicCargoCapable(_unit)
|
|||||||
--ctld.logDebug("ctld.unitDynamicCargoCapable(_type=[%s])", ctld.p(_type))
|
--ctld.logDebug("ctld.unitDynamicCargoCapable(_type=[%s])", ctld.p(_type))
|
||||||
for _, _name in ipairs(ctld.dynamicCargoUnits) do
|
for _, _name in ipairs(ctld.dynamicCargoUnits) do
|
||||||
local _nameLower = string.lower(_name)
|
local _nameLower = string.lower(_name)
|
||||||
if string.find(_type, _nameLower, 1, true) then --string.match does not work with patterns containing '-' as it is a magic character
|
if string.find(_type, _nameLower, 1, true) then --string.match does not work with patterns containing '-' as it is a magic character
|
||||||
result = true
|
result = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -5929,7 +5953,6 @@ function ctld.addTransportF10MenuOptions(_unitName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ctld.enableCrates and _unitActions.crates then
|
if ctld.enableCrates and _unitActions.crates then
|
||||||
if ctld.unitCanCarryVehicles(_unit) == false then
|
|
||||||
-- sort the crate categories alphabetically
|
-- sort the crate categories alphabetically
|
||||||
local crateCategories = {}
|
local crateCategories = {}
|
||||||
for category, _ in pairs(ctld.spawnableCrates) do
|
for category, _ in pairs(ctld.spawnableCrates) do
|
||||||
@@ -5991,7 +6014,6 @@ function ctld.addTransportF10MenuOptions(_unitName)
|
|||||||
end
|
end
|
||||||
missionCommands.addCommandForGroup(_groupId, _menu.text, _subMenuPath,
|
missionCommands.addCommandForGroup(_groupId, _menu.text, _subMenuPath,
|
||||||
ctld.spawnCrate, { _unitName, _menu.crate.weight })
|
ctld.spawnCrate, { _unitName, _menu.crate.weight })
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -8540,7 +8562,7 @@ function ctld.eventHandler:onEvent(event)
|
|||||||
for _, aircraftType in pairs(ctld.aircraftTypeTable) do
|
for _, aircraftType in pairs(ctld.aircraftTypeTable) do
|
||||||
if aircraftType == playerTypeName then
|
if aircraftType == playerTypeName then
|
||||||
ctld.logTrace("adding by aircraft type, unitName = %s", ctld.p(unitName))
|
ctld.logTrace("adding by aircraft type, unitName = %s", ctld.p(unitName))
|
||||||
if ctld.isValueInIpairTable(ctld.transportPilotNames, unitName) == false then
|
if ctld.tools.isValueInIpairTable(ctld.transportPilotNames, unitName) == false then
|
||||||
table.insert(ctld.transportPilotNames, unitName) -- add transport unit to the list
|
table.insert(ctld.transportPilotNames, unitName) -- add transport unit to the list
|
||||||
end
|
end
|
||||||
if ctld.addedTo[tostring(_groupId)] == nil then -- only if menu not already set up
|
if ctld.addedTo[tostring(_groupId)] == nil then -- only if menu not already set up
|
||||||
@@ -8618,7 +8640,8 @@ function ctld.RandomReal(mini, maxi)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Tools
|
-- Tools
|
||||||
function ctld.isValueInIpairTable(tab, value)
|
ctld.tools = {}
|
||||||
|
function ctld.tools.isValueInIpairTable(tab, value)
|
||||||
for i, v in ipairs(tab) do
|
for i, v in ipairs(tab) do
|
||||||
if v == value then
|
if v == value then
|
||||||
return true -- La valeur existe
|
return true -- La valeur existe
|
||||||
@@ -8626,6 +8649,58 @@ function ctld.isValueInIpairTable(tab, value)
|
|||||||
end
|
end
|
||||||
return false -- La valeur n'existe pas
|
return false -- La valeur n'existe pas
|
||||||
end
|
end
|
||||||
|
------------------------------------------------------------------------------------
|
||||||
|
--- Calculates the orientation of an end point relative to a reference point.
|
||||||
|
--- The calculation takes into account the current orientation of the reference point.
|
||||||
|
---
|
||||||
|
--- @param refLat number Latitude of the reference point in degrees.
|
||||||
|
--- @param refLon number Longitude of the reference point in degrees.
|
||||||
|
--- @param refHeading number Current orientation of the reference point in degrees (0 = North, 90 = East).
|
||||||
|
--- @param destLat number Latitude of the arrival point in degrees.
|
||||||
|
--- @param destLon number Longitude of the arrival point in degrees.
|
||||||
|
--- @param resultFormat string The desired output format: "radian", "degree" or "clock".
|
||||||
|
--- @return number The relative orientation in the specified resultFormat.
|
||||||
|
function ctld.tools.getRelativeBearing(refLat, refLon, refHeading, destLat, destLon, resultFormat)
|
||||||
|
-- Converting degrees to radians for geometric calculations
|
||||||
|
local radrefLat = math.rad(refLat)
|
||||||
|
local raddestLat = math.rad(destLat)
|
||||||
|
local radrefLon = math.rad(refLon)
|
||||||
|
local raddestLon = math.rad(destLon)
|
||||||
|
local radrefHeading = math.rad(refHeading)
|
||||||
|
|
||||||
|
-- Calculating the longitude difference between the two points
|
||||||
|
local deltaLon = raddestLon - radrefLon
|
||||||
|
|
||||||
|
-- Using the great circle formula for azimuth (bearing)
|
||||||
|
-- This formula is based on spherical trigonometry and uses atan2
|
||||||
|
-- to correctly handle all quadrants.
|
||||||
|
local y = math.sin(deltaLon) * math.cos(raddestLat)
|
||||||
|
local x = math.cos(radrefLat) * math.sin(raddestLat) - math.sin(radrefLat) * math.cos(raddestLat) * math.cos(deltaLon)
|
||||||
|
local absoluteBearingRad = math.atan2(y, x)
|
||||||
|
|
||||||
|
-- Calculate relative orientation by subtracting the reference refHeading
|
||||||
|
local relativeBearingRad = absoluteBearingRad - radrefHeading
|
||||||
|
|
||||||
|
-- Normalizes the angle to be in the range [-pi, pi]
|
||||||
|
-- This ensures a consistent angle, whether positive or negative.
|
||||||
|
local normalizedRad = (relativeBearingRad + math.pi) % (2 * math.pi) - math.pi
|
||||||
|
|
||||||
|
-- Returns the value in the requested resultFormat
|
||||||
|
if resultFormat == "radian" then
|
||||||
|
return normalizedRad, resultFormat
|
||||||
|
elseif resultFormat == "clock" then
|
||||||
|
-- Convert to clock position (12h = front, 3h = right, 6h = back, etc..)
|
||||||
|
local bearingDeg = math.deg(normalizedRad)
|
||||||
|
local clockPosition = ((bearingDeg + 360) % 360) / 30
|
||||||
|
clockPosition = clockPosition >= 0 and math.floor(clockPosition + 0.5) or math.ceil(clockPosition - 0.5), resultFormat -- rounded clockPosition
|
||||||
|
if clockPosition == 0 then clockPosition = 12 end
|
||||||
|
return clockPosition, resultFormat
|
||||||
|
else -- By default, the resultFormat is "degree"
|
||||||
|
resultFormat = "degree"
|
||||||
|
local bearingDeg = math.deg(normalizedRad)
|
||||||
|
return (bearingDeg + 360) % 360, resultFormat
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Enable/Disable error boxes displayed on screen.
|
--- Enable/Disable error boxes displayed on screen.
|
||||||
env.setErrorMessageBoxEnabled(false)
|
env.setErrorMessageBoxEnabled(false)
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ Optionaly, you can disable the STTS (text to speech over SRS) feature (4).
|
|||||||
![dynamic_loading]
|
![dynamic_loading]
|
||||||
|
|
||||||
### Script Setup
|
### Script Setup
|
||||||
**This script requires MIST version 4.0.57 or above: https://github.com/mrSkortch/MissionScriptingTools**
|
🔴IMPORTANT: This script requires MIST supplied in the CTLD zipped pack to correctly manage dynamic spwans.
|
||||||
|
|
||||||
First make sure MIST is loaded, either as an Initialization Script for the mission or the first DO SCRIPT with a "TIME MORE" of 1. "TIME MORE" means run the actions after X seconds into the mission.
|
First make sure MIST is loaded, either as an Initialization Script for the mission or the first DO SCRIPT with a "TIME MORE" of 1. "TIME MORE" means run the actions after X seconds into the mission.
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ mist = {}
|
|||||||
-- don't change these
|
-- don't change these
|
||||||
mist.majorVersion = 4
|
mist.majorVersion = 4
|
||||||
mist.minorVersion = 5
|
mist.minorVersion = 5
|
||||||
mist.build = "128-DYNSLOTS-01"
|
mist.build = "128-DYNSLOTS-02"
|
||||||
|
|
||||||
-- forward declaration of log shorthand
|
-- forward declaration of log shorthand
|
||||||
local log
|
local log
|
||||||
@@ -826,11 +826,11 @@ do -- the main scope
|
|||||||
if zone.verticies then
|
if zone.verticies then
|
||||||
local offset = {}
|
local offset = {}
|
||||||
for i = 1, #zone.verticies do
|
for i = 1, #zone.verticies do
|
||||||
table.insert(offset, {dist = mist.utils.get2DDist(uRef.point, zone.verticies[i]), heading = mist.getHeadingPoints(uRef.point, zone.verticies[i]) + uRef.heading})
|
table.insert(offset, {dist = mist.utils.get2DDist(uRef.point, zone.verticies[i]), heading = mist.utils.getHeadingPoints(uRef.point, zone.verticies[i]) + uRef.heading})
|
||||||
end
|
end
|
||||||
zone.offset = offset
|
zone.offset = offset
|
||||||
else
|
else
|
||||||
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
|
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.utils.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1484,16 +1484,24 @@ do -- the main scope
|
|||||||
if Object.getCategory(event.initiator) == 1 then
|
if Object.getCategory(event.initiator) == 1 then
|
||||||
--log:info('Object is a Unit')
|
--log:info('Object is a Unit')
|
||||||
local g = Unit.getGroup(event.initiator)
|
local g = Unit.getGroup(event.initiator)
|
||||||
if g and event.initiator:getPlayerName() ~= "" and not mist.DBs.MEunitsByName[event.initiator:getName()] then
|
if not g then
|
||||||
|
log:error('groupSpawned event handler: cannot get hold of Group via Unit. This is a DCS bug')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if event.initiator:getPlayerName() == "" then
|
||||||
|
log:error('groupSpawned event handler: cannot get initiator playerName. This is a DCS bug')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not mist.DBs.MEunitsByName[event.initiator:getName()] then
|
||||||
|
log:error('groupSpawned event handler: cannot find initiator unit in MiST tables. This is a DCS bug')
|
||||||
|
return
|
||||||
|
end
|
||||||
-- log:info(Unit.getGroup(event.initiator):getName())
|
-- log:info(Unit.getGroup(event.initiator):getName())
|
||||||
local gName = g:getName()
|
local gName = g:getName()
|
||||||
if not tempSpawnedGroups[gName] then
|
if not tempSpawnedGroups[gName] then
|
||||||
--log:warn('addedTo tempSpawnedGroups: $1', gName)
|
--log:warn('addedTo tempSpawnedGroups: $1', gName)
|
||||||
tempSpawnedGroups[gName] = {type = 'group', gp = g}
|
tempSpawnedGroups[gName] = {type = 'group', gp = g}
|
||||||
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
||||||
end
|
|
||||||
else
|
|
||||||
log:error('Group not accessible by unit in event handler. This is a DCS bug')
|
|
||||||
end
|
end
|
||||||
elseif Object.getCategory(event.initiator) == 3 or Object.getCategory(event.initiator) == 6 then
|
elseif Object.getCategory(event.initiator) == 3 or Object.getCategory(event.initiator) == 6 then
|
||||||
--log:info('staticSpawnEvent')
|
--log:info('staticSpawnEvent')
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user