Home   Help Search Login Register  

Author Topic: BinoTarget - use binoculars to target position (ACCEPTED)  (Read 5247 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Here is a release of my binotarget scripts that allow a unit to target using binoculars. The only problem I am having is that they do not work when targeting from within or on top of buildings. Any help with this would be appreciated. I have tried adding a vertical offset based on the unit's height from unit modelToWorld [0,0,0] and unit modelToWorld [0,0,1] and it does not help.
« Last Edit: 25 Sep 2007, 23:06:37 by Mandoble »
urp!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: BinoTarget - use binoculars to target position
« Reply #1 on: 21 Apr 2007, 23:32:41 »
Test it a bit and for some reason I got bombed several times when targeting from the top of the radar tower, didnt have time to investigate why. Anyway at first look I've found a modelToWorld somwhere and as far as I remember that has the same problem as GetPos: top of buildings returns ground level (0 altitude). If that is the case, top of radar tower would be also 0 alt, instead of the real 15m or so above the ground. getPosASL and setPosASL should not lie as these are the only functions that return/set REAL space positions.

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: BinoTarget - use binoculars to target position
« Reply #2 on: 22 Apr 2007, 00:10:42 »
I once knew that the altitude of the player depends on the terrain and buildings below him.

I've flown over tower blocks and seen my altitude in planes drop to something small.

That was around 1.02 area, I would have thought this was fixed since then, but maybe not?  :dry:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: BinoTarget - use binoculars to target position
« Reply #3 on: 22 Apr 2007, 02:31:42 »
@Mandible:I tried getPos ASL but it did not work either. Try it. Might resort to empty detector and distance.

@Jason:It is still this way. Multilevel buildings are really screwed up.

Edit: fixed, I think, and new version attached to first post. Had a kink in my logic.
« Last Edit: 22 Apr 2007, 02:54:14 by Mr.Peanut »
urp!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: BinoTarget - use binoculars to target position
« Reply #4 on: 22 Apr 2007, 04:10:09 »
Is then modelToWorld returning correct heights when over buildings?

You may also try this other working way:
Code: [Select]
private ["_unit", "_obj", "_ds", "_max", "_offset", "_dvec", "_mpos", "_wpos", "_gl_north", "_breakflag", "_i", "_min"];

_ds = 0.50;
_max = 1000;
_min = 20;
_offset = 1;
_unit = _this select 0;
if (count _this > 1) then {_obj = _this select 1;};
_dvec = _unit weaponDirection "BINOCULAR";

_wpos = [];
_gl_north = "LOGIC" createVehicleLocal [0,0,0];
_sea = "EmptyDetector" createVehicleLocal [0,0,0];
_sea setPosASL [getPos _unit select 0, getPos _unit select 1, 0];
_mpos = [getPos _unit select 0, getPos _unit select 1, _sea distance _unit];;

_breakflag = TRUE;
for [{_i = (_min + _ds)},{_i <= _max && _breakflag},{_i = _i + _ds}] do
{
      _wpos = [(_mpos select 0)+_i * (_dvec select 0), (_mpos select 1)+_i * (_dvec select 1), (_mpos select 2)+_i * (_dvec select 2) + _offset];
      _gl_north setPosASL _wpos;
      if ((getPos _gl_north select 2) <= 0.1) then {_breakflag = FALSE;};
};
deleteVehicle _gl_north;
deleteVehicle _sea;

if (!_breakflag) then
{
   if (isnil "_obj") then
   {
      _wpos
   }
   else
   {
      _obj setPos _wpos;
      TRUE
   };
};

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: BinoTarget - use binoculars to target position
« Reply #5 on: 22 Apr 2007, 16:16:41 »
http://www.ofpec.com/forum/index.php?topic=29008.0

Maybe this is useful for finding building height? I'm not sure.

Edit : Ahh you fixed it, missed that  :whistle:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: BinoTarget - use binoculars to target position
« Reply #6 on: 23 Apr 2007, 15:45:14 »
Is then modelToWorld returning correct heights when over buildings?
You may also try this other working way:
Code: [Select]
....

No need, I think I have fixed it.

modelToWorld does return decent values when infanty are in buildings. In some multistage buildings, when the bottom part of the building is actually part of the terrain/world model, the values are too small. What perplexes me a little is that when I added the unit height to the line of sight vector, which is then passed through modelToWorld it did not work, but when I added the height in the final check for vector intersection with the ground, it did. Mathematically these should be equivalent.

Edit: would be very helpful to see the source for modelToWorld.
urp!

Offline Blanco

  • Former Staff
  • ****
Re: BinoTarget - use binoculars to target position
« Reply #7 on: 23 Apr 2007, 19:20:34 »
Damn, this is awesome.  :good:

This will make artillery, airstrike scripts user-friendlier. Every day I'm amazed what the new commands are capable of...and this just the start.
Search or search or search before you ask.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: BinoTarget - use binoculars to target position
« Reply #8 on: 25 Sep 2007, 17:17:03 »
In case there is any doubt about its status, this script is ready for the ED.
urp!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: BinoTarget - use binoculars to target position (ACCEPTED)
« Reply #9 on: 30 Sep 2007, 11:58:42 »
Some suggestions to make the script a little more friendly to mission-makers (though the advice is applicable to most scripts in the forum ::)):

