mirror of
https://github.com/mrSkortch/MissionScriptingTools.git
synced 2026-07-19 10:17:18 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da53d53087 | |||
| a6e14558a2 | |||
| b5d905fd6e | |||
| 94629d2cfd | |||
| 4922d756d5 | |||
| 67f2c5f983 | |||
| 9c3c67817b | |||
| debded08f4 | |||
| 52555f73f7 | |||
| effa8eb5b1 | |||
| b5c7b16500 | |||
| de420ca158 | |||
| 240b8a3abb |
@@ -35,7 +35,7 @@ mist = {}
|
||||
-- don't change these
|
||||
mist.majorVersion = 4
|
||||
mist.minorVersion = 5
|
||||
mist.build = 128
|
||||
mist.build = 126
|
||||
|
||||
-- forward declaration of log shorthand
|
||||
local log
|
||||
@@ -1072,12 +1072,6 @@ 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
|
||||
@@ -1098,11 +1092,7 @@ do -- the main scope
|
||||
mistAddedObjects[index] = nil
|
||||
end
|
||||
if found == false then
|
||||
if newTable.dynamicSlot then
|
||||
newTable.units[unitId].skill = "Client"
|
||||
else
|
||||
newTable.units[unitId].skill = "High"
|
||||
end
|
||||
newTable.units[unitId].skill = "High"
|
||||
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
|
||||
@@ -1165,7 +1155,6 @@ do -- the main scope
|
||||
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
|
||||
@@ -1257,12 +1246,8 @@ 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
|
||||
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
|
||||
if dbData and type(dbData) == 'table' then
|
||||
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
|
||||
end
|
||||
end
|
||||
-- Work done, so remove
|
||||
@@ -1282,11 +1267,6 @@ 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
|
||||
@@ -1362,13 +1342,6 @@ 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
|
||||
@@ -1411,9 +1384,6 @@ 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
|
||||
@@ -1443,8 +1413,7 @@ do -- the main scope
|
||||
if i > 0 then
|
||||
--dbLog:info('updateDBTables: $1', #writeGroups)
|
||||
|
||||
for x = i, 1, -1 do
|
||||
--dbLog:info(x)
|
||||
for x = 1, i do
|
||||
local res = writeDBTables(writeGroups[x])
|
||||
if res and res == true then
|
||||
--dbLog:info('result: complete')
|
||||
@@ -1454,7 +1423,6 @@ do -- the main scope
|
||||
end
|
||||
end
|
||||
if x%savesPerRun == 0 then
|
||||
--dbLog:info("yield")
|
||||
coroutine.yield()
|
||||
end
|
||||
if timer.getTime() > lastUpdateTime then
|
||||
@@ -1469,15 +1437,14 @@ 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 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
|
||||
--log:info('Object is a Unit')
|
||||
local g = Unit.getGroup(event.initiator)
|
||||
if g and event.initiator:getPlayerName() ~= "" and not mist.DBs.MEunitsByName[event.initiator:getName()] then
|
||||
if Unit.getGroup(event.initiator) then
|
||||
-- log:info(Unit.getGroup(event.initiator):getName())
|
||||
local gName = g:getName()
|
||||
if not tempSpawnedGroups[gName] then
|
||||
--log:warn('addedTo tempSpawnedGroups: $1', gName)
|
||||
tempSpawnedGroups[gName] = {type = 'group', gp = g}
|
||||
local g = Unit.getGroup(event.initiator)
|
||||
if not tempSpawnedGroups[g:getName()] then
|
||||
--log:info('added')
|
||||
tempSpawnedGroups[g:getName()] = {type = 'group', gp = g}
|
||||
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
||||
end
|
||||
else
|
||||
@@ -1555,29 +1522,25 @@ do -- the main scope
|
||||
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_])
|
||||
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
|
||||
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
|
||||
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_])
|
||||
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
|
||||
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
|
||||
else --attempt to determine if static object...
|
||||
--log:info('object not found in alive units or old alive units')
|
||||
if Object.isExist(val.object) then
|
||||
@@ -1777,7 +1740,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
|
||||
@@ -4837,9 +4800,6 @@ 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
|
||||
@@ -5243,7 +5203,7 @@ do -- mist.util scope
|
||||
|
||||
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
||||
if north then
|
||||
local p1 = mist.utils.makeVec3(point1)
|
||||
local p1 = mist.utils.get3DDist(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)))
|
||||
@@ -7852,7 +7812,7 @@ do
|
||||
if type(id) == 'table' then
|
||||
for ind, val in pairs(id) do
|
||||
local r
|
||||
if type(val) == "table" and val.markId then
|
||||
if val.markId then
|
||||
r = val.markId
|
||||
else
|
||||
r = getMarkId(val)
|
||||
@@ -8775,13 +8735,6 @@ 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 = {}
|
||||
|
||||
@@ -35,7 +35,7 @@ mist = {}
|
||||
-- don't change these
|
||||
mist.majorVersion = 4
|
||||
mist.minorVersion = 5
|
||||
mist.build = 128
|
||||
mist.build = 125
|
||||
|
||||
-- forward declaration of log shorthand
|
||||
local log
|
||||
@@ -1072,12 +1072,6 @@ 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
|
||||
@@ -1098,11 +1092,7 @@ do -- the main scope
|
||||
mistAddedObjects[index] = nil
|
||||
end
|
||||
if found == false then
|
||||
if newTable.dynamicSlot then
|
||||
newTable.units[unitId].skill = "Client"
|
||||
else
|
||||
newTable.units[unitId].skill = "High"
|
||||
end
|
||||
newTable.units[unitId].skill = "High"
|
||||
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
|
||||
@@ -1165,7 +1155,6 @@ do -- the main scope
|
||||
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
|
||||
@@ -1257,12 +1246,8 @@ 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
|
||||
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
|
||||
if dbData and type(dbData) == 'table' then
|
||||
writeGroups[#writeGroups+1] = {data = dbData, isUpdated = updated}
|
||||
end
|
||||
end
|
||||
-- Work done, so remove
|
||||
@@ -1282,11 +1267,6 @@ 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
|
||||
@@ -1362,13 +1342,6 @@ 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
|
||||
@@ -1411,9 +1384,6 @@ 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
|
||||
@@ -1443,8 +1413,7 @@ do -- the main scope
|
||||
if i > 0 then
|
||||
--dbLog:info('updateDBTables: $1', #writeGroups)
|
||||
|
||||
for x = i, 1, -1 do
|
||||
--dbLog:info(x)
|
||||
for x = 1, i do
|
||||
local res = writeDBTables(writeGroups[x])
|
||||
if res and res == true then
|
||||
--dbLog:info('result: complete')
|
||||
@@ -1454,7 +1423,6 @@ do -- the main scope
|
||||
end
|
||||
end
|
||||
if x%savesPerRun == 0 then
|
||||
--dbLog:info("yield")
|
||||
coroutine.yield()
|
||||
end
|
||||
if timer.getTime() > lastUpdateTime then
|
||||
@@ -1469,15 +1437,14 @@ 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 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
|
||||
--log:info('Object is a Unit')
|
||||
local g = Unit.getGroup(event.initiator)
|
||||
if g and event.initiator:getPlayerName() ~= "" and not mist.DBs.MEunitsByName[event.initiator:getName()] then
|
||||
if Unit.getGroup(event.initiator) then
|
||||
-- log:info(Unit.getGroup(event.initiator):getName())
|
||||
local gName = g:getName()
|
||||
if not tempSpawnedGroups[gName] then
|
||||
--log:warn('addedTo tempSpawnedGroups: $1', gName)
|
||||
tempSpawnedGroups[gName] = {type = 'group', gp = g}
|
||||
local g = Unit.getGroup(event.initiator)
|
||||
if not tempSpawnedGroups[g:getName()] then
|
||||
--log:info('added')
|
||||
tempSpawnedGroups[g:getName()] = {type = 'group', gp = g}
|
||||
tempSpawnGroupsCounter = tempSpawnGroupsCounter + 1
|
||||
end
|
||||
else
|
||||
@@ -1555,29 +1522,25 @@ do -- the main scope
|
||||
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_])
|
||||
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
|
||||
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
|
||||
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_])
|
||||
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
|
||||
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
|
||||
else --attempt to determine if static object...
|
||||
--log:info('object not found in alive units or old alive units')
|
||||
if Object.isExist(val.object) then
|
||||
@@ -1777,7 +1740,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
|
||||
@@ -4837,9 +4800,6 @@ 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
|
||||
@@ -5243,7 +5203,7 @@ do -- mist.util scope
|
||||
|
||||
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
||||
if north then
|
||||
local p1 = mist.utils.makeVec3(point1)
|
||||
local p1 = mist.utils.get3DDist(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)))
|
||||
@@ -7852,7 +7812,7 @@ do
|
||||
if type(id) == 'table' then
|
||||
for ind, val in pairs(id) do
|
||||
local r
|
||||
if type(val) == "table" and val.markId then
|
||||
if val.markId then
|
||||
r = val.markId
|
||||
else
|
||||
r = getMarkId(val)
|
||||
@@ -8775,13 +8735,6 @@ 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 = {}
|
||||
Reference in New Issue
Block a user