hcpookie 3770 Posted April 22, 2017 Doing some experimentation today. Discovered that terrainIntersect always returns "true" in my script past ~30km. https://community.bistudio.com/wiki/terrainIntersect Is there a hard-coded limit to terrainIntersect distance? What I need is a way to check > 30km away... I know this is CPU intensive however I only need to do it a few times per script. Is there a "long distance" solution for this? EDIT - the "checkVisibility" also returns "0" at those ranges... so the caveat "may be affected by terrain Grid Size" seems to apply Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted April 22, 2017 Why on earth would you need a 30km terrainIntersect check? Cheers Share this post Link to post Share on other sites
hcpookie 3770 Posted April 22, 2017 Because my Patriot has a 70km intercept range, SA20 has 150km range, and SA21 has 215km range. 5 Share this post Link to post Share on other sites
killzone_kid 1331 Posted April 22, 2017 6 minutes ago, hcpookie said: Because my Patriot has a 70km intercept range, SA20 has 150km range, and SA21 has 215km range. And what are TTLs of those missiles? It can have 100000 millions Km range but if its TTL 3 sec, it will be deleted in 3 seconds. As for long distance intersection checks, you can do it 5 km segments for example. 0->5->10->15... Share this post Link to post Share on other sites
hcpookie 3770 Posted April 22, 2017 TTL is about 120 seconds. Takes about 70 seconds for it to travel 130km so I may reduce TTL so missiles that miss their target don't linger. Which is very close to RL speeds of about Mach 6.5-7. Not sure what you mean by the segments... the problem is that w/o the check the AI will launch missiles into mountains if you're flying low enough. I am thinking that for more realism I may do a height check of the target so that at progressive ranges the "lowest" engagement height will incrementally increase, which will simulate the horizon aperture (I think it is called). Still however I suppose there could be terrain situations where the missile could still shoot into a mountain. 1 Share this post Link to post Share on other sites
killzone_kid 1331 Posted April 22, 2017 2 minutes ago, hcpookie said: Not sure what you mean by the segments. Say you have 10 km to check but max command range is 5km you check the intersection between 0m and 5000m first if no intersection then you continue and check intersection between 5000m and 10000m if there is nointesection there as well you can safely say there is no intersection between 0m and 10000m as well This is what I mean by the segments Share this post Link to post Share on other sites
hcpookie 3770 Posted April 22, 2017 That's an interesting idea... I don't know if it will "see" beyond the 30km limit I'm seeing... I am working on the ASSUMPTION that it is a limit from the launcher to the actual target, but if it is a "distance" limit of the measurement, I could start at the 30km mark and measure to the 60km mark that would certainly work around what appears to be the hard limit. That might work... I guess I need to research those vector commands more closely to find that "start" point at the 30km mark Share this post Link to post Share on other sites
killzone_kid 1331 Posted April 23, 2017 15 hours ago, hcpookie said: That's an interesting idea... I don't know if it will "see" beyond the 30km limit I'm seeing... I am working on the ASSUMPTION that it is a limit from the launcher to the actual target, but if it is a "distance" limit of the measurement, I could start at the 30km mark and measure to the 60km mark that would certainly work around what appears to be the hard limit. That might work... I guess I need to research those vector commands more closely to find that "start" point at the 30km mark It seems the max range for terrainIntersect depends on your current view distance settings as well and god knows on what else. At 12000 view distance the limit seems to be 180 km for me Share this post Link to post Share on other sites
hcpookie 3770 Posted April 23, 2017 Odd it works for you... my overall settings are also at 12000... Object 5791... "and who knows what else"... lol I am adding a hint str(_terrainIntersect) which always returns "0" at those long distances which is how the script decides to proceed, or abandon that target. Thanks for researching it however! I'm going to play around with it some more to see if I can find that magic combination of settings. I mean, if you can make it work then I should be able as well. Share this post Link to post Share on other sites
killzone_kid 1331 Posted April 23, 2017 51 minutes ago, hcpookie said: Object 5791 Are you intersecting to some static map object? It might not exist, especially at great distances 51 minutes ago, hcpookie said: hint str(_terrainIntersect) which always returns "0" Terrain intersect command returns boolean, not sure what you are doing there Share this post Link to post Share on other sites
hcpookie 3770 Posted April 24, 2017 Sorry I've been sick and a bit punchy. What I mean is that it always returns "true" even at long distance, meaning that regardless of altitude the script never sees you as a valid target, even if you're at altitudes well above the terrain. Have to fly closer, around the 40km mark, for it to work correctly. These are all on the PMC maps which don't have anything but the terrain. Been sick so I haven't tested it on any other maps yet. Share this post Link to post Share on other sites
hcpookie 3770 Posted April 24, 2017 Adding - I moved the plane and SAM launcher to the Virtual Reality map... same thing. Returns "true" at any distance. SO... I decided to check a normal sized terrain: VR map, and Chernarus. In this script, "_radarVehicle" is making the terrainIntersect check. "_detectedVehicle" is the enemy plane. The "_detectedVehicle" is discovered via a nearEntities check. _terrainCheck = terrainIntersect [getPosATL _radarVehicle, getPosATL _DetectedVehicle]; hint format ["terraincheck %1",_terrainCheck]; The _terrainCheck is ALWAYS "true". Always. Testing anywhere from 20km down to about 3km. So. I added this just to reset it in case it was keeping something in memory: _terrainCheck = false; _terrainCheck = terrainIntersect [getPosATL _radarVehicle, getPosATL _DetectedVehicle]; hint format ["terraincheck %1",_terrainCheck]; I have *NEVER* seen it return "false". So I am obviously doing something wrong but it doesn't seem obvious to me. I have tried "position" as well as "getPosATL". I'm feeling better today so I may to look into this some more. I tried several variations of the command and it hasn't ever made a difference. Frustrating! I hope I'm just doing something really dumb but the BIKI article is pretty simple... To add... if I completely remove the terrainIntersect check, the SAM's will shoot at me regardless of distance. So I know that the SAM launcher vehicle itself has the capabilities to actually shoot at me that far away. So I feel I can safely rule out the vehicle itself since it definitely works Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted April 24, 2017 terrainIntersect is using positionAGL, you're feeding it positionATL. Try using terrainIntersectASL and use getposASL to get the object positions. You might also try using the barrel end of the model as reference position, so you're actually checking the position where the missile will spawn, not the position of the vehicle that's shooting the missile. _gun = YourVehicle; _gunEnd = getText (configfile >> "CfgVehicles" >> (typeOf _gun) >> "Turrets" >> "MainTurret" >> "gunEnd"); _gunpos = ATLtoASL (_gun modeltoworld(_gun selectionposition _gunEnd)); Cheers 1 Share this post Link to post Share on other sites
hcpookie 3770 Posted May 11, 2017 SOLVED: It has NOTHING to do with getpos vs getpos ATL vs getpos ASL. I tried all and had the same results! It DOES depend on the vehicle position on the terrain. The static vehicle in this case returns getpos vehicle select 2 as a negative value, only -0.09, and with this condition the check always returns TRUE even if you are hovering 1km high and 1km away :) Taking your suggestion as a cue, I set the "getpos vehicle" portion to be Z +20: (getpos vehicle select 2) + 20. Suddenly the terrainCheck correctly returns "false" when the target plane is flying at altitude. Therefore, it appears to be that the terrainIntersect check assumes a Z + position. "SOLVED". So my challenge is why does getPos return a negative (Z - ) value for the vehicle. I presume getPos finds center of mass which is low enough to the ground on these STATIC launcher vehicles to produce a negative value in some cases. My "+ 20" check seems to work 100% of the time. Your "get gun position" seems like a good idea. Additional observation: The terrainIntersect appears to be affected by ground clutter at distance. At 150km (again, the PMC maps), I had to climb rather high, around 3,000m, before it would return "false". Kind of difficult to evaluate via the camera view at that distance, but it seems that the farther away you are the higher you must be for terrainIntersect to return "false" as if the Jets "ground clutter" sensor value is being applied. This is my observation only. It is anecdotal and may not be accurate. 1 Share this post Link to post Share on other sites
Sniperwolf572 758 Posted May 11, 2017 It's probably a precision thing, especially on larger maps, the floating point precision goes whack the further something is from [0,0,0], you can even see your weapon and attachments shaking in your hands. Since the Z offset is underground by so little, you could always try getPosWorld to get the position of the center of the vehicle instead of it's position on the ground. It should compensate for the lack of precision. Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted May 11, 2017 The further away you get the smaller the angle of elevation (basically the line that's being checked by terrainIntersect) will be. _angle = atan (_height / _distance); If you check a position at a distance of 1km and an altitude of 100m, the angle will be around 5.7°. if you check at a distance of 10km and altitude of 100m the angle will only be around 0.57°. Now considering your example of 150km and 3km altitude you'll get an angle of around 1.1458°. This is flat enough that you'll most likely hit terrain within the first few hundred meters, since a small hill would suffice. As an example: _angle = atan (20 / 1000) 20m hill at a distance of 1000m, results in an angle of exactly the same angle when checking for 150km at 3km altitude: 1.1458° Your terrainIntersect would return true. Please correct me if I'm wrong, since school has been a while for me. Cheers Share this post Link to post Share on other sites
x3kj 1247 Posted May 13, 2017 On 11.5.2017 at 2:12 PM, Grumpy Old Man said: 20m hill at a distance of 1000m, results in an angle of exactly the same angle when checking for 150km at 3km altitude: 1.1458° Your terrainIntersect would return true. Please correct me if I'm wrong, since school has been a while for me. Not wrong. But not a complete representation of what should be happening. The long range missiles launch at large angles upwards and only steer towards the target when they reached some altitude. So small bumps are not really an issue, and the terrain intersect check should be conducted from a startingposition considerably above the vehicle. Regarding the -0.09 Z axis - The center of the vehicle could be the center of the models bounding box (which is automatically calculated), so if you have some memorypoints and stuff below the vehicle this could be the cause. If you want to use positions from the vehicle, i would recommend defining a custom memorypoint in the launchervehicle, then get the modelspace coordinate of this memorypoint selection and convert that into worldspace. Share this post Link to post Share on other sites