Spades_Neil Posted February 4, 2017 Share Posted February 4, 2017 (edited) I'd like to make an event that activates not when a unit enters a zone, but rather, specifically when a hostile unit is picked up by radar scanning, such as EWR, or a ship. The goal is to cause being detected on radar to cause fighters to try taking off from the airfield. The mission objective is to fly in below the radar and attempt to take out the airfield before the fighters can take off to defend it. Edited February 11, 2017 by Spades_Neil I wasn't being clear, so I'm editing this. Link to comment Share on other sites More sharing options...
Grimes Posted February 5, 2017 Share Posted February 5, 2017 You are going to have to use scripting. There are two main ways to do it, both are kinda similar. So you get the controller for a radar system and then use two functions to see if any of the a specific unit is detected. You can iterate a list of known objects to see if the radar sees any of them with isTargetDetected or you can get a list of detected targets with getDetectedTargets For the Viggen mission "Tuapse Embargo" I made a simple little script to see if the ships you are shooting at have detected anti-ship missiles fired at them. if #foundMis > 0 then for i = 1, #foundMis do if Object.getCoalition(foundMis[i]) == 2 then if Unit.getByName('Rezky') and Unit.getByName('Rezky'):getLife() > 0 then if Group.getByName('Rezky'):getController():isTargetDetected(foundMis[i], 'VISUAL', 'RADAR', 'OPTIC', 'RWR') == true then trigger.action.setFlag(1, true) end end end end end foundMis is just a table of missiles fired. So if it detects any missile object via visual, radar, optical, or rwr sensors it sets flag 1 to true which changes the groups ROE from return fire to fire at will. I didn't use scripting for changing the ROE because I was lazy. 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 Link to comment Share on other sites More sharing options...
Spades_Neil Posted February 6, 2017 Author Share Posted February 6, 2017 I'm not at all familiar with scripting in DCS. How exactly would I adapt this for aircraft? I see missiles there so I mean I know how missiles would be detected. If missiles is more than one, then for each missile in the array, get the coalition. If the coalition == 2 (Blue I guess?), then after that I have no idea what is happening. Link to comment Share on other sites More sharing options...
Grimes Posted February 6, 2017 Share Posted February 6, 2017 Ok, so if you follow the documentation for isTargetDetected the misObject table is simply used to supply data for the "Object Target" entry. This means it accepts any object type whether it is a unit, missile, static object, or whatever. In a simple example you can define the list of units via their name in a table like this: local units = {'u1', 'u2', 'u3'} You can then modify the isTargetDetected line to be similar to this: Group.getByName('Rezky'):getController():isTargetDetected(Unit.getByName(units), 'VISUAL', 'RADAR', 'OPTIC', 'RWR') So when i = 2 it would go to the 2nd entry of the table (u2) and try to get the unit object for it by doing Unit.getByName('u2') Bear in mind you may need to add an extra check to make sure the unit object is accessible to begin with. If it was a client aircraft for example and the aircraft isn't spawned in you'd be feeding the function a nil value because Unit.getByName('u2') wouldn't return anything. That is basically what the line above it from my example is doing to make sure that the unit "Rezky" is still alive. 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 Link to comment Share on other sites More sharing options...
Spades_Neil Posted February 11, 2017 Author Share Posted February 11, 2017 (edited) I'm afraid you've lost me. I'm sorry if I seem dense. I have no experience with LUA scripting, but I don't want to make you feel like I'm just asking you to do it for me. Let's recap first so I make sure I understand. I added comments to your original code to translate into layman's terms what is happening. if #foundMis > 0 then -- If the array of foundMis is bigger than 0... for i = 1, #foundMis do -- For each missile, do the following... if Object.getCoalition(foundMis[i]) == 2 then -- Make sure it's the Blue Team, and then... if Unit.getByName('Rezky') and Unit.getByName('Rezky'):getLife() > 0 then -- Make sure the Rezky is alive because we need that for this next part... if Group.getByName('Rezky'):getController():isTargetDetected(foundMis[i], 'VISUAL', 'RADAR', 'OPTIC', 'RWR') == true then -- Get the address for the Rezky, then get its controller and run the function isTargetDetected. If it finds one of the missiles in the current part of the array foundMis by Visual, Radar, Optic, or RWR... trigger.action.setFlag(1, true) -- Set the flag 1 to true. end end end end end I think I understand what the code here does, but I'm not sure how or even why foundMis is defined. When I run this, I get the error "Attempt to get length of global 'foundMis' (a nil value)" I assume it's because the variable is not correctly defined. But why would I want that variable for this application? I am not looking for anything in a specific list of units or objects. I'm looking for any object that is Blue team. And what's this about a unit list? I'm not looking for a specific unit called u1, u2, or u3. That's helpful if I ever am doing that, but right now I am not. I hope I do not have to define an array for literally the entire Blue Team. The goal is to have a ground based early warning radar detect anything from an opposing force, and then trigger a flag. It sounds like all I want is for isTargetDetected to just check if a unit it's detecting is Blue. I do not know how to do that. EDIT: The explanation you gave is exactly what I asked for--but what I asked for isn't what I meant to ask for. Whoops. ^^; I edited my original post to clarify better. Edited February 11, 2017 by Spades_Neil Link to comment Share on other sites More sharing options...
FlightControl Posted February 11, 2017 Share Posted February 11, 2017 I'd like to make an event that activates not when a unit enters a zone, but rather, specifically when that unit is picked up by enemy radar scanning, such as EWR, or a ship. The goal is to cause being detected on radar to cause fighters to try taking off from the airfield. The mission objective is to fly in below the radar and attempt to take out the airfield before the fighters can take off to defend it. Can be done... Wait till next week... [TABLE][sIGPIC][/sIGPIC]| Join MOOSE community on: DISCORD :thumbup: Website of the MOOSE LUA Framework. MOOSE framework Downloads. Check out Example Missions to try out and learn. MOOSE YouTube Channel for live demonstrations and tutorials. [/TABLE] Link to comment Share on other sites More sharing options...
Spades_Neil Posted February 11, 2017 Author Share Posted February 11, 2017 Can be done... Wait till next week... Wait, why? What happens next week? :huh: Link to comment Share on other sites More sharing options...
ENO Posted February 12, 2017 Share Posted February 12, 2017 Flight control and his magic fingers! "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art Link to comment Share on other sites More sharing options...
Spades_Neil Posted February 12, 2017 Author Share Posted February 12, 2017 I'm just even more confused now. Link to comment Share on other sites More sharing options...
FlightControl Posted February 12, 2017 Share Posted February 12, 2017 I'm just even more confused now. Currently in development is a detection class that triggers an event upon detection. That event can be catched in an event handler. See the following demo script. --- -- Name: DET-120 - Detection Probability Zones -- Author: FlightControl -- Date Created: 04 Feb 2017 -- -- # Situation: -- -- Demonstrates the DistanceProbability factor during the detection of units. -- A forest zone has been declared that stimulates invisibility while those units drive in the forest. -- -- Two Recce are detecting 4 units, which are located in a forest. -- The first Recce has no Zone probability set in the forest. -- The second Recce has a Zone Probability set. -- -- # Test cases: -- -- 1. Observe the reporting of both the first and second Recce. The second should report slower the detection than the first. -- 2. Eventually all units should be detected by both Recce. Especially when the units drive out of the forest. -- 3. Each detection results in an event being called. local RecceSetGroup1 = SET_GROUP:New():FilterPrefixes( "Recce 1" ):FilterStart() local RecceSetGroup2 = SET_GROUP:New():FilterPrefixes( "Recce 2" ):FilterStart() local HQ = GROUP:FindByName( "HQ" ) local CC = COMMANDCENTER:New( HQ, "HQ" ) local RecceDetection1 = DETECTION_UNITS:New( RecceSetGroup1 ) local RecceDetection2 = DETECTION_UNITS:New( RecceSetGroup2 ) local ForestZone = ZONE_POLYGON:New( "ForestZone", GROUP:FindByName( "ForestZone" ) ) RecceDetection2:SetZoneProbability( { { ForestZone, 0.1 } } ) -- Set a 10% probability that a vehicle can be detected within the forest. RecceDetection1:Start() RecceDetection2:Start() --- OnAfter Transition Handler for Event Detect. -- @param Functional.Detection#DETECTION_UNITS self -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. function RecceDetection1:OnAfterDetect(From,Event,To) local DetectionReport = self:DetectedReportDetailed() HQ:MessageToAll( DetectionReport, 15, "Detection 1 - No Zone Probability" ) end --- OnAfter Transition Handler for Event Detect. -- @param Functional.Detection#DETECTION_UNITS self -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. function RecceDetection2:OnAfterDetect(From,Event,To) local DetectionReport = self:DetectedReportDetailed() HQ:MessageToAll( DetectionReport, 15, "Detection 2 - Forest Zone Probability" ) end garbagecollect() Trying to release this next week... To check some of the magic fingers, see my signature... Sven [TABLE][sIGPIC][/sIGPIC]| Join MOOSE community on: DISCORD :thumbup: Website of the MOOSE LUA Framework. MOOSE framework Downloads. Check out Example Missions to try out and learn. MOOSE YouTube Channel for live demonstrations and tutorials. [/TABLE] Link to comment Share on other sites More sharing options...
Grimes Posted February 13, 2017 Share Posted February 13, 2017 And what's this about a unit list? I'm not looking for a specific unit called u1, u2, or u3. That's helpful if I ever am doing that, but right now I am not. I hope I do not have to define an array for literally the entire Blue Team. The goal is to have a ground based early warning radar detect anything from an opposing force, and then trigger a flag. It sounds like all I want is for isTargetDetected to just check if a unit it's detecting is Blue. I do not know how to do that. EDIT: The explanation you gave is exactly what I asked for--but what I asked for isn't what I meant to ask for. Whoops. ^^; I edited my original post to clarify better. Its perfectly understandable, this stuff also confused me at first. Once you get the hang of it, its not so bad. So as I said before there are two ways to do it. With isTargetDetected you will need to define a table of all the possible units. With getDetectedTargets it gives you a table of whatever is detected and you need to filter it out from there. Both have their uses, but if you are wanting to just do a blanket "anything from blue" then getDetectedTargets would be better. That said for the sake of information I will answer how you could build an array of all the blue units. To define a table of all units isn't terribly difficult with scripting. At its simplest you can use a function like coalition.getGroups() to return all the groups for a team, iterate each group and use Group.getUnits to return a list of the units, and add them all up into a new table. Alternatively you can use scripting library like mist, moose, msf, or other libraries creatively placed usage of "mission" and "scripting" into the acronym. These scripts all just use what is already available to the scripting engine anyways, its just organized for a specific purpose. With mist there are two main ways to do it, both would replace the 'units' table from my above example. 1. Is to iterate mist.DBs.unitsByName, check if the unit is on blue, and add it to a new table. local uTable = {} for uName, uData in pairs(mist.DBs.unitsByName) do if uData.coalition == 'blue' then uTable[#uTable+1] = uName end end-- sorry I was to lazy to type this in notepad++ to correctly tab it and copy back here 2. Is to use a function Speed wrote just such a purpose via the mist.makeUnitTable() function. local bluePlanes = mist.makeUnitTable({'[blue][plane]'}) And finally here is an example of how it would work with getDetectedTargets, which as stated earlier returns a table of all things the AI is detecting. if Group.getByName('radar') then local targets = Group.getByName('radar'):getController():getDetectedTargets('RADAR') -- gets a table of targets detected by radar if type(targets) == 'table' and #targets > 0 then -- if it is a table and there is 1 or more table entries for i = 1, #targets do -- iterate table if Object.getCategory(targets[i]) == 1 then -- if the object is a unit if Unit.getCoalition(targets[i]) == 2 then -- if the unit is coaliton blue trigger.action.setUserFlag('1', true) break end end end end end I hope that didn't add to the confusion. 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 Link to comment Share on other sites More sharing options...
Spades_Neil Posted February 18, 2017 Author Share Posted February 18, 2017 http://www.dropbox.com/s/voppomseyhjc2nv/Screenshot%202017-02-17%2016.13.57.png :( Wiki is giving me a 502 error right now so I cannot investigate. Link to comment Share on other sites More sharing options...
Spades_Neil Posted February 19, 2017 Author Share Posted February 19, 2017 Aaaaaa I am so close yet so far away! I'm stumped. Bumping in the hopes that someone knows what is going wrong.MG.miz Link to comment Share on other sites More sharing options...
Goodwin Posted October 13, 2019 Share Posted October 13, 2019 Aaaaaa I am so close yet so far away! I'm stumped. Bumping in the hopes that someone knows what is going wrong. is there no solution? Link to comment Share on other sites More sharing options...
Tiramisu Posted November 6, 2019 Share Posted November 6, 2019 Can we check, whether the RWR of an aircraft detects a search- or a lock-radar signal? Link to comment Share on other sites More sharing options...
Rookie1983 Posted September 13, 2020 Share Posted September 13, 2020 Is it possible to make a such trigger for A-10c in ME? "X:COCKPIT INDICATION HAS TEXT"? Link to comment Share on other sites More sharing options...
Rudel_chw Posted September 13, 2020 Share Posted September 13, 2020 Can we check, whether the RWR of an aircraft detects a search- or a lock-radar signal? Yes, but it depends on the specific aircraft, here is a mission where I distinguish amongst signals on the JF-17 RWR dIH6_vPP578 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...
Recommended Posts