Jump to content
Sign in to follow this  
00dc15

Can you get the range from rangefinders into a scrript

Recommended Posts

Hi,

I would like to know if it's possible to get the range off the rangefinders into a script, what I want is to have an AI soldier looking through his rangefinder binoculars and then be able to put that distance from them into a script to compare to the actual range to confirm that he has line of sight (as the distance on rangefinders is stopped by buildings) ?

Thanks for any help

Regards

James

Share this post


Link to post
Share on other sites

I can't give you an answer but maybe this points towards the right direction:

Not sure how the rangefinders work but I would assume its like the laser designators, which basically "shoot" an object/target, in the designator's case it creates a laserTarget object. Perhaps the rangefinder makes another object and gets the distance from the player to the target and that's what it returns. If so I'm sure you'd be able to intercept that returned value or just check for the object it creates and check the distance yourself.

Share this post


Link to post
Share on other sites

@ JDOG,

Thanks for the response, the range displayed doesn't seem detectable with nearestobject(s) like a laser dot is but I think Kylania may have put me onto something good.

@ Kylania,

Thanks for the response,I have tested this with the AI & by initial testing it seems it could be what I need, it seems to return the range of the first object before the target object (I'm getting an AI to target me & then moving behind other objects), I need to do alot more testing yet. Thanks very much for pointing me in the direction of a command that I never realised existed, I really do need to go through the command list & look at all the commands that I don't know about.

Edit: No I see it now Hint Format ["%1", unit distance cursortarget] returns the distance between where I'm looking and the unit, I need to get the distance between his cursorTarget & him, which I suspect may not be possible, oh well back to the drawing board.

Regards

James

Edited by 00dc15
New Information

Share this post


Link to post
Share on other sites

Try the format:

laserTarget unitWithLaserDesignator

The command isn't in wiki yet, so little known about it. And most likely it only deals with designators, not range finders.

Can't think of any solutions for range finding, I'm not sure if AI works with cursorTarget even internally.

If all you want to do is check line of fire, and can live without the distance, you might try intersect instead? Hmm, I don't think I've ever tested it though.

Share this post


Link to post
Share on other sites

@ CarlGustaffa,

Good work, Using Hint format ["%1", player distance lasertarget player] gives me a return of the range displayed on the designator, which if great, but as you say & I've tried it doen't deal with range finders. Your idea would now work for me if I could find a way to get the AI to turn on there designator without the need for an enemy tank to be present, any ideas ?

Thanks very much for your command, it will go in my list of code snippits as I know I'll need it in the future.

Regards

James

Share this post


Link to post
Share on other sites

I'm implementing polar designation for my Domino artillery system, and came up with the following solution. Although you're probably not interested in direction, I think it may be relevant for those who search, so I'll add that as well. Both direction (in 6000 mils system, as vanilla default compass outer ring) and distance (in meters) are rounded to nearest 10.

Direction:

_control ctrlSetText format ["%1",if (cameraView == "GUNNER" && currentWeapon player == "Binocular_Vector") then {((round (((player weaponDirection (currentWeapon player) select 0) atan2 (player weaponDirection (currentWeapon player) select 1))/360 * 600) * 10) + 6000) % 6000} else {"0000"}];

Distance:

_control ctrlSetText format ["%1", if (cameraView == "GUNNER" && currentWeapon player == "Binocular_Vector") then {round ((player distance screenToWorld [0.5,0.5])/10) * 10} else {"0"}];

The cameraView check is important, since in 3rd person (not possible in vanilla, but mods may allow it) the weapondirection may not be the same as the center of the screen. If this is detected, in your case you should exit your script and provide a hint to the player that he must be in 1st person view.

In your particular case I would use something like:

if (cameraView != "GUNNER" || currentWeapon player != "Binocular_Vector") exitWith {hint "You can't do that, exiting"};
if (abs ((_target distance player) - (player distance screenToWorld [0.5,0.5])) > 10) exitWith {hint "You have no line of sight, exiting."};

Not tested, but I think you can see where it is going.

Oh and btw, laserTarget object is local to player, it doesn't seem to exist on server. At least I couldn't get it to work with my own copperhead guidance script, although it worked fine during singleplayer testing.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

Thx for this direction and range displaying carlgustaffa

I try that ASAP on the new "image transmission system" inter unit we developping.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×