mirror of
https://github.com/weyne85/MIST.git
synced 2025-10-29 16:56:32 +00:00
commit
4e8b70ce73
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -27,3 +27,4 @@
|
||||
.gitignore export-ignore
|
||||
README.md export-ignore
|
||||
mist_doc_file.doc export-ignore
|
||||
mist.lua export-ignore
|
||||
|
||||
BIN
Mist guide.pdf
BIN
Mist guide.pdf
Binary file not shown.
331
mist.lua
331
mist.lua
@ -7,8 +7,8 @@ mist = {}
|
||||
|
||||
-- don't change these
|
||||
mist.majorVersion = 3
|
||||
mist.minorVersion = 5
|
||||
mist.build = 37
|
||||
mist.minorVersion = 6
|
||||
mist.build = 42
|
||||
|
||||
|
||||
|
||||
@ -160,7 +160,8 @@ do
|
||||
newTable.units[unitId].point.x = newTable.units[unitId].x
|
||||
newTable.units[unitId].point.y = newTable.units[unitId].y
|
||||
newTable.units[unitId].alt = mist.utils.round(unitData:getPosition().p.y)
|
||||
|
||||
newTable.units[unitId].speed = mist.vec.mag(unitData:getVelocity())
|
||||
|
||||
newTable.units[unitId].heading = mist.getHeading(unitData, true)
|
||||
|
||||
newTable.units[unitId].type = unitData:getTypeName()
|
||||
@ -650,7 +651,7 @@ do
|
||||
end
|
||||
|
||||
if newCat == 'AIRPLANE' or newCat == 'HELICOPTER' then
|
||||
if (newGroup.units[unitIndex].alt_type ~= 'RADIO' or newGroup.units[unitIndex].alt_type ~= 'BARO') or not newGroup.units[unitIndex].alt_type then
|
||||
if newGroup.units[unitIndex].alt_type and newGroup.units[unitIndex].alt_type ~= 'BARO' or not newGroup.units[unitIndex].alt_type then
|
||||
newGroup.units[unitIndex].alt_type = 'RADIO'
|
||||
end
|
||||
if not unitData.speed then
|
||||
@ -678,6 +679,7 @@ do
|
||||
newGroup.country = newCountry
|
||||
|
||||
|
||||
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, 'newGroup.lua')
|
||||
|
||||
-- sanitize table
|
||||
newGroup.groupName = nil
|
||||
@ -1235,7 +1237,7 @@ mist.utils.tableShow = function(tbl, loc, indent, tableshow_tbls) --based on ser
|
||||
end
|
||||
elseif type(val) == 'function' then
|
||||
if debug and debug.getinfo then
|
||||
fcnname = tostring(val)
|
||||
local fcnname = tostring(val)
|
||||
local info = debug.getinfo(val, "S")
|
||||
if info.what == "C" then
|
||||
tbl_str[#tbl_str + 1] = string.format('%q', fcnname .. ', C function') .. ',\n'
|
||||
@ -1478,7 +1480,7 @@ mist.getNorthCorrection = function(point) --gets the correction needed for true
|
||||
end
|
||||
|
||||
mist.getUnitSkill = function(unitName)
|
||||
if Unit.getByName(unitName) then
|
||||
if Unit.getByName(unitName) and Unit.getByName(unitName):isExist() == true then
|
||||
local lunit = Unit.getByName(unitName)
|
||||
for name, data in pairs(mist.DBs.unitsByName) do
|
||||
if name == unitName and data.type == lunit:getTypeName() and data.unitId == lunit:getID() and data.skill then
|
||||
@ -1489,7 +1491,14 @@ mist.getUnitSkill = function(unitName)
|
||||
return false
|
||||
end
|
||||
|
||||
function mist.getGroupPoints(groupname) -- if groupname exists in env.mission, then returns table of the group's points in numerical order, such as: { [1] = {x = 299435.224, y = -1146632.6773}, [2] = { x = 663324.6563, y = 322424.1112}}
|
||||
|
||||
function mist.getGroupPoints(groupIdent) -- if groupname exists in env.mission, then returns table of the group's points in numerical order, such as: { [1] = {x = 299435.224, y = -1146632.6773}, [2] = { x = 663324.6563, y = 322424.1112}}
|
||||
-- refactor to search by groupId and allow groupId and groupName as inputs
|
||||
local gpId = groupIdent
|
||||
if type(groupIdent) == 'string' and not tonumber(groupIdent) then
|
||||
gpId = mist.DBs.MEgroupsByName[groupIdent].groupId
|
||||
end
|
||||
|
||||
for coa_name, coa_data in pairs(env.mission.coalition) do
|
||||
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
|
||||
if coa_data.country then --there is a country table
|
||||
@ -1498,7 +1507,7 @@ function mist.getGroupPoints(groupname) -- if groupname exists in env.mission,
|
||||
if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" then -- only these types have points
|
||||
if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then --there's a group!
|
||||
for group_num, group_data in pairs(obj_type_data.group) do
|
||||
if group_data and group_data.name and mist.stringMatch(group_data.name, groupname) then -- this is the group we are looking for
|
||||
if group_data and group_data.groupId == gpId then -- this is the group we are looking for
|
||||
if group_data.route and group_data.route.points and #group_data.route.points > 0 then
|
||||
local points = {}
|
||||
for point_num, point in pairs(group_data.route.points) do
|
||||
@ -1974,7 +1983,7 @@ mist.DBs.MEunitsById = mist.utils.deepCopy(mist.DBs.unitsById)
|
||||
mist.DBs.MEunitsByCat = mist.utils.deepCopy(mist.DBs.unitsByCat)
|
||||
mist.DBs.MEunitsByNum = mist.utils.deepCopy(mist.DBs.unitsByNum)
|
||||
mist.DBs.MEgroupsByName = mist.utils.deepCopy(mist.DBs.groupsByName)
|
||||
mist.DBs.MEgroupsById = mist.utils.deepCopy(mist.DBs.groupsByID)
|
||||
mist.DBs.MEgroupsById = mist.utils.deepCopy(mist.DBs.groupsById)
|
||||
-------------
|
||||
|
||||
|
||||
@ -2569,7 +2578,7 @@ initial_number
|
||||
end
|
||||
|
||||
if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then
|
||||
if (#mist.getDeadMapObjsInZones(zones) - initial_number) >= req_num then
|
||||
if (#mist.getDeadMapObjsInZones(zones) - initial_number) >= req_num and trigger.misc.getUserFlag(flag) == false then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
return
|
||||
else
|
||||
@ -2612,7 +2621,7 @@ initial_number
|
||||
end
|
||||
|
||||
if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then
|
||||
if (#mist.getDeadMapObjsInPolygonZone(zone) - initial_number) >= req_num then
|
||||
if (#mist.getDeadMapObjsInPolygonZone(zone) - initial_number) >= req_num and trigger.misc.getUserFlag(flag) == false then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
return
|
||||
else
|
||||
@ -2726,7 +2735,7 @@ toggle = boolean or nil
|
||||
local pos = unit:getPosition().p
|
||||
if mist.pointInPolygon(pos, zone, maxalt) then
|
||||
num_in_zone = num_in_zone + 1
|
||||
if num_in_zone >= req_num then
|
||||
if num_in_zone >= req_num and trigger.misc.getUserFlag(flag) == false then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
break
|
||||
end
|
||||
@ -2846,7 +2855,7 @@ function mist.flagFunc.units_in_zones(vars)
|
||||
|
||||
local in_zone_units = mist.getUnitsInZones(units, zones, zone_type)
|
||||
|
||||
if #in_zone_units >= req_num then
|
||||
if #in_zone_units >= req_num and trigger.misc.getUserFlag(flag) == false then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
elseif #in_zone_units < req_num and toggle then
|
||||
trigger.action.setUserFlag(flag, false)
|
||||
@ -2960,7 +2969,7 @@ function mist.flagFunc.units_in_moving_zones(vars)
|
||||
|
||||
local in_zone_units = mist.getUnitsInMovingZones(units, zone_units, radius, zone_type)
|
||||
|
||||
if #in_zone_units >= req_num then
|
||||
if #in_zone_units >= req_num and trigger.misc.getUserFlag(flag) == false then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
elseif #in_zone_units < req_num and toggle then
|
||||
trigger.action.setUserFlag(flag, false)
|
||||
@ -3078,7 +3087,7 @@ toggle = boolean or nil
|
||||
|
||||
local unitLOSdata = mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
||||
|
||||
if #unitLOSdata >= req_num then
|
||||
if #unitLOSdata >= req_num and trigger.misc.getUserFlag(flag) == false then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
elseif #unitLOSdata < req_num and toggle then
|
||||
trigger.action.setUserFlag(flag, false)
|
||||
@ -3118,7 +3127,7 @@ stopFlag
|
||||
|
||||
|
||||
if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isActive() then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then
|
||||
if trigger.misc.getUserFlag(flag) == 0 then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
end
|
||||
@ -3155,7 +3164,7 @@ mist.flagFunc.group_dead = function(vars)
|
||||
|
||||
|
||||
if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then
|
||||
if not Group.getByName(groupName) then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == false or not Group.getByName(groupName) then
|
||||
if trigger.misc.getUserFlag(flag) == 0 then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
end
|
||||
@ -3193,7 +3202,7 @@ mist.flagFunc.group_alive_less_than = function(vars)
|
||||
|
||||
|
||||
if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isActive() then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then
|
||||
if Group.getByName(groupName):getSize()/Group.getByName(groupName):getInitialSize() < percent/100 then
|
||||
if trigger.misc.getUserFlag(flag) == 0 then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
@ -3237,7 +3246,7 @@ mist.flagFunc.group_alive_more_than = function(vars)
|
||||
|
||||
|
||||
if stopflag == -1 or (type(trigger.misc.getUserFlag(stopflag)) == 'number' and trigger.misc.getUserFlag(stopflag) == 0) or (type(trigger.misc.getUserFlag(stopflag)) == 'boolean' and trigger.misc.getUserFlag(stopflag) == false) then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isActive() then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then
|
||||
if Group.getByName(groupName):getSize()/Group.getByName(groupName):getInitialSize() > percent/100 then
|
||||
if trigger.misc.getUserFlag(flag) == 0 then
|
||||
trigger.action.setUserFlag(flag, true)
|
||||
@ -3267,7 +3276,7 @@ mist.getAvgPos = function(unitNames)
|
||||
for i = 1, #unitNames do
|
||||
local unit = Unit.getByName(unitNames[i])
|
||||
if unit then
|
||||
oneUnit = true -- at least one unit existed.
|
||||
|
||||
local pos = unit:getPosition().p
|
||||
avgX = avgX + pos.x
|
||||
avgY = avgY + pos.y
|
||||
@ -3281,7 +3290,7 @@ mist.getAvgPos = function(unitNames)
|
||||
end
|
||||
|
||||
mist.getAvgGroupPos = function(groupName)
|
||||
if type(groupName) == 'string' and Group.getByName(groupName) then
|
||||
if type(groupName) == 'string' and Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then
|
||||
groupName = Group.getByName(groupName)
|
||||
end
|
||||
local units = {}
|
||||
@ -3360,9 +3369,9 @@ mist.demos.printFlightData = function(unit)
|
||||
local axialGs = 'NA'
|
||||
local transGs = 'NA'
|
||||
if prevVel and prevTime then
|
||||
xAcc = (unitVel.x - prevVel.x)/(curTime - prevTime)
|
||||
yAcc = (unitVel.y - prevVel.y)/(curTime - prevTime)
|
||||
zAcc = (unitVel.z - prevVel.z)/(curTime - prevTime)
|
||||
local xAcc = (unitVel.x - prevVel.x)/(curTime - prevTime)
|
||||
local yAcc = (unitVel.y - prevVel.y)/(curTime - prevTime)
|
||||
local zAcc = (unitVel.z - prevVel.z)/(curTime - prevTime)
|
||||
|
||||
unitAcc = string.format('%12.2f', mist.vec.mag({x = xAcc, y = yAcc, z = zAcc}))
|
||||
Gs = string.format('%12.2f', mist.vec.mag({x = xAcc, y = yAcc + 9.81, z = zAcc})/9.81)
|
||||
@ -3441,7 +3450,13 @@ mist.goRoute = function(group, path)
|
||||
return false
|
||||
end
|
||||
|
||||
function mist.getGroupRoute(groupname, task) -- same as getGroupPoints but returns speed and formation type along with vec2 of point}
|
||||
function mist.getGroupRoute(groupIdent, task) -- same as getGroupPoints but returns speed and formation type along with vec2 of point}
|
||||
-- refactor to search by groupId and allow groupId and groupName as inputs
|
||||
local gpId = groupIdent
|
||||
if type(groupIdent) == 'string' and not tonumber(groupIdent) then
|
||||
gpId = mist.DBs.MEgroupsByName[groupIdent].groupId
|
||||
end
|
||||
|
||||
for coa_name, coa_data in pairs(env.mission.coalition) do
|
||||
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
|
||||
if coa_data.country then --there is a country table
|
||||
@ -3450,7 +3465,7 @@ function mist.getGroupRoute(groupname, task) -- same as getGroupPoints but ret
|
||||
if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" then -- only these types have points
|
||||
if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then --there's a group!
|
||||
for group_num, group_data in pairs(obj_type_data.group) do
|
||||
if group_data and group_data.name and mist.stringMatch(group_data.name, groupname) then -- this is the group we are looking for
|
||||
if group_data and group_data.groupId == gpId then -- this is the group we are looking for
|
||||
if group_data.route and group_data.route.points and #group_data.route.points > 0 then
|
||||
local points = {}
|
||||
|
||||
@ -3706,6 +3721,13 @@ function mist.getRandPointInCircle(point, radius, innerRadius)
|
||||
return rndCoord
|
||||
end
|
||||
|
||||
mist.getRandomPointInZone = function(zoneName, innerRadius)
|
||||
if type(zoneName) == 'string' and type(trigger.misc.getZone(zoneName)) == 'table' then
|
||||
return mist.getRandPointInCircle(trigger.misc.getZone(zoneName).point, trigger.misc.getZone(zoneName).radius, innerRadius)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
mist.groupToRandomPoint = function(vars)
|
||||
local group = vars.group --Required
|
||||
local point = vars.point --required
|
||||
@ -4077,14 +4099,17 @@ do
|
||||
new.messageID = messageID
|
||||
|
||||
--mist.debug.writeData(mist.utils.serialize,{'msg', new}, 'newMsg.txt')
|
||||
|
||||
|
||||
messageList[#messageList + 1] = new
|
||||
|
||||
local mt = { __index = mist.message}
|
||||
setmetatable(new, mt)
|
||||
|
||||
|
||||
|
||||
|
||||
if #messageList == 0 then
|
||||
--displayManager()
|
||||
end
|
||||
|
||||
return messageID
|
||||
|
||||
end,
|
||||
@ -4254,7 +4279,118 @@ do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function mistdisplayV4()
|
||||
-- goal of v4, send new messages only if message has changed, rather than at a constant rate
|
||||
-- make process more effecient!
|
||||
-- possibly change messages for CA players
|
||||
|
||||
local caMessageRed = false
|
||||
local caMessageBlue = false
|
||||
local audioRed = false
|
||||
local audioBlue = false
|
||||
local audioPlaying = false
|
||||
|
||||
if #messageList > 0 then
|
||||
--mist.debug.writeData(mist.utils.serialize,{'msg', messageList}, 'messageList.lua')
|
||||
for messageId, messageData in pairs(messageList) do
|
||||
if messageData.displayedFor > messageData.displayTime then
|
||||
--mistMSGDestroy(messageData)
|
||||
messageData:remove() -- now using the remove/destroy function.
|
||||
|
||||
else
|
||||
if messageList[messageId].displayedFor then
|
||||
messageList[messageId].displayedFor = messageList[messageId].displayedFor + messageDisplayRate
|
||||
end
|
||||
--[[else
|
||||
if messageData.fileName then
|
||||
audioPlaying = true
|
||||
end]]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
for coaData, coaId in pairs(coalition.side) do
|
||||
local CAmsg = {}
|
||||
local newestMsg = 100000000
|
||||
|
||||
for messageIndex, messageData in pairs(messageList) do
|
||||
for forIndex, forData in pairs(messageData.msgFor) do
|
||||
|
||||
if coaData == forData then
|
||||
if messageData.addedAt < newestMsg then
|
||||
newestMsg = messageData.addedAt
|
||||
end
|
||||
if messageData.text then
|
||||
CAmsg[#CAmsg + 1] = messageData.text
|
||||
CAmsg[#CAmsg + 1] = '\n ---------------- \n'
|
||||
end
|
||||
if type(messageData.sound) == 'string' and messageData.addedAt + messageDisplayRate > timer.getTime() then
|
||||
if coaData == 'RED' then
|
||||
audioRed = true
|
||||
trigger.action.outSoundForCoalition(coalition.side.RED, messageData.sound)
|
||||
elseif coaData == 'BLUE' then
|
||||
audioBlue = true
|
||||
trigger.action.outSoundForCoalition(coalition.side.BLUE, messageData.sound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #CAmsg > 0 then
|
||||
if newestMsg < timer.getTime() + .5 then
|
||||
if coaData == 'BLUE' then
|
||||
trigger.action.outTextForCoalition(coalition.side.BLUE, table.concat(CAmsg), 1)
|
||||
caMessageBlue = true
|
||||
elseif coaData == 'RED' then
|
||||
trigger.action.outTextForCoalition(coalition.side.RED, table.concat(CAmsg), 1)
|
||||
caMessageRed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for clientId, clientData in pairs(mist.DBs.humansById) do
|
||||
local clientDisplay = {}
|
||||
|
||||
for messageIndex, messageData in pairs(messageList) do
|
||||
for forIndex, forData in pairs(messageData.msgFor) do
|
||||
if clientId == forData and Group.getByName(clientData.groupName) then
|
||||
if messageData.text then
|
||||
clientDisplay[#clientDisplay + 1] = messageData.text
|
||||
clientDisplay[#clientDisplay + 1] = '\n ---------------- \n'
|
||||
end
|
||||
if string.lower(clientData.coalition) == 'red' and audioRed == false or string.lower(clientData.coalition) == 'blue' and audioBlue == false then
|
||||
if type(messageData.sound) == 'string' and messageData.addedAt + messageDisplayRate > timer.getTime() then
|
||||
trigger.action.outSoundForGroup(clientData.groupId, messageData.sound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if #clientDisplay > 0 then
|
||||
trigger.action.outTextForGroup(clientData.groupId, table.concat(clientDisplay), 1)
|
||||
|
||||
elseif #clientDisplay == 0 then
|
||||
if clientData.coalition == 'blue' and caMessageBlue == true then
|
||||
trigger.action.outTextForGroup(clientData.groupId, 'Blue CA Recieving Message', 1) -- I'd rather this recive the message with a note that its for CA than a blank message box.
|
||||
elseif clientData.coalition == 'red' and caMessageRed == true then
|
||||
trigger.action.outTextForGroup(clientData.groupId, 'Red CA Recieving Message', 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
local funcId = 0
|
||||
local function displayManager()
|
||||
if #messageList > 0 and funcId > 0 then
|
||||
mistdisplayV3()
|
||||
funcId = mist.scheduleFunction(displayManager, {}, timer.getTime() + messageDisplayRate, messageDisplayRate)
|
||||
else
|
||||
mist.removeFunction(funcId)-- kill
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
mist.scheduleFunction(mistdisplayV3, {}, timer.getTime() + messageDisplayRate, messageDisplayRate) -- add this to the main mist thing
|
||||
@ -4503,12 +4639,15 @@ mist.msgMGRS = function(vars)
|
||||
|
||||
local s = mist.getMGRSString{units = units, acc = acc}
|
||||
local newText
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
newText = s
|
||||
end
|
||||
|
||||
mist.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
@ -4534,10 +4673,14 @@ mist.msgLL = function(vars)
|
||||
|
||||
local s = mist.getLLString{units = units, acc = acc, DMS = DMS}
|
||||
local newText
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
newText = s
|
||||
end
|
||||
|
||||
mist.message.add{
|
||||
@ -4569,10 +4712,14 @@ mist.msgBR = function(vars)
|
||||
|
||||
local s = mist.getBRString{units = units, ref = ref, alt = alt, metric = metric}
|
||||
local newText
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
newText = s
|
||||
end
|
||||
|
||||
mist.message.add{
|
||||
@ -4616,7 +4763,7 @@ vars.msgFor - scope
|
||||
]]
|
||||
|
||||
mist.msgBRA = function(vars)
|
||||
if Unit.getByName(vars.ref) then
|
||||
if Unit.getByName(vars.ref) and Unit.getByName(vars.ref):isExist() == true then
|
||||
vars.ref = Unit.getByName(vars.ref):getPosition().p
|
||||
if not vars.alt then
|
||||
vars.alt = true
|
||||
@ -4648,10 +4795,14 @@ mist.msgLeadingMGRS = function(vars)
|
||||
|
||||
local s = mist.getLeadingMGRSString{units = units, heading = heading, radius = radius, headingDegrees = headingDegrees, acc = acc}
|
||||
local newText
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
newText = s
|
||||
end
|
||||
|
||||
mist.message.add{
|
||||
@ -4686,10 +4837,15 @@ mist.msgLeadingLL = function(vars)
|
||||
|
||||
local s = mist.getLeadingLLString{units = units, heading = heading, radius = radius, headingDegrees = headingDegrees, acc = acc, DMS = DMS}
|
||||
local newText
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
newText = s
|
||||
end
|
||||
|
||||
mist.message.add{
|
||||
@ -4726,10 +4882,15 @@ mist.msgLeadingBR = function(vars)
|
||||
|
||||
local s = mist.getLeadingBRString{units = units, heading = heading, radius = radius, headingDegrees = headingDegrees, metric = metric, alt = alt, ref = ref}
|
||||
local newText
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
newText = s
|
||||
end
|
||||
|
||||
mist.message.add{
|
||||
@ -4774,7 +4935,7 @@ mist.groupTableCheck = function(groupData)
|
||||
end
|
||||
|
||||
mist.getCurrentGroupData = function(gpName)
|
||||
if Group.getByName(gpName) then
|
||||
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
|
||||
local newGroup = Group.getByName(gpName)
|
||||
local newData = {}
|
||||
newData.name = gpName
|
||||
@ -4870,7 +5031,14 @@ mist.getGroupData = function(gpName)
|
||||
end
|
||||
end
|
||||
|
||||
mist.getPayload = function(unitName)
|
||||
mist.getPayload = function(unitIdent)
|
||||
-- refactor to search by groupId and allow groupId and groupName as inputs
|
||||
local unitId = unitIdent
|
||||
if type(unitIdent) == 'string' and not tonumber(unitIdent) then
|
||||
unitId = mist.DBs.MEunitsById[unitIdent].unitId
|
||||
end
|
||||
local gpId = mist.DBs.MEunitsById[unitId].groupId
|
||||
|
||||
if unitName and type(unitName) == 'string' then
|
||||
for coa_name, coa_data in pairs(env.mission.coalition) do
|
||||
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
|
||||
@ -4880,9 +5048,9 @@ mist.getPayload = function(unitName)
|
||||
if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" then -- only these types have points
|
||||
if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then --there's a group!
|
||||
for group_num, group_data in pairs(obj_type_data.group) do
|
||||
if group_data and group_data.name then
|
||||
if group_data and group_data.groupId == groupId then
|
||||
for unitIndex, unitData in pairs(group_data.units) do --group index
|
||||
if mist.stringMatch(unitName, unitData.name) == true then
|
||||
if unitData.unitId == unitId then
|
||||
return unitData.payload
|
||||
end
|
||||
end
|
||||
@ -4903,8 +5071,13 @@ mist.getPayload = function(unitName)
|
||||
return
|
||||
end
|
||||
|
||||
mist.getGroupPayload = function(groupName)
|
||||
if groupName and type(groupName) == 'string' then
|
||||
mist.getGroupPayload = function(groupIdent)
|
||||
local gpId = groupIdent
|
||||
if type(groupIdent) == 'string' and not tonumber(groupIdent) then
|
||||
gpId = mist.DBs.MEgroupsByName[groupIdent].groupId
|
||||
end
|
||||
|
||||
if gpId then
|
||||
for coa_name, coa_data in pairs(env.mission.coalition) do
|
||||
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
|
||||
if coa_data.country then --there is a country table
|
||||
@ -4913,7 +5086,7 @@ mist.getGroupPayload = function(groupName)
|
||||
if obj_type_name == "helicopter" or obj_type_name == "ship" or obj_type_name == "plane" or obj_type_name == "vehicle" then -- only these types have points
|
||||
if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then --there's a group!
|
||||
for group_num, group_data in pairs(obj_type_data.group) do
|
||||
if group_data and group_data.name and mist.stringMatch(groupName, group_data.name) == true then
|
||||
if group_data and group_data.groupId == gpId then
|
||||
local payloads = {}
|
||||
for unitIndex, unitData in pairs(group_data.units) do --group index
|
||||
payloads[unitIndex] = unitData.payload
|
||||
@ -5009,6 +5182,13 @@ mist.teleportToPoint = function(vars) -- main teleport function that all of tele
|
||||
return false
|
||||
end
|
||||
end
|
||||
if not newGroupData.country and mist.DBs.groupsByName[newGroupData.groupName].country then
|
||||
newGroupData.country = mist.DBs.groupsByName[newGroupData.groupName].country
|
||||
end
|
||||
if not newGroupData.category and mist.DBs.groupsByName[newGroupData.groupName].category then
|
||||
newGroupData.category = mist.DBs.groupsByName[newGroupData.groupName].category
|
||||
end
|
||||
|
||||
for unitNum, unitData in pairs(newGroupData.units) do
|
||||
if disperse then
|
||||
if maxDisp and type(maxDisp) == 'number' and unitNum ~= 1 then
|
||||
@ -5023,15 +5203,19 @@ mist.teleportToPoint = function(vars) -- main teleport function that all of tele
|
||||
newGroupData.units[unitNum]["x"] = unitData.x + diff.x
|
||||
newGroupData.units[unitNum]["y"] = unitData.y + diff.y
|
||||
end
|
||||
if point then
|
||||
if (newGroupData.category == 'plane' or newGroupData.category == 'helicopter') and point.z then
|
||||
if point.y > 0 and point.y > terrain.getHeight({newGroupData.units[unitNum]["x"], newGroupData.units[unitNum]["y"]}) + 10 then
|
||||
newGroupData.units[unitNum]["alt"] = point.y
|
||||
else
|
||||
newGroupData.units[unitNum]["alt"] = terrain.getHeight({newGroupData.units[unitNum]["x"], newGroupData.units[unitNum]["y"]}) + 300
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--tostring, tostring(),
|
||||
if not newGroupData.country and mist.DBs.groupsByName[newGroupData.groupName].country then
|
||||
newGroupData.country = mist.DBs.groupsByName[newGroupData.groupName].country
|
||||
end
|
||||
if not newGroupData.category and mist.DBs.groupsByName[newGroupData.groupName].category then
|
||||
newGroupData.category = mist.DBs.groupsByName[newGroupData.groupName].category
|
||||
end
|
||||
|
||||
|
||||
if route then
|
||||
newGroupData.route = route
|
||||
@ -5041,6 +5225,7 @@ mist.teleportToPoint = function(vars) -- main teleport function that all of tele
|
||||
|
||||
return mist.dynAddStatic(newGroupData)
|
||||
end
|
||||
--mist.debug.writeData(mist.utils.serialize,{'targets', newGroupData}, 'newGroupData.lua')
|
||||
return mist.dynAdd(newGroupData)
|
||||
|
||||
end
|
||||
@ -5162,7 +5347,7 @@ mist.teleportGroup = function(gpName, task)
|
||||
end
|
||||
|
||||
mist.spawnRandomizedGroup = function(groupName, vars) -- need to debug
|
||||
if Group.getByName(groupName) then
|
||||
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then
|
||||
local gpData = mist.getGroupData(groupName)
|
||||
gpData.units = mist.randomizeGroupOrder(gpData.units, vars)
|
||||
gpData.route = mist.getGroupRoute(groupName, 'task')
|
||||
@ -5311,7 +5496,7 @@ mist.randomizeGroupOrder = function(passedUnits, vars)
|
||||
end
|
||||
end
|
||||
return newGroup
|
||||
end
|
||||
end
|
||||
|
||||
mist.ground.patrolRoute = function(vars)
|
||||
|
||||
@ -5386,7 +5571,7 @@ mist.ground.patrolRoute = function(vars)
|
||||
useRoute[1].action = useRoute[#useRoute].action -- make it so the first WP matches the last WP
|
||||
end
|
||||
|
||||
cTask3 = {}
|
||||
local cTask3 = {}
|
||||
local newPatrol = {}
|
||||
newPatrol.route = useRoute
|
||||
newPatrol.gpData = gpData:getName()
|
||||
@ -5595,4 +5780,4 @@ scope examples:
|
||||
]]
|
||||
end
|
||||
mist.main()
|
||||
env.info(('Mist version ' .. mist.majorVersion .. '.' .. mist.minorVersion .. '.' .. mist.build .. ' loaded.'))
|
||||
env.info(('Mist version ' .. mist.majorVersion .. '.' .. mist.minorVersion .. '.' .. mist.build .. ' loaded.'))
|
||||
|
||||
Binary file not shown.
5783
mistv3_6_42.lua
Normal file
5783
mistv3_6_42.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,29 @@
|
||||
-- changelog
|
||||
-- changelog
|
||||
v42 v3.6 release
|
||||
-added mist.getRandomPointInZone. Function uses mist.getRandomPointInCircle.
|
||||
-fixed bug with altitude switching to radio if baro was specified
|
||||
-added the speed to DBs if a unit is dynamically spawned in
|
||||
-added extra checks in case Group/Unit.getByName returns dead objects
|
||||
- Mission file searching functions now search by Id instead of group or unit names.
|
||||
The name input variable hasnt changed, value gets converted to Id automatically if found.
|
||||
Functions now also accept a numerical groupId or unitId
|
||||
getPayload
|
||||
getGroupPayload
|
||||
getGroupPoints
|
||||
getGroupRoute
|
||||
|
||||
v38
|
||||
- fixed bug with optional variables for coordinate messages not actually being optional
|
||||
|
||||
v37
|
||||
- Teleport To Point related functions now check the altitude of a given point if specified for teleporting aircraft
|
||||
- fixed bug with mist.flagFunc.group_alive_less_than and mist.flagFunc.group_alive_more_than
|
||||
|
||||
v36
|
||||
-fixed a bug with databases getting an incorrect countryId value
|
||||
|
||||
v35
|
||||
- fixed bug with mist.teleportToPoint
|
||||
|
||||
v34 v3.5 release
|
||||
- fixed missing entries in dbupdate
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user