Compare commits

...

9 Commits

Author SHA1 Message Date
mrSkortch dd0fd71bc0 DB tweaks
FIXED: check for getPlayerName to only add the dynamicSlot entry
FIXED: checkSpwanEventsNew to verify the passed table has the correct entries needed to add it to the database
FIXED: writeDBTables to handle if a name entry is not passed
MODIFIED: updateDBTables to iterate backwards
FIXED: to handle if passed a table of tables
2024-12-16 03:23:08 -07:00
mrSkortch 2e1de45f06 Fixed errors
FIXED: error in event handler attempting to run functions on non existing units due to changes in DCS.
FIXED: mist.utils.getHeadingPoints
ADDED: experimental mist.insertTastToWP function to add a task to a WP table due to annoyances in how that table is formatted. (UNTESTED).
2024-10-25 20:55:59 -06:00
mrSkortch e76ca8013e Dynamic Slot Support
MODIFIED: dbUpdate to check getPlayerName on the object to add dynamicSlot value
MODIFIED: dbUpdate to save skill to client if it is from a dynamic slot
MODIFIED: groupSpawned event to check playerName and MEunitsByName to add the unit to tempSpawnedGroups
MODIFIED: writeDBTables to check if dynamicSlot is a passed value. If present will update mist.DBs.humansByName and mist.DBs.humansById for any player spawned in a dynamic slot
FIXED: mist.random to just call math.random if the highNum is larger than 50.
2024-07-02 16:33:38 -06:00
mrSkortch c6b7b957d1 groupIsDead fix
FIXED: mist.groupIsDead to account for instances where isExist() still returns true.
2024-04-03 16:53:09 -06:00
mrSkortch 8985ba9a7e minor change to getCurrentGroupData
FIXED: mist.getCurrentGroupData to inherit all values that are saved in DB.
2024-03-26 15:38:19 -06:00
mrSkortch 730e5d37ab markid fix
FIXED: returning markId rather than id
2024-02-23 19:04:39 -07:00
mrSkortch e01bfd25d5 marker fixes and other things
FIXED: error occurring when oil well and gas platform are destroyed. Will investigate further and report the bug to ED.
FIXED: mist.getUnitsLOS to verify each unit being checked is alive
MODIFIED: validateColor to verify the passed table is 4 digits, if digit is missing it will default a value to 0.8
FIXED: typo in S_EVENT_MARK_ADDED event
MODIFIED: removeMark to check if the passed table has a markId value, if so then use that to remove the mark
FIXED: error check if getMarkId is nil
FIXED: draw using markScope value when drawing a maker panel
FIXED: passing markScope to the draw function
2024-02-23 18:56:36 -07:00
mrSkortch ab11c65512 getUnitsLOS fix.
FIXED: error message inside of scheduledFunctions
FIXED: typo in getUnitsLOS that caused an error
2023-12-12 04:56:11 -07:00
mrSkortch 1ed42de92a linkUnit fix
FIXED: error if a zone is linked to a unit.
2023-11-21 22:37:21 -07:00
2 changed files with 420 additions and 268 deletions
+210 -134
View File
@@ -35,7 +35,7 @@ mist = {}
-- don't change these
mist.majorVersion = 4
mist.minorVersion = 5
mist.build = 121
mist.build = 128
-- forward declaration of log shorthand
local log
@@ -97,57 +97,6 @@ do -- the main scope
mist.DBs.missionData.countries = {}
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.drawingIndexed = {}
@@ -746,7 +695,6 @@ do -- the main scope
["FARP"] = "farps",
["Fueltank"] = "fueltank_cargo",
["Gate"] = "gate",
["FARP Fuel Depot"] = "gsm rus",
["Armed house"] = "home1_a",
["FARP Command Post"] = "kp-ug",
["Watch Tower Armed"] = "ohr-vyshka",
@@ -755,7 +703,6 @@ do -- the main scope
["Pipes big"] = "pipes_big_cargo",
["Oil platform"] = "plavbaza",
["Tetrapod"] = "tetrapod_cargo",
["Fuel tank"] = "toplivo",
["Trunks long"] = "trunks_long_cargo",
["Trunks small"] = "trunks_small_cargo",
["Passenger liner"] = "yastrebow",
@@ -842,6 +789,59 @@ do -- the main scope
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
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
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].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
@@ -1092,7 +1098,11 @@ do -- the main scope
mistAddedObjects[index] = nil
end
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"
end
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
--dbLog:warn(newTable)
--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
--mist.debug.dumpDBs()
--end
--dbLog:warn(newTable)
--dbLog:info('endDbUpdate')
return newTable
end
@@ -1245,8 +1257,12 @@ do -- the main scope
if stillExists == true and (updated == true or not mist.DBs.groupsByName[name]) then
--dbLog:info('Get Table')
local dbData = dbUpdate(name, gData.type, staticGroupName)
if dbData and type(dbData) == 'table' then
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
if dbData and type(dbData) == 'table' then
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
-- Work done, so remove
@@ -1266,6 +1282,11 @@ do -- the main scope
--dbLog:info(newTable)
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
dbLog:warn("Failed to add to database: $1. Stopped at state: $2", newTable.name, updateChecker[newTable.name])
return false
@@ -1341,6 +1362,13 @@ do -- the main scope
--dbLog:info('byId')
mist.DBs.unitsById[tonumber(newUnitData.unitId)] = ldeepCopy(newUnitData)
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)
end
-- 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')
mist.DBs.dynGroupsAdded[#mist.DBs.dynGroupsAdded + 1] = ldeepCopy(newTable)
--dbLog:info('clear entry')
updateChecker[newTable.name] = nil
--dbLog:info('return')
return true
@@ -1412,7 +1443,8 @@ do -- the main scope
if i > 0 then
--dbLog:info('updateDBTables: $1', #writeGroups)
for x = 1, i do
for x = i, 1, -1 do
--dbLog:info(x)
local res = writeDBTables(writeGroups[x])
if res and res == true then
--dbLog:info('result: complete')
@@ -1422,6 +1454,7 @@ do -- the main scope
end
end
if x%savesPerRun == 0 then
--dbLog:info("yield")
coroutine.yield()
end
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
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')
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())
local g = Unit.getGroup(event.initiator)
if not tempSpawnedGroups[g:getName()] then
--log:info('added')
tempSpawnedGroups[g:getName()] = {type = 'group', gp = g}
local gName = g:getName()
if not tempSpawnedGroups[gName] then
--log:warn('addedTo tempSpawnedGroups: $1', gName)
tempSpawnedGroups[gName] = {type = 'group', gp = g}
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
end
else
@@ -1491,7 +1525,7 @@ do -- the main scope
task.t = timer.getTime() + task.rep --schedule next run
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
if not err then
log:error('Error in scheduled function: $1' .. errmsg)
log:error('Error in scheduled function: $1', errmsg)
end
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
i = i + 1
@@ -1517,53 +1551,63 @@ do -- the main scope
id = tostring(original_id) .. ' #' .. tostring(id_ind)
id_ind = id_ind + 1
end
local valid
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
--log:info('object found in alive_units')
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
local pos = Object.getPosition(val.object)
if pos then
val.objectPos = pos.p
if Object.isExist(val.object) then
local pos = Object.getPosition(val.object)
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
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
--log:info('object found in old_alive_units')
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
local pos = Object.getPosition(val.object)
if pos then
val.objectPos = pos.p
if Object.isExist(val.object) then
local pos = Object.getPosition(val.object)
if pos then
val.objectPos = pos.p
end
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
valid = true
end
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
else --attempt to determine if static object...
--log:info('object not found in alive units or old alive units')
local pos = Object.getPosition(val.object)
if pos then
local static_found = false
for ind, static in pairs(mist.DBs.unitsByCat.static) do
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...
--log:info('correlated dead static object to position')
val.objectData = static
val.objectPos = pos.p
val.objectType = 'static'
static_found = true
break
if Object.isExist(val.object) then
local pos = Object.getPosition(val.object)
if pos then
local static_found = false
for ind, static in pairs(mist.DBs.unitsByCat.static) do
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...
--log:info('correlated dead static object to position')
val.objectData = static
val.objectPos = pos.p
val.objectType = 'static'
static_found = true
break
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
if not static_found then
val.objectPos = pos.p
val.objectType = 'building'
val.typeName = Object.getTypeName(val.object)
end
else
val.objectType = 'unknown'
valid = true
end
end
mist.DBs.deadObjects[id] = val
if valid then
mist.DBs.deadObjects[id] = val
end
end
end
end
@@ -1733,7 +1777,7 @@ do -- the main scope
function mist.dynAddStatic(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
for entry, val in pairs(newObj.units[1]) do
if newObj[entry] and newObj[entry] ~= val or not newObj[entry] then
@@ -2017,7 +2061,7 @@ do -- the main scope
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)
-- sanitize table
newGroup.groupName = nil
@@ -3558,7 +3602,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty
end
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
local unit_info1 = {}
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.
for unitset1_ind = 1, #unitset1 do
local unit1 = Unit.getByName(unitset1[unitset1_ind])
local lCat = Object.getCategory(unit1)
if unit1 and ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info1[#unit_info1 + 1] = {}
unit_info1[#unit_info1].unit = unit1
unit_info1[#unit_info1].pos = unit1:getPosition().p
if unit1 then
local lCat = Object.getCategory(unit1)
if ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit1:isExist() == true then
unit_info1[#unit_info1 + 1] = {}
unit_info1[#unit_info1].unit = unit1
unit_info1[#unit_info1].pos = unit1:getPosition().p
end
end
end
for unitset2_ind = 1, #unitset2 do
local unit2 = Unit.getByName(unitset2[unitset2_ind])
local lCat = Object.getCategory(unit2)
if unit2 and ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info2[#unit_info2 + 1] = {}
unit_info2[#unit_info2].unit = unit2
unit_info2[#unit_info2].pos = unit2:getPosition().p
if unit2 then
local lCat = Object.getCategory(unit2)
if ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit2:isExist() == true then
unit_info2[#unit_info2 + 1] = {}
unit_info2[#unit_info2].unit = unit2
unit_info2[#unit_info2].pos = unit2:getPosition().p
end
end
end
@@ -4010,13 +4058,14 @@ do -- group functions scope
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
local newGroup = Group.getByName(gpName)
local newData = {}
local newData = mist.utils.deepCopy(dbData)
newData.name = gpName
newData.groupId = tonumber(newGroup:getID())
newData.category = newGroup:getCategory()
newData.groupName = gpName
newData.hidden = dbData.hidden
if newData.category == 2 then
newData.category = 'vehicle'
elseif newData.category == 3 then
@@ -4788,6 +4837,9 @@ do -- group functions scope
highNum = secondNum
end
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
total = math.modf(50/math.abs(highNum - lowNum + 1)) -- make x copies required to be above 50
end
@@ -5191,7 +5243,8 @@ do -- mist.util scope
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
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
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
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')
--trigger.action.outText(errmsg, 10)
end
end
end
--- Write debug data to file.
-- This function requires you to disable script sanitization
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
@@ -7651,7 +7704,10 @@ do
--log:warn(s)
if type(s) == 'table' then
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
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
elseif markScope == 'group' then
@@ -7709,10 +7765,15 @@ do
local function validateColor(val)
if type(val) == 'table' then
for i = 1, #val do
if type(val[i]) == 'number' and val[i] > 1 then
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
end
for i = 1, 4 do
if val[i] then
if type(val[i]) == 'number' and val[i] > 1 then
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
elseif type(val) == 'string' then
val = mist.utils.hexToRGB(val)
@@ -7753,7 +7814,7 @@ do
--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}
if e.unit then
mist.DBs.markList[e.idx].unit = e.intiator:getName()
mist.DBs.markList[e.idx].unit = e.initiator:getName()
end
--log:info(mist.marker.list[e.idx])
end
@@ -7776,7 +7837,7 @@ do
else
for mEntry, mData in pairs(mist.DBs.markList) do
if id == mData.name or id == mData.id then
return mData.id
return mData.markId
end
end
end
@@ -7786,11 +7847,16 @@ do
local function removeMark(id)
--log:info("Removing Mark: $1", id
--log:info("Removing Mark: $1", id)
local removed = false
if type(id) == 'table' then
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
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
@@ -7800,9 +7866,11 @@ do
else
local r = getMarkId(id)
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
if r then
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
end
end
return removed
end
@@ -7924,6 +7992,7 @@ do
if markForCoa then
if type(markForCoa) == 'string' then
--log:warn("coa is string")
if tonumber(markForCoa) then
coa = coas[tonumber(markForCoa)]
markScope = 'coa'
@@ -7938,11 +8007,10 @@ do
end
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
coa = markForCoa
markScore = 'coa'
--log:warn("coa is number")
markScope = 'coa'
end
markFor = coa
elseif markFor then
if type(markFor) == 'number' then -- groupId
if mist.DBs.groupsById[markFor] then
@@ -8051,7 +8119,7 @@ do
end
for i = 1, #markForTable do
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
table.insert(list, data)
@@ -8175,6 +8243,7 @@ do
end
function mist.marker.remove(id)
return removeMark(id)
end
@@ -8706,6 +8775,13 @@ do -- group tasks scope
return
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)
local vars = {}
@@ -8965,8 +9041,8 @@ do -- group tasks scope
minR = mist.utils.get2DDist(avg, zone[i])
end
end
--log:warn('Radius: $1', radius)
--log:warn('minR: $1', minR)
--log:warn('Radius: $1', radius)
local lSpawnPos = {}
for j = 1, 100 do
newCoord = mist.getRandPointInCircle(avg, radius)
@@ -9198,7 +9274,7 @@ do -- group tasks scope
function mist.groupIsDead(groupName) -- copy more or less from on station
local gp = Group.getByName(groupName)
if gp then
if #gp:getUnits() > 0 or gp:isExist() == true then
if #gp:getUnits() > 0 and gp:isExist() == true then
return false
end
end
+210 -134
View File
@@ -35,7 +35,7 @@ mist = {}
-- don't change these
mist.majorVersion = 4
mist.minorVersion = 5
mist.build = 121
mist.build = 128
-- forward declaration of log shorthand
local log
@@ -97,57 +97,6 @@ do -- the main scope
mist.DBs.missionData.countries = {}
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.drawingIndexed = {}
@@ -746,7 +695,6 @@ do -- the main scope
["FARP"] = "farps",
["Fueltank"] = "fueltank_cargo",
["Gate"] = "gate",
["FARP Fuel Depot"] = "gsm rus",
["Armed house"] = "home1_a",
["FARP Command Post"] = "kp-ug",
["Watch Tower Armed"] = "ohr-vyshka",
@@ -755,7 +703,6 @@ do -- the main scope
["Pipes big"] = "pipes_big_cargo",
["Oil platform"] = "plavbaza",
["Tetrapod"] = "tetrapod_cargo",
["Fuel tank"] = "toplivo",
["Trunks long"] = "trunks_long_cargo",
["Trunks small"] = "trunks_small_cargo",
["Passenger liner"] = "yastrebow",
@@ -842,6 +789,59 @@ do -- the main scope
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
mist.DBs.MEunits = mist.utils.deepCopy(mist.DBs.units)
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].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
@@ -1092,7 +1098,11 @@ do -- the main scope
mistAddedObjects[index] = nil
end
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"
end
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
--dbLog:warn(newTable)
--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
--mist.debug.dumpDBs()
--end
--dbLog:warn(newTable)
--dbLog:info('endDbUpdate')
return newTable
end
@@ -1245,8 +1257,12 @@ do -- the main scope
if stillExists == true and (updated == true or not mist.DBs.groupsByName[name]) then
--dbLog:info('Get Table')
local dbData = dbUpdate(name, gData.type, staticGroupName)
if dbData and type(dbData) == 'table' then
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
if dbData and type(dbData) == 'table' then
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
-- Work done, so remove
@@ -1266,6 +1282,11 @@ do -- the main scope
--dbLog:info(newTable)
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
dbLog:warn("Failed to add to database: $1. Stopped at state: $2", newTable.name, updateChecker[newTable.name])
return false
@@ -1341,6 +1362,13 @@ do -- the main scope
--dbLog:info('byId')
mist.DBs.unitsById[tonumber(newUnitData.unitId)] = ldeepCopy(newUnitData)
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)
end
-- 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')
mist.DBs.dynGroupsAdded[#mist.DBs.dynGroupsAdded + 1] = ldeepCopy(newTable)
--dbLog:info('clear entry')
updateChecker[newTable.name] = nil
--dbLog:info('return')
return true
@@ -1412,7 +1443,8 @@ do -- the main scope
if i > 0 then
--dbLog:info('updateDBTables: $1', #writeGroups)
for x = 1, i do
for x = i, 1, -1 do
--dbLog:info(x)
local res = writeDBTables(writeGroups[x])
if res and res == true then
--dbLog:info('result: complete')
@@ -1422,6 +1454,7 @@ do -- the main scope
end
end
if x%savesPerRun == 0 then
--dbLog:info("yield")
coroutine.yield()
end
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
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')
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())
local g = Unit.getGroup(event.initiator)
if not tempSpawnedGroups[g:getName()] then
--log:info('added')
tempSpawnedGroups[g:getName()] = {type = 'group', gp = g}
local gName = g:getName()
if not tempSpawnedGroups[gName] then
--log:warn('addedTo tempSpawnedGroups: $1', gName)
tempSpawnedGroups[gName] = {type = 'group', gp = g}
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
end
else
@@ -1491,7 +1525,7 @@ do -- the main scope
task.t = timer.getTime() + task.rep --schedule next run
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
if not err then
log:error('Error in scheduled function: $1' .. errmsg)
log:error('Error in scheduled function: $1', errmsg)
end
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
i = i + 1
@@ -1517,53 +1551,63 @@ do -- the main scope
id = tostring(original_id) .. ' #' .. tostring(id_ind)
id_ind = id_ind + 1
end
local valid
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
--log:info('object found in alive_units')
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
local pos = Object.getPosition(val.object)
if pos then
val.objectPos = pos.p
if Object.isExist(val.object) then
local pos = Object.getPosition(val.object)
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
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
--log:info('object found in old_alive_units')
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
local pos = Object.getPosition(val.object)
if pos then
val.objectPos = pos.p
if Object.isExist(val.object) then
local pos = Object.getPosition(val.object)
if pos then
val.objectPos = pos.p
end
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
valid = true
end
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
else --attempt to determine if static object...
--log:info('object not found in alive units or old alive units')
local pos = Object.getPosition(val.object)
if pos then
local static_found = false
for ind, static in pairs(mist.DBs.unitsByCat.static) do
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...
--log:info('correlated dead static object to position')
val.objectData = static
val.objectPos = pos.p
val.objectType = 'static'
static_found = true
break
if Object.isExist(val.object) then
local pos = Object.getPosition(val.object)
if pos then
local static_found = false
for ind, static in pairs(mist.DBs.unitsByCat.static) do
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...
--log:info('correlated dead static object to position')
val.objectData = static
val.objectPos = pos.p
val.objectType = 'static'
static_found = true
break
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
if not static_found then
val.objectPos = pos.p
val.objectType = 'building'
val.typeName = Object.getTypeName(val.object)
end
else
val.objectType = 'unknown'
valid = true
end
end
mist.DBs.deadObjects[id] = val
if valid then
mist.DBs.deadObjects[id] = val
end
end
end
end
@@ -1733,7 +1777,7 @@ do -- the main scope
function mist.dynAddStatic(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
for entry, val in pairs(newObj.units[1]) do
if newObj[entry] and newObj[entry] ~= val or not newObj[entry] then
@@ -2017,7 +2061,7 @@ do -- the main scope
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)
-- sanitize table
newGroup.groupName = nil
@@ -3558,7 +3602,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty
end
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
local unit_info1 = {}
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.
for unitset1_ind = 1, #unitset1 do
local unit1 = Unit.getByName(unitset1[unitset1_ind])
local lCat = Object.getCategory(unit1)
if unit1 and ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info1[#unit_info1 + 1] = {}
unit_info1[#unit_info1].unit = unit1
unit_info1[#unit_info1].pos = unit1:getPosition().p
if unit1 then
local lCat = Object.getCategory(unit1)
if ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit1:isExist() == true then
unit_info1[#unit_info1 + 1] = {}
unit_info1[#unit_info1].unit = unit1
unit_info1[#unit_info1].pos = unit1:getPosition().p
end
end
end
for unitset2_ind = 1, #unitset2 do
local unit2 = Unit.getByName(unitset2[unitset2_ind])
local lCat = Object.getCategory(unit2)
if unit2 and ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit:isExist() == true then
unit_info2[#unit_info2 + 1] = {}
unit_info2[#unit_info2].unit = unit2
unit_info2[#unit_info2].pos = unit2:getPosition().p
if unit2 then
local lCat = Object.getCategory(unit2)
if ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit2:isExist() == true then
unit_info2[#unit_info2 + 1] = {}
unit_info2[#unit_info2].unit = unit2
unit_info2[#unit_info2].pos = unit2:getPosition().p
end
end
end
@@ -4010,13 +4058,14 @@ do -- group functions scope
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
local newGroup = Group.getByName(gpName)
local newData = {}
local newData = mist.utils.deepCopy(dbData)
newData.name = gpName
newData.groupId = tonumber(newGroup:getID())
newData.category = newGroup:getCategory()
newData.groupName = gpName
newData.hidden = dbData.hidden
if newData.category == 2 then
newData.category = 'vehicle'
elseif newData.category == 3 then
@@ -4788,6 +4837,9 @@ do -- group functions scope
highNum = secondNum
end
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
total = math.modf(50/math.abs(highNum - lowNum + 1)) -- make x copies required to be above 50
end
@@ -5191,7 +5243,8 @@ do -- mist.util scope
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
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
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
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')
--trigger.action.outText(errmsg, 10)
end
end
end
--- Write debug data to file.
-- This function requires you to disable script sanitization
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
@@ -7651,7 +7704,10 @@ do
--log:warn(s)
if type(s) == 'table' then
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
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
elseif markScope == 'group' then
@@ -7709,10 +7765,15 @@ do
local function validateColor(val)
if type(val) == 'table' then
for i = 1, #val do
if type(val[i]) == 'number' and val[i] > 1 then
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
end
for i = 1, 4 do
if val[i] then
if type(val[i]) == 'number' and val[i] > 1 then
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
elseif type(val) == 'string' then
val = mist.utils.hexToRGB(val)
@@ -7753,7 +7814,7 @@ do
--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}
if e.unit then
mist.DBs.markList[e.idx].unit = e.intiator:getName()
mist.DBs.markList[e.idx].unit = e.initiator:getName()
end
--log:info(mist.marker.list[e.idx])
end
@@ -7776,7 +7837,7 @@ do
else
for mEntry, mData in pairs(mist.DBs.markList) do
if id == mData.name or id == mData.id then
return mData.id
return mData.markId
end
end
end
@@ -7786,11 +7847,16 @@ do
local function removeMark(id)
--log:info("Removing Mark: $1", id
--log:info("Removing Mark: $1", id)
local removed = false
if type(id) == 'table' then
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
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
@@ -7800,9 +7866,11 @@ do
else
local r = getMarkId(id)
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
if r then
trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true
end
end
return removed
end
@@ -7924,6 +7992,7 @@ do
if markForCoa then
if type(markForCoa) == 'string' then
--log:warn("coa is string")
if tonumber(markForCoa) then
coa = coas[tonumber(markForCoa)]
markScope = 'coa'
@@ -7938,11 +8007,10 @@ do
end
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
coa = markForCoa
markScore = 'coa'
--log:warn("coa is number")
markScope = 'coa'
end
markFor = coa
elseif markFor then
if type(markFor) == 'number' then -- groupId
if mist.DBs.groupsById[markFor] then
@@ -8051,7 +8119,7 @@ do
end
for i = 1, #markForTable do
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
table.insert(list, data)
@@ -8175,6 +8243,7 @@ do
end
function mist.marker.remove(id)
return removeMark(id)
end
@@ -8706,6 +8775,13 @@ do -- group tasks scope
return
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)
local vars = {}
@@ -8965,8 +9041,8 @@ do -- group tasks scope
minR = mist.utils.get2DDist(avg, zone[i])
end
end
--log:warn('Radius: $1', radius)
--log:warn('minR: $1', minR)
--log:warn('Radius: $1', radius)
local lSpawnPos = {}
for j = 1, 100 do
newCoord = mist.getRandPointInCircle(avg, radius)
@@ -9198,7 +9274,7 @@ do -- group tasks scope
function mist.groupIsDead(groupName) -- copy more or less from on station
local gp = Group.getByName(groupName)
if gp then
if #gp:getUnits() > 0 or gp:isExist() == true then
if #gp:getUnits() > 0 and gp:isExist() == true then
return false
end
end