PhoenixTunes Posted March 29, 2019 Posted March 29, 2019 Hey guys, i've been trying to create a mission with MIST for me and my friend to use for Tomcat training, and i've set a group of 2 F-4Es down which can be activated via a radio command. Once they are both dead, I can re-use the radio command to respawn them with MIST, which is working. However, for some reason they continue on their waypoint as usual, fly defensive whenever they're launched on but never seem to fly offensively. I've never seen them launch a missile in this current scenario. Has anyone else had this issue? Any help is much appreciated! :pilotfly:
Grimes Posted March 29, 2019 Posted March 29, 2019 Are you respawning them with something like the following? The 2nd value is important because it gives them their old tasking back, otherwise they just follow the route: mist.respawnGroup('drones', true) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
PhoenixTunes Posted March 30, 2019 Author Posted March 30, 2019 Are you respawning them with something like the following? The 2nd value is important because it gives them their old tasking back, otherwise they just follow the route: mist.respawnGroup('drones', true) can confirm, the script I am using goes "mist.respawnGroup('A/A F-4Es', true)"
djacd Posted March 28, 2020 Posted March 28, 2020 This is annoying as I am experiencing this as well. The groups spawn fine. I've tried true and a delay 5 secs or so. On the F10 screen before they died when you highlight them they have a task. ie CAP, fighter sweep etc... but upon respawn they are taskless. I've tried both the mist.respawnGroup('groupname', true) and mist.cloneGroup('groupname', true) Did you ever figure this out?
Mikaa Posted March 8, 2021 Posted March 8, 2021 Necroed I stumbled upon this thread while trying to do the exact same thing. Initial spawn is conducted using in-game triggers through the F10 menu. Subsequent respawns are using the group respawn MIST script (do script once the radio menu flag has been triggered). The respawned AI aircraft don't follow any tasking, and only react defensively, despite being hostile on the initial spawn. Any help would be greatly appreciated!
toutenglisse Posted March 9, 2021 Posted March 9, 2021 Take a look at Grimes' post from Nov. 1st 2020 : MIssion Scripting Tools (Mist)- enhancing mission scripting Lua - Page 64 - Mission Editor Discussion and Questions - ED Forums (eagle.ru)
The_Dan Posted April 9, 2021 Posted April 9, 2021 (edited) Attention a slight rant incoming, TL:DR and solution at the end of the post. On 3/9/2021 at 1:29 AM, toutenglisse said: Take a look at Grimes' post from Nov. 1st 2020 : MIssion Scripting Tools (Mist)- enhancing mission scripting Lua - Page 64 - Mission Editor Discussion and Questions - ED Forums (eagle.ru) The solution in this post either doesn't work. After some years in mission design and scripting, i've come to the conclusion that MIST and MOOSE are a little bit bloated. They are both mighty and usefull tools for mission designers but they attempt to fill every niche with big prefab functions to automate complex tasks. This comes to the downside of complex maintenance and, like in this case, fail in rather easy tasks (which i think are the most asked features, if i count threads like OP and others asking for a simple respawn of groups). So i now avoid to use them and write my own simple as possible lua functions (in fact this the current approach in every aspect of my mission design: keep it simple, bc. of the AI and buggy triggers it is a bit difficult to have a complex mission where everything works as intendet). I really don't want to complain much about these scripts. The community has put a lot of hard work into it, which i appreciate. I have learned a lot about lua in the past years from these scripts. But take this as example: i spent the past few days to try to find a way around this bug from MIST (it is anyway in the mission bc. of the use of CTLD). That were some hours i put into this to find a solution that works for me. Now i gave up after reading this threads and the corresponding github issue. On the other hand writing my own respawn function took me about 10 minutes and it works. I think the problem in MIST for this topic is the seperate and scheduled assignemt of the tasks in the teleport function from MIST instead of just copy the route and tasks from the group that has to be respawned. I really think MIST and MOOSE are great for what they are build. But i would appreciate an easy to use less complex lua function collection for easy tasks like this. If i had enough time i would build one on my own. In the meantime i share my solution for this: local function DeepCopy(object) -- Code below is partly from DCS MOOSE https://github.com/FlightControl-Master/MOOSE -- Kopiert (auch verschachtelte) Tables local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for index, value in pairs(object) do new_table[_copy(index)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end local objectreturn = _copy(object) return objectreturn end local function MTableGetDictkey(_mtable) --- Funktion die die Namen der Gruppen usw aus der Dictionary ausliest local Temp = _mtable for _key, _value in pairs(_mtable) do if _key == "name" then Temp.name = env.getValueDictByKey(_value) elseif (type(_value) == "table") then Temp[_key] = MTableGetDictkey(_value) end end return Temp end local function FindGroupByName(GroupName) -- Code below is partly from DCS MOOSE https://github.com/FlightControl-Master/MOOSE local groupTable = {} groupTable.Template = {} for CoalitionName, Coalition in pairs(env.mission.coalition) do if type(Coalition) == 'table' and Coalition.country then --there is a country table for cntry_id, Country in pairs(Coalition.country) do groupTable.CountryID = Country.id for obj_type_name, obj_type_data in pairs(Country) do 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 for group_num, GroupTemplate in pairs(obj_type_data.group) do if env.getValueDictByKey(GroupTemplate.name) == GroupName then groupTable.Template = DeepCopy(MTableGetDictkey(GroupTemplate)) groupTable.Template.lateActivation = false --_gtemplate.Template.groupId = nil return groupTable end end --for group_num, GroupTemplate in pairs(obj_type_data.group) do end --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 end --for obj_type_name, obj_type_data in pairs(cntry_data) do end --for cntry_id, cntry_data in pairs(coa_data.country) do end --if type(Coalition) == 'table' and coa_data.country then --there is a country table end --for coa_name, coa_data in pairs(mission.coalition) do end function RespawnPlanes(groupName) local c_group = FindGroupByName(groupName) coalition.addGroup(c_group.CountryID, Group.Category.AIRPLANE, c_group.Template) end You can copy this code in a file and load it similar as you load the MIST or MOOSE lua files in the mission editor. Then you can use the function RespawnPlanes(groupName) as do script or in an seperate script file to respawn a plane group in DCS that behaves exactly like the old group. Edited April 9, 2021 by The_Dan 1 1
toutenglisse Posted April 9, 2021 Posted April 9, 2021 (edited) 42 minutes ago, The_Dan said: Attention a slight rant incoming, TL:DR and solution at the end of the post. ... I agree - Choose what works for you. I went through same issue with MIST respawn function, replaced it by a simple new spawn with same properties because MIST respawn seemed broken and didn't apply original tasks and routes and behaviour. Then I understood that it was the way MIST respawn was designed (just a simple respawn of "static" units on the field), and I then was able to use it again, I just define routes/tasks/options after respawn and it works OK. Several solutions with same result. Choose the simpliest working one for you. Edit : I also share the pain we have when facing an issue with scripting, it can be a big amount of time and brainfarts to solve. Kudos for finding a working solution ! Edited April 9, 2021 by toutenglisse in post 1
TOViper Posted November 2, 2021 Posted November 2, 2021 (edited) On 4/9/2021 at 3:15 PM, toutenglisse said: Edit : I also share the pain we have when facing an issue with scripting, it can be a big amount of time and brainfarts to solve. Kudos for finding a working solution ! On 4/9/2021 at 2:42 PM, The_Dan said: In the meantime i share my solution for this: local function DeepCopy(object) -- Code below is partly from DCS MOOSE https://github.com/FlightControl-Master/MOOSE -- Kopiert (auch verschachtelte) Tables local lookup_table = {} local function _copy(object) if type(object) ~= "table" then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for index, value in pairs(object) do new_table[_copy(index)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end local objectreturn = _copy(object) return objectreturn end local function MTableGetDictkey(_mtable) --- Funktion die die Namen der Gruppen usw aus der Dictionary ausliest local Temp = _mtable for _key, _value in pairs(_mtable) do if _key == "name" then Temp.name = env.getValueDictByKey(_value) elseif (type(_value) == "table") then Temp[_key] = MTableGetDictkey(_value) end end return Temp end local function FindGroupByName(GroupName) -- Code below is partly from DCS MOOSE https://github.com/FlightControl-Master/MOOSE local groupTable = {} groupTable.Template = {} for CoalitionName, Coalition in pairs(env.mission.coalition) do if type(Coalition) == 'table' and Coalition.country then --there is a country table for cntry_id, Country in pairs(Coalition.country) do groupTable.CountryID = Country.id for obj_type_name, obj_type_data in pairs(Country) do 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 for group_num, GroupTemplate in pairs(obj_type_data.group) do if env.getValueDictByKey(GroupTemplate.name) == GroupName then groupTable.Template = DeepCopy(MTableGetDictkey(GroupTemplate)) groupTable.Template.lateActivation = false --_gtemplate.Template.groupId = nil return groupTable end end --for group_num, GroupTemplate in pairs(obj_type_data.group) do end --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 end --for obj_type_name, obj_type_data in pairs(cntry_data) do end --for cntry_id, cntry_data in pairs(coa_data.country) do end --if type(Coalition) == 'table' and coa_data.country then --there is a country table end --for coa_name, coa_data in pairs(mission.coalition) do end function RespawnPlanes(groupName) local c_group = FindGroupByName(groupName) coalition.addGroup(c_group.CountryID, Group.Category.AIRPLANE, c_group.Template) end Thanks buddy, this solution works solid as a rock! You are my man for today! Edited November 2, 2021 by TOViper 1 Visit https://www.viggen.training ...Viggen... what more can you ask for? my computer: AMD Ryzen 5600G 4.4 GHz | NVIDIA RTX 3080 10GB | 32 GB 3.2 GHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TRP | Rift CV1
Tibador Posted February 11, 2022 Posted February 11, 2022 On 4/9/2021 at 8:15 AM, toutenglisse said: Then I understood that it was the way MIST respawn was designed (just a simple respawn of "static" units on the field), and I then was able to use it again, I just define routes/tasks/options after respawn and it works OK. I am trying to figure out how to assign new task or mission or whatever once i mist.cloneInZone and i am unable they "seem" to keep the tasking of cap or Fighter Sweep but not in the zone where the original unit was designated to do it, and i read from Grimes that they lose the original route data but i am struggling to try what he suggested in his post mist.getGroupRoute(gpName, true). newGroup.route = mist.getGroupRoute('whatever', true) i think those commands only pull the relevant data then you have to somehow send that data to the Aircraft and i have no idea how to accomplish that or if there is a simpler way of just saying unit123 go do this at this place etc. Any help would be appreciated i am just dipping my toes in the water and I am over my head.
Grimes Posted February 11, 2022 Posted February 11, 2022 I added a feature to respawnInZone, teleportInZone, and cloneInZone that allows you to keep and modify the route tasking. Assuming you are on a recent build of mist 4.5 it should be there. Actually in the process of pushing the dev branch to master. https://wiki.hoggitworld.com/view/MIST_cloneInZone So with this example it would randomly spawn that group anywhere within a 100 km radius of the zone and the AI would adjust their entire route acordingly. So if it was a north south orbit they'd just orbit north south where they started. mist.cloneInZone('groupName', 'zone', nil, 100000, {offsetRoute = true, initTasks = true}) If you set offsetWP1 to true instead of offsetRoute then the AI would start randomly in the that zone and then go to the next waypoint as set in the editor. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Tibador Posted February 11, 2022 Posted February 11, 2022 i was on 4.4 so that is why i was unable to get that to work thanks Grimes ill give it a try
Tibador Posted February 11, 2022 Posted February 11, 2022 That is working Great thanks again Grimes. I was wondering is it possible to get them doing random altitudes and routes within the zone for Fighter sweeps ?
Grimes Posted February 11, 2022 Posted February 11, 2022 At that point you are just better off randomizing it with your own code. Which is the point I was probably making with the partial code snippet you had copied in. local gp = mist.getGroupData('wahtever', true) gp.clone = true if gp.route and gp.route.points then for i = 1, #gp.route.points do local ref = gp.route.points[i] if ref.type ~= "Takeoff" and ref.type ~= "Landing" then local newWP = mist.getRandPointInCircle({x = ref.x, y = ref.y}, 30000) ref.x = newWP.x ref.y = newWP.y end ref.alt = math.random(3000, 8000) end end mist.dynAdd(gp) That just purely randomizes each WP to within 30km of where that waypoint was placed in the editor and does a rather inconsistent altitude change throughout the route. It doesn't check if that point would be underground due to terrain changes though. Point is you take something simple like that and then gradually add on what you need it to do. 2 The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Walshtimothy Posted July 28, 2023 Posted July 28, 2023 this is great , im only learning mist and am having some issues - I'd like to respawn a group once killed in one of 20 random zones , would someone mind outlining to me what I should do ? have been trying this all day but cant get my head around it ... So far I've tried this ; if (Group.getByName('AX_VILDAY_PUMA') and Group.getByName('AX_VILDAY_PUMA'):getSize() < 1) or not Group.getByName('AX_VILDAY_PUMA') then mist.respawnInZone('AX_VILDAY_PUMA', {"SPAWNAREA","SPAWNAREA-1","SPAWNAREA-2","SPAWNAREA-3","SPAWNAREA-4","SPAWNAREA-5","SPAWNAREA-6","SPAWNAREA-7", "SPAWNAREA-8","SPAWNAREA-9","SPAWNAREA-10","SPAWNAREA-11","SPAWNAREA-12","SPAWNAREA-13","SPAWNAREA-14","SPAWNAREA-15","SPAWNAREA-16","SPAWNAREA-17","SPAWNAREA-18","SPAWNAREA-19","SPAWNAREA-20"}, nil, 50000, {offsetWP1 = true, initTasks = true}) end walshtimothyWW2 virtual flier - currently playing on 4ya ww2 - youtube channel here https://www.ww2adinfinitum.blog - https://projectoverlord.co.uk/
Walshtimothy Posted July 28, 2023 Posted July 28, 2023 the code seems to work but it always seems to pick zone 1 and even though a delay is set this respawn happens instantly ... so , some testing and trying to get my thick head around this , i made a smaller test mission , 2 units in a field , greyhound (unit '1') destroys unit '2' , a truck . once destroyed it respawns instantly and slightly jittered from last point but only in zone1 . Would the code be picking 1 as preference , should i call it something else ? cheers . if (Group.getByName('2') and Group.getByName('2'):getSize() < 1) or not Group.getByName('2') then mist.respawnInZone('2', 'zone1','zone2','zone3', false, 100000) end doh , i see my error for delay , have changed false to true , now how to solve the zone issue ? is there something i need to do re zone tables etc ? walshtimothyWW2 virtual flier - currently playing on 4ya ww2 - youtube channel here https://www.ww2adinfinitum.blog - https://projectoverlord.co.uk/
HR-Crumble Posted July 5, 2024 Posted July 5, 2024 Using this code from MIST here -> how do I get it to retain the advanced actions of the group such as immortal? initially they are immortal but after a respawn using the mist code they loose their immortal. local groupName = 'tic1' local groupData = mist.getGroupData(groupName) if not Group.getByName(groupName) then mist.dynAdd(groupData) end Thanks in advance.
Kanelbolle Posted July 5, 2024 Posted July 5, 2024 9 hours ago, HR-Crumble said: Using this code from MIST here -> how do I get it to retain the advanced actions of the group such as immortal? initially they are immortal but after a respawn using the mist code they loose their immortal. local groupName = 'tic1' local groupData = mist.getGroupData(groupName) if not Group.getByName(groupName) then mist.dynAdd(groupData) end Thanks in advance. Not sure if immortal is preserved, but you can take a look at MIST getGroupRoute - DCS World Wiki - Hoggitworld.com There is a "task" parameter that can be set to True. Have not tested if this works. WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
HR-Crumble Posted July 5, 2024 Posted July 5, 2024 46 minutes ago, Kanelbolle said: Not sure if immortal is preserved, but you can take a look at MIST getGroupRoute - DCS World Wiki - Hoggitworld.com There is a "task" parameter that can be set to True. Have not tested if this works. You’re taking to a man with the early coding skills of a fridge-freezer unit here boss - do I just add this code into my above code before ‘end’? And do I have to have the same group names in as group 1? do mist.goRoute('myGroup2', mist.getGroupRoute('myGroup1')) end
Kanelbolle Posted July 5, 2024 Posted July 5, 2024 (edited) 1 hour ago, HR-Crumble said: You’re taking to a man with the early coding skills of a fridge-freezer unit here boss - do I just add this code into my above code before ‘end’? And do I have to have the same group names in as group 1? do mist.goRoute('myGroup2', mist.getGroupRoute('myGroup1')) end hehe, no worris im not an advanced coder, i try and fail a lot No idea if this even works, have no way of testing it, but might try this. local groupName = 'tic1' local groupData = mist.getGroupData(groupName) if not Group.getByName(groupName) then local _spawnedGroup = Group.getByName(mist.dynAdd(groupData).name) local _spawnedGroupName = _spawnedGroup:getName() mist.goRoute(_spawnedGroupName , mist.getGroupRoute(groupName, true)) end Edited July 5, 2024 by Kanelbolle forgot the task true and mixed group and name WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Kanelbolle Posted July 5, 2024 Posted July 5, 2024 (edited) Might also just try this as Grimes posted above: local groupName = 'tic1' if not Group.getByName(groupName) then mist.respawnGroup(groupName, true) end Edited July 5, 2024 by Kanelbolle WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
HR-Crumble Posted July 5, 2024 Posted July 5, 2024 4 hours ago, Kanelbolle said: hehe, no worris im not an advanced coder, i try and fail a lot No idea if this even works, have no way of testing it, but might try this. local groupName = 'tic1' local groupData = mist.getGroupData(groupName) if not Group.getByName(groupName) then local _spawnedGroup = Group.getByName(mist.dynAdd(groupData).name) local _spawnedGroupName = _spawnedGroup:getName() mist.goRoute(_spawnedGroupName , mist.getGroupRoute(groupName, true)) end This on the other hand!!!!!!!!!!! @Kanelbolle you legend it seems to have worked. The groups spawn and keep their advanced options! Thanks a million mate. Crumble
Recommended Posts