mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge remote-tracking branch 'origin/performance-optimization' into 326-add-advanced-rts-options
This commit is contained in:
@@ -5,13 +5,16 @@ local debug = true
|
||||
Olympus.unitCounter = 1
|
||||
Olympus.payloadRegistry = {}
|
||||
Olympus.groupIndex = 0
|
||||
Olympus.groupStep = 40
|
||||
Olympus.groupStep = 5
|
||||
|
||||
Olympus.OlympusDLL = nil
|
||||
Olympus.DLLsloaded = false
|
||||
Olympus.OlympusModPath = os.getenv('DCSOLYMPUS_PATH')..'\\bin\\'
|
||||
Olympus.log = mist.Logger:new("Olympus", 'info')
|
||||
|
||||
Olympus.missionData = {}
|
||||
Olympus.unitsData = {}
|
||||
|
||||
function Olympus.debug(message, displayFor)
|
||||
if debug == true then
|
||||
trigger.action.outText(message, displayFor)
|
||||
@@ -706,22 +709,9 @@ function Olympus.hasKey(tab, key)
|
||||
return false
|
||||
end
|
||||
|
||||
function Olympus.setMissionData(arg, time)
|
||||
local missionData = {}
|
||||
|
||||
-- Bullseye data
|
||||
local bullseyes = {}
|
||||
for i = 0, 2 do
|
||||
local bullseyeVec3 = coalition.getMainRefPoint(i)
|
||||
local bullseyeLatitude, bullseyeLongitude, bullseyeAltitude = coord.LOtoLL(bullseyeVec3)
|
||||
bullseyes[i] = {}
|
||||
bullseyes[i]["latitude"] = bullseyeLatitude
|
||||
bullseyes[i]["longitude"] = bullseyeLongitude
|
||||
bullseyes[i]["coalition"] = Olympus.getCoalitionByCoalitionID(i)
|
||||
end
|
||||
|
||||
-- Units tactical data
|
||||
local unitsData = {}
|
||||
function Olympus.setUnitsData(arg, time)
|
||||
-- Units data
|
||||
local units = {}
|
||||
|
||||
local startIndex = Olympus.groupIndex
|
||||
local endIndex = startIndex + Olympus.groupStep
|
||||
@@ -736,31 +726,73 @@ function Olympus.setMissionData(arg, time)
|
||||
-- Get the targets detected by the group controller
|
||||
local controller = group:getController()
|
||||
local controllerTargets = controller:getDetectedTargets()
|
||||
local contacts = {}
|
||||
for i, target in ipairs(controllerTargets) do
|
||||
for det, enum in pairs(Controller.Detection) do
|
||||
if target.object ~= nil then
|
||||
target["detectionMethod"] = det
|
||||
contacts[#contacts + 1] = target
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Update the units position
|
||||
for index, unit in pairs(group:getUnits()) do
|
||||
local unitController = unit:getController()
|
||||
local table = {}
|
||||
table["contacts"] = {}
|
||||
|
||||
for i, target in ipairs(controllerTargets) do
|
||||
for det, enum in pairs(Controller.Detection) do
|
||||
if target.object ~= nil then
|
||||
local detected = unitController:isTargetDetected(target.object, enum)
|
||||
|
||||
if detected then
|
||||
target["detectionMethod"] = det
|
||||
table["contacts"][#table["contacts"] + 1] = target
|
||||
end
|
||||
end
|
||||
table["category"] = "None"
|
||||
|
||||
-- Get the object category in Olympus name
|
||||
local objectCategory = unit:getCategory()
|
||||
if objectCategory == Object.Category.UNIT then
|
||||
if unit:getDesc().category == Unit.Category.AIRPLANE then
|
||||
table["category"] = "Aircraft"
|
||||
elseif unit:getDesc().category == Unit.Category.HELICOPTER then
|
||||
table["category"] = "Helicopter"
|
||||
elseif unit:getDesc().category == Unit.Category.GROUND_UNIT then
|
||||
table["category"] = "GroundUnit"
|
||||
elseif unit:getDesc().category == Unit.Category.SHIP then
|
||||
table["category"] = "NavyUnit"
|
||||
end
|
||||
elseif objectCategory == Object.Category.WEAPON then
|
||||
if unit:getDesc().category == Weapon.Category.MISSILE then
|
||||
table["category"] = "Missile"
|
||||
elseif unit:getDesc().category == Weapon.Category.ROCKET then
|
||||
table["category"] = "Missile"
|
||||
elseif unit:getDesc().category == Unit.Category.BOMB then
|
||||
table["category"] = "Bomb"
|
||||
end
|
||||
end
|
||||
|
||||
table["hasTask"] = controller:hasTask()
|
||||
|
||||
table["ammo"] = unit:getAmmo()
|
||||
table["fuel"] = unit:getFuel()
|
||||
table["life"] = unit:getLife() / unit:getLife0()
|
||||
unitsData[unit:getObjectID()] = table
|
||||
-- If the category is handled by Olympus, get the data
|
||||
if table["category"] ~= "None" then
|
||||
-- Compute unit position and heading
|
||||
local lat, lng, alt = coord.LOtoLL(unit:getPoint())
|
||||
local position = unit:getPosition()
|
||||
local heading = math.atan2( position.x.z, position.x.x )
|
||||
|
||||
-- Fill the data table
|
||||
table["name"] = unit:getTypeName()
|
||||
table["unitName"] = unit:getName()
|
||||
table["groupName"] = group:getName()
|
||||
table["isHuman"] = (unit:getPlayerName() ~= nil)
|
||||
table["coalitionID"] = unit:getCoalition()
|
||||
table["hasTask"] = controller:hasTask()
|
||||
table["ammo"] = unit:getAmmo() --TODO remove a lot of stuff we don't really need
|
||||
table["fuel"] = unit:getFuel()
|
||||
table["life"] = unit:getLife() / unit:getLife0()
|
||||
table["isAlive"] = (unit:getLife() > 1) and unit:isExist()
|
||||
table["contacts"] = contacts
|
||||
table["position"] = {}
|
||||
table["position"]["lat"] = lat
|
||||
table["position"]["lng"] = lng
|
||||
table["position"]["alt"] = alt
|
||||
table["speed"] = mist.vec.mag(unit:getVelocity())
|
||||
table["heading"] = heading
|
||||
table["country"] = unit:getCountry()
|
||||
|
||||
units[unit:getObjectID()] = table
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -776,6 +808,25 @@ function Olympus.setMissionData(arg, time)
|
||||
end
|
||||
end
|
||||
|
||||
-- Assemble unitsData table
|
||||
Olympus.unitsData["units"] = units
|
||||
|
||||
Olympus.OlympusDLL.setUnitsData()
|
||||
return time + 0.05
|
||||
end
|
||||
|
||||
function Olympus.setMissionData(arg, time)
|
||||
-- Bullseye data
|
||||
local bullseyes = {}
|
||||
for i = 0, 2 do
|
||||
local bullseyeVec3 = coalition.getMainRefPoint(i)
|
||||
local bullseyeLatitude, bullseyeLongitude, bullseyeAltitude = coord.LOtoLL(bullseyeVec3)
|
||||
bullseyes[i] = {}
|
||||
bullseyes[i]["latitude"] = bullseyeLatitude
|
||||
bullseyes[i]["longitude"] = bullseyeLongitude
|
||||
bullseyes[i]["coalition"] = Olympus.getCoalitionByCoalitionID(i)
|
||||
end
|
||||
|
||||
-- Airbases data
|
||||
local base = world.getAirbases()
|
||||
local airbases = {}
|
||||
@@ -792,6 +843,7 @@ function Olympus.setMissionData(arg, time)
|
||||
airbases[i] = info
|
||||
end
|
||||
|
||||
-- Mission
|
||||
local mission = {}
|
||||
mission.theatre = env.mission.theatre
|
||||
mission.dateAndTime = {
|
||||
@@ -801,13 +853,11 @@ function Olympus.setMissionData(arg, time)
|
||||
["date"] = env.mission.date
|
||||
}
|
||||
|
||||
-- Assemble missionData table
|
||||
missionData["bullseyes"] = bullseyes
|
||||
missionData["unitsData"] = unitsData
|
||||
missionData["airbases"] = airbases
|
||||
missionData["mission"] = mission
|
||||
-- Assemble table
|
||||
Olympus.missionData["bullseyes"] = bullseyes
|
||||
Olympus.missionData["airbases"] = airbases
|
||||
Olympus.missionData["mission"] = mission
|
||||
|
||||
Olympus.missionData = missionData
|
||||
Olympus.OlympusDLL.setMissionData()
|
||||
return time + 1
|
||||
end
|
||||
@@ -821,6 +871,7 @@ else
|
||||
Olympus.notify('Failed to load '..OlympusName, 20)
|
||||
end
|
||||
|
||||
timer.scheduleFunction(Olympus.setUnitsData, {}, timer.getTime() + 0.05)
|
||||
timer.scheduleFunction(Olympus.setMissionData, {}, timer.getTime() + 1)
|
||||
|
||||
Olympus.notify("OlympusCommand script " .. version .. " loaded successfully", 2, true)
|
||||
|
||||
@@ -1351,4 +1351,141 @@ templates =
|
||||
}, -- end of [18]
|
||||
}, -- end of ["units"]
|
||||
}, -- end of ["SA-10 SAM Battery"]
|
||||
["SA-5 SAM Battery"] =
|
||||
{
|
||||
["type"] = "vehicle",
|
||||
["name"] = "SA-5 SAM Battery",
|
||||
["country"] = 0,
|
||||
["units"] =
|
||||
{
|
||||
[1] =
|
||||
{
|
||||
["dx"] = 0,
|
||||
["dy"] = 0,
|
||||
["name"] = "RPC_5N62V",
|
||||
["skill"] = "High",
|
||||
["heading"] = 4.7123889803847,
|
||||
}, -- end of [1]
|
||||
[2] =
|
||||
{
|
||||
["dx"] = 0.69314285699511,
|
||||
["dy"] = 127.97571428004,
|
||||
["name"] = "RLS_19J6",
|
||||
["skill"] = "High",
|
||||
["heading"] = 0,
|
||||
},
|
||||
[3] =
|
||||
{
|
||||
["dx"] = 83.349983285123,
|
||||
["dy"] = -1.3806866992963,
|
||||
["name"] = "S-200_Launcher",
|
||||
["skill"] = "High",
|
||||
["heading"] = 3.1415926535898,
|
||||
}, -- end of [5]
|
||||
[4] =
|
||||
{
|
||||
["dx"] = 82.498640577192,
|
||||
["dy"] = 16.104647497996,
|
||||
["name"] = "S-200_Launcher",
|
||||
["skill"] = "High",
|
||||
["heading"] = 3.3161255787892,
|
||||
}, -- end of [6]
|
||||
[5] =
|
||||
{
|
||||
["dx"] = 82.547616217693,
|
||||
["dy"] = -18.227276489837,
|
||||
["name"] = "S-200_Launcher",
|
||||
["skill"] = "High",
|
||||
["heading"] = 2.9670597283904,
|
||||
}, -- end of [7]
|
||||
[6] =
|
||||
{
|
||||
["dx"] = -82.640406328603,
|
||||
["dy"] = -0.41562629467808,
|
||||
["name"] = "S-200_Launcher",
|
||||
["skill"] = "High",
|
||||
["heading"] = 0,
|
||||
}, -- end of [8]
|
||||
[7] =
|
||||
{
|
||||
["dx"] = -81.939684967569,
|
||||
["dy"] = 17.115632734494,
|
||||
["name"] = "S-200_Launcher",
|
||||
["skill"] = "High",
|
||||
["heading"] = 6.1086523819802,
|
||||
}, -- end of [9]
|
||||
[8] =
|
||||
{
|
||||
["dx"] = -81.939684967569,
|
||||
["dy"] = -17.99454369233,
|
||||
["name"] = "S-200_Launcher",
|
||||
["skill"] = "High",
|
||||
["heading"] = 0.17453292519943,
|
||||
}, -- end of [10]
|
||||
[9] =
|
||||
{
|
||||
["dx"] = -9.0858776818495,
|
||||
["dy"] = 187.67713509151,
|
||||
["name"] = "generator_5i57",
|
||||
["skill"] = "High",
|
||||
["heading"] = 1.5707963267949,
|
||||
}, -- end of [11]
|
||||
[10] =
|
||||
{
|
||||
["dx"] = 0.83760223048739,
|
||||
["dy"] = 187.51811292395,
|
||||
["name"] = "generator_5i57",
|
||||
["skill"] = "High",
|
||||
["heading"] = 1.5707963267949,
|
||||
}, -- end of [12]
|
||||
[11] =
|
||||
{
|
||||
["dx"] = -59.823818980018,
|
||||
["dy"] = 168.63468487991,
|
||||
["name"] = "ATZ-5",
|
||||
["skill"] = "High",
|
||||
["heading"] = 0,
|
||||
}, -- end of [13]
|
||||
[12] =
|
||||
{
|
||||
["dx"] = -59.823818980018,
|
||||
["dy"] = 179.2654343833,
|
||||
["name"] = "ATZ-5",
|
||||
["skill"] = "High",
|
||||
["heading"] = 0,
|
||||
}, -- end of [14]
|
||||
[13] =
|
||||
{
|
||||
["dx"] = 20.947679329896,
|
||||
["dy"] = -62.811427216162,
|
||||
["name"] = "GAZ-66",
|
||||
["skill"] = "High",
|
||||
["heading"] = 1.5707963267949,
|
||||
}, -- end of [15]
|
||||
[14] =
|
||||
{
|
||||
["dx"] = 66.751355714747,
|
||||
["dy"] = 151.35592090525,
|
||||
["name"] = "ATZ-60_Maz",
|
||||
["skill"] = "High",
|
||||
["heading"] = 3.9269908169872,
|
||||
}, -- end of [16]
|
||||
[15] =
|
||||
{
|
||||
["dx"] = 59.63926918729,
|
||||
["dy"] = 158.46800743265,
|
||||
["name"] = "ATZ-60_Maz",
|
||||
["skill"] = "High",
|
||||
["heading"] = 3.9269908169872,
|
||||
}, -- end of [17]
|
||||
[16] =
|
||||
{
|
||||
["dx"] = -16.327227612433,
|
||||
["dy"] = -62.472874663305,
|
||||
["name"] = "KAMAZ Truck",
|
||||
["skill"] = "High",
|
||||
["heading"] = 1.5707963267949,
|
||||
}, -- end of [18]
|
||||
}, -- end of ["units"]
|
||||
} -- end of ["SA-5 SAM Battery"]
|
||||
} -- end of templates
|
||||
|
||||
Reference in New Issue
Block a user