mist.cloneInZone not cloning entire group of static
Opened this issue · 4 comments
mist.cloneInZone is cloning only the first element of a group of static objects and switching unit side.
The mission editor doesn't support groups of static objects. How are these objects grouped?
DCS.2023-07-18.18-35-07.mp4
That's the result, one single helipad with side switched:
Using:
local helipadData = mist.cloneInZone('Invisible FARP', city, 1, cityIntel.radius)
An interesting thing is that if I echo helipadData I got all 4 Invisible FARPs but the first unit will always have the same id of the first unit in the model group, 66 in this case:
["helipadData"] = {
["categoryStatic"] = "Heliports",
["category"] = "Heliports",
["unitName"] = "Invisible FARP-1",
["dead"] = false,
["shape_name"] = "invisiblefarp",
["heading"] = 0,
["country"] = "brazil",
["name"] = "BRAZIL static 2",
["y"] = 604679.35965604,
["groupName"] = "Invisible FARP",
["units"] = {
[1] = {
["shape_name"] = "invisiblefarp",
["x"] = -258517.04755099,
["type"] = "Invisible FARP",
["unitId"] = 66,
["unitName"] = "Invisible FARP-1",
["categoryStatic"] = "Heliports",
["heading"] = 0,
["y"] = 604679.35965604,
},
[2] = {
["shape_name"] = "invisiblefarp",
["x"] = -258067.00444912,
["type"] = "Invisible FARP",
["unitId"] = 86,
["unitName"] = "Invisible FARP-2",
["categoryStatic"] = "Heliports",
["heading"] = 0,
["y"] = 604319.57903086,
},
[3] = {
["shape_name"] = "invisiblefarp",
["x"] = -258014.84864033,
["type"] = "Invisible FARP",
["unitId"] = 87,
["unitName"] = "Invisible FARP-3",
["categoryStatic"] = "Heliports",
["heading"] = 0,
["y"] = 605221.24353206,
},
[4] = {
["shape_name"] = "invisiblefarp",
["x"] = -258939.72355511,
["type"] = "Invisible FARP",
["unitId"] = 88,
["unitName"] = "Invisible FARP-4",
["categoryStatic"] = "Heliports",
["heading"] = 0,
["y"] = 605174.8337748,
},
},
["coalition"] = "blue",
["x"] = -258517.04755099,
["clone"] = "order66",
["type"] = "Invisible FARP",
["groupId"] = 7003,
["unitId"] = "7016",
["hidden"] = false,
["countryId"] = 64,
},
Didn't realize they had enabled that for FARP objects. The option to add units to other static types is greyed out for everything else. The idea of a group of static objects is a mission editor construct and serves no purpose while the game is running. AFAIK we can't spawn statics in a group via scripting, Rather is would be 4 individual static objects spawned 1 at a time.
Looking at the functions mist uses it doesn't sanitize/delete anything from the table that gets passed to coalition.addStaticObject. This is why the units entry is still there in the returned table, it grabs the data of the first object, because that is how it is stored in the miz file, and then it adds that info into the root of the table.
The mist databases try to mimic the miz format where everything has a group and a units table. I'd have to re-jig some things to make it keep any group level properties. Right now it just overwrites it all anytime a static object is spawned. I also need to experiment with some things because FARP objects are unique in that they are supposed to be spawned via coalition.addGroup and passing a -1 value for the group type. No idea if this would work with multiple objects and I never fully added support for FARPs to use it if you tried to clone or teleport them.
A group of Invisible FARP is good because if a helicopter group tries to land in a helipad they will get adapted to the number of helipads available. Sorry if this will give you a lot of work 👷