Jump to content

MIST Respawning Tasks


PhoenixTunes

Recommended Posts

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:

Link to comment
Share on other sites

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 ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

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)"

Link to comment
Share on other sites

  • 11 months later...

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?

Link to comment
Share on other sites

  • 11 months later...

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!

Link to comment
Share on other sites

  • 1 month later...

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:

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 by The_Dan
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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 by toutenglisse
in post
  • Like 1
Link to comment
Share on other sites

  • 6 months later...
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! :thumbup:

 


Edited by TOViper
  • Thanks 1

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

  • 3 months later...
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.

 

Link to comment
Share on other sites

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 ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

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. 

  • Like 2

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • 1 year later...

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

 

sig sm.png

walshtimothyWW2 virtual flier - currently playing on 4ya ww2 - youtube channel here

https://www.ww2adinfinitum.blog -  https://projectoverlord.co.uk/

 

Link to comment
Share on other sites

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 ?

sig sm.png

walshtimothyWW2 virtual flier - currently playing on 4ya ww2 - youtube channel here

https://www.ww2adinfinitum.blog -  https://projectoverlord.co.uk/

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...