mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added basic template spawning
This commit is contained in:
@@ -232,17 +232,34 @@ end
|
||||
function Olympus.spawnGroundUnit(coalition, unitType, lat, lng)
|
||||
Olympus.debug("Olympus.spawnGroundUnit " .. coalition .. " " .. unitType .. " (" .. lat .. ", " .. lng ..")", 2)
|
||||
local spawnLocation = mist.utils.makeVec3GL(coord.LLtoLO(lat, lng, 0))
|
||||
local unitTable =
|
||||
{
|
||||
[1] =
|
||||
|
||||
local unitTable = {}
|
||||
|
||||
if Olympus.hasKey(templates, unitType) then
|
||||
for idx, value in pairs(templates[unitType].units) do
|
||||
unitTable[#unitTable + 1] = {
|
||||
["type"] = value.name,
|
||||
["x"] = spawnLocation.x + value.dx,
|
||||
["y"] = spawnLocation.z + value.dy,
|
||||
["playerCanDrive"] = true,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High"
|
||||
}
|
||||
end
|
||||
else
|
||||
unitTable =
|
||||
{
|
||||
["type"] = unitType,
|
||||
["x"] = spawnLocation.x,
|
||||
["y"] = spawnLocation.z,
|
||||
["playerCanDrive"] = true,
|
||||
["heading"] = 0,
|
||||
},
|
||||
}
|
||||
[1] =
|
||||
{
|
||||
["type"] = unitType,
|
||||
["x"] = spawnLocation.x,
|
||||
["y"] = spawnLocation.z,
|
||||
["playerCanDrive"] = true,
|
||||
["heading"] = 0,
|
||||
["skill"] = "High"
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local countryID = Olympus.getCountryIDByCoalition(coalition)
|
||||
|
||||
@@ -475,7 +492,26 @@ function Olympus.isArray(t)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function Olympus.hasValue(tab, val)
|
||||
for index, value in ipairs(tab) do
|
||||
if value == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function Olympus.hasKey(tab, key)
|
||||
for k, value in pairs(tab) do
|
||||
if k == key then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function Olympus.setMissionData(arg, time)
|
||||
local missionData = {}
|
||||
@@ -503,14 +539,27 @@ function Olympus.setMissionData(arg, time)
|
||||
if groupName ~= nil then
|
||||
local group = Group.getByName(groupName)
|
||||
if group ~= nil then
|
||||
-- Get the targets detected by the group controller
|
||||
local controller = group:getController()
|
||||
local controllerTargets = controller:getDetectedTargets()
|
||||
|
||||
for index, unit in pairs(group:getUnits()) do
|
||||
local unitController = unit:getController()
|
||||
local table = {}
|
||||
table["targets"] = {}
|
||||
table["targets"]["visual"] = controller:getDetectedTargets(1)
|
||||
table["targets"]["radar"] = controller:getDetectedTargets(4)
|
||||
table["targets"]["rwr"] = controller:getDetectedTargets(16)
|
||||
table["targets"]["other"] = controller:getDetectedTargets(2, 8, 32)
|
||||
|
||||
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["targets"][#table["targets"] + 1] = target
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table["hasTask"] = controller:hasTask()
|
||||
|
||||
|
||||
1354
scripts/templates.lua
Normal file
1354
scripts/templates.lua
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user