Merge pull request #67 from mrSkortch/development

4.5 Release Hotfix 1
This commit is contained in:
mrSkortch 2022-03-02 18:12:58 -07:00 committed by GitHub
commit 67f2c5f983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 144 additions and 54 deletions

View File

@ -9,9 +9,9 @@ Forum Thread: http://forums.eagle.ru/showthread.php?t=98616
Documentation Documentation
==== ====
The MIST Wiki page can be fore at this address: http://wiki.hoggit.us/view/Mission_Scripting_Tools_Documentation The MIST Wiki page can be found at this address: http://wiki.hoggit.us/view/Mission_Scripting_Tools_Documentation
The attached pdf "mist gude.pdf" is attached in the download. The attached pdf "mist gude.pdf" is attached in the download however is no longer being updated.
Description Description
==== ====

View File

@ -35,7 +35,7 @@ mist = {}
-- don't change these -- don't change these
mist.majorVersion = 4 mist.majorVersion = 4
mist.minorVersion = 5 mist.minorVersion = 5
mist.build = 106 mist.build = 107
-- forward declaration of log shorthand -- forward declaration of log shorthand
local log local log
@ -163,7 +163,6 @@ do -- the main scope
elseif copy.polygonMode == "circle" then elseif copy.polygonMode == "circle" then
copy.points = {x = copy.mapX, y = copy.mapY} copy.points = {x = copy.mapX, y = copy.mapY}
elseif copy.polygonMode == 'oval' then elseif copy.polygonMode == 'oval' then
-- oval bugs. Scale and rotation are off.
copy.points = {} copy.points = {}
local numPoints = 24 local numPoints = 24
local angleStep = (math.pi*2)/numPoints local angleStep = (math.pi*2)/numPoints
@ -180,8 +179,7 @@ do -- the main scope
doOffset = true doOffset = true
end end
-- NOTE TO SELF. FIGURE OUT WHICH SHAPES NEED TO BE OFFSET. OVAL YES.
--log:warn('check offset')
if theta ~= 0 and copy.points and doOffset == true then if theta ~= 0 and copy.points and doOffset == true then
--log:warn('offsetting Values') --log:warn('offsetting Values')
@ -192,11 +190,13 @@ do -- the main scope
--log:warn(copy.points[1]) --log:warn(copy.points[1])
end end
elseif copy.primitiveType == "Line" and copy.closed == true then
table.insert(copy.points, mist.utils.deepCopy(copy.points[1]))
end end
if copy.points and #copy.points > 1 then if copy.points and #copy.points > 1 then
for u = 1, #copy.points do for u = 1, #copy.points do
copy.points[u].x = copy.points[u].x + copy.mapX copy.points[u].x = mist.utils.round(copy.points[u].x + copy.mapX, 2)
copy.points[u].y = copy.points[u].y + copy.mapY copy.points[u].y = mist.utils.round(copy.points[u].y + copy.mapY, 2)
end end
end end
@ -1618,7 +1618,7 @@ do -- the main scope
mistAddedObjects[#mistAddedObjects + 1] = mist.utils.deepCopy(newObj) mistAddedObjects[#mistAddedObjects + 1] = mist.utils.deepCopy(newObj)
if newObj.x and newObj.y and newObj.type and type(newObj.x) == 'number' and type(newObj.y) == 'number' and type(newObj.type) == 'string' then if newObj.x and newObj.y and newObj.type and type(newObj.x) == 'number' and type(newObj.y) == 'number' and type(newObj.type) == 'string' then
log:info(newObj) --log:warn(newObj)
coalition.addStaticObject(country.id[newCountry], newObj) coalition.addStaticObject(country.id[newCountry], newObj)
return newObj return newObj
@ -4230,7 +4230,7 @@ do -- group functions scope
--log:warn(newGroupData) --log:warn(newGroupData)
--mist.debug.writeData(mist.utils.serialize,{'teleportToPoint', newGroupData}, 'newGroupData.lua') --mist.debug.writeData(mist.utils.serialize,{'teleportToPoint', newGroupData}, 'newGroupData.lua')
if string.lower(newGroupData.category) == 'static' then if string.lower(newGroupData.category) == 'static' then
--log:info(newGroupData) --log:warn(newGroupData)
return mist.dynAddStatic(newGroupData) return mist.dynAddStatic(newGroupData)
end end
return mist.dynAdd(newGroupData) return mist.dynAdd(newGroupData)
@ -6410,13 +6410,14 @@ do -- mist.msg scope
--mist.debug.writeData(mist.utils.serialize,{'msg', messageList}, 'messageList.lua') --mist.debug.writeData(mist.utils.serialize,{'msg', messageList}, 'messageList.lua')
local msgTableText = {} local msgTableText = {}
local msgTableSound = {} local msgTableSound = {}
local curTime = timer.getTime()
for mInd, messageData in pairs(messageList) do for mInd, messageData in pairs(messageList) do
if messageData.displayedFor > messageData.displayTime then --log:warn(messageData)
if messageData.displayTill < curTime then
messageData:remove() -- now using the remove/destroy function. messageData:remove() -- now using the remove/destroy function.
else else
if messageData.displayedFor then if messageData.displayedFor then
messageData.displayedFor = messageData.displayedFor + messageDisplayRate messageData.displayedFor = curTime - messageData.addedAt
end end
local nextSound = 1000 local nextSound = 1000
local soundIndex = 0 local soundIndex = 0
@ -6672,6 +6673,7 @@ end]]
new.text = vars.text -- The actual message new.text = vars.text -- The actual message
new.displayTime = vars.displayTime -- How long will the message appear for new.displayTime = vars.displayTime -- How long will the message appear for
new.displayedFor = 0 -- how long the message has been displayed so far new.displayedFor = 0 -- how long the message has been displayed so far
new.displayTill = timer.getTime() + vars.displayTime
new.name = vars.name -- ID to overwrite the older message (if it exists) Basically it replaces a message that is displayed with new text. new.name = vars.name -- ID to overwrite the older message (if it exists) Basically it replaces a message that is displayed with new text.
new.addedAt = timer.getTime() new.addedAt = timer.getTime()
--log:warn('New Message: $1', new.text) --log:warn('New Message: $1', new.text)
@ -6759,6 +6761,7 @@ end]]
if messageList[i].name then if messageList[i].name then
if messageList[i].name == vars.name then if messageList[i].name == vars.name then
--log:info('updateMessage') --log:info('updateMessage')
messageList[i].displayTill = timer.getTime() + messageList[i].displayTime
messageList[i].displayedFor = 0 messageList[i].displayedFor = 0
messageList[i].addedAt = timer.getTime() messageList[i].addedAt = timer.getTime()
messageList[i].sound = new.sound messageList[i].sound = new.sound
@ -7387,20 +7390,38 @@ do
end end
local function getMarkId(id)
if mist.DBs.markList[id] then
return id
else
for mEntry, mData in pairs(mist.DBs.markList) do
if id == mData.name or id == mData.id then
return mData.id
end
end
end
end
local function removeMark(id) local function removeMark(id)
--log:info("Removing Mark: $1", id --log:info("Removing Mark: $1", id
local removed = false local removed = false
if type(id) == 'table' then if type(id) == 'table' then
for ind, val in pairs(id) do for ind, val in pairs(id) do
if type(val) == 'number' then local r = getMarkId(val)
trigger.action.removeMark(val) if r then
mist.DBs.markList[val] = nil trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true removed = true
end end
end end
else else
trigger.action.removeMark(id) local r = getMarkId(id)
mist.DBs.markList[id] = nil trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true removed = true
end end
return removed return removed
@ -7670,10 +7691,34 @@ do
fCal[#fCal+1] = mType fCal[#fCal+1] = mType
fCal[#fCal+1] = coa fCal[#fCal+1] = coa
fCal[#fCal+1] = usedId fCal[#fCal+1] = usedId
local likeARainCoat = false
if mType == 7 then
local score = 0
for i = 1, #pos do
if i < #pos then
local val = ((pos[i+1].x - pos[i].x)*(pos[i+1].z + pos[i].z))
--log:warn("$1 index score is: $2", i, val)
score = score + val
else
score = score + ((pos[1].x - pos[i].x)*(pos[1].z + pos[i].z))
end
end
--log:warn(score)
if score > 0 then -- it is anti-clockwise. Due to DCS bug make it clockwise.
likeARainCoat = true
--log:warn('flip')
for i = #pos, 1, -1 do
fCal[#fCal+1] = pos[i]
end
end
end
if likeARainCoat == false then
for i = 1, #pos do for i = 1, #pos do
fCal[#fCal+1] = pos[i] fCal[#fCal+1] = pos[i]
end end
end
if radius and mType == 2 then if radius and mType == 2 then
fCal[#fCal+1] = radius fCal[#fCal+1] = radius
end end
@ -7763,7 +7808,7 @@ do
table.insert(names, data) table.insert(names, data)
end end
end end
if #names > 1 then if #names >= 1 then
return names return names
end end
end end
@ -7798,7 +7843,7 @@ do
local d = v or {} local d = v or {}
local o = mist.utils.deepCopy(mist.DBs.drawingByName[name]) local o = mist.utils.deepCopy(mist.DBs.drawingByName[name])
mist.marker.add({point = {x = o.mapX, z = o.mapY}, text = name}) --mist.marker.add({point = {x = o.mapX, z = o.mapY}, text = name})
--log:warn(o) --log:warn(o)
d.points = o.points or {} d.points = o.points or {}
if o.primitiveType == "Polygon" then if o.primitiveType == "Polygon" then

View File

@ -35,7 +35,7 @@ mist = {}
-- don't change these -- don't change these
mist.majorVersion = 4 mist.majorVersion = 4
mist.minorVersion = 5 mist.minorVersion = 5
mist.build = 106 mist.build = 107
-- forward declaration of log shorthand -- forward declaration of log shorthand
local log local log
@ -163,7 +163,6 @@ do -- the main scope
elseif copy.polygonMode == "circle" then elseif copy.polygonMode == "circle" then
copy.points = {x = copy.mapX, y = copy.mapY} copy.points = {x = copy.mapX, y = copy.mapY}
elseif copy.polygonMode == 'oval' then elseif copy.polygonMode == 'oval' then
-- oval bugs. Scale and rotation are off.
copy.points = {} copy.points = {}
local numPoints = 24 local numPoints = 24
local angleStep = (math.pi*2)/numPoints local angleStep = (math.pi*2)/numPoints
@ -180,8 +179,7 @@ do -- the main scope
doOffset = true doOffset = true
end end
-- NOTE TO SELF. FIGURE OUT WHICH SHAPES NEED TO BE OFFSET. OVAL YES.
--log:warn('check offset')
if theta ~= 0 and copy.points and doOffset == true then if theta ~= 0 and copy.points and doOffset == true then
--log:warn('offsetting Values') --log:warn('offsetting Values')
@ -192,11 +190,13 @@ do -- the main scope
--log:warn(copy.points[1]) --log:warn(copy.points[1])
end end
elseif copy.primitiveType == "Line" and copy.closed == true then
table.insert(copy.points, mist.utils.deepCopy(copy.points[1]))
end end
if copy.points and #copy.points > 1 then if copy.points and #copy.points > 1 then
for u = 1, #copy.points do for u = 1, #copy.points do
copy.points[u].x = copy.points[u].x + copy.mapX copy.points[u].x = mist.utils.round(copy.points[u].x + copy.mapX, 2)
copy.points[u].y = copy.points[u].y + copy.mapY copy.points[u].y = mist.utils.round(copy.points[u].y + copy.mapY, 2)
end end
end end
@ -1618,7 +1618,7 @@ do -- the main scope
mistAddedObjects[#mistAddedObjects + 1] = mist.utils.deepCopy(newObj) mistAddedObjects[#mistAddedObjects + 1] = mist.utils.deepCopy(newObj)
if newObj.x and newObj.y and newObj.type and type(newObj.x) == 'number' and type(newObj.y) == 'number' and type(newObj.type) == 'string' then if newObj.x and newObj.y and newObj.type and type(newObj.x) == 'number' and type(newObj.y) == 'number' and type(newObj.type) == 'string' then
log:info(newObj) --log:warn(newObj)
coalition.addStaticObject(country.id[newCountry], newObj) coalition.addStaticObject(country.id[newCountry], newObj)
return newObj return newObj
@ -4230,7 +4230,7 @@ do -- group functions scope
--log:warn(newGroupData) --log:warn(newGroupData)
--mist.debug.writeData(mist.utils.serialize,{'teleportToPoint', newGroupData}, 'newGroupData.lua') --mist.debug.writeData(mist.utils.serialize,{'teleportToPoint', newGroupData}, 'newGroupData.lua')
if string.lower(newGroupData.category) == 'static' then if string.lower(newGroupData.category) == 'static' then
--log:info(newGroupData) --log:warn(newGroupData)
return mist.dynAddStatic(newGroupData) return mist.dynAddStatic(newGroupData)
end end
return mist.dynAdd(newGroupData) return mist.dynAdd(newGroupData)
@ -6410,13 +6410,14 @@ do -- mist.msg scope
--mist.debug.writeData(mist.utils.serialize,{'msg', messageList}, 'messageList.lua') --mist.debug.writeData(mist.utils.serialize,{'msg', messageList}, 'messageList.lua')
local msgTableText = {} local msgTableText = {}
local msgTableSound = {} local msgTableSound = {}
local curTime = timer.getTime()
for mInd, messageData in pairs(messageList) do for mInd, messageData in pairs(messageList) do
if messageData.displayedFor > messageData.displayTime then --log:warn(messageData)
if messageData.displayTill < curTime then
messageData:remove() -- now using the remove/destroy function. messageData:remove() -- now using the remove/destroy function.
else else
if messageData.displayedFor then if messageData.displayedFor then
messageData.displayedFor = messageData.displayedFor + messageDisplayRate messageData.displayedFor = curTime - messageData.addedAt
end end
local nextSound = 1000 local nextSound = 1000
local soundIndex = 0 local soundIndex = 0
@ -6672,6 +6673,7 @@ end]]
new.text = vars.text -- The actual message new.text = vars.text -- The actual message
new.displayTime = vars.displayTime -- How long will the message appear for new.displayTime = vars.displayTime -- How long will the message appear for
new.displayedFor = 0 -- how long the message has been displayed so far new.displayedFor = 0 -- how long the message has been displayed so far
new.displayTill = timer.getTime() + vars.displayTime
new.name = vars.name -- ID to overwrite the older message (if it exists) Basically it replaces a message that is displayed with new text. new.name = vars.name -- ID to overwrite the older message (if it exists) Basically it replaces a message that is displayed with new text.
new.addedAt = timer.getTime() new.addedAt = timer.getTime()
--log:warn('New Message: $1', new.text) --log:warn('New Message: $1', new.text)
@ -6759,6 +6761,7 @@ end]]
if messageList[i].name then if messageList[i].name then
if messageList[i].name == vars.name then if messageList[i].name == vars.name then
--log:info('updateMessage') --log:info('updateMessage')
messageList[i].displayTill = timer.getTime() + messageList[i].displayTime
messageList[i].displayedFor = 0 messageList[i].displayedFor = 0
messageList[i].addedAt = timer.getTime() messageList[i].addedAt = timer.getTime()
messageList[i].sound = new.sound messageList[i].sound = new.sound
@ -7387,20 +7390,38 @@ do
end end
local function getMarkId(id)
if mist.DBs.markList[id] then
return id
else
for mEntry, mData in pairs(mist.DBs.markList) do
if id == mData.name or id == mData.id then
return mData.id
end
end
end
end
local function removeMark(id) local function removeMark(id)
--log:info("Removing Mark: $1", id --log:info("Removing Mark: $1", id
local removed = false local removed = false
if type(id) == 'table' then if type(id) == 'table' then
for ind, val in pairs(id) do for ind, val in pairs(id) do
if type(val) == 'number' then local r = getMarkId(val)
trigger.action.removeMark(val) if r then
mist.DBs.markList[val] = nil trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true removed = true
end end
end end
else else
trigger.action.removeMark(id) local r = getMarkId(id)
mist.DBs.markList[id] = nil trigger.action.removeMark(r)
mist.DBs.markList[r] = nil
removed = true removed = true
end end
return removed return removed
@ -7670,10 +7691,34 @@ do
fCal[#fCal+1] = mType fCal[#fCal+1] = mType
fCal[#fCal+1] = coa fCal[#fCal+1] = coa
fCal[#fCal+1] = usedId fCal[#fCal+1] = usedId
local likeARainCoat = false
if mType == 7 then
local score = 0
for i = 1, #pos do
if i < #pos then
local val = ((pos[i+1].x - pos[i].x)*(pos[i+1].z + pos[i].z))
--log:warn("$1 index score is: $2", i, val)
score = score + val
else
score = score + ((pos[1].x - pos[i].x)*(pos[1].z + pos[i].z))
end
end
--log:warn(score)
if score > 0 then -- it is anti-clockwise. Due to DCS bug make it clockwise.
likeARainCoat = true
--log:warn('flip')
for i = #pos, 1, -1 do
fCal[#fCal+1] = pos[i]
end
end
end
if likeARainCoat == false then
for i = 1, #pos do for i = 1, #pos do
fCal[#fCal+1] = pos[i] fCal[#fCal+1] = pos[i]
end end
end
if radius and mType == 2 then if radius and mType == 2 then
fCal[#fCal+1] = radius fCal[#fCal+1] = radius
end end
@ -7763,7 +7808,7 @@ do
table.insert(names, data) table.insert(names, data)
end end
end end
if #names > 1 then if #names >= 1 then
return names return names
end end
end end
@ -7798,7 +7843,7 @@ do
local d = v or {} local d = v or {}
local o = mist.utils.deepCopy(mist.DBs.drawingByName[name]) local o = mist.utils.deepCopy(mist.DBs.drawingByName[name])
mist.marker.add({point = {x = o.mapX, z = o.mapY}, text = name}) --mist.marker.add({point = {x = o.mapX, z = o.mapY}, text = name})
--log:warn(o) --log:warn(o)
d.points = o.points or {} d.points = o.points or {}
if o.primitiveType == "Polygon" then if o.primitiveType == "Polygon" then