- Instead of requiring the user to place 3 lines of code in the init, why not just have this (or an equivalent),
Code: [Select]
call compile preprocessFileLineNumbers "binotarget\init.sqf";

- Rather than having "nadebarrage.sqf" hardcoded within "binotarget\binotarget.sqf", why not have the user pass a code block via the action so that the user does,
Code: [Select]
_targetFunction =
{
    _pos = _this select 0;

    [_pos] execVM "nadebarrage.sqf";
};
_unit addAction ["Select Target", "binotarget\binotarget.sqf",[_targetFunction],0,FALSE, TRUE,""];

so the user doesn't have to edit any of your files. To make it even more idiot-proof, though slightly less versatile, ask the user to pass the script name into the action and just pass _pos to it in your script,
Code: [Select]
_unit addAction ["Select Target", "binotarget\binotarget.sqf",["nadebarrage.sqf"],0,FALSE, TRUE,""];

Either of those options make it possible to have "Request airstrike", "Request smoke" AND "Request supplies" run from the same script.

- As far as using Kronsky's string functions, you admit that they are very slow and that they only work for the BIS functions. Why not keep it simple and just check if the animation state is in ["awoppercmstpsoptwbindnon_rfl", "awoppknlmstpsoptwbindnon_rfl", "awopppnemstpsoptwbindnon_rfl"] ? (Those were all the bino anims I could find, but if there are more, I could do with knowing them!)
« Last Edit: 30 Sep 2007, 12:47:56 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Blanco

  • Former Staff
  • ****
Re: BinoTarget - use binoculars to target position (ACCEPTED)
« Reply #10 on: 30 Sep 2007, 15:23:10 »
There are a lot more binoc anims:

STANDING

UNARMED   
"amovpercmstpsnonwnondnon_awoppercmstpsoptwbindnon"     Taking binoculars (start)
"amovpercmstpsnonwnondnon_awoppercmstpsoptwbindnon_end"   Taking binoculars (end)
"awoppercmstpsoptwbindnon_non"   Watching through the binoculars
"awoppercmstpsoptwbindnon_amovpercmstpsnonwnondnon"   Put the binoculars away (start)
"awoppercmstpsoptwbindnon_amovpercmstpsnonwnondnon_end"   Put the binoculars away (end)

WITH A RIFLE   
"amovpercmstpsraswrfldnon_awoppercmstpsoptwbindnon"   put rifle away take the binocular (start)
"amovpercmstpsraswrfldnon_awoppercmstpsoptwbindnon_end"   bringing the binocular in front of his eyes (end)
"awoppercmstpsoptwbindnon_rfl"   Watching through the binoculars
"awoppercmstpsoptwbindnon_amovpercmstpsraswrfldnon"   put binocular away & take the rifle back (start)
"awoppercmstpsoptwbindnon_amovpercmstpsraswrfldnon_end"   put binocular away & take the rifle back (end)

WITH A PISTOL   
"amovpercmstpsraswpstdnon_awoppercmstpsoptwbindnon"   put pistol away and take the binocular (start)
"amovpercmstpsraswpstdnon_awoppercmstpsoptwbindnon_end"   bringing the binocular in front of his eyes (end)
"awoppercmstpsoptwbindnon_pst"   watching through the binoc
"awoppercmstpsoptwbindnon_amovpercmstpsraswpstdnon"   Put binocular away  & take the pistol back (start)
"awoppercmstpsoptwbindnon_amovpercmstpsraswpstdnon_mid"   Put binocular away  & take the pistol back (transition)
"awoppercmstpsoptwbindnon_amovpercmstpsraswpstdnon_end"   Put binocular away  & take the pistol back (end)


