Rudel_chw Posted September 13, 2022 Share Posted September 13, 2022 Hello, I'm editing a mission for the recent OV-10A Mod, and at the end of it I would like to be able to rate the landing performance of the player, at least in terms of how long was the landing run. Does anyone have a script like that, one that takes a Unit's Name and can measure the distance between the point where it first touched the ground, and the point where its speed came to zero? Wish programming DCS scripts were easier, but the most I've been able to do is modify (slightly) other peoples' scripts and now I'm too old to learn Lua programming. Thanks beforehand for any help with my mission. Cheers! Eduardo For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1 Mobile: iPad Pro 12.9" of 256 GB Link to comment Share on other sites More sharing options...
toutenglisse Posted September 14, 2022 Share Posted September 14, 2022 (edited) @Rudel_chw hi ! Here is a script I wrote for you. Create a mission start trigger and load latest MIST and this script. Script will detect when a Player or Client lands on an airbase with an airplane on any map. Player gets a "TouchDown" message, and another one if he's outside of runway's boundaries. Then when Player stops he gets message with airbase callsign, runway name, landing distance, distance from runway's entry to landing point and distance from stop point to runway's end. Or another message if he stopped outside of boundaries. (gray quad mark is displayed on F10 map until 60sec after stop to show boundaries) EDIT : script/example updated to include both metric/imperial units and landing in openfield. Spoiler Pilot = {} mId = 0 function landing(event) if event.id == world.event.S_EVENT_LAND and event.place and event.place:getDesc()["category"] == 0 and event.initiator:isExist() == true and event.initiator:getPlayerName() and event.initiator:getDesc()["category"] == 0 then local PilotID = event.initiator:getID() trigger.action.outTextForUnit(PilotID , 'TouchDown !',3) local PilotName = event.initiator:getPlayerName() Pilot[PilotID] = nil local landPoint = event.initiator:getPoint() local airbaseCall = event.place:getCallsign() local runways = event.place:getRunways() if #runways > 0 then for i = 1, #runways do local points = {} local init = runways[i].position local bearing = runways[i].course * -1 local L2 = runways[i].length/2 local offset1 = {y = 0, x = init.x + (math.cos(bearing + math.pi) * L2), z = init.z + (math.sin(bearing + math.pi) * L2)} local offset2 = {y = 0, x = init.x - (math.cos(bearing + math.pi) * L2), z = init.z - (math.sin(bearing + math.pi) * L2)} local width = runways[i].width/2 points[1] = {x = offset1.x + (math.cos(bearing + (math.pi/2)) * width), y = 0, z = offset1.z + (math.sin(bearing + (math.pi/2)) * width)} points[2] = {x = offset1.x + (math.cos(bearing - (math.pi/2)) * width), y = 0, z = offset1.z + (math.sin(bearing - (math.pi/2)) * width)} points[3] = {x = offset2.x + (math.cos(bearing - (math.pi/2)) * width), y = 0, z = offset2.z + (math.sin(bearing - (math.pi/2)) * width)} points[4] = {x = offset2.x + (math.cos(bearing + (math.pi/2)) * width), y = 0, z = offset2.z + (math.sin(bearing + (math.pi/2)) * width)} if mist.pointInPolygon(landPoint, points) == true then mId = mId + 1 trigger.action.quadToAll(-1, mId, points[1], points[2], points[3], points[4], {0, 0, 0, 1}, {0, 0, 0, .5}, 3) Pilot[PilotID] = { [1] = landPoint, [2] = airbaseCall, [3] = runways[i].Name, [4] = math.floor(mist.utils.get2DDist(landPoint, offset1)), [5] = math.floor(mist.utils.get2DDist(landPoint, offset2)), [6] = points, [7] = offset1, [8] = offset2, [9] = mId, [10] = math.floor(mist.utils.get2DDist(landPoint, offset1)*3.28), [11] = math.floor(mist.utils.get2DDist(landPoint, offset2)*3.28) } end end end if Pilot[PilotID] ~= nil then mist.scheduleFunction(PilotStopped, {event.initiator, PilotID, PilotName}, timer.getTime()+5) else trigger.action.outTextForUnit(PilotID , PilotName..' you landed outside of runway boundaries !',10) end elseif event.id == world.event.S_EVENT_LAND and not event.place and event.initiator:isExist() == true and event.initiator:getPlayerName() and event.initiator:getDesc()["category"] == 0 then local PilotID = event.initiator:getID() trigger.action.outTextForUnit(PilotID , 'TouchDown !',3) local PilotName = event.initiator:getPlayerName() Pilot[PilotID] = nil Pilot[PilotID] = {[1] = event.initiator:getPoint()} mist.scheduleFunction(PilotStopped2, {event.initiator, PilotID, PilotName}, timer.getTime()+3) end end function PilotStopped2(PilotUnit, PilotID, PilotName) if PilotUnit:isExist() == true then local PilotVec = PilotUnit:getVelocity() local PilotSpeed = math.floor(math.sqrt(PilotVec.x^2 + PilotVec.y^2 + PilotVec.z^2)) local stopPoint = PilotUnit:getPoint() if PilotSpeed == 0 then local landDist = math.floor(mist.utils.get2DDist(Pilot[PilotID][1], stopPoint)) local landDist2 = math.floor(mist.utils.get2DDist(Pilot[PilotID][1], stopPoint)*3.28) trigger.action.outTextForUnit(PilotID , PilotName..' you landed in openfield.\n\nLanding distance : '..landDist.. ' meters / '..landDist2..' feet.',30) else mist.scheduleFunction(PilotStopped2, {PilotUnit, PilotID, PilotName}, timer.getTime()+0.5) end end end function PilotStopped(PilotUnit, PilotID, PilotName) if PilotUnit:isExist() == true then local PilotVec = PilotUnit:getVelocity() local PilotSpeed = math.floor(math.sqrt(PilotVec.x^2 + PilotVec.y^2 + PilotVec.z^2)) local stopPoint = PilotUnit:getPoint() if PilotSpeed == 0 then if mist.pointInPolygon(stopPoint, Pilot[PilotID][6]) == true then if math.floor(mist.utils.get2DDist(stopPoint, Pilot[PilotID][7])) > Pilot[PilotID][4] then landDistEntry = Pilot[PilotID][4] landDistEntry2 = Pilot[PilotID][10] landDistStop = math.floor(mist.utils.get2DDist(stopPoint, Pilot[PilotID][8])) landDistStop2 = math.floor(mist.utils.get2DDist(stopPoint, Pilot[PilotID][8])*3.28) else landDistEntry = Pilot[PilotID][5] landDistEntry2 = Pilot[PilotID][11] landDistStop = math.floor(mist.utils.get2DDist(stopPoint, Pilot[PilotID][7])) landDistStop2 = math.floor(mist.utils.get2DDist(stopPoint, Pilot[PilotID][7])*3.28) end local landDist = math.floor(mist.utils.get2DDist(Pilot[PilotID][1], stopPoint)) local landDist2 = math.floor(mist.utils.get2DDist(Pilot[PilotID][1], stopPoint)*3.28) trigger.action.outTextForUnit(PilotID , PilotName..' you landed at '..Pilot[PilotID][2]..' on runway '..Pilot[PilotID][3].. '.\n\nLanding distance : '..landDist.. ' meters / '..landDist2.. ' feet.\n\nDistance from runway entry at landing point : '..landDistEntry.. ' meters / '..landDistEntry2.. ' feet.\n\nDistance from runway end at stop point : '..landDistStop.. ' meters / '..landDistStop2..' feet.',30) else trigger.action.outTextForUnit(PilotID , PilotName..' you stopped outside of runway boundaries !',10) end mist.scheduleFunction(trigger.action.removeMark, {Pilot[PilotID][9]}, timer.getTime()+60) else mist.scheduleFunction(PilotStopped, {PilotUnit, PilotID, PilotName}, timer.getTime()+0.5) end end end landingID = mist.addEventHandler(landing) test-landing-distance.miz Edited September 21, 2022 by toutenglisse second script update 1 1 Link to comment Share on other sites More sharing options...
Rudel_chw Posted September 14, 2022 Author Share Posted September 14, 2022 1 hour ago, toutenglisse said: Here is a script I wrote for you Thank you so much for doing this for me hopefully it will be useful to other mission designers as well. I'm having great fun trying to land this aircraft on as little space as possible: So I tought about giving the playeer feedback on this after landing ... thanks a lot again for this, will test the script tonight and save it on my script library for future use Best regards, Eduardo 2 For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1 Mobile: iPad Pro 12.9" of 256 GB Link to comment Share on other sites More sharing options...
Rudel_chw Posted September 14, 2022 Author Share Posted September 14, 2022 4 hours ago, Rudel_chw said: will test the script tonight and save it on my script library for future use @toutenglisse .. just tested it, worked perfectly, thanks a lot 2 For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1 Mobile: iPad Pro 12.9" of 256 GB Link to comment Share on other sites More sharing options...
Zeagle Posted September 14, 2022 Share Posted September 14, 2022 Rudel learning Lua is fun. It is much simpler than many other languages. Anyway that script can be written without Mist. Link to comment Share on other sites More sharing options...
Rudel_chw Posted September 14, 2022 Author Share Posted September 14, 2022 1 hour ago, Zeagle said: Rudel learning Lua is fun. It is much simpler than many other languages. Anyway that script can be written without Mist. While I find the DCS MIssion Editor to be almost as fun as flying the aircrafts, learning LUA programming within the context of DCS is not simple ... for one there is much too little documentation (sure, there is a lot for standard LUA, but not for using it within DCS) and little tutorials and code samples. From my point of view, using LUA frameworks like Moose or Mist is not a detriment, since they don't require the end user to install anything, they are not User Mods, as they are encapsulated inside the MIZ file. For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1 Mobile: iPad Pro 12.9" of 256 GB Link to comment Share on other sites More sharing options...
Rudel_chw Posted September 18, 2022 Author Share Posted September 18, 2022 On 9/14/2022 at 9:02 AM, toutenglisse said: Script will detect when a Player or Client lands on an airbase with an airplane on any map. Hi @toutenglisse .. just a short post to let you know that I finished the mission that uses your script, a training one for the OV-10A mod, it worked perfectly and since the script works on any airbase at any map, I will probably use it on other missions of this kind ... here you can take a look at how it improves the feedback that a studentr pilot receives after landing Cheers, and thanks again 2 For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1 Mobile: iPad Pro 12.9" of 256 GB Link to comment Share on other sites More sharing options...
toutenglisse Posted September 18, 2022 Share Posted September 18, 2022 @Rudel_chw nice work with this training mission ! Link to comment Share on other sites More sharing options...
MPalmer Posted September 20, 2022 Share Posted September 20, 2022 That is fantastic!!!, toutenglisse...my I use your script and it possible, can I have it displayed in imperial measurements (feet). Marvin "Cactus" Palmer DCS:World 2.5(ob) Gigabyte Z390 Designare i7-9700K (4.6GHz), 32Gb RAM (3600MHz), GTX2070, 40" 1080p Monitor, TM Warthog, Saitek Rudder pedals,TM Cougar MFD, and an ipad. Link to comment Share on other sites More sharing options...
toutenglisse Posted September 21, 2022 Share Posted September 21, 2022 (edited) On 9/21/2022 at 12:57 AM, MPalmer said: That is fantastic!!!, toutenglisse...my I use your script and it possible, can I have it displayed in imperial measurements (feet). No problem. I have updated my previous post with script and example, to display both metric and imperial units. EDIT : I've updated again right now my previous post to also include landing in openfield (ouside of any base radius. Note ! : this invisible radius in game is 4kms around airbase center, while in mission editor it is a 2kms black circle). Edited September 23, 2022 by toutenglisse in post 2 Link to comment Share on other sites More sharing options...
Recommended Posts