Jump to content
Sign in to follow this  
Ćlçi®-�yon

Colisionpointrequest

Recommended Posts

Hello everybody,

I'd like to get the coordinates of the point where the bullet of my weapon or my tank hit ground. Is it possible to get this point? Please help me.

With best regards

Ćlçi®-Åyon

Share this post


Link to post
Share on other sites

Yes, by "grabbing" your bullet with nearestObject -command at the instant of firing and checking it's coordinates before its alive-status changed to negative, that is, when it ceased to exist.

It's something like this:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_bullet = nearestObject [player, "bullet"];

#loop

_coords = getPos _bullet;

?!(alive _bullet) : goto "bulletDead";

goto "loop";

#bulletDead

hint format ["The bullet ceased to exist at %1",_coords];<span id='postcolor'>

That was all off the top of my head. I'm not sure if the object is "bullet". Remember that bullet doesn't fly longer than 3 secs in any case, so it may stop in the air. If this is the case, you will notice that the z-coordinate of the bullet is more than 0 when it "dies".

edit:

there could be a problem that the bulled dies between the last alive-status detection and the next getPos, in which case the coordinates will be [0,0,0]. Replace the line </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_coords = getPos _bullet;<span id='postcolor'> with </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!((getPos _bullet) == [0,0,0]) : _coords = getPos _bullet;<span id='postcolor'>

I don't really know if this will work, I haven't tested any of it, but this is the general idea to follow.

Share this post


Link to post
Share on other sites

add this to the initline of the player soldier:

this addeventhandler ["Fired",{exec "fired.sqs"}]

make the script look like this:

_Bullet=nearestobject [vehicle player,"BulletSingleW"]

#Loop

?alive _Bullet:_Bulletpos=getpos _Bullet;goto "Loop"

hint format ["X=%1\nY=%2\nZ=%3", _Bulletpos select 0, _Bulletpos select 1, _Bulletpos select 2]

exit

this script will ofcourse not work on all weapons since the bulletnames are different for different weapons.

Here is a list of bulletnames:

BulletSniperW

BulletSingleW

BulletBurstW

BulletSilencedSingleW

BulletSilencedBurstW

UZI

Bullet7_6W

G36a

Steyr

GlockS

Beretta

RevolverBullet

GrenadeHand

Grenade

MortarShell

AA

CarlGustav

LAW

BulletSingleE

BulletBurstE

BulletFullAutoE

Bullet7_6E

BulletSniperE

Bizon

Tokarev

Skorpion

9K32

AT4

BulletSingleG

BulletBurstG

BulletFullAutoG

KozliceBall

KozliceShell

CZ75

HuntingRifle

Bullet7_6

Heat73

Shell73

AT3

Cannon30AP

Cannon30HE

Bullet12_7

Heat120

Shell120

Cannon25HE

Heat105

Shell105

Bullet4x23

Heat125

Shell125

Bullet4x20

Bullet30W

Maverick

Bullet30A10

LaserGuidedBomb

Bullet30

HellfireApach

Hellfire

Zuni

Rocket57

Bullet30E

AT6

BISBulletCamel

BISGrenadeCamel

CH29T

Share this post


Link to post
Share on other sites

Thanks for the clarification, InqWiper. I knew my solution would suck - it never works when writing off top of the head wink.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">Thanks for the clarification, InqWiper. I knew my solution would suck - it never works when writing off top of the head  

<span id='postcolor'>

It didnt suck, it looked like you were thinking in the right direction  smile.gif

-Edit

When you shoot real close to youself you will see some strange text in the hintbox because the script doesnt have time to check for the bullets position before its !alive.

Share this post


Link to post
Share on other sites

If you use:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Bullet=nearestobject [vehicle player, _this select 4]<span id='postcolor'>you don't have to care about the amunition name, since it is a parameter of the "fired" event wink.gif

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Ćlçi®-Åyon @ Feb. 02 2003,13:48)</td></tr><tr><td id="QUOTE">Is that command only working on OFP Versions higher than 1.85?

I always get an error : Fired|#| : Wrong command (or like this)

Greets

Åyon<span id='postcolor'>

you should copy&paste your script, too.

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  

×