Home   Help Search Login Register  

Author Topic: using a script to find a bullet  (Read 1882 times)

0 Members and 1 Guest are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
using a script to find a bullet
« on: 27 May 2005, 02:51:43 »
hi,


im trying to make a script that finds out when the player fires a bullet, and then follows the bullet and when it hits anything and stops then a drop thing is executed where the bullet hit, how would i go about this, i have the drop comand i need but its the script thats causing problems

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:using a script to find a bullet
« Reply #1 on: 27 May 2005, 09:33:32 »
eventHandler "fired" then grab the bullet with a nearestObject command.
Plenty of reviewed ArmA missions for you to play

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:using a script to find a bullet
« Reply #2 on: 27 May 2005, 14:44:35 »
If you are using some rifle the bullet is too fast for even the fastest OFP .sqs loop...
« Last Edit: 27 May 2005, 14:44:48 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:using a script to find a bullet
« Reply #3 on: 27 May 2005, 20:17:17 »
what about a ~0 second loop and slow the speed down to something about
set acctime 0.10
that might just work

bdfy1

  • Guest
Re:using a script to find a bullet
« Reply #4 on: 27 May 2005, 21:10:34 »
It was discussed dozens of times...
example

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:using a script to find a bullet
« Reply #5 on: 27 May 2005, 23:20:52 »
thanks but actualy, ive goten the script to detect the bullet, its the finding where it hit the dirt that im haveing probs with,

how do i find the exact place where a bullet hit?

thanks

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:using a script to find a bullet
« Reply #6 on: 28 May 2005, 04:33:31 »
Quote
how do i find the exact place where a bullet hit?
You can't, due to the speed...

If you follow the bullet with a script the scripts 'drags' behind and reports the wrong position in the end...

Here's thread that this same thing was discussed...
As you can see from there even the fastest loop can't keep up with the bullet...
I suggested the fast loop there myself at first because MCAR uses such thing on the Recoilless Gun jeep but the projectile on that is so slow you can actually keep up with it quite accurately (accurately enough for our use)...
But in the end a mathematical solution was found...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:using a script to find a bullet
« Reply #7 on: 28 May 2005, 05:44:24 »
1.hmm, interesting, but say my bullet was slow enough to catch in the loop, how would i find its final position.


2.
Quote
As you can see from there even the fastest loop can't keep up with the bullet...
i think i know how to solve this

after the bullet is fired, camcreate an object behind it in its wake, an object that wont disapeer after it hits somthing, like a bottle. then propel the bottle in the same direction and speed as the bullet using setvelocity, at the same velocity the bullet is going, after the bullet hits and disapeers, the bottle will hit in the same spot(same velocity) and will stop, then you just get the position of the bottle and delete it. and i could use that position, for my drop comand.  possible?

Offline 456820

  • Contributing Member
  • **
Re:using a script to find a bullet
« Reply #8 on: 28 May 2005, 09:03:18 »
ehhh i supose so but seems a bit how about cam creating a bullet set velocity it to the same speed of the rifle bullets then name it _bullet1 then target it with a camera so you know where it is

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:using a script to find a bullet
« Reply #9 on: 28 May 2005, 10:19:00 »
Once you have grabbed the bullet with the EH you can name it - you don't need to create other objects.     Good idea though.
Plenty of reviewed ArmA missions for you to play

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:using a script to find a bullet
« Reply #10 on: 28 May 2005, 11:44:46 »
Quote
1.hmm, interesting, but say my bullet was slow enough to catch in the loop, how would i find its final position.
With a loop similar to this:
Code: [Select]
#loop
_pos = position _bullet
@alive _bullet: goto "loop"
?_time >= 2.8: exit

<insert drop[] stuff here>
Now, the final time _pos is updated should be pretty close to the last position of the bullet...
Why ?_time >= 2.8: exit  ?
Because OFP bullets 'live' only for roughly 3 secs, and without something like this you would get the drop[] 'created' in mid-air once the bullet exceeds it's lifetime...

Quote
after the bullet is fired, camcreate an object behind it in its wake, an object that wont disapeer after it hits somthing, like a bottle. then propel the bottle in the same direction and speed as the bullet using setvelocity, at the same velocity the bullet is going, after the bullet hits and disapeers, the bottle will hit in the same spot(same velocity) and will stop, then you just get the position of the bottle and delete it. and i could use that position, for my drop comand.  possible?
Yeah, in theory that should work...

But, you would still need that fastest loop to get the bullets velocity and update the bottle's velocity... You can't just shove the bottle to some velocity...
And this means the object could actually 'overfly' a bit the bullets last position because the velocity could have just been updated and the loop starts over again and while the loop is restarting the bullet 'dies'...
But this could be more reliable than the position thingy...

Better use something less visible (and less destructable) than a bottle, like a game logic ("logic")... Dunno if gamelogics can be 'setVelocitied' though...

Worth a try, you never know...

Quote
ehhh i supose so but seems a bit how about cam creating a bullet set velocity it to the same speed of the rifle bullets then name it _bullet1 then target it with a camera so you know where it is
What good would this do ???
Then you would have a camera that points to the position where the bullet hit, that's all...
There is no function getPosWhereTheCameraPoints... ;)

Or did I misunderstand something??
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:using a script to find a bullet
« Reply #11 on: 28 May 2005, 14:55:09 »
bo but then you camcreate <object> setpos get pos _camera
wich would leave it right where it landed

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:using a script to find a bullet
« Reply #12 on: 28 May 2005, 23:59:12 »
so hater, how would one make the script that shoots the game logic,








Offline Roni

  • Members
  • *
  • Play the Game !
Re:using a script to find a bullet
« Reply #13 on: 29 May 2005, 03:47:20 »
Hi PM

I just learned how to use EH's and drop effects in the past few months and have been having lots of fun creating new sounds, particle effects and weapons from standard items.

One thing I did was turn the standard grenade into a Molotov cocktail.  All I did was to use a "fired" EH to add a custom smoke and flame trail behind any thrown grenade, then replace the detonation effect with flame drop effects and sounds and a quick trigger placement to "burn" anyone within 5m of the impact point.

For your purposes you could use the same thing, but with a "killed" EH inside the "fired" EH to get the death point of the captured bullet, like so -

Put a "fired" EH on the unit that is shooting.

In the EH script put in just two lines -

_bullet = nearestobject [_this select 0, _this select 4]
_bullet addEventHandler ["killed", "_bullet exec {bulletImpact.sqs}"]


Now create a script called bulletImpact.sqs and put in this line

_impactPoint = getPos (_this select 0)


Voila !  You now have the exact point of bullet death for you to add your custom smoke puffs, sound effects or game effects.

Hpe that this helps.


roni

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:using a script to find a bullet
« Reply #14 on: 29 May 2005, 07:26:05 »
Nope.

You can add eventhandlers only to class CfgVehicles, which means men, vehicles, houses etc...
« Last Edit: 29 May 2005, 07:29:10 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.