L39Tom Posted June 30, 2019 Share Posted June 30, 2019 Hi, I want to know if a unit has detected a plane and found that function: boolean, Object Unit.getRadar(Class Self ) example: unitRadar,target=Unit.getByName(red):getRadar() 1st val gets true, if the unit has a search radar. The 2nd val returns the object that has been detected, right? How can I get the name of the detected object("target")? Link to comment Share on other sites More sharing options...
Hardcard Posted June 30, 2019 Share Posted June 30, 2019 (edited) I haven't tested it, but I'm guessing this would work: unitRadar,target = Unit.getByName("[color="Red"]ME PILOT name of the unit using the radar[/color]"):getRadar() target:getName() [color="Blue"]-- Should return a string containing the name of the unit being painted[/color] [color="Blue"]-- It can be used in messages:[/color] trigger.action.outText("Name of the unit being painted = "..target:getName(),10) [color="blue"]-- In logic checks (probably what you're after):[/color] if target:getName() == "[color="Red"]ME PILOT name of the unit you're interested in[/color]" then do stuff end [color="blue"]-- etc.[/color] Edited June 30, 2019 by Hardcard [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
L39Tom Posted June 30, 2019 Author Share Posted June 30, 2019 As I wanted to know when a plane gets detected by radar from a sam site, I hope the function getRadar() could bring me further. With your help Hardcard I find something interesting. 1.The boolean "unitRadar" is getting true just for search radar units. 2.In the case of a S300-site just the launcher-units gives you the "target", but just before it fires a missile. Is there an other function fits better. (In a mission I want to fire a flag when a player flies to high an gets detected by radar) PS: Try it with "isTargetDetected" aswell, but that function stays true in line of sight and radar detection after once gets true. Link to comment Share on other sites More sharing options...
Hardcard Posted June 30, 2019 Share Posted June 30, 2019 (edited) Ok, so you're only interested in triggering a flag when a client flies over a certain altitude and gets detected... right? What would be the altitude threshold? Also, can you provide more details on detection conditions? Do you want the flag to be triggered when the client gets detected by ANY radar or only when it gets detected by certain specific radar units? Edited June 30, 2019 by Hardcard [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
L39Tom Posted July 1, 2019 Author Share Posted July 1, 2019 Ok, so you're only interested in triggering a flag when a client flies over a certain altitude and gets detected... right? The client/player should stay as low as possible to avoid the radar and should use the terrain to stay undetected. If getting detected a red flight should start. This is not done with checking MSL-AGL, so I wanted to combine radar detection (search radar sites - radar picture) and some visual detection (red units - Line of sight and distance). To get LOS and distance is no problem, but I have still no clue to get that radar detection. Link to comment Share on other sites More sharing options...
Hardcard Posted July 1, 2019 Share Posted July 1, 2019 (edited) Here's a way of getting the unit's altitude from ground (required fields marked in red, don't remove the quotation marks): local Target = Unit.getByName("Unit/PILOT name of the client in ME") local Target_Position = Target:getPosition() local Ground_Elevation_MSL = land.getHeight( { x = Target_Position.p.x, y = Target_Position.p.z } ) local Target_Altitude_Ground = ( Target_Position.p.y - Ground_Elevation_MSL ) -- This will return the client's altitude from ground in meters -- If you want to get the value in feet, use this (keep in mind that the DCS scripting engine works in meters, though): local Target_Altitude_Ground_Feet = Target_Altitude_Ground * 3.281 -- If you want to, you can also round the altitude values (it isn't required for logic checks, but comes in handy when you need to include the values in text messages): local Target_Altitude_Ground_Rounded = math.floor( Target_Altitude_Ground + 0.5 ) -- This will return the client's altitude from ground in meters (rounded) local Target_Altitude_Ground_Feet_Rounded = math.floor( Target_Altitude_Ground_Feet + 0.5 ) -- This will return the client's altitude from ground in feet (rounded) -- In any case, you can then use the client's altitude from ground in logic checks: if Target_Altitude_Ground > altitude from ground threshold in meters then do stuff end As for radar detection, let me think about it. Edited July 1, 2019 by Hardcard [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Habu_69 Posted July 1, 2019 Share Posted July 1, 2019 I have scripted similar scenarios using MOOSE: PlayerHt = F18_Grp:GetHeight( true ) -- True = from ground. False = from MSL if PlayerHt > 200 then do stuff end I "assumed" a max height AGL above which the unit was detected. Link to comment Share on other sites More sharing options...
Hardcard Posted July 1, 2019 Share Posted July 1, 2019 @Habu I was deliberately avoiding MOOSE ;) @L39Tom :GetHeight( true ) (MOOSE function) will basically run the standard DCS code I provided, requiring a considerably shorter script, as Habu has shown (you'll need to load Moose.lua at mission start for it to work, though). [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Recommended Posts