mirror of
https://github.com/mrSkortch/MissionScriptingTools.git
synced 2026-07-20 13:54:02 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dd0fd71bc0 | |||
| 2e1de45f06 | |||
| e76ca8013e | |||
| c6b7b957d1 | |||
| 8985ba9a7e | |||
| 730e5d37ab | |||
| e01bfd25d5 | |||
| ab11c65512 | |||
| 1ed42de92a |
@@ -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 = 121
|
mist.build = 128
|
||||||
|
|
||||||
-- forward declaration of log shorthand
|
-- forward declaration of log shorthand
|
||||||
local log
|
local log
|
||||||
@@ -97,57 +97,6 @@ do -- the main scope
|
|||||||
mist.DBs.missionData.countries = {}
|
mist.DBs.missionData.countries = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
mist.DBs.zonesByName = {}
|
|
||||||
mist.DBs.zonesByNum = {}
|
|
||||||
|
|
||||||
|
|
||||||
if env.mission.triggers and env.mission.triggers.zones then
|
|
||||||
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
|
|
||||||
if type(zone_data) == 'table' then
|
|
||||||
local zone = mist.utils.deepCopy(zone_data)
|
|
||||||
--log:warn(zone)
|
|
||||||
zone.point = {} -- point is used by SSE
|
|
||||||
zone.point.x = zone_data.x
|
|
||||||
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
|
|
||||||
zone.point.z = zone_data.y
|
|
||||||
zone.properties = {}
|
|
||||||
if zone_data.properties then
|
|
||||||
for propInd, prop in pairs(zone_data.properties) do
|
|
||||||
if prop.value and tostring(prop.value) ~= "" then
|
|
||||||
zone.properties[prop.key] = prop.value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if zone.verticies then -- trust but verify
|
|
||||||
local r = 0
|
|
||||||
for i = 1, #zone.verticies do
|
|
||||||
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
|
|
||||||
if dist > r then
|
|
||||||
r = mist.utils.deepCopy(dist)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
zone.radius = r
|
|
||||||
|
|
||||||
end
|
|
||||||
if zone.linkUnit then
|
|
||||||
local uRef = mist.DBs.unitsByName[zone.linkUnit]
|
|
||||||
if zone.verticies then
|
|
||||||
local offset = {}
|
|
||||||
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})
|
|
||||||
end
|
|
||||||
zone.offset = offset
|
|
||||||
else
|
|
||||||
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mist.DBs.zonesByName[zone_data.name] = zone
|
|
||||||
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
|
|
||||||
zones_by_num se are different objects.. don't want them linked.]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mist.DBs.drawingByName = {}
|
mist.DBs.drawingByName = {}
|
||||||
mist.DBs.drawingIndexed = {}
|
mist.DBs.drawingIndexed = {}
|
||||||
@@ -746,7 +695,6 @@ do -- the main scope
|
|||||||
["FARP"] = "farps",
|
["FARP"] = "farps",
|
||||||
["Fueltank"] = "fueltank_cargo",
|
["Fueltank"] = "fueltank_cargo",
|
||||||
["Gate"] = "gate",
|
["Gate"] = "gate",
|
||||||
["FARP Fuel Depot"] = "gsm rus",
|
|
||||||
["Armed house"] = "home1_a",
|
["Armed house"] = "home1_a",
|
||||||
["FARP Command Post"] = "kp-ug",
|
["FARP Command Post"] = "kp-ug",
|
||||||
["Watch Tower Armed"] = "ohr-vyshka",
|
["Watch Tower Armed"] = "ohr-vyshka",
|
||||||
@@ -755,7 +703,6 @@ do -- the main scope
|
|||||||
["Pipes big"] = "pipes_big_cargo",
|
["Pipes big"] = "pipes_big_cargo",
|
||||||
["Oil platform"] = "plavbaza",
|
["Oil platform"] = "plavbaza",
|
||||||
["Tetrapod"] = "tetrapod_cargo",
|
["Tetrapod"] = "tetrapod_cargo",
|
||||||
["Fuel tank"] = "toplivo",
|
|
||||||
["Trunks long"] = "trunks_long_cargo",
|
["Trunks long"] = "trunks_long_cargo",
|
||||||
["Trunks small"] = "trunks_small_cargo",
|
["Trunks small"] = "trunks_small_cargo",
|
||||||
["Passenger liner"] = "yastrebow",
|
["Passenger liner"] = "yastrebow",
|
||||||
@@ -842,6 +789,59 @@ do -- the main scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mist.DBs.zonesByName = {}
|
||||||
|
mist.DBs.zonesByNum = {}
|
||||||
|
|
||||||
|
if env.mission.triggers and env.mission.triggers.zones then
|
||||||
|
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
|
||||||
|
if type(zone_data) == 'table' then
|
||||||
|
local zone = mist.utils.deepCopy(zone_data)
|
||||||
|
--log:warn(zone)
|
||||||
|
zone.point = {} -- point is used by SSE
|
||||||
|
zone.point.x = zone_data.x
|
||||||
|
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
|
||||||
|
zone.point.z = zone_data.y
|
||||||
|
zone.properties = {}
|
||||||
|
if zone_data.properties then
|
||||||
|
for propInd, prop in pairs(zone_data.properties) do
|
||||||
|
if prop.value and tostring(prop.value) ~= "" then
|
||||||
|
zone.properties[prop.key] = prop.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if zone.verticies then -- trust but verify
|
||||||
|
local r = 0
|
||||||
|
for i = 1, #zone.verticies do
|
||||||
|
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
|
||||||
|
if dist > r then
|
||||||
|
r = mist.utils.deepCopy(dist)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
zone.radius = r
|
||||||
|
|
||||||
|
end
|
||||||
|
if zone.linkUnit then
|
||||||
|
local uRef = mist.DBs.unitsByName[zone.linkUnit]
|
||||||
|
if uRef then
|
||||||
|
if zone.verticies then
|
||||||
|
local offset = {}
|
||||||
|
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})
|
||||||
|
end
|
||||||
|
zone.offset = offset
|
||||||
|
else
|
||||||
|
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mist.DBs.zonesByName[zone_data.name] = zone
|
||||||
|
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
|
||||||
|
zones_by_num se are different objects.. don't want them linked.]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--DynDBs
|
--DynDBs
|
||||||
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
|
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
|
||||||
mist.DBs.MEunitsByName = mist.utils.deepCopy(mist.DBs.unitsByName)
|
mist.DBs.MEunitsByName = mist.utils.deepCopy(mist.DBs.unitsByName)
|
||||||
@@ -1072,6 +1072,12 @@ do -- the main scope
|
|||||||
|
|
||||||
newTable.units[unitId].type = unitData:getTypeName()
|
newTable.units[unitId].type = unitData:getTypeName()
|
||||||
newTable.units[unitId].unitId = tonumber(unitData:getID())
|
newTable.units[unitId].unitId = tonumber(unitData:getID())
|
||||||
|
|
||||||
|
local pName = unitData:getPlayerName()
|
||||||
|
--log:warn("'$1'", pName)
|
||||||
|
if (pName and pName ~= "") and not mist.DBs.MEunitsByName[newTable.units[unitId].unitName] then
|
||||||
|
newTable.dynamicSlot = timer.getTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
newTable.units[unitId].groupName = newTable.groupName
|
newTable.units[unitId].groupName = newTable.groupName
|
||||||
@@ -1092,7 +1098,11 @@ do -- the main scope
|
|||||||
mistAddedObjects[index] = nil
|
mistAddedObjects[index] = nil
|
||||||
end
|
end
|
||||||
if found == false then
|
if found == false then
|
||||||
newTable.units[unitId].skill = "High"
|
if newTable.dynamicSlot then
|
||||||
|
newTable.units[unitId].skill = "Client"
|
||||||
|
else
|
||||||
|
newTable.units[unitId].skill = "High"
|
||||||
|
end
|
||||||
newTable.units[unitId].alt_type = "BARO"
|
newTable.units[unitId].alt_type = "BARO"
|
||||||
end
|
end
|
||||||
if newTable.units[unitId].alt_type == "RADIO" then -- raw postition MSL was grabbed for group, but spawn is AGL, so re-offset it
|
if newTable.units[unitId].alt_type == "RADIO" then -- raw postition MSL was grabbed for group, but spawn is AGL, so re-offset it
|
||||||
@@ -1150,10 +1160,12 @@ do -- the main scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--dbLog:warn(newTable)
|
||||||
--mist.debug.writeData(mist.utils.serialize,{'msg', newTable}, timer.getAbsTime() ..'Group.lua')
|
--mist.debug.writeData(mist.utils.serialize,{'msg', newTable}, timer.getAbsTime() ..'Group.lua')
|
||||||
newTable.timeAdded = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time
|
newTable.timeAdded = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time
|
||||||
--mist.debug.dumpDBs()
|
--mist.debug.dumpDBs()
|
||||||
--end
|
--end
|
||||||
|
--dbLog:warn(newTable)
|
||||||
--dbLog:info('endDbUpdate')
|
--dbLog:info('endDbUpdate')
|
||||||
return newTable
|
return newTable
|
||||||
end
|
end
|
||||||
@@ -1245,8 +1257,12 @@ do -- the main scope
|
|||||||
if stillExists == true and (updated == true or not mist.DBs.groupsByName[name]) then
|
if stillExists == true and (updated == true or not mist.DBs.groupsByName[name]) then
|
||||||
--dbLog:info('Get Table')
|
--dbLog:info('Get Table')
|
||||||
local dbData = dbUpdate(name, gData.type, staticGroupName)
|
local dbData = dbUpdate(name, gData.type, staticGroupName)
|
||||||
if dbData and type(dbData) == 'table' then
|
if dbData and type(dbData) == 'table' then
|
||||||
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
|
if dbData.name then
|
||||||
|
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
|
||||||
|
else
|
||||||
|
dbLog:warn("dbUpdate failed to populate data: $1 $2 $3", name, gData.type, gData)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Work done, so remove
|
-- Work done, so remove
|
||||||
@@ -1266,6 +1282,11 @@ do -- the main scope
|
|||||||
--dbLog:info(newTable)
|
--dbLog:info(newTable)
|
||||||
|
|
||||||
local state = 0
|
local state = 0
|
||||||
|
if not newTable.name then
|
||||||
|
dbLog:warn("Failed to add to database; sufficent data missing $1", newTable)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if updateChecker[newTable.name] then
|
if updateChecker[newTable.name] then
|
||||||
dbLog:warn("Failed to add to database: $1. Stopped at state: $2", newTable.name, updateChecker[newTable.name])
|
dbLog:warn("Failed to add to database: $1. Stopped at state: $2", newTable.name, updateChecker[newTable.name])
|
||||||
return false
|
return false
|
||||||
@@ -1341,6 +1362,13 @@ do -- the main scope
|
|||||||
--dbLog:info('byId')
|
--dbLog:info('byId')
|
||||||
mist.DBs.unitsById[tonumber(newUnitData.unitId)] = ldeepCopy(newUnitData)
|
mist.DBs.unitsById[tonumber(newUnitData.unitId)] = ldeepCopy(newUnitData)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if newTable.dynamicSlot then
|
||||||
|
mist.DBs.humansByName[newTable.units[1].unitName] = ldeepCopy(newUnitData)
|
||||||
|
if newUnitData.unitId then
|
||||||
|
mist.DBs.humansById[newTable.units[1].unitId] = ldeepCopy(newUnitData)
|
||||||
|
end
|
||||||
|
end
|
||||||
mist.DBs.unitsByName[newUnitData.unitName] = ldeepCopy(newUnitData)
|
mist.DBs.unitsByName[newUnitData.unitName] = ldeepCopy(newUnitData)
|
||||||
end
|
end
|
||||||
-- this is a really annoying DB to populate. Gotta create new tables in case its missing
|
-- this is a really annoying DB to populate. Gotta create new tables in case its missing
|
||||||
@@ -1383,6 +1411,9 @@ do -- the main scope
|
|||||||
--dbLog:info('add to dynGroups')
|
--dbLog:info('add to dynGroups')
|
||||||
mist.DBs.dynGroupsAdded[#mist.DBs.dynGroupsAdded + 1] = ldeepCopy(newTable)
|
mist.DBs.dynGroupsAdded[#mist.DBs.dynGroupsAdded + 1] = ldeepCopy(newTable)
|
||||||
--dbLog:info('clear entry')
|
--dbLog:info('clear entry')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateChecker[newTable.name] = nil
|
updateChecker[newTable.name] = nil
|
||||||
--dbLog:info('return')
|
--dbLog:info('return')
|
||||||
return true
|
return true
|
||||||
@@ -1412,7 +1443,8 @@ do -- the main scope
|
|||||||
if i > 0 then
|
if i > 0 then
|
||||||
--dbLog:info('updateDBTables: $1', #writeGroups)
|
--dbLog:info('updateDBTables: $1', #writeGroups)
|
||||||
|
|
||||||
for x = 1, i do
|
for x = i, 1, -1 do
|
||||||
|
--dbLog:info(x)
|
||||||
local res = writeDBTables(writeGroups[x])
|
local res = writeDBTables(writeGroups[x])
|
||||||
if res and res == true then
|
if res and res == true then
|
||||||
--dbLog:info('result: complete')
|
--dbLog:info('result: complete')
|
||||||
@@ -1422,6 +1454,7 @@ do -- the main scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if x%savesPerRun == 0 then
|
if x%savesPerRun == 0 then
|
||||||
|
--dbLog:info("yield")
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
if timer.getTime() > lastUpdateTime then
|
if timer.getTime() > lastUpdateTime then
|
||||||
@@ -1436,14 +1469,15 @@ do -- the main scope
|
|||||||
-- dont need to add units spawned in at the start of the mission if mist is loaded in init line
|
-- dont need to add units spawned in at the start of the mission if mist is loaded in init line
|
||||||
if event.id == world.event.S_EVENT_BIRTH and timer.getTime0() < timer.getAbsTime() then
|
if event.id == world.event.S_EVENT_BIRTH and timer.getTime0() < timer.getAbsTime() then
|
||||||
|
|
||||||
if Object.getCategory(event.initiator) == 1 and not Unit.getPlayerName(event.initiator) then -- simple player check, will need to later check to see if unit was spawned with a player in a flight
|
if Object.getCategory(event.initiator) == 1 then
|
||||||
--log:info('Object is a Unit')
|
--log:info('Object is a Unit')
|
||||||
if Unit.getGroup(event.initiator) then
|
local g = Unit.getGroup(event.initiator)
|
||||||
|
if g and event.initiator:getPlayerName() ~= "" and not mist.DBs.MEunitsByName[event.initiator:getName()] then
|
||||||
-- log:info(Unit.getGroup(event.initiator):getName())
|
-- log:info(Unit.getGroup(event.initiator):getName())
|
||||||
local g = Unit.getGroup(event.initiator)
|
local gName = g:getName()
|
||||||
if not tempSpawnedGroups[g:getName()] then
|
if not tempSpawnedGroups[gName] then
|
||||||
--log:info('added')
|
--log:warn('addedTo tempSpawnedGroups: $1', gName)
|
||||||
tempSpawnedGroups[g:getName()] = {type = 'group', gp = g}
|
tempSpawnedGroups[gName] = {type = 'group', gp = g}
|
||||||
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1491,7 +1525,7 @@ do -- the main scope
|
|||||||
task.t = timer.getTime() + task.rep --schedule next run
|
task.t = timer.getTime() + task.rep --schedule next run
|
||||||
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
||||||
if not err then
|
if not err then
|
||||||
log:error('Error in scheduled function: $1' .. errmsg)
|
log:error('Error in scheduled function: $1', errmsg)
|
||||||
end
|
end
|
||||||
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
||||||
i = i + 1
|
i = i + 1
|
||||||
@@ -1517,53 +1551,63 @@ do -- the main scope
|
|||||||
id = tostring(original_id) .. ' #' .. tostring(id_ind)
|
id = tostring(original_id) .. ' #' .. tostring(id_ind)
|
||||||
id_ind = id_ind + 1
|
id_ind = id_ind + 1
|
||||||
end
|
end
|
||||||
|
local valid
|
||||||
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
|
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
|
||||||
--log:info('object found in alive_units')
|
--log:info('object found in alive_units')
|
||||||
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
|
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
|
||||||
local pos = Object.getPosition(val.object)
|
if Object.isExist(val.object) then
|
||||||
if pos then
|
local pos = Object.getPosition(val.object)
|
||||||
val.objectPos = pos.p
|
if pos then
|
||||||
|
val.objectPos = pos.p
|
||||||
|
end
|
||||||
|
val.objectType = mist.DBs.aliveUnits[val.object.id_].category
|
||||||
|
--[[if mist.DBs.activeHumans[Unit.getName(val.object)] then
|
||||||
|
--trigger.action.outText('remove via death: ' .. Unit.getName(val.object),20)
|
||||||
|
mist.DBs.activeHumans[Unit.getName(val.object)] = nil
|
||||||
|
end]]
|
||||||
|
valid = true
|
||||||
end
|
end
|
||||||
val.objectType = mist.DBs.aliveUnits[val.object.id_].category
|
|
||||||
--[[if mist.DBs.activeHumans[Unit.getName(val.object)] then
|
|
||||||
--trigger.action.outText('remove via death: ' .. Unit.getName(val.object),20)
|
|
||||||
mist.DBs.activeHumans[Unit.getName(val.object)] = nil
|
|
||||||
end]]
|
|
||||||
elseif mist.DBs.removedAliveUnits and mist.DBs.removedAliveUnits[val.object.id_] then -- it didn't exist in alive_units, check old_alive_units
|
elseif mist.DBs.removedAliveUnits and mist.DBs.removedAliveUnits[val.object.id_] then -- it didn't exist in alive_units, check old_alive_units
|
||||||
--log:info('object found in old_alive_units')
|
--log:info('object found in old_alive_units')
|
||||||
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
|
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
|
||||||
local pos = Object.getPosition(val.object)
|
if Object.isExist(val.object) then
|
||||||
if pos then
|
local pos = Object.getPosition(val.object)
|
||||||
val.objectPos = pos.p
|
if pos then
|
||||||
|
val.objectPos = pos.p
|
||||||
|
end
|
||||||
|
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
|
||||||
|
valid = true
|
||||||
end
|
end
|
||||||
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
|
|
||||||
|
|
||||||
else --attempt to determine if static object...
|
else --attempt to determine if static object...
|
||||||
--log:info('object not found in alive units or old alive units')
|
--log:info('object not found in alive units or old alive units')
|
||||||
local pos = Object.getPosition(val.object)
|
if Object.isExist(val.object) then
|
||||||
if pos then
|
local pos = Object.getPosition(val.object)
|
||||||
local static_found = false
|
if pos then
|
||||||
for ind, static in pairs(mist.DBs.unitsByCat.static) do
|
local static_found = false
|
||||||
if ((pos.p.x - static.point.x)^2 + (pos.p.z - static.point.y)^2)^0.5 < 0.1 then --really, it should be zero...
|
for ind, static in pairs(mist.DBs.unitsByCat.static) do
|
||||||
--log:info('correlated dead static object to position')
|
if ((pos.p.x - static.point.x)^2 + (pos.p.z - static.point.y)^2)^0.5 < 0.1 then --really, it should be zero...
|
||||||
val.objectData = static
|
--log:info('correlated dead static object to position')
|
||||||
val.objectPos = pos.p
|
val.objectData = static
|
||||||
val.objectType = 'static'
|
val.objectPos = pos.p
|
||||||
static_found = true
|
val.objectType = 'static'
|
||||||
break
|
static_found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
if not static_found then
|
||||||
|
val.objectPos = pos.p
|
||||||
|
val.objectType = 'building'
|
||||||
|
val.typeName = Object.getTypeName(val.object)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
val.objectType = 'unknown'
|
||||||
end
|
end
|
||||||
if not static_found then
|
valid = true
|
||||||
val.objectPos = pos.p
|
|
||||||
val.objectType = 'building'
|
|
||||||
val.typeName = Object.getTypeName(val.object)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
val.objectType = 'unknown'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mist.DBs.deadObjects[id] = val
|
if valid then
|
||||||
|
mist.DBs.deadObjects[id] = val
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1733,7 +1777,7 @@ do -- the main scope
|
|||||||
function mist.dynAddStatic(n)
|
function mist.dynAddStatic(n)
|
||||||
|
|
||||||
local newObj = mist.utils.deepCopy(n)
|
local newObj = mist.utils.deepCopy(n)
|
||||||
log:warn(newObj)
|
--log:warn(newObj)
|
||||||
if newObj.units and newObj.units[1] then -- if its mist format
|
if newObj.units and newObj.units[1] then -- if its mist format
|
||||||
for entry, val in pairs(newObj.units[1]) do
|
for entry, val in pairs(newObj.units[1]) do
|
||||||
if newObj[entry] and newObj[entry] ~= val or not newObj[entry] then
|
if newObj[entry] and newObj[entry] ~= val or not newObj[entry] then
|
||||||
@@ -2017,7 +2061,7 @@ do -- the main scope
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, 'newGroupPushedToAddGroup.lua')
|
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, newGroup.name ..'.lua')
|
||||||
--log:warn(newGroup)
|
--log:warn(newGroup)
|
||||||
-- sanitize table
|
-- sanitize table
|
||||||
newGroup.groupName = nil
|
newGroup.groupName = nil
|
||||||
@@ -3558,7 +3602,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
||||||
log:info("$1, $2, $3, $4, $5", unitset1, altoffset1, unitset2, altoffset2, radius)
|
--log:info("$1, $2, $3, $4, $5", unitset1, altoffset1, unitset2, altoffset2, radius)
|
||||||
radius = radius or math.huge
|
radius = radius or math.huge
|
||||||
local unit_info1 = {}
|
local unit_info1 = {}
|
||||||
local unit_info2 = {}
|
local unit_info2 = {}
|
||||||
@@ -3566,21 +3610,25 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
|||||||
-- get the positions all in one step, saves execution time.
|
-- get the positions all in one step, saves execution time.
|
||||||
for unitset1_ind = 1, #unitset1 do
|
for unitset1_ind = 1, #unitset1 do
|
||||||
local unit1 = Unit.getByName(unitset1[unitset1_ind])
|
local unit1 = Unit.getByName(unitset1[unitset1_ind])
|
||||||
local lCat = Object.getCategory(unit1)
|
if unit1 then
|
||||||
if unit1 and ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit:isExist() == true then
|
local lCat = Object.getCategory(unit1)
|
||||||
unit_info1[#unit_info1 + 1] = {}
|
if ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit1:isExist() == true then
|
||||||
unit_info1[#unit_info1].unit = unit1
|
unit_info1[#unit_info1 + 1] = {}
|
||||||
unit_info1[#unit_info1].pos = unit1:getPosition().p
|
unit_info1[#unit_info1].unit = unit1
|
||||||
|
unit_info1[#unit_info1].pos = unit1:getPosition().p
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for unitset2_ind = 1, #unitset2 do
|
for unitset2_ind = 1, #unitset2 do
|
||||||
local unit2 = Unit.getByName(unitset2[unitset2_ind])
|
local unit2 = Unit.getByName(unitset2[unitset2_ind])
|
||||||
local lCat = Object.getCategory(unit2)
|
if unit2 then
|
||||||
if unit2 and ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit:isExist() == true then
|
local lCat = Object.getCategory(unit2)
|
||||||
unit_info2[#unit_info2 + 1] = {}
|
if ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit2:isExist() == true then
|
||||||
unit_info2[#unit_info2].unit = unit2
|
unit_info2[#unit_info2 + 1] = {}
|
||||||
unit_info2[#unit_info2].pos = unit2:getPosition().p
|
unit_info2[#unit_info2].unit = unit2
|
||||||
|
unit_info2[#unit_info2].pos = unit2:getPosition().p
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4010,13 +4058,14 @@ do -- group functions scope
|
|||||||
|
|
||||||
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
|
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
|
||||||
local newGroup = Group.getByName(gpName)
|
local newGroup = Group.getByName(gpName)
|
||||||
local newData = {}
|
local newData = mist.utils.deepCopy(dbData)
|
||||||
newData.name = gpName
|
newData.name = gpName
|
||||||
newData.groupId = tonumber(newGroup:getID())
|
newData.groupId = tonumber(newGroup:getID())
|
||||||
newData.category = newGroup:getCategory()
|
newData.category = newGroup:getCategory()
|
||||||
newData.groupName = gpName
|
newData.groupName = gpName
|
||||||
newData.hidden = dbData.hidden
|
newData.hidden = dbData.hidden
|
||||||
|
|
||||||
|
|
||||||
if newData.category == 2 then
|
if newData.category == 2 then
|
||||||
newData.category = 'vehicle'
|
newData.category = 'vehicle'
|
||||||
elseif newData.category == 3 then
|
elseif newData.category == 3 then
|
||||||
@@ -4788,6 +4837,9 @@ do -- group functions scope
|
|||||||
highNum = secondNum
|
highNum = secondNum
|
||||||
end
|
end
|
||||||
local total = 1
|
local total = 1
|
||||||
|
if highNum > 50 then
|
||||||
|
return math.random(lowNum, highNum)
|
||||||
|
end
|
||||||
if math.abs(highNum - lowNum + 1) < 50 then -- if total values is less than 50
|
if math.abs(highNum - lowNum + 1) < 50 then -- if total values is less than 50
|
||||||
total = math.modf(50/math.abs(highNum - lowNum + 1)) -- make x copies required to be above 50
|
total = math.modf(50/math.abs(highNum - lowNum + 1)) -- make x copies required to be above 50
|
||||||
end
|
end
|
||||||
@@ -5191,7 +5243,8 @@ do -- mist.util scope
|
|||||||
|
|
||||||
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
||||||
if north then
|
if north then
|
||||||
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)), (mist.utils.makeVec3(point1)))
|
local p1 = mist.utils.makeVec3(point1)
|
||||||
|
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), p1), p1)
|
||||||
else
|
else
|
||||||
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
|
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
|
||||||
end
|
end
|
||||||
@@ -5835,8 +5888,8 @@ do -- mist.debug scope
|
|||||||
log:alert('insufficient libraries to run mist.debug.dump_G, you must disable the sanitization of the io and lfs libraries in ./Scripts/MissionScripting.lua')
|
log:alert('insufficient libraries to run mist.debug.dump_G, you must disable the sanitization of the io and lfs libraries in ./Scripts/MissionScripting.lua')
|
||||||
--trigger.action.outText(errmsg, 10)
|
--trigger.action.outText(errmsg, 10)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
--- Write debug data to file.
|
--- Write debug data to file.
|
||||||
-- This function requires you to disable script sanitization
|
-- This function requires you to disable script sanitization
|
||||||
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
|
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
|
||||||
@@ -7651,7 +7704,10 @@ do
|
|||||||
--log:warn(s)
|
--log:warn(s)
|
||||||
if type(s) == 'table' then
|
if type(s) == 'table' then
|
||||||
local mType = s.markType
|
local mType = s.markType
|
||||||
if mType == 'panel' then
|
--log:echo(s)
|
||||||
|
|
||||||
|
if mType == 'panel' then
|
||||||
|
local markScope = s.markScope or "all"
|
||||||
if markScope == 'coa' then
|
if markScope == 'coa' then
|
||||||
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
|
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
|
||||||
elseif markScope == 'group' then
|
elseif markScope == 'group' then
|
||||||
@@ -7709,10 +7765,15 @@ do
|
|||||||
|
|
||||||
local function validateColor(val)
|
local function validateColor(val)
|
||||||
if type(val) == 'table' then
|
if type(val) == 'table' then
|
||||||
for i = 1, #val do
|
for i = 1, 4 do
|
||||||
if type(val[i]) == 'number' and val[i] > 1 then
|
if val[i] then
|
||||||
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
|
if type(val[i]) == 'number' and val[i] > 1 then
|
||||||
end
|
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
|
||||||
|
end
|
||||||
|
else
|
||||||
|
val[i] = 0.8
|
||||||
|
log:warn("index $1 of color to mist.marker.add was missing, defaulted to 0.8", i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif type(val) == 'string' then
|
elseif type(val) == 'string' then
|
||||||
val = mist.utils.hexToRGB(val)
|
val = mist.utils.hexToRGB(val)
|
||||||
@@ -7753,7 +7814,7 @@ do
|
|||||||
--log:info('create maker DB: $1', e.idx)
|
--log:info('create maker DB: $1', e.idx)
|
||||||
mist.DBs.markList[e.idx] = {time = e.time, pos = e.pos, groupId = e.groupId, mType = 'panel', text = e.text, markId = e.idx, coalition = e.coalition}
|
mist.DBs.markList[e.idx] = {time = e.time, pos = e.pos, groupId = e.groupId, mType = 'panel', text = e.text, markId = e.idx, coalition = e.coalition}
|
||||||
if e.unit then
|
if e.unit then
|
||||||
mist.DBs.markList[e.idx].unit = e.intiator:getName()
|
mist.DBs.markList[e.idx].unit = e.initiator:getName()
|
||||||
end
|
end
|
||||||
--log:info(mist.marker.list[e.idx])
|
--log:info(mist.marker.list[e.idx])
|
||||||
end
|
end
|
||||||
@@ -7776,7 +7837,7 @@ do
|
|||||||
else
|
else
|
||||||
for mEntry, mData in pairs(mist.DBs.markList) do
|
for mEntry, mData in pairs(mist.DBs.markList) do
|
||||||
if id == mData.name or id == mData.id then
|
if id == mData.name or id == mData.id then
|
||||||
return mData.id
|
return mData.markId
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -7786,11 +7847,16 @@ do
|
|||||||
|
|
||||||
|
|
||||||
local function removeMark(id)
|
local function removeMark(id)
|
||||||
--log:info("Removing Mark: $1", id
|
--log:info("Removing Mark: $1", id)
|
||||||
local removed = false
|
local removed = false
|
||||||
if type(id) == 'table' then
|
if type(id) == 'table' then
|
||||||
for ind, val in pairs(id) do
|
for ind, val in pairs(id) do
|
||||||
local r = getMarkId(val)
|
local r
|
||||||
|
if type(val) == "table" and val.markId then
|
||||||
|
r = val.markId
|
||||||
|
else
|
||||||
|
r = getMarkId(val)
|
||||||
|
end
|
||||||
if r then
|
if r then
|
||||||
trigger.action.removeMark(r)
|
trigger.action.removeMark(r)
|
||||||
mist.DBs.markList[r] = nil
|
mist.DBs.markList[r] = nil
|
||||||
@@ -7800,9 +7866,11 @@ do
|
|||||||
|
|
||||||
else
|
else
|
||||||
local r = getMarkId(id)
|
local r = getMarkId(id)
|
||||||
trigger.action.removeMark(r)
|
if r then
|
||||||
mist.DBs.markList[r] = nil
|
trigger.action.removeMark(r)
|
||||||
removed = true
|
mist.DBs.markList[r] = nil
|
||||||
|
removed = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return removed
|
return removed
|
||||||
end
|
end
|
||||||
@@ -7924,6 +7992,7 @@ do
|
|||||||
|
|
||||||
if markForCoa then
|
if markForCoa then
|
||||||
if type(markForCoa) == 'string' then
|
if type(markForCoa) == 'string' then
|
||||||
|
--log:warn("coa is string")
|
||||||
if tonumber(markForCoa) then
|
if tonumber(markForCoa) then
|
||||||
coa = coas[tonumber(markForCoa)]
|
coa = coas[tonumber(markForCoa)]
|
||||||
markScope = 'coa'
|
markScope = 'coa'
|
||||||
@@ -7938,11 +8007,10 @@ do
|
|||||||
end
|
end
|
||||||
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
|
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
|
||||||
coa = markForCoa
|
coa = markForCoa
|
||||||
markScore = 'coa'
|
--log:warn("coa is number")
|
||||||
|
markScope = 'coa'
|
||||||
end
|
end
|
||||||
|
markFor = coa
|
||||||
|
|
||||||
|
|
||||||
elseif markFor then
|
elseif markFor then
|
||||||
if type(markFor) == 'number' then -- groupId
|
if type(markFor) == 'number' then -- groupId
|
||||||
if mist.DBs.groupsById[markFor] then
|
if mist.DBs.groupsById[markFor] then
|
||||||
@@ -8051,7 +8119,7 @@ do
|
|||||||
end
|
end
|
||||||
for i = 1, #markForTable do
|
for i = 1, #markForTable do
|
||||||
local newId = iterate()
|
local newId = iterate()
|
||||||
local data = {markId = newId, text = text, pos = pos[i], markFor = markForTable[i], markType = 'panel', name = name, readOnly = readOnly, time = timer.getTime()}
|
local data = {markId = newId, text = text, pos = pos[i], markScope = markScope, markFor = markForTable[i], markType = 'panel', name = name, readOnly = readOnly, time = timer.getTime()}
|
||||||
mist.DBs.markList[newId] = data
|
mist.DBs.markList[newId] = data
|
||||||
table.insert(list, data)
|
table.insert(list, data)
|
||||||
|
|
||||||
@@ -8175,6 +8243,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mist.marker.remove(id)
|
function mist.marker.remove(id)
|
||||||
|
|
||||||
return removeMark(id)
|
return removeMark(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -8706,6 +8775,13 @@ do -- group tasks scope
|
|||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mist.insertTaskToWP(wp, task)
|
||||||
|
if not wp.task then
|
||||||
|
wp.task = {["id"] = "ComboTask", ["params"] = {tasks = {}}}
|
||||||
|
end
|
||||||
|
table.insert(wp.task.params.tasks, task)
|
||||||
|
end
|
||||||
|
|
||||||
function mist.ground.patrol(gpData, pType, form, speed)
|
function mist.ground.patrol(gpData, pType, form, speed)
|
||||||
local vars = {}
|
local vars = {}
|
||||||
@@ -8965,8 +9041,8 @@ do -- group tasks scope
|
|||||||
minR = mist.utils.get2DDist(avg, zone[i])
|
minR = mist.utils.get2DDist(avg, zone[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--log:warn('Radius: $1', radius)
|
|
||||||
--log:warn('minR: $1', minR)
|
--log:warn('minR: $1', minR)
|
||||||
|
--log:warn('Radius: $1', radius)
|
||||||
local lSpawnPos = {}
|
local lSpawnPos = {}
|
||||||
for j = 1, 100 do
|
for j = 1, 100 do
|
||||||
newCoord = mist.getRandPointInCircle(avg, radius)
|
newCoord = mist.getRandPointInCircle(avg, radius)
|
||||||
@@ -9198,7 +9274,7 @@ do -- group tasks scope
|
|||||||
function mist.groupIsDead(groupName) -- copy more or less from on station
|
function mist.groupIsDead(groupName) -- copy more or less from on station
|
||||||
local gp = Group.getByName(groupName)
|
local gp = Group.getByName(groupName)
|
||||||
if gp then
|
if gp then
|
||||||
if #gp:getUnits() > 0 or gp:isExist() == true then
|
if #gp:getUnits() > 0 and gp:isExist() == true then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+210
-134
@@ -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 = 121
|
mist.build = 128
|
||||||
|
|
||||||
-- forward declaration of log shorthand
|
-- forward declaration of log shorthand
|
||||||
local log
|
local log
|
||||||
@@ -97,57 +97,6 @@ do -- the main scope
|
|||||||
mist.DBs.missionData.countries = {}
|
mist.DBs.missionData.countries = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
mist.DBs.zonesByName = {}
|
|
||||||
mist.DBs.zonesByNum = {}
|
|
||||||
|
|
||||||
|
|
||||||
if env.mission.triggers and env.mission.triggers.zones then
|
|
||||||
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
|
|
||||||
if type(zone_data) == 'table' then
|
|
||||||
local zone = mist.utils.deepCopy(zone_data)
|
|
||||||
--log:warn(zone)
|
|
||||||
zone.point = {} -- point is used by SSE
|
|
||||||
zone.point.x = zone_data.x
|
|
||||||
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
|
|
||||||
zone.point.z = zone_data.y
|
|
||||||
zone.properties = {}
|
|
||||||
if zone_data.properties then
|
|
||||||
for propInd, prop in pairs(zone_data.properties) do
|
|
||||||
if prop.value and tostring(prop.value) ~= "" then
|
|
||||||
zone.properties[prop.key] = prop.value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if zone.verticies then -- trust but verify
|
|
||||||
local r = 0
|
|
||||||
for i = 1, #zone.verticies do
|
|
||||||
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
|
|
||||||
if dist > r then
|
|
||||||
r = mist.utils.deepCopy(dist)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
zone.radius = r
|
|
||||||
|
|
||||||
end
|
|
||||||
if zone.linkUnit then
|
|
||||||
local uRef = mist.DBs.unitsByName[zone.linkUnit]
|
|
||||||
if zone.verticies then
|
|
||||||
local offset = {}
|
|
||||||
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})
|
|
||||||
end
|
|
||||||
zone.offset = offset
|
|
||||||
else
|
|
||||||
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mist.DBs.zonesByName[zone_data.name] = zone
|
|
||||||
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
|
|
||||||
zones_by_num se are different objects.. don't want them linked.]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mist.DBs.drawingByName = {}
|
mist.DBs.drawingByName = {}
|
||||||
mist.DBs.drawingIndexed = {}
|
mist.DBs.drawingIndexed = {}
|
||||||
@@ -746,7 +695,6 @@ do -- the main scope
|
|||||||
["FARP"] = "farps",
|
["FARP"] = "farps",
|
||||||
["Fueltank"] = "fueltank_cargo",
|
["Fueltank"] = "fueltank_cargo",
|
||||||
["Gate"] = "gate",
|
["Gate"] = "gate",
|
||||||
["FARP Fuel Depot"] = "gsm rus",
|
|
||||||
["Armed house"] = "home1_a",
|
["Armed house"] = "home1_a",
|
||||||
["FARP Command Post"] = "kp-ug",
|
["FARP Command Post"] = "kp-ug",
|
||||||
["Watch Tower Armed"] = "ohr-vyshka",
|
["Watch Tower Armed"] = "ohr-vyshka",
|
||||||
@@ -755,7 +703,6 @@ do -- the main scope
|
|||||||
["Pipes big"] = "pipes_big_cargo",
|
["Pipes big"] = "pipes_big_cargo",
|
||||||
["Oil platform"] = "plavbaza",
|
["Oil platform"] = "plavbaza",
|
||||||
["Tetrapod"] = "tetrapod_cargo",
|
["Tetrapod"] = "tetrapod_cargo",
|
||||||
["Fuel tank"] = "toplivo",
|
|
||||||
["Trunks long"] = "trunks_long_cargo",
|
["Trunks long"] = "trunks_long_cargo",
|
||||||
["Trunks small"] = "trunks_small_cargo",
|
["Trunks small"] = "trunks_small_cargo",
|
||||||
["Passenger liner"] = "yastrebow",
|
["Passenger liner"] = "yastrebow",
|
||||||
@@ -842,6 +789,59 @@ do -- the main scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mist.DBs.zonesByName = {}
|
||||||
|
mist.DBs.zonesByNum = {}
|
||||||
|
|
||||||
|
if env.mission.triggers and env.mission.triggers.zones then
|
||||||
|
for zone_ind, zone_data in pairs(env.mission.triggers.zones) do
|
||||||
|
if type(zone_data) == 'table' then
|
||||||
|
local zone = mist.utils.deepCopy(zone_data)
|
||||||
|
--log:warn(zone)
|
||||||
|
zone.point = {} -- point is used by SSE
|
||||||
|
zone.point.x = zone_data.x
|
||||||
|
zone.point.y = land.getHeight({x = zone_data.x, y = zone_data.y})
|
||||||
|
zone.point.z = zone_data.y
|
||||||
|
zone.properties = {}
|
||||||
|
if zone_data.properties then
|
||||||
|
for propInd, prop in pairs(zone_data.properties) do
|
||||||
|
if prop.value and tostring(prop.value) ~= "" then
|
||||||
|
zone.properties[prop.key] = prop.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if zone.verticies then -- trust but verify
|
||||||
|
local r = 0
|
||||||
|
for i = 1, #zone.verticies do
|
||||||
|
local dist = mist.utils.get2DDist(zone.point, zone.verticies[i])
|
||||||
|
if dist > r then
|
||||||
|
r = mist.utils.deepCopy(dist)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
zone.radius = r
|
||||||
|
|
||||||
|
end
|
||||||
|
if zone.linkUnit then
|
||||||
|
local uRef = mist.DBs.unitsByName[zone.linkUnit]
|
||||||
|
if uRef then
|
||||||
|
if zone.verticies then
|
||||||
|
local offset = {}
|
||||||
|
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})
|
||||||
|
end
|
||||||
|
zone.offset = offset
|
||||||
|
else
|
||||||
|
zone.offset = {dist = mist.utils.get2DDist(uRef.point, zone.point), heading = mist.getHeadingPoints(uRef.point, zone.point) + uRef.heading}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mist.DBs.zonesByName[zone_data.name] = zone
|
||||||
|
mist.DBs.zonesByNum[#mist.DBs.zonesByNum + 1] = mist.utils.deepCopy(zone) --[[deepcopy so that the zone in zones_by_name and the zone in
|
||||||
|
zones_by_num se are different objects.. don't want them linked.]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--DynDBs
|
--DynDBs
|
||||||
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
|
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
|
||||||
mist.DBs.MEunitsByName = mist.utils.deepCopy(mist.DBs.unitsByName)
|
mist.DBs.MEunitsByName = mist.utils.deepCopy(mist.DBs.unitsByName)
|
||||||
@@ -1072,6 +1072,12 @@ do -- the main scope
|
|||||||
|
|
||||||
newTable.units[unitId].type = unitData:getTypeName()
|
newTable.units[unitId].type = unitData:getTypeName()
|
||||||
newTable.units[unitId].unitId = tonumber(unitData:getID())
|
newTable.units[unitId].unitId = tonumber(unitData:getID())
|
||||||
|
|
||||||
|
local pName = unitData:getPlayerName()
|
||||||
|
--log:warn("'$1'", pName)
|
||||||
|
if (pName and pName ~= "") and not mist.DBs.MEunitsByName[newTable.units[unitId].unitName] then
|
||||||
|
newTable.dynamicSlot = timer.getTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
newTable.units[unitId].groupName = newTable.groupName
|
newTable.units[unitId].groupName = newTable.groupName
|
||||||
@@ -1092,7 +1098,11 @@ do -- the main scope
|
|||||||
mistAddedObjects[index] = nil
|
mistAddedObjects[index] = nil
|
||||||
end
|
end
|
||||||
if found == false then
|
if found == false then
|
||||||
newTable.units[unitId].skill = "High"
|
if newTable.dynamicSlot then
|
||||||
|
newTable.units[unitId].skill = "Client"
|
||||||
|
else
|
||||||
|
newTable.units[unitId].skill = "High"
|
||||||
|
end
|
||||||
newTable.units[unitId].alt_type = "BARO"
|
newTable.units[unitId].alt_type = "BARO"
|
||||||
end
|
end
|
||||||
if newTable.units[unitId].alt_type == "RADIO" then -- raw postition MSL was grabbed for group, but spawn is AGL, so re-offset it
|
if newTable.units[unitId].alt_type == "RADIO" then -- raw postition MSL was grabbed for group, but spawn is AGL, so re-offset it
|
||||||
@@ -1150,10 +1160,12 @@ do -- the main scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--dbLog:warn(newTable)
|
||||||
--mist.debug.writeData(mist.utils.serialize,{'msg', newTable}, timer.getAbsTime() ..'Group.lua')
|
--mist.debug.writeData(mist.utils.serialize,{'msg', newTable}, timer.getAbsTime() ..'Group.lua')
|
||||||
newTable.timeAdded = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time
|
newTable.timeAdded = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time
|
||||||
--mist.debug.dumpDBs()
|
--mist.debug.dumpDBs()
|
||||||
--end
|
--end
|
||||||
|
--dbLog:warn(newTable)
|
||||||
--dbLog:info('endDbUpdate')
|
--dbLog:info('endDbUpdate')
|
||||||
return newTable
|
return newTable
|
||||||
end
|
end
|
||||||
@@ -1245,8 +1257,12 @@ do -- the main scope
|
|||||||
if stillExists == true and (updated == true or not mist.DBs.groupsByName[name]) then
|
if stillExists == true and (updated == true or not mist.DBs.groupsByName[name]) then
|
||||||
--dbLog:info('Get Table')
|
--dbLog:info('Get Table')
|
||||||
local dbData = dbUpdate(name, gData.type, staticGroupName)
|
local dbData = dbUpdate(name, gData.type, staticGroupName)
|
||||||
if dbData and type(dbData) == 'table' then
|
if dbData and type(dbData) == 'table' then
|
||||||
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
|
if dbData.name then
|
||||||
|
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
|
||||||
|
else
|
||||||
|
dbLog:warn("dbUpdate failed to populate data: $1 $2 $3", name, gData.type, gData)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Work done, so remove
|
-- Work done, so remove
|
||||||
@@ -1266,6 +1282,11 @@ do -- the main scope
|
|||||||
--dbLog:info(newTable)
|
--dbLog:info(newTable)
|
||||||
|
|
||||||
local state = 0
|
local state = 0
|
||||||
|
if not newTable.name then
|
||||||
|
dbLog:warn("Failed to add to database; sufficent data missing $1", newTable)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if updateChecker[newTable.name] then
|
if updateChecker[newTable.name] then
|
||||||
dbLog:warn("Failed to add to database: $1. Stopped at state: $2", newTable.name, updateChecker[newTable.name])
|
dbLog:warn("Failed to add to database: $1. Stopped at state: $2", newTable.name, updateChecker[newTable.name])
|
||||||
return false
|
return false
|
||||||
@@ -1341,6 +1362,13 @@ do -- the main scope
|
|||||||
--dbLog:info('byId')
|
--dbLog:info('byId')
|
||||||
mist.DBs.unitsById[tonumber(newUnitData.unitId)] = ldeepCopy(newUnitData)
|
mist.DBs.unitsById[tonumber(newUnitData.unitId)] = ldeepCopy(newUnitData)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if newTable.dynamicSlot then
|
||||||
|
mist.DBs.humansByName[newTable.units[1].unitName] = ldeepCopy(newUnitData)
|
||||||
|
if newUnitData.unitId then
|
||||||
|
mist.DBs.humansById[newTable.units[1].unitId] = ldeepCopy(newUnitData)
|
||||||
|
end
|
||||||
|
end
|
||||||
mist.DBs.unitsByName[newUnitData.unitName] = ldeepCopy(newUnitData)
|
mist.DBs.unitsByName[newUnitData.unitName] = ldeepCopy(newUnitData)
|
||||||
end
|
end
|
||||||
-- this is a really annoying DB to populate. Gotta create new tables in case its missing
|
-- this is a really annoying DB to populate. Gotta create new tables in case its missing
|
||||||
@@ -1383,6 +1411,9 @@ do -- the main scope
|
|||||||
--dbLog:info('add to dynGroups')
|
--dbLog:info('add to dynGroups')
|
||||||
mist.DBs.dynGroupsAdded[#mist.DBs.dynGroupsAdded + 1] = ldeepCopy(newTable)
|
mist.DBs.dynGroupsAdded[#mist.DBs.dynGroupsAdded + 1] = ldeepCopy(newTable)
|
||||||
--dbLog:info('clear entry')
|
--dbLog:info('clear entry')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateChecker[newTable.name] = nil
|
updateChecker[newTable.name] = nil
|
||||||
--dbLog:info('return')
|
--dbLog:info('return')
|
||||||
return true
|
return true
|
||||||
@@ -1412,7 +1443,8 @@ do -- the main scope
|
|||||||
if i > 0 then
|
if i > 0 then
|
||||||
--dbLog:info('updateDBTables: $1', #writeGroups)
|
--dbLog:info('updateDBTables: $1', #writeGroups)
|
||||||
|
|
||||||
for x = 1, i do
|
for x = i, 1, -1 do
|
||||||
|
--dbLog:info(x)
|
||||||
local res = writeDBTables(writeGroups[x])
|
local res = writeDBTables(writeGroups[x])
|
||||||
if res and res == true then
|
if res and res == true then
|
||||||
--dbLog:info('result: complete')
|
--dbLog:info('result: complete')
|
||||||
@@ -1422,6 +1454,7 @@ do -- the main scope
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if x%savesPerRun == 0 then
|
if x%savesPerRun == 0 then
|
||||||
|
--dbLog:info("yield")
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
if timer.getTime() > lastUpdateTime then
|
if timer.getTime() > lastUpdateTime then
|
||||||
@@ -1436,14 +1469,15 @@ do -- the main scope
|
|||||||
-- dont need to add units spawned in at the start of the mission if mist is loaded in init line
|
-- dont need to add units spawned in at the start of the mission if mist is loaded in init line
|
||||||
if event.id == world.event.S_EVENT_BIRTH and timer.getTime0() < timer.getAbsTime() then
|
if event.id == world.event.S_EVENT_BIRTH and timer.getTime0() < timer.getAbsTime() then
|
||||||
|
|
||||||
if Object.getCategory(event.initiator) == 1 and not Unit.getPlayerName(event.initiator) then -- simple player check, will need to later check to see if unit was spawned with a player in a flight
|
if Object.getCategory(event.initiator) == 1 then
|
||||||
--log:info('Object is a Unit')
|
--log:info('Object is a Unit')
|
||||||
if Unit.getGroup(event.initiator) then
|
local g = Unit.getGroup(event.initiator)
|
||||||
|
if g and event.initiator:getPlayerName() ~= "" and not mist.DBs.MEunitsByName[event.initiator:getName()] then
|
||||||
-- log:info(Unit.getGroup(event.initiator):getName())
|
-- log:info(Unit.getGroup(event.initiator):getName())
|
||||||
local g = Unit.getGroup(event.initiator)
|
local gName = g:getName()
|
||||||
if not tempSpawnedGroups[g:getName()] then
|
if not tempSpawnedGroups[gName] then
|
||||||
--log:info('added')
|
--log:warn('addedTo tempSpawnedGroups: $1', gName)
|
||||||
tempSpawnedGroups[g:getName()] = {type = 'group', gp = g}
|
tempSpawnedGroups[gName] = {type = 'group', gp = g}
|
||||||
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -1491,7 +1525,7 @@ do -- the main scope
|
|||||||
task.t = timer.getTime() + task.rep --schedule next run
|
task.t = timer.getTime() + task.rep --schedule next run
|
||||||
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
||||||
if not err then
|
if not err then
|
||||||
log:error('Error in scheduled function: $1' .. errmsg)
|
log:error('Error in scheduled function: $1', errmsg)
|
||||||
end
|
end
|
||||||
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
||||||
i = i + 1
|
i = i + 1
|
||||||
@@ -1517,53 +1551,63 @@ do -- the main scope
|
|||||||
id = tostring(original_id) .. ' #' .. tostring(id_ind)
|
id = tostring(original_id) .. ' #' .. tostring(id_ind)
|
||||||
id_ind = id_ind + 1
|
id_ind = id_ind + 1
|
||||||
end
|
end
|
||||||
|
local valid
|
||||||
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
|
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
|
||||||
--log:info('object found in alive_units')
|
--log:info('object found in alive_units')
|
||||||
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
|
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
|
||||||
local pos = Object.getPosition(val.object)
|
if Object.isExist(val.object) then
|
||||||
if pos then
|
local pos = Object.getPosition(val.object)
|
||||||
val.objectPos = pos.p
|
if pos then
|
||||||
|
val.objectPos = pos.p
|
||||||
|
end
|
||||||
|
val.objectType = mist.DBs.aliveUnits[val.object.id_].category
|
||||||
|
--[[if mist.DBs.activeHumans[Unit.getName(val.object)] then
|
||||||
|
--trigger.action.outText('remove via death: ' .. Unit.getName(val.object),20)
|
||||||
|
mist.DBs.activeHumans[Unit.getName(val.object)] = nil
|
||||||
|
end]]
|
||||||
|
valid = true
|
||||||
end
|
end
|
||||||
val.objectType = mist.DBs.aliveUnits[val.object.id_].category
|
|
||||||
--[[if mist.DBs.activeHumans[Unit.getName(val.object)] then
|
|
||||||
--trigger.action.outText('remove via death: ' .. Unit.getName(val.object),20)
|
|
||||||
mist.DBs.activeHumans[Unit.getName(val.object)] = nil
|
|
||||||
end]]
|
|
||||||
elseif mist.DBs.removedAliveUnits and mist.DBs.removedAliveUnits[val.object.id_] then -- it didn't exist in alive_units, check old_alive_units
|
elseif mist.DBs.removedAliveUnits and mist.DBs.removedAliveUnits[val.object.id_] then -- it didn't exist in alive_units, check old_alive_units
|
||||||
--log:info('object found in old_alive_units')
|
--log:info('object found in old_alive_units')
|
||||||
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
|
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
|
||||||
local pos = Object.getPosition(val.object)
|
if Object.isExist(val.object) then
|
||||||
if pos then
|
local pos = Object.getPosition(val.object)
|
||||||
val.objectPos = pos.p
|
if pos then
|
||||||
|
val.objectPos = pos.p
|
||||||
|
end
|
||||||
|
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
|
||||||
|
valid = true
|
||||||
end
|
end
|
||||||
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
|
|
||||||
|
|
||||||
else --attempt to determine if static object...
|
else --attempt to determine if static object...
|
||||||
--log:info('object not found in alive units or old alive units')
|
--log:info('object not found in alive units or old alive units')
|
||||||
local pos = Object.getPosition(val.object)
|
if Object.isExist(val.object) then
|
||||||
if pos then
|
local pos = Object.getPosition(val.object)
|
||||||
local static_found = false
|
if pos then
|
||||||
for ind, static in pairs(mist.DBs.unitsByCat.static) do
|
local static_found = false
|
||||||
if ((pos.p.x - static.point.x)^2 + (pos.p.z - static.point.y)^2)^0.5 < 0.1 then --really, it should be zero...
|
for ind, static in pairs(mist.DBs.unitsByCat.static) do
|
||||||
--log:info('correlated dead static object to position')
|
if ((pos.p.x - static.point.x)^2 + (pos.p.z - static.point.y)^2)^0.5 < 0.1 then --really, it should be zero...
|
||||||
val.objectData = static
|
--log:info('correlated dead static object to position')
|
||||||
val.objectPos = pos.p
|
val.objectData = static
|
||||||
val.objectType = 'static'
|
val.objectPos = pos.p
|
||||||
static_found = true
|
val.objectType = 'static'
|
||||||
break
|
static_found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
if not static_found then
|
||||||
|
val.objectPos = pos.p
|
||||||
|
val.objectType = 'building'
|
||||||
|
val.typeName = Object.getTypeName(val.object)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
val.objectType = 'unknown'
|
||||||
end
|
end
|
||||||
if not static_found then
|
valid = true
|
||||||
val.objectPos = pos.p
|
|
||||||
val.objectType = 'building'
|
|
||||||
val.typeName = Object.getTypeName(val.object)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
val.objectType = 'unknown'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mist.DBs.deadObjects[id] = val
|
if valid then
|
||||||
|
mist.DBs.deadObjects[id] = val
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1733,7 +1777,7 @@ do -- the main scope
|
|||||||
function mist.dynAddStatic(n)
|
function mist.dynAddStatic(n)
|
||||||
|
|
||||||
local newObj = mist.utils.deepCopy(n)
|
local newObj = mist.utils.deepCopy(n)
|
||||||
log:warn(newObj)
|
--log:warn(newObj)
|
||||||
if newObj.units and newObj.units[1] then -- if its mist format
|
if newObj.units and newObj.units[1] then -- if its mist format
|
||||||
for entry, val in pairs(newObj.units[1]) do
|
for entry, val in pairs(newObj.units[1]) do
|
||||||
if newObj[entry] and newObj[entry] ~= val or not newObj[entry] then
|
if newObj[entry] and newObj[entry] ~= val or not newObj[entry] then
|
||||||
@@ -2017,7 +2061,7 @@ do -- the main scope
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, 'newGroupPushedToAddGroup.lua')
|
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, newGroup.name ..'.lua')
|
||||||
--log:warn(newGroup)
|
--log:warn(newGroup)
|
||||||
-- sanitize table
|
-- sanitize table
|
||||||
newGroup.groupName = nil
|
newGroup.groupName = nil
|
||||||
@@ -3558,7 +3602,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
||||||
log:info("$1, $2, $3, $4, $5", unitset1, altoffset1, unitset2, altoffset2, radius)
|
--log:info("$1, $2, $3, $4, $5", unitset1, altoffset1, unitset2, altoffset2, radius)
|
||||||
radius = radius or math.huge
|
radius = radius or math.huge
|
||||||
local unit_info1 = {}
|
local unit_info1 = {}
|
||||||
local unit_info2 = {}
|
local unit_info2 = {}
|
||||||
@@ -3566,21 +3610,25 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
|||||||
-- get the positions all in one step, saves execution time.
|
-- get the positions all in one step, saves execution time.
|
||||||
for unitset1_ind = 1, #unitset1 do
|
for unitset1_ind = 1, #unitset1 do
|
||||||
local unit1 = Unit.getByName(unitset1[unitset1_ind])
|
local unit1 = Unit.getByName(unitset1[unitset1_ind])
|
||||||
local lCat = Object.getCategory(unit1)
|
if unit1 then
|
||||||
if unit1 and ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit:isExist() == true then
|
local lCat = Object.getCategory(unit1)
|
||||||
unit_info1[#unit_info1 + 1] = {}
|
if ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit1:isExist() == true then
|
||||||
unit_info1[#unit_info1].unit = unit1
|
unit_info1[#unit_info1 + 1] = {}
|
||||||
unit_info1[#unit_info1].pos = unit1:getPosition().p
|
unit_info1[#unit_info1].unit = unit1
|
||||||
|
unit_info1[#unit_info1].pos = unit1:getPosition().p
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for unitset2_ind = 1, #unitset2 do
|
for unitset2_ind = 1, #unitset2 do
|
||||||
local unit2 = Unit.getByName(unitset2[unitset2_ind])
|
local unit2 = Unit.getByName(unitset2[unitset2_ind])
|
||||||
local lCat = Object.getCategory(unit2)
|
if unit2 then
|
||||||
if unit2 and ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit:isExist() == true then
|
local lCat = Object.getCategory(unit2)
|
||||||
unit_info2[#unit_info2 + 1] = {}
|
if ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit2:isExist() == true then
|
||||||
unit_info2[#unit_info2].unit = unit2
|
unit_info2[#unit_info2 + 1] = {}
|
||||||
unit_info2[#unit_info2].pos = unit2:getPosition().p
|
unit_info2[#unit_info2].unit = unit2
|
||||||
|
unit_info2[#unit_info2].pos = unit2:getPosition().p
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4010,13 +4058,14 @@ do -- group functions scope
|
|||||||
|
|
||||||
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
|
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
|
||||||
local newGroup = Group.getByName(gpName)
|
local newGroup = Group.getByName(gpName)
|
||||||
local newData = {}
|
local newData = mist.utils.deepCopy(dbData)
|
||||||
newData.name = gpName
|
newData.name = gpName
|
||||||
newData.groupId = tonumber(newGroup:getID())
|
newData.groupId = tonumber(newGroup:getID())
|
||||||
newData.category = newGroup:getCategory()
|
newData.category = newGroup:getCategory()
|
||||||
newData.groupName = gpName
|
newData.groupName = gpName
|
||||||
newData.hidden = dbData.hidden
|
newData.hidden = dbData.hidden
|
||||||
|
|
||||||
|
|
||||||
if newData.category == 2 then
|
if newData.category == 2 then
|
||||||
newData.category = 'vehicle'
|
newData.category = 'vehicle'
|
||||||
elseif newData.category == 3 then
|
elseif newData.category == 3 then
|
||||||
@@ -4788,6 +4837,9 @@ do -- group functions scope
|
|||||||
highNum = secondNum
|
highNum = secondNum
|
||||||
end
|
end
|
||||||
local total = 1
|
local total = 1
|
||||||
|
if highNum > 50 then
|
||||||
|
return math.random(lowNum, highNum)
|
||||||
|
end
|
||||||
if math.abs(highNum - lowNum + 1) < 50 then -- if total values is less than 50
|
if math.abs(highNum - lowNum + 1) < 50 then -- if total values is less than 50
|
||||||
total = math.modf(50/math.abs(highNum - lowNum + 1)) -- make x copies required to be above 50
|
total = math.modf(50/math.abs(highNum - lowNum + 1)) -- make x copies required to be above 50
|
||||||
end
|
end
|
||||||
@@ -5191,7 +5243,8 @@ do -- mist.util scope
|
|||||||
|
|
||||||
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
||||||
if north then
|
if north then
|
||||||
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)), (mist.utils.makeVec3(point1)))
|
local p1 = mist.utils.makeVec3(point1)
|
||||||
|
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), p1), p1)
|
||||||
else
|
else
|
||||||
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
|
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
|
||||||
end
|
end
|
||||||
@@ -5835,8 +5888,8 @@ do -- mist.debug scope
|
|||||||
log:alert('insufficient libraries to run mist.debug.dump_G, you must disable the sanitization of the io and lfs libraries in ./Scripts/MissionScripting.lua')
|
log:alert('insufficient libraries to run mist.debug.dump_G, you must disable the sanitization of the io and lfs libraries in ./Scripts/MissionScripting.lua')
|
||||||
--trigger.action.outText(errmsg, 10)
|
--trigger.action.outText(errmsg, 10)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
--- Write debug data to file.
|
--- Write debug data to file.
|
||||||
-- This function requires you to disable script sanitization
|
-- This function requires you to disable script sanitization
|
||||||
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
|
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
|
||||||
@@ -7651,7 +7704,10 @@ do
|
|||||||
--log:warn(s)
|
--log:warn(s)
|
||||||
if type(s) == 'table' then
|
if type(s) == 'table' then
|
||||||
local mType = s.markType
|
local mType = s.markType
|
||||||
if mType == 'panel' then
|
--log:echo(s)
|
||||||
|
|
||||||
|
if mType == 'panel' then
|
||||||
|
local markScope = s.markScope or "all"
|
||||||
if markScope == 'coa' then
|
if markScope == 'coa' then
|
||||||
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
|
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
|
||||||
elseif markScope == 'group' then
|
elseif markScope == 'group' then
|
||||||
@@ -7709,10 +7765,15 @@ do
|
|||||||
|
|
||||||
local function validateColor(val)
|
local function validateColor(val)
|
||||||
if type(val) == 'table' then
|
if type(val) == 'table' then
|
||||||
for i = 1, #val do
|
for i = 1, 4 do
|
||||||
if type(val[i]) == 'number' and val[i] > 1 then
|
if val[i] then
|
||||||
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
|
if type(val[i]) == 'number' and val[i] > 1 then
|
||||||
end
|
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
|
||||||
|
end
|
||||||
|
else
|
||||||
|
val[i] = 0.8
|
||||||
|
log:warn("index $1 of color to mist.marker.add was missing, defaulted to 0.8", i)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif type(val) == 'string' then
|
elseif type(val) == 'string' then
|
||||||
val = mist.utils.hexToRGB(val)
|
val = mist.utils.hexToRGB(val)
|
||||||
@@ -7753,7 +7814,7 @@ do
|
|||||||
--log:info('create maker DB: $1', e.idx)
|
--log:info('create maker DB: $1', e.idx)
|
||||||
mist.DBs.markList[e.idx] = {time = e.time, pos = e.pos, groupId = e.groupId, mType = 'panel', text = e.text, markId = e.idx, coalition = e.coalition}
|
mist.DBs.markList[e.idx] = {time = e.time, pos = e.pos, groupId = e.groupId, mType = 'panel', text = e.text, markId = e.idx, coalition = e.coalition}
|
||||||
if e.unit then
|
if e.unit then
|
||||||
mist.DBs.markList[e.idx].unit = e.intiator:getName()
|
mist.DBs.markList[e.idx].unit = e.initiator:getName()
|
||||||
end
|
end
|
||||||
--log:info(mist.marker.list[e.idx])
|
--log:info(mist.marker.list[e.idx])
|
||||||
end
|
end
|
||||||
@@ -7776,7 +7837,7 @@ do
|
|||||||
else
|
else
|
||||||
for mEntry, mData in pairs(mist.DBs.markList) do
|
for mEntry, mData in pairs(mist.DBs.markList) do
|
||||||
if id == mData.name or id == mData.id then
|
if id == mData.name or id == mData.id then
|
||||||
return mData.id
|
return mData.markId
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -7786,11 +7847,16 @@ do
|
|||||||
|
|
||||||
|
|
||||||
local function removeMark(id)
|
local function removeMark(id)
|
||||||
--log:info("Removing Mark: $1", id
|
--log:info("Removing Mark: $1", id)
|
||||||
local removed = false
|
local removed = false
|
||||||
if type(id) == 'table' then
|
if type(id) == 'table' then
|
||||||
for ind, val in pairs(id) do
|
for ind, val in pairs(id) do
|
||||||
local r = getMarkId(val)
|
local r
|
||||||
|
if type(val) == "table" and val.markId then
|
||||||
|
r = val.markId
|
||||||
|
else
|
||||||
|
r = getMarkId(val)
|
||||||
|
end
|
||||||
if r then
|
if r then
|
||||||
trigger.action.removeMark(r)
|
trigger.action.removeMark(r)
|
||||||
mist.DBs.markList[r] = nil
|
mist.DBs.markList[r] = nil
|
||||||
@@ -7800,9 +7866,11 @@ do
|
|||||||
|
|
||||||
else
|
else
|
||||||
local r = getMarkId(id)
|
local r = getMarkId(id)
|
||||||
trigger.action.removeMark(r)
|
if r then
|
||||||
mist.DBs.markList[r] = nil
|
trigger.action.removeMark(r)
|
||||||
removed = true
|
mist.DBs.markList[r] = nil
|
||||||
|
removed = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return removed
|
return removed
|
||||||
end
|
end
|
||||||
@@ -7924,6 +7992,7 @@ do
|
|||||||
|
|
||||||
if markForCoa then
|
if markForCoa then
|
||||||
if type(markForCoa) == 'string' then
|
if type(markForCoa) == 'string' then
|
||||||
|
--log:warn("coa is string")
|
||||||
if tonumber(markForCoa) then
|
if tonumber(markForCoa) then
|
||||||
coa = coas[tonumber(markForCoa)]
|
coa = coas[tonumber(markForCoa)]
|
||||||
markScope = 'coa'
|
markScope = 'coa'
|
||||||
@@ -7938,11 +8007,10 @@ do
|
|||||||
end
|
end
|
||||||
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
|
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
|
||||||
coa = markForCoa
|
coa = markForCoa
|
||||||
markScore = 'coa'
|
--log:warn("coa is number")
|
||||||
|
markScope = 'coa'
|
||||||
end
|
end
|
||||||
|
markFor = coa
|
||||||
|
|
||||||
|
|
||||||
elseif markFor then
|
elseif markFor then
|
||||||
if type(markFor) == 'number' then -- groupId
|
if type(markFor) == 'number' then -- groupId
|
||||||
if mist.DBs.groupsById[markFor] then
|
if mist.DBs.groupsById[markFor] then
|
||||||
@@ -8051,7 +8119,7 @@ do
|
|||||||
end
|
end
|
||||||
for i = 1, #markForTable do
|
for i = 1, #markForTable do
|
||||||
local newId = iterate()
|
local newId = iterate()
|
||||||
local data = {markId = newId, text = text, pos = pos[i], markFor = markForTable[i], markType = 'panel', name = name, readOnly = readOnly, time = timer.getTime()}
|
local data = {markId = newId, text = text, pos = pos[i], markScope = markScope, markFor = markForTable[i], markType = 'panel', name = name, readOnly = readOnly, time = timer.getTime()}
|
||||||
mist.DBs.markList[newId] = data
|
mist.DBs.markList[newId] = data
|
||||||
table.insert(list, data)
|
table.insert(list, data)
|
||||||
|
|
||||||
@@ -8175,6 +8243,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mist.marker.remove(id)
|
function mist.marker.remove(id)
|
||||||
|
|
||||||
return removeMark(id)
|
return removeMark(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -8706,6 +8775,13 @@ do -- group tasks scope
|
|||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mist.insertTaskToWP(wp, task)
|
||||||
|
if not wp.task then
|
||||||
|
wp.task = {["id"] = "ComboTask", ["params"] = {tasks = {}}}
|
||||||
|
end
|
||||||
|
table.insert(wp.task.params.tasks, task)
|
||||||
|
end
|
||||||
|
|
||||||
function mist.ground.patrol(gpData, pType, form, speed)
|
function mist.ground.patrol(gpData, pType, form, speed)
|
||||||
local vars = {}
|
local vars = {}
|
||||||
@@ -8965,8 +9041,8 @@ do -- group tasks scope
|
|||||||
minR = mist.utils.get2DDist(avg, zone[i])
|
minR = mist.utils.get2DDist(avg, zone[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--log:warn('Radius: $1', radius)
|
|
||||||
--log:warn('minR: $1', minR)
|
--log:warn('minR: $1', minR)
|
||||||
|
--log:warn('Radius: $1', radius)
|
||||||
local lSpawnPos = {}
|
local lSpawnPos = {}
|
||||||
for j = 1, 100 do
|
for j = 1, 100 do
|
||||||
newCoord = mist.getRandPointInCircle(avg, radius)
|
newCoord = mist.getRandPointInCircle(avg, radius)
|
||||||
@@ -9198,7 +9274,7 @@ do -- group tasks scope
|
|||||||
function mist.groupIsDead(groupName) -- copy more or less from on station
|
function mist.groupIsDead(groupName) -- copy more or less from on station
|
||||||
local gp = Group.getByName(groupName)
|
local gp = Group.getByName(groupName)
|
||||||
if gp then
|
if gp then
|
||||||
if #gp:getUnits() > 0 or gp:isExist() == true then
|
if #gp:getUnits() > 0 and gp:isExist() == true then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user