CROUCHED

WITH A RIFLE
"amovpknlmstpsraswrfldnon_awoppknlmstpsoptwbindnon"  put rifle away take the binocular (start)
"amovpknlmstpsraswrfldnon_awoppknlmstpsoptwbindnon_end"   bringing the binocular in front of his eyes (end)
"amovpknlmstpsraswrfldnon_awoppknlmstpsoptwbindnon_rfl"   watching through the binoc
"awoppknlmstpsoptwbindnon_amovpknlmstpsraswrfldnon"   put binocular away & take the rifle back (start)
"awoppknlmstpsoptwbindnon_amovpknlmstpsraswrfldnon_end"   put binocular away & take the rifle back (end)

WITH A PISTOL
"amovpknlmstpsraswpstdnon_awoppknlmstpsoptwbindnon"  put pistol away and take the binocular (start)
"amovpknlmstpsraswpstdnon_awoppknlmstpsoptwbindnon_mid"  put pistol away and take the binocular (transition)
"amovpknlmstpsraswpstdnon_awoppknlmstpsoptwbindnon_end"   put pistol away and take the binocular (end)
"awoppknlmstpsoptwbindnon_pst"    watching through the binocular
"awoppknlmstpsoptwbindnon_amovpknlmstpsraswpstdnon"   Put binocular away  & take the pistol back (start)
"awoppknlmstpsoptwbindnon_amovpknlmstpsraswpstdnon_mid"  Put binocular away  & take the pistol back (transition)
"awoppknlmstpsoptwbindnon_amovpknlmstpsraswpstdnon_end" : Put binocular away  & take the pistol back (end)


PRONE

UNARMED   
"amovppnemstpsnonwnondnon_amovopppnemstpsoptwbindnon"   Take the binoculars (start)
"amovppnemstpsnonwnondnon_amovopppnemstpsoptwbindnon_end"   Take the binoculars (end)
"amovopppnemstpsoptwbindnon_non"   watching through the binoculars
"awopppnemstpsoptwbindnon_amovppnemstpsnonwnondnon"   Put binoculars away (start)
"awopppnemstpsoptwbindnon_amovppnemstpsnonwnondnon_end"   Put binoculars away (end)

WITH A RIFLE   
"amovppnemstpsraswrfldnon_awopppnemstpsoptwbindnon"   Put the rifle away & take the binoculars (start)
"amovppnemstpsraswrfldnon_awopppnemstpsoptwbindnon_end"   Put the rifle away & take the binoculars (end)
"awopppnemstpsoptwbindnon_rfl"   watching through the binoculars
"awopppnemstpsoptwbindnon_amovppnemstpsraswrfldnon"   put the binoculars away & take the rifle back (start)
"awopppnemstpsoptwbindnon_amovppnemstpsraswrfldnon_end"   put the binoculars away & take the rifle back (end)

WITH A PISTOL   
"amovppnemstpsraswpstdnon_awopppnemstpsoptwbindnon"   Put the pistol away & take the binoculars (start)
"amovppnemstpsraswpstdnon_awopppnemstpsoptwbindnon_mid"   Put the rifle away & take the binoculars (transition)
"amovppnemstpsraswpstdnon_awopppnemstpsoptwbindnon_end"   Put the pistol away & take the binoculars (end)
"awopppnemstpsoptwbindnon_pst"   watching through the binoculars
"awopppnemstpsoptwbindnon_amovppnemstpsraswpstdnon"   put the binoculars away & take the pistol back (start)
"awopppnemstpsoptwbindnon_amovppnemstpsraswpstdnon_mid"   put the binoculars away & take the pistol back (transition)
"awopppnemstpsoptwbindnon_amovppnemstpsraswpstdnon_end"   put the binoculars away & take the pistol back (end)



You could skip all the transitions/start & end anims tho. There would be 8 anims left.



« Last Edit: 01 Oct 2007, 00:14:31 by Blanco »
Search or search or search before you ask.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: BinoTarget - use binoculars to target position (ACCEPTED)
« Reply #11 on: 30 Sep 2007, 16:02:34 »
Thanks for that list, since this muppet wasn't thinking when he made the list of 3 (just for the rifle) :-[. Regardless, even allowing for 8 anims, just using in has to be significantly quicker than resorting to brute-force string manipulation.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)