Announcement

Collapse
No announcement yet.

MIssion Scripting Tools (Mist)- enhancing mission scripting Lua

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by Grimes View Post
    Uploaded a potential fix on the development branch to try and fix the issues that have been occurring due to a error when mist updates the database. If it continues to happen please upload the mission file so I can test with it. For whatever reason me trying to replicate within my own little test mission fails to reproduce the result.
    I started having the same errors as above in the checkSpawnedEventsNew function after DCS update a couple weeks ago in a mission I have been running online for a few months. The only MIST functions I am using in the mission are map object checks with no calls to spawn or respawn through MIST.

    I just dropped in 4.4.87 into the mission and have it running online.

    I will try to remember to report back.
    475th Fighter Group Discord https://discord.gg/xkKsApD
    sigpic

    Comment


      My range script using mist does not pick up hits by the SLAM. It is fine with LGB, JDAMs etc. Do I have to add SLAM to the script somehow for it to recognize the hit?
      The State Military (CVW-17)

      sigpic

      RAM 301
      F/A-18C BuNo 165212
      VFA-83

      CAPT W. “Grekko” Loomis
      www.statelyfe.com

      Comment


        Dead and damaged units

        Hello. Im starting to do some lua scripting, im in a very beginner state yet. But im super interested in MIST, awesome work!
        I have read almost all pages but a I haven't got a final conclusion about this:
        Can I get a list of dead units after a mission ends? Most sure the answer is yes.
        But Im not sure how to save that info so I can read it in another mission.
        My objective is to be able to run a mission and in the next mission units destroyed or damaged should simply be removed or deactivated, so a very interesting "interactive" scenario would be possible.
        Most sure this has already been done? If so can someone point me to an example mission or show me the scripting to do this?
        Thanks very much in advance

        Comment


          Originally posted by wrl11 View Post
          My range script using mist does not pick up hits by the SLAM. It is fine with LGB, JDAMs etc. Do I have to add SLAM to the script somehow for it to recognize the hit?
          I dont think there is anything special about the slam and hit events. Are you checking for just the hit and the weapon name?

          Originally posted by Tinchus2009 View Post
          Can I get a list of dead units after a mission ends? Most sure the answer is yes.
          But Im not sure how to save that info so I can read it in another mission.
          My objective is to be able to run a mission and in the next mission units destroyed or damaged should simply be removed or deactivated, so a very interesting "interactive" scenario would be possible.
          Most sure this has already been done? If so can someone point me to an example mission or show me the scripting to do this?
          Thanks very much in advance
          A lot of people have done something like this. People tend to make their own and use it for specific purposes withing their own missions. The game by default does save all of the events that occur in the debrief.log in your savedgames/DCS/Logs folder. Most modify the game to allow the reading and writing of files.

          Mist does keep track of all dead objects via the database mist.DBs.deadObjects. So you could periodically write that table to a file. Alternatively you can create your own event handler that updates and writes to a file for whenever certain types of objects die. For instance if you don't want to track world objects or clients you don't have to.
          The right man in the wrong place makes all the difference in the world.
          Current Projects: Scripting Wiki, Something...
          Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

          Comment


            Originally posted by Grimes View Post
            I dont think there is anything special about the slam and hit events. Are you checking for just the hit and the weapon name?



            A lot of people have done something like this. People tend to make their own and use it for specific purposes withing their own missions. The game by default does save all of the events that occur in the debrief.log in your savedgames/DCS/Logs folder. Most modify the game to allow the reading and writing of files.

            Mist does keep track of all dead objects via the database mist.DBs.deadObjects. So you could periodically write that table to a file. Alternatively you can create your own event handler that updates and writes to a file for whenever certain types of objects die. For instance if you don't want to track world objects or clients you don't have to.

            Thanks for the info. I have tried loking for examples, and found nothing. Do you have any example I can see? im not really skilled in LUA si It would help me a lot to see some examples on how to do this.

            Comment


              hi,
              mist.goroute for aircraft (helicopter) with AGL/RADIO altitude tips

              mist.dynAdd a helicopter with waypoint(s) at a scpecified altitude with "RADIO" altitude type is ok - but dynamically adding further waypoints with "RADIO" altitude isn't ok.

              I've failed since a long time to make it work with mist.heli.buildWP and AGL/RADIO type altitude. The synthax in manual is for exemple :

              path[#path + 1] = mist.heli.buildWP(startPoint, TurningPoint, 170, 10, 'agl') --means speed 170, altitude 10 above ground level.

              And it's said that without altitude type specified it defaults to agl/radio. But it doesn't work and without alt.type it defaults to asl/baro in fact.

              I wanted to use it to build waypoints at specified altitude above a ground group, but impossible to find a working synthax ('agl', "agl", 'radio', "RADIO", etc...) and ASL/BARO altitude doesn't fit (heli will be too high or too low - even crash - relative to ground group's altitude).
              I found this synthax that works for me :

              local dest = mist.getRandPointInCircle(mist.getLeadPos('Red Target Group'), 1000, 200)
              local startPoint = mist.getLeadPos('Blue Defender Group ' .. enemyFighterCount)
              local path = {}
              path[#path + 1] = mist.heli.buildWP(startPoint, TurningPoint, 40, land.getHeight(mist.utils.makeVec2(mist.getLeadPos('Red Target Group')))+500)
              path[#path + 1] = mist.heli.buildWP(dest, TurningPoint, 40, land.getHeight(mist.utils.makeVec2(mist.getLeadPos('Red Target Group')))+500)
              mist.goRoute('Blue Defender Group ' .. enemyFighterCount, path)

              This way the heli always get a waypoint at altitude of ground group + 500, with speed 40.

              1) If someone knows the real working synthax please share. Without the real working synthax be aware that land.getHeight allows a workaround for AGL/radio type altitude.

              2) I use this, repeating every 60/90s this function that build a waypoint/ give goroute task to heli, so the heli is "escorting" the ground group until it reaches its destination (and engaging air or ground threats with CAS task option set), BECAUSE I fail to make DCS_task_escort (https://wiki.hoggitworld.com/view/DCS_task_escort) to work.
              If someone has a working exemple of DCS escort task (heli escorting ground vehicles), I'm interested.
              Hardware : I7 7700K - Z270 gaming M5 - 32GB ( 4x8 ) ddr4 3200Mhz - 1080Ti gaming X - SSD M2 - TM Twcs / TM Rgt yaw pedals / MS sidewinder FF2 + TM Warthog - Oculus Rift CV1.

              Comment


                mist.respawn task bug ?

                Probably known, if bug true, but here two situations (2 tracks) when mist.respawnGroup('GroupName', true) does bug relative to main tasks. (exemple is tanker, but same with AWACS or others)

                1) if group is late activated, mist.respawn don't keep tasks and tanker can't be contacted.

                2) if group (no late act.) is respawned 1 time, it's ok (tanker does his task), but if respawned a second time then same issue as 1).

                It's not a major problem as instead of respawning M.E. groups I can simply mist.dynAdd similar groups (if groups still exist then destroy and dynAdd same group = same as respawn) and then tasks are kept.
                But I think there is maybe an issue to fix ?
                Attached Files
                Hardware : I7 7700K - Z270 gaming M5 - 32GB ( 4x8 ) ddr4 3200Mhz - 1080Ti gaming X - SSD M2 - TM Twcs / TM Rgt yaw pedals / MS sidewinder FF2 + TM Warthog - Oculus Rift CV1.

                Comment


                  Scuze me for being thick here but how do i download the 4.4.88? it only gets me 4.3.74
                  Supercarrier | Flaming Cliffs 3 | M-2000C | AJS-37 Viggen| MIG-21Bis | L-39 Albatros | Yak-52 | Spitfire LF MK IX | Mig-15Bis | Mig-19P Farmer | P-51D Mustang | F/A-18 | F-14 | F-5E Tiger II | C-101 Aviojet | I-16 | UH-1H Huey | Mil MI-8tv2 | Sa 342M Gazelle | Combined Arms | NS-430 Navigation System | NEVADA | Persian Gulf | Normandy1944 | World war II assets pack | Black Shark 2 | F-5E Agressors ACM campaign |F-5E Agressors BFM Campaign | L-39 Albatros Kursant Campaign | DCS:Syria

                  Comment


                    Originally posted by Thor_H View Post
                    Scuze me for being thick here but how do i download the 4.4.88? it only gets me 4.3.74
                    here : https://github.com/mrSkortch/Mission...ee/development

                    Click on green button "code" then "download zip".
                    Hardware : I7 7700K - Z270 gaming M5 - 32GB ( 4x8 ) ddr4 3200Mhz - 1080Ti gaming X - SSD M2 - TM Twcs / TM Rgt yaw pedals / MS sidewinder FF2 + TM Warthog - Oculus Rift CV1.

                    Comment


                      Originally posted by toutenglisse View Post
                      here : https://github.com/mrSkortch/Mission...ee/development

                      Click on green button "code" then "download zip".
                      Thank you!
                      Supercarrier | Flaming Cliffs 3 | M-2000C | AJS-37 Viggen| MIG-21Bis | L-39 Albatros | Yak-52 | Spitfire LF MK IX | Mig-15Bis | Mig-19P Farmer | P-51D Mustang | F/A-18 | F-14 | F-5E Tiger II | C-101 Aviojet | I-16 | UH-1H Huey | Mil MI-8tv2 | Sa 342M Gazelle | Combined Arms | NS-430 Navigation System | NEVADA | Persian Gulf | Normandy1944 | World war II assets pack | Black Shark 2 | F-5E Agressors ACM campaign |F-5E Agressors BFM Campaign | L-39 Albatros Kursant Campaign | DCS:Syria

                      Comment


                        Hi,
                        I've been trying to teleport some units(ships) on (late) spawn to a random point along their route, but if they are teleported they just sit there and don't continue on their route. Even if I schedule a mist.goRoute with the original group's route, these units only start moving if they actually spawn on WP1.
                        Does anyone have any idea how to solve for this issue?
                        for i=1, #units_ships do
                        local unit_id=Unit.getByName(units_ships[i])
                        local unit_name=unit_id:getName()
                        local group_id=Unit.getGroup(unit_id)
                        local naval_group_name=group_id:getName()
                        naval_originalroute={}
                        naval_originalroute=mist.getGroupRoute(naval_group_name, true)
                        naval_waypoints = mist.getGroupPoints(naval_group_name)
                        for x = 1,5 do
                        value = math.random(0, #naval_waypoints-2)
                        if value == 0 then
                        waypointstart=value+1
                        waypointdest=value+2
                        elseif value == #naval_waypoints then
                        waypointstart=value
                        waypointdest=value
                        else
                        waypointstart=value
                        waypointdest=value+1
                        end
                        end

                        local vars = {}
                        vars.gpName=naval_group_name
                        vars.action = 'respawn'
                        vars.point = { x=naval_waypoints[waypointstart].x,
                        y=naval_waypoints[waypointstart].y }
                        vars.route = naval_originalroute
                        mist.teleportToPoint(vars, true)
                        mist.goRoute(naval_group_name, naval_originalroute)
                        -- I know this one might not work because the group technically gets destroyed and re-spawned, but then how can I fix this?
                        Thanks a lot!

                        Comment


                          Finally got around to fixing a few things and merging everything back into the master branch.

                          https://github.com/mrSkortch/Mission...ses/tag/4.4.90
                          The right man in the wrong place makes all the difference in the world.
                          Current Projects: Scripting Wiki, Something...
                          Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                          Comment


                            Originally posted by Jagohu View Post
                            Hi,
                            I've been trying to teleport some units(ships) on (late) spawn to a random point along their route, but if they are teleported they just sit there and don't continue on their route. Even if I schedule a mist.goRoute with the original group's route, these units only start moving if they actually spawn on WP1.
                            Does anyone have any idea how to solve for this issue?
                            -- I know this one might not work because the group technically gets destroyed and re-spawned, but then how can I fix this?
                            Thanks a lot!
                            When you get the route for a given group it is a verbatim copy of the original route. What you can do is get that route, but modify it to account for the groups current location. Going by the first unit in the group is a good way to do that.

                            Code:
                            local nGroup = mist.teleportToPoint(vars)
                            naval_originalroute[1].x = nGroup.units[1].x
                            naval_originalroute[1].y = nGroup.units[1].y
                            mist.goRoute(naval_group_name, naval_originalroute)
                            Might need to schedule the mist.goRoute for half a second or so after the group spawns. Sometimes the game doesnt like it when you immediately give a new task as it spawns.
                            The right man in the wrong place makes all the difference in the world.
                            Current Projects: Scripting Wiki, Something...
                            Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                            Comment


                              Thanks a lot Grimes, this is awesome!

                              Beer money is sent, thank you very much for all your time you've put into MIST!

                              Comment


                                Much appreciated.
                                The right man in the wrong place makes all the difference in the world.
                                Current Projects: Scripting Wiki, Something...
                                Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                                Comment


                                  Jagohu here a working exemple if it can help :

                                  staticObj = {
                                  ["heading"] =mist.utils.toRadian(mist.random(359)),
                                  ["type"] = "Comms tower M",
                                  ["rate"] = 100,
                                  ["name"] = "CoCenter",
                                  ["category"] = "Fortifications",
                                  ["y"] = unitSpawnZone.y,
                                  ["x"] = unitSpawnZone.x,
                                  ["dead"] = false,
                                  }
                                  coalition.addStaticObject(country.id.RUSSIA, staticObj)
                                  Last edited 09-25-2020, 12:06 PM.
                                  Hardware : I7 7700K - Z270 gaming M5 - 32GB ( 4x8 ) ddr4 3200Mhz - 1080Ti gaming X - SSD M2 - TM Twcs / TM Rgt yaw pedals / MS sidewinder FF2 + TM Warthog - Oculus Rift CV1.

                                  Comment


                                    Thanks toutenglisse, just found the solution, I didn't realize you posted in the meanwhile Thanks a lot though!

                                    Comment


                                      When I load mist 4.4.90 in my mission, the coordinates returned by :

                                      lat, lon = coord.LOtoLL(unitSpawnZone)
                                      llString = mist.tostringLL(lat, lon, 2)

                                      are false. With mist 4.3.74 no issue.

                                      EDIT : in fact it's not always false - when unitSpawnZone is on road the coordinates are right with 4.4.90, when it's not on road but on land coordinates are false.

                                      On road unitSpawnZone given by :

                                      local unitType
                                      local zone = trigger.misc.getZone('Wash-IN')
                                      local zoneOUT = trigger.misc.getZone('Wash-OUT')
                                      local EXpointV3 = mist.utils.zoneToVec3(zoneOUT)
                                      local EXpointV2 = mist.utils.makeVec2(EXpointV3)
                                      repeat
                                      unitSpawnZone1 = mist.getRandPointInCircle(zone.point, zone.radius)
                                      until mist.utils.get2DDist(unitSpawnZone1, EXpointV2) > zoneOUT.radius
                                      and mist.utils.get2DDist(mist.utils.makeVec2(mist.getLeadPos('Blue F18c 3')), unitSpawnZone1) > 25000
                                      local x, y = land.getClosestPointOnRoads('roads', unitSpawnZone1.x, unitSpawnZone1.y)
                                      local Npoint = {x = x, y = y}
                                      local NpointH = land.getHeight(Npoint)
                                      local unitSpawnZone = mist.utils.makeVec3(Npoint, NpointH)

                                      On land unitSpawnZone given by :

                                      local unitType
                                      local zone = trigger.misc.getZone('Wash-IN')
                                      local zoneOUT = trigger.misc.getZone('Wash-OUT')
                                      local EXpointV3 = mist.utils.zoneToVec3(zoneOUT)
                                      local EXpointV2 = mist.utils.makeVec2(EXpointV3)
                                      repeat
                                      unitSpawnZone = mist.getRandPointInCircle(zone.point, zone.radius)
                                      until land.getSurfaceType(unitSpawnZone) == land.SurfaceType.LAND and mist.terrainHeightDiff (unitSpawnZone, 250) < 30
                                      and mist.utils.get2DDist(unitSpawnZone, EXpointV2) > zoneOUT.radius
                                      and mist.utils.get2DDist(mist.utils.makeVec2(mist.getLeadPos('Blue F18c 3')), unitSpawnZone) > 20000
                                      Attached Files
                                      Last edited 09-28-2020, 11:15 AM. Reason: in post
                                      Hardware : I7 7700K - Z270 gaming M5 - 32GB ( 4x8 ) ddr4 3200Mhz - 1080Ti gaming X - SSD M2 - TM Twcs / TM Rgt yaw pedals / MS sidewinder FF2 + TM Warthog - Oculus Rift CV1.

                                      Comment


                                        I had to modify the getting the point on land code because it was missing a conversion to vec3 from the vec2 returned from getRandPointInCircle that you had with getting an on road point. Otherwise the coord.LOtoLL was being given a vec2 and instead of creating an error, it assumed the value was 0 and returned the lon value to be at map origin. At least tested with that code in 3.4.74 and 4.4.90 I was able to get accurate readback of coordinates on both versions using my modification.

                                        Code:
                                        local zone = trigger.misc.getZone('Wash-IN')
                                        local zoneOUT = trigger.misc.getZone('Wash-OUT')
                                        local EXpointV3 = mist.utils.zoneToVec3(zoneOUT)
                                        local EXpointV2 = mist.utils.makeVec2(EXpointV3)
                                        local altPoint
                                        repeat
                                            altPoint = mist.getRandPointInCircle(zone.point, zone.radius)
                                        until land.getSurfaceType(altPoint) == land.SurfaceType.LAND and mist.terrainHeightDiff (altPoint, 250) < 30 and mist.utils.get2DDist(altPoint, EXpointV2) > zoneOUT.radius and mist.utils.get2DDist(mist.utils.makeVec2(mist.getLeadPos('Blue F18c 3')), altPoint) > 20000
                                        altPoint = mist.utils.makeVec3GL(altPoint)
                                        local lat1, lon1 = coord.LOtoLL(altPoint)
                                        trigger.action.outText(mist.tostringLL(lat1, lon1, 2), 60)
                                        trigger.action.markToAll(2, mist.tostringLL(lat1, lon1, 3), altPoint)
                                        The right man in the wrong place makes all the difference in the world.
                                        Current Projects: Scripting Wiki, Something...
                                        Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

                                        Comment


                                          Originally posted by Grimes View Post
                                          I had to modify the getting the point on land code because it was missing a conversion to vec3 from the vec2 returned from getRandPointInCircle that you had with getting an on road point. Otherwise the coord.LOtoLL was being given a vec2 and instead of creating an error, it assumed the value was 0 and returned the lon value to be at map origin. At least tested with that code in 3.4.74 and 4.4.90 I was able to get accurate readback of coordinates on both versions using my modification.
                                          Much thanks !
                                          Hardware : I7 7700K - Z270 gaming M5 - 32GB ( 4x8 ) ddr4 3200Mhz - 1080Ti gaming X - SSD M2 - TM Twcs / TM Rgt yaw pedals / MS sidewinder FF2 + TM Warthog - Oculus Rift CV1.

                                          Comment

                                          Working...
                                          X