OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mandoble on 27 May 2006, 12:28:18

Title: Where you are pointing at? part 2
Post by: Mandoble on 27 May 2006, 12:28:18
This was an old post without apparent solution.
With getDir you get your heading, but you dont know where your weapon is really pointing at (some degrees left from your heading, a bit low, etc). Firing a bullet and catching its velocity vector was not an option (you should not fire any round).

Now I have a possible solution based on two drop commands and selection names.
A drop command for soldier righthand selection name using righthandgetpos.sqs as the script for particle end of life and a life of 0.2 seconds for the particle.
And a drop command for soldier weapon selection name using weapongetpos.sqs as the script for particle end of life and a life of 0.2 seconds for the particle.
These scripts should get the [x,y,z] pos of respective particles in "this" after 0.2 seconds, so the angles between righthand and weapon would be quite easy to calculate.

But whatever selection name I use, the particles always summon near the feet of the soldier.

Code: [Select]
_soldier  = _this select 0
drop ["cl_basic", "", "Billboard", 1, 0.2, "pruka", [0,0,0], 0,25.50,20,0, [0.1], [[1,1,1,1]], [0], 0, 0, "", "righthandgetpos.sqs", _soldier]
drop ["cl_basic", "", "Billboard", 1, 0.2, "zbran", [0,0,0], 0,25.50,20,0, [0.1], [[1,1,1,1]], [0], 0, 0, "", "weapongetpos.sqs", _soldier]

Am I missing the correct selection names or something?

Got the selection names from here:
Lowlands warrior soldier model selection reference (http://llw.the-dropzone.net/home/index.php?option=com_content&task=view&id=8&Itemid=8)
Title: Re: Where you are pointing at? part 2
Post by: uiox on 27 May 2006, 13:00:17
use this script in the fired event :

Fired= "[ _This select 0, _this select 1,_this select 2,_this select 3,_this select 4,velocity(nearestObject [_this select 0 , _this select 4 ]), getpos (nearestObject [_this select 0 , _this select 4 ]),getDir (nearestObject [_this select 0 , _this select 4 ])] exec {thescript.sqs} "
         
the script sqs:

_Vel = _This select 5

_x = _Vel select 0
_y =_Vel select 1
_z = _Vel select 2
_x2 = _x * _x
_y2 = _y * _y
_z2 = _z * _z
_Rac = sqrt (_x2 + _y2 +_z2)
_Rac2d = sqrt (_x2 + _y2 )
_AngleShot =     acos  ( (( _x2 * 2)+( _y2 * 2))/ (2 * (_Rac * _Rac2d )) )

I make calculation directly in the event for avoid OFP do not "catch" the value with hight speed bullet gun.



Cool OFPEC is back... :)
Title: Re: Where you are pointing at? part 2
Post by: Mandoble on 27 May 2006, 13:09:17
Thanks Uiox, but, as indicated, firing is not an option, the unit should not fire, just aim. If the unit fires, the enemies nearby may detect your unit.
Title: Re: Where you are pointing at? part 2
Post by: uiox on 27 May 2006, 13:21:30
Without fire, 4 me no solution to this problem, problems with particule but don't remember  ??? (an other not yours, think when above the sea)

And for your problem it's OFP, you need to create your own selection point in the addon, cz name does nothing.
Title: Re: Where you are pointing at? part 2
Post by: hardrock on 27 May 2006, 16:10:43
Thanks Uiox, but, as indicated, firing is not an option, the unit should not fire, just aim. If the unit fires, the enemies nearby may detect your unit.
Apparently drops can't be placed at animated memory points. I once tried to read the RPM of a vehicle this way, by using an rpm animation together with a drop on the animated point meant to get the location of the point. The drop was always created at the center of the model though, which seems to have been the same problem as you're having now.
Title: Re: Where you are pointing at? part 2
Post by: h- on 27 May 2006, 18:03:32
You could try to use Fwatch (search from http://ofp2.info), more precisely it's mouse pointer related functions..
Although how would you calculate the direction where the weapon is pointing at from screen coords i another matter :P
Title: Re: Where you are pointing at? part 2
Post by: Mandoble on 27 May 2006, 21:42:56
Fwatch means players need that installed, so this is not an option.
Do selection names and drop work for vehicles (T80, T72, M1A1)? I cannot test as I have no idea which are these names.
Title: Re: Where you are pointing at? part 2
Post by: uiox on 27 May 2006, 22:01:11
1)Fwatch means players need that installed, so this is not an option.
2)Do selection names and drop work for vehicles (T80, T72, M1A1)? I cannot test as I have no idea which are these names.

1)Fwatch not work with linux so MP ...
2)For galix of the leclerc it was my first idea, not good idea, I use a dummy shot for have the rotation of the turret (you can have everything with a dummy shot)...

PS if you want to add a gun to vehicle forget this idea.
Title: Re: Where you are pointing at? part 2
Post by: Mandoble on 28 May 2006, 21:13:55
Uniox, by dummy shot do you mean the Fired eventhandler deleting the round?
Title: Re: Where you are pointing at? part 2
Post by: hardrock on 28 May 2006, 23:50:23
Well, you could try creating a weapon with an invisible round and zero damage plus some other values to hide it. When you need the facing of the turret, you add the weapon, fire a round, select the round and its velocity, delete it and remove the weapon again. I don't know how well that would work, but theoretically it'd be possible.
Title: Re: Where you are pointing at? part 2
Post by: Blanco on 29 May 2006, 10:26:01
...or just wait until Arma comes out, I'm sure there will be a new command to handle this  :)