@jtff/miztemplate-lib 3.2.1 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lua/lib/Moose_.lua +1883 -362
- package/lua/lib/{mist_4_5_122.lua → mist.lua} +86 -59
- package/package.json +1 -1
- package/scripts/inject-scripts.js +1 -1
|
@@ -35,7 +35,7 @@ mist = {}
|
|
|
35
35
|
-- don't change these
|
|
36
36
|
mist.majorVersion = 4
|
|
37
37
|
mist.minorVersion = 5
|
|
38
|
-
mist.build =
|
|
38
|
+
mist.build = 126
|
|
39
39
|
|
|
40
40
|
-- forward declaration of log shorthand
|
|
41
41
|
local log
|
|
@@ -695,7 +695,6 @@ do -- the main scope
|
|
|
695
695
|
["FARP"] = "farps",
|
|
696
696
|
["Fueltank"] = "fueltank_cargo",
|
|
697
697
|
["Gate"] = "gate",
|
|
698
|
-
["FARP Fuel Depot"] = "gsm rus",
|
|
699
698
|
["Armed house"] = "home1_a",
|
|
700
699
|
["FARP Command Post"] = "kp-ug",
|
|
701
700
|
["Watch Tower Armed"] = "ohr-vyshka",
|
|
@@ -704,7 +703,6 @@ do -- the main scope
|
|
|
704
703
|
["Pipes big"] = "pipes_big_cargo",
|
|
705
704
|
["Oil platform"] = "plavbaza",
|
|
706
705
|
["Tetrapod"] = "tetrapod_cargo",
|
|
707
|
-
["Fuel tank"] = "toplivo",
|
|
708
706
|
["Trunks long"] = "trunks_long_cargo",
|
|
709
707
|
["Trunks small"] = "trunks_small_cargo",
|
|
710
708
|
["Passenger liner"] = "yastrebow",
|
|
@@ -1152,6 +1150,7 @@ do -- the main scope
|
|
|
1152
1150
|
end
|
|
1153
1151
|
end
|
|
1154
1152
|
end
|
|
1153
|
+
--dbLog:warn(newTable)
|
|
1155
1154
|
--mist.debug.writeData(mist.utils.serialize,{'msg', newTable}, timer.getAbsTime() ..'Group.lua')
|
|
1156
1155
|
newTable.timeAdded = timer.getAbsTime() -- only on the dynGroupsAdded table. For other reference, see start time
|
|
1157
1156
|
--mist.debug.dumpDBs()
|
|
@@ -1493,7 +1492,7 @@ do -- the main scope
|
|
|
1493
1492
|
task.t = timer.getTime() + task.rep --schedule next run
|
|
1494
1493
|
local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
|
|
1495
1494
|
if not err then
|
|
1496
|
-
log:error('Error in scheduled function: $1'
|
|
1495
|
+
log:error('Error in scheduled function: $1', errmsg)
|
|
1497
1496
|
end
|
|
1498
1497
|
--scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
|
|
1499
1498
|
i = i + 1
|
|
@@ -1519,7 +1518,7 @@ do -- the main scope
|
|
|
1519
1518
|
id = tostring(original_id) .. ' #' .. tostring(id_ind)
|
|
1520
1519
|
id_ind = id_ind + 1
|
|
1521
1520
|
end
|
|
1522
|
-
|
|
1521
|
+
local valid
|
|
1523
1522
|
if mist.DBs.aliveUnits and mist.DBs.aliveUnits[val.object.id_] then
|
|
1524
1523
|
--log:info('object found in alive_units')
|
|
1525
1524
|
val.objectData = mist.utils.deepCopy(mist.DBs.aliveUnits[val.object.id_])
|
|
@@ -1532,6 +1531,7 @@ do -- the main scope
|
|
|
1532
1531
|
--trigger.action.outText('remove via death: ' .. Unit.getName(val.object),20)
|
|
1533
1532
|
mist.DBs.activeHumans[Unit.getName(val.object)] = nil
|
|
1534
1533
|
end]]
|
|
1534
|
+
valid = true
|
|
1535
1535
|
elseif mist.DBs.removedAliveUnits and mist.DBs.removedAliveUnits[val.object.id_] then -- it didn't exist in alive_units, check old_alive_units
|
|
1536
1536
|
--log:info('object found in old_alive_units')
|
|
1537
1537
|
val.objectData = mist.utils.deepCopy(mist.DBs.removedAliveUnits[val.object.id_])
|
|
@@ -1540,32 +1540,37 @@ do -- the main scope
|
|
|
1540
1540
|
val.objectPos = pos.p
|
|
1541
1541
|
end
|
|
1542
1542
|
val.objectType = mist.DBs.removedAliveUnits[val.object.id_].category
|
|
1543
|
-
|
|
1543
|
+
valid = true
|
|
1544
1544
|
else --attempt to determine if static object...
|
|
1545
1545
|
--log:info('object not found in alive units or old alive units')
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1546
|
+
if Object.isExist(val.object) then
|
|
1547
|
+
local pos = Object.getPosition(val.object)
|
|
1548
|
+
if pos then
|
|
1549
|
+
local static_found = false
|
|
1550
|
+
for ind, static in pairs(mist.DBs.unitsByCat.static) do
|
|
1551
|
+
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...
|
|
1552
|
+
--log:info('correlated dead static object to position')
|
|
1553
|
+
val.objectData = static
|
|
1554
|
+
val.objectPos = pos.p
|
|
1555
|
+
val.objectType = 'static'
|
|
1556
|
+
static_found = true
|
|
1557
|
+
break
|
|
1558
|
+
end
|
|
1559
|
+
end
|
|
1560
|
+
if not static_found then
|
|
1553
1561
|
val.objectPos = pos.p
|
|
1554
|
-
val.objectType = '
|
|
1555
|
-
|
|
1556
|
-
break
|
|
1562
|
+
val.objectType = 'building'
|
|
1563
|
+
val.typeName = Object.getTypeName(val.object)
|
|
1557
1564
|
end
|
|
1565
|
+
else
|
|
1566
|
+
val.objectType = 'unknown'
|
|
1558
1567
|
end
|
|
1559
|
-
|
|
1560
|
-
val.objectPos = pos.p
|
|
1561
|
-
val.objectType = 'building'
|
|
1562
|
-
val.typeName = Object.getTypeName(val.object)
|
|
1563
|
-
end
|
|
1564
|
-
else
|
|
1565
|
-
val.objectType = 'unknown'
|
|
1568
|
+
valid = true
|
|
1566
1569
|
end
|
|
1567
1570
|
end
|
|
1568
|
-
|
|
1571
|
+
if valid then
|
|
1572
|
+
mist.DBs.deadObjects[id] = val
|
|
1573
|
+
end
|
|
1569
1574
|
end
|
|
1570
1575
|
end
|
|
1571
1576
|
end
|
|
@@ -2019,7 +2024,7 @@ do -- the main scope
|
|
|
2019
2024
|
|
|
2020
2025
|
end
|
|
2021
2026
|
end
|
|
2022
|
-
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, '
|
|
2027
|
+
--mist.debug.writeData(mist.utils.serialize,{'msg', newGroup}, newGroup.name ..'.lua')
|
|
2023
2028
|
--log:warn(newGroup)
|
|
2024
2029
|
-- sanitize table
|
|
2025
2030
|
newGroup.groupName = nil
|
|
@@ -3560,7 +3565,7 @@ function mist.getUnitsInMovingZones(unit_names, zone_unit_names, radius, zone_ty
|
|
|
3560
3565
|
end
|
|
3561
3566
|
|
|
3562
3567
|
function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
|
3563
|
-
log:info("$1, $2, $3, $4, $5", unitset1, altoffset1, unitset2, altoffset2, radius)
|
|
3568
|
+
--log:info("$1, $2, $3, $4, $5", unitset1, altoffset1, unitset2, altoffset2, radius)
|
|
3564
3569
|
radius = radius or math.huge
|
|
3565
3570
|
local unit_info1 = {}
|
|
3566
3571
|
local unit_info2 = {}
|
|
@@ -3568,21 +3573,25 @@ function mist.getUnitsLOS(unitset1, altoffset1, unitset2, altoffset2, radius)
|
|
|
3568
3573
|
-- get the positions all in one step, saves execution time.
|
|
3569
3574
|
for unitset1_ind = 1, #unitset1 do
|
|
3570
3575
|
local unit1 = Unit.getByName(unitset1[unitset1_ind])
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
+
if unit1 then
|
|
3577
|
+
local lCat = Object.getCategory(unit1)
|
|
3578
|
+
if ((lCat == 1 and unit1:isActive()) or lCat ~= 1) and unit1:isExist() == true then
|
|
3579
|
+
unit_info1[#unit_info1 + 1] = {}
|
|
3580
|
+
unit_info1[#unit_info1].unit = unit1
|
|
3581
|
+
unit_info1[#unit_info1].pos = unit1:getPosition().p
|
|
3582
|
+
end
|
|
3576
3583
|
end
|
|
3577
3584
|
end
|
|
3578
3585
|
|
|
3579
3586
|
for unitset2_ind = 1, #unitset2 do
|
|
3580
3587
|
local unit2 = Unit.getByName(unitset2[unitset2_ind])
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3588
|
+
if unit2 then
|
|
3589
|
+
local lCat = Object.getCategory(unit2)
|
|
3590
|
+
if ((lCat == 1 and unit2:isActive()) or lCat ~= 1) and unit2:isExist() == true then
|
|
3591
|
+
unit_info2[#unit_info2 + 1] = {}
|
|
3592
|
+
unit_info2[#unit_info2].unit = unit2
|
|
3593
|
+
unit_info2[#unit_info2].pos = unit2:getPosition().p
|
|
3594
|
+
end
|
|
3586
3595
|
end
|
|
3587
3596
|
end
|
|
3588
3597
|
|
|
@@ -4012,13 +4021,14 @@ do -- group functions scope
|
|
|
4012
4021
|
|
|
4013
4022
|
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
|
|
4014
4023
|
local newGroup = Group.getByName(gpName)
|
|
4015
|
-
local newData =
|
|
4024
|
+
local newData = mist.utils.deepCopy(dbData)
|
|
4016
4025
|
newData.name = gpName
|
|
4017
4026
|
newData.groupId = tonumber(newGroup:getID())
|
|
4018
4027
|
newData.category = newGroup:getCategory()
|
|
4019
4028
|
newData.groupName = gpName
|
|
4020
4029
|
newData.hidden = dbData.hidden
|
|
4021
|
-
|
|
4030
|
+
|
|
4031
|
+
|
|
4022
4032
|
if newData.category == 2 then
|
|
4023
4033
|
newData.category = 'vehicle'
|
|
4024
4034
|
elseif newData.category == 3 then
|
|
@@ -5193,7 +5203,8 @@ do -- mist.util scope
|
|
|
5193
5203
|
|
|
5194
5204
|
function mist.utils.getHeadingPoints(point1, point2, north) -- sick of writing this out.
|
|
5195
5205
|
if north then
|
|
5196
|
-
|
|
5206
|
+
local p1 = mist.utils.get3DDist(point1)
|
|
5207
|
+
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), p1), p1)
|
|
5197
5208
|
else
|
|
5198
5209
|
return mist.utils.getDir(mist.vec.sub(mist.utils.makeVec3(point2), mist.utils.makeVec3(point1)))
|
|
5199
5210
|
end
|
|
@@ -5837,8 +5848,8 @@ do -- mist.debug scope
|
|
|
5837
5848
|
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')
|
|
5838
5849
|
--trigger.action.outText(errmsg, 10)
|
|
5839
5850
|
end
|
|
5840
|
-
end
|
|
5841
5851
|
|
|
5852
|
+
end
|
|
5842
5853
|
--- Write debug data to file.
|
|
5843
5854
|
-- This function requires you to disable script sanitization
|
|
5844
5855
|
-- in $DCS_ROOT\Scripts\MissionScripting.lua to access lfs and io
|
|
@@ -7653,7 +7664,10 @@ do
|
|
|
7653
7664
|
--log:warn(s)
|
|
7654
7665
|
if type(s) == 'table' then
|
|
7655
7666
|
local mType = s.markType
|
|
7656
|
-
|
|
7667
|
+
--log:echo(s)
|
|
7668
|
+
|
|
7669
|
+
if mType == 'panel' then
|
|
7670
|
+
local markScope = s.markScope or "all"
|
|
7657
7671
|
if markScope == 'coa' then
|
|
7658
7672
|
trigger.action.markToCoalition(s.markId, s.text, s.pos, s.markFor, s.readOnly)
|
|
7659
7673
|
elseif markScope == 'group' then
|
|
@@ -7711,10 +7725,15 @@ do
|
|
|
7711
7725
|
|
|
7712
7726
|
local function validateColor(val)
|
|
7713
7727
|
if type(val) == 'table' then
|
|
7714
|
-
for i = 1,
|
|
7715
|
-
if
|
|
7716
|
-
|
|
7717
|
-
|
|
7728
|
+
for i = 1, 4 do
|
|
7729
|
+
if val[i] then
|
|
7730
|
+
if type(val[i]) == 'number' and val[i] > 1 then
|
|
7731
|
+
val[i] = val[i]/255 -- convert RGB values from 0-255 to 0-1 equivilent.
|
|
7732
|
+
end
|
|
7733
|
+
else
|
|
7734
|
+
val[i] = 0.8
|
|
7735
|
+
log:warn("index $1 of color to mist.marker.add was missing, defaulted to 0.8", i)
|
|
7736
|
+
end
|
|
7718
7737
|
end
|
|
7719
7738
|
elseif type(val) == 'string' then
|
|
7720
7739
|
val = mist.utils.hexToRGB(val)
|
|
@@ -7755,7 +7774,7 @@ do
|
|
|
7755
7774
|
--log:info('create maker DB: $1', e.idx)
|
|
7756
7775
|
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}
|
|
7757
7776
|
if e.unit then
|
|
7758
|
-
mist.DBs.markList[e.idx].unit = e.
|
|
7777
|
+
mist.DBs.markList[e.idx].unit = e.initiator:getName()
|
|
7759
7778
|
end
|
|
7760
7779
|
--log:info(mist.marker.list[e.idx])
|
|
7761
7780
|
end
|
|
@@ -7778,7 +7797,7 @@ do
|
|
|
7778
7797
|
else
|
|
7779
7798
|
for mEntry, mData in pairs(mist.DBs.markList) do
|
|
7780
7799
|
if id == mData.name or id == mData.id then
|
|
7781
|
-
return mData.
|
|
7800
|
+
return mData.markId
|
|
7782
7801
|
end
|
|
7783
7802
|
end
|
|
7784
7803
|
end
|
|
@@ -7788,11 +7807,16 @@ do
|
|
|
7788
7807
|
|
|
7789
7808
|
|
|
7790
7809
|
local function removeMark(id)
|
|
7791
|
-
|
|
7810
|
+
--log:info("Removing Mark: $1", id)
|
|
7792
7811
|
local removed = false
|
|
7793
7812
|
if type(id) == 'table' then
|
|
7794
7813
|
for ind, val in pairs(id) do
|
|
7795
|
-
|
|
7814
|
+
local r
|
|
7815
|
+
if val.markId then
|
|
7816
|
+
r = val.markId
|
|
7817
|
+
else
|
|
7818
|
+
r = getMarkId(val)
|
|
7819
|
+
end
|
|
7796
7820
|
if r then
|
|
7797
7821
|
trigger.action.removeMark(r)
|
|
7798
7822
|
mist.DBs.markList[r] = nil
|
|
@@ -7802,9 +7826,11 @@ do
|
|
|
7802
7826
|
|
|
7803
7827
|
else
|
|
7804
7828
|
local r = getMarkId(id)
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7829
|
+
if r then
|
|
7830
|
+
trigger.action.removeMark(r)
|
|
7831
|
+
mist.DBs.markList[r] = nil
|
|
7832
|
+
removed = true
|
|
7833
|
+
end
|
|
7808
7834
|
end
|
|
7809
7835
|
return removed
|
|
7810
7836
|
end
|
|
@@ -7926,6 +7952,7 @@ do
|
|
|
7926
7952
|
|
|
7927
7953
|
if markForCoa then
|
|
7928
7954
|
if type(markForCoa) == 'string' then
|
|
7955
|
+
--log:warn("coa is string")
|
|
7929
7956
|
if tonumber(markForCoa) then
|
|
7930
7957
|
coa = coas[tonumber(markForCoa)]
|
|
7931
7958
|
markScope = 'coa'
|
|
@@ -7940,11 +7967,10 @@ do
|
|
|
7940
7967
|
end
|
|
7941
7968
|
elseif type(markForCoa) == 'number' and markForCoa >=-1 and markForCoa <= #coas then
|
|
7942
7969
|
coa = markForCoa
|
|
7943
|
-
|
|
7970
|
+
--log:warn("coa is number")
|
|
7971
|
+
markScope = 'coa'
|
|
7944
7972
|
end
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7973
|
+
markFor = coa
|
|
7948
7974
|
elseif markFor then
|
|
7949
7975
|
if type(markFor) == 'number' then -- groupId
|
|
7950
7976
|
if mist.DBs.groupsById[markFor] then
|
|
@@ -8053,7 +8079,7 @@ do
|
|
|
8053
8079
|
end
|
|
8054
8080
|
for i = 1, #markForTable do
|
|
8055
8081
|
local newId = iterate()
|
|
8056
|
-
local data = {markId = newId, text = text, pos = pos[i], markFor = markForTable[i], markType = 'panel', name = name, readOnly = readOnly, time = timer.getTime()}
|
|
8082
|
+
local data = {markId = newId, text = text, pos = pos[i], markScope = markScope, markFor = markForTable[i], markType = 'panel', name = name, readOnly = readOnly, time = timer.getTime()}
|
|
8057
8083
|
mist.DBs.markList[newId] = data
|
|
8058
8084
|
table.insert(list, data)
|
|
8059
8085
|
|
|
@@ -8177,6 +8203,7 @@ do
|
|
|
8177
8203
|
end
|
|
8178
8204
|
|
|
8179
8205
|
function mist.marker.remove(id)
|
|
8206
|
+
|
|
8180
8207
|
return removeMark(id)
|
|
8181
8208
|
end
|
|
8182
8209
|
|
|
@@ -8967,8 +8994,8 @@ do -- group tasks scope
|
|
|
8967
8994
|
minR = mist.utils.get2DDist(avg, zone[i])
|
|
8968
8995
|
end
|
|
8969
8996
|
end
|
|
8970
|
-
--log:warn('Radius: $1', radius)
|
|
8971
8997
|
--log:warn('minR: $1', minR)
|
|
8998
|
+
--log:warn('Radius: $1', radius)
|
|
8972
8999
|
local lSpawnPos = {}
|
|
8973
9000
|
for j = 1, 100 do
|
|
8974
9001
|
newCoord = mist.getRandPointInCircle(avg, radius)
|
|
@@ -9200,7 +9227,7 @@ do -- group tasks scope
|
|
|
9200
9227
|
function mist.groupIsDead(groupName) -- copy more or less from on station
|
|
9201
9228
|
local gp = Group.getByName(groupName)
|
|
9202
9229
|
if gp then
|
|
9203
|
-
if #gp:getUnits() > 0
|
|
9230
|
+
if #gp:getUnits() > 0 and gp:isExist() == true then
|
|
9204
9231
|
return false
|
|
9205
9232
|
end
|
|
9206
9233
|
end
|
package/package.json
CHANGED
|
@@ -186,7 +186,7 @@ async function doInject(ciObject, sourceMizFileName, workspacePath,destinationMi
|
|
|
186
186
|
libsArray.push({
|
|
187
187
|
folder: 'lib',
|
|
188
188
|
scriptTitle: 'Mist',
|
|
189
|
-
scripts: ['
|
|
189
|
+
scripts: ['mist.lua'],
|
|
190
190
|
timing: 12,
|
|
191
191
|
color: '0x008000ff'
|
|
192
192
|
});
|