Home   Help Search Login Register  

Author Topic: Detecting bullets  (Read 642 times)

0 Members and 1 Guest are viewing this topic.

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Detecting bullets
« on: 28 Aug 2004, 22:21:56 »
Quote
The game actually creates a (very temporary) bullet object each time you fire a weapon.  The engine moves this object a little bit, checks for collisions with people, objects or the ground and then moves it a bit more.  Once the bullet does hit something it is removed and the engine calculates the damage it causes to the hit object.

I found this when i did a search on Bullets.If this is true,there must be a way to detect bullets(or shells whatever) in a certain area.Anybody has an idea how?

I could use this to create a Safezone,where no-one could shoot you.IÂ'm thinking of an extended safezone around your Safezone,once this extended safezone detects bullets,delete it before it enters the Safezone.We would then have a Safezone that works with "prevent" instead of "repair" in MP games.

PP
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Bart

  • Guest
Re:Detecting bullets
« Reply #1 on: 28 Aug 2004, 23:19:51 »
I duno how to do this but maybe you could check out the 'bullet chase cam' you can download it here on ofpec

the camera is attached to the bullet so it probably has to do about the 'bulletobject'

cheers!  8)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Detecting bullets
« Reply #2 on: 28 Aug 2004, 23:36:23 »
You can grab a bullet just after its been fired by using a nearestObject command from an eventhandler "fired".  (I think.)

Dunno how you'd catch an incoming bullet though.    I suppose you could try a nearestObject command on each of the units you wanted to protect, but given that you'd have to check for every kind of bullet on the map it would be very CPU intensive if you have a lot of units and/or a lot of ammo types.    And it may not even be fast enough.
Plenty of reviewed ArmA missions for you to play

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Detecting bullets
« Reply #3 on: 29 Aug 2004, 10:41:06 »
Quote
And it may not even be fast enough.
Indeed.
Take a moment and consider the speed of a bullet... ::)

Furthermore, In OFP the bullets 'live' about 2-3 seconds after which they disappear, and in that time the bullet has travelled miles...

What you would need to do is to 'grab' the bullet via "fired" eventHandler, then use an .sqs loop that constantly, and I mean constantly: in intervals of 0.000001 seconds (impossible for OFP, unless you run it on some NEC CPU computer... ::) and I think even that's not fast enough loop...), checks the nearestObject [bullet,typeOf player] and once player is detected deletes the bullet.

In theory that would be easy peacy, but if you add even a tiniest bit of lag, that stuff goes right out of the window, as OFP interrupts the .sqs code when there's more 'important' algorithms/processes that need CPU power, which means all the stuff the engine does, like AI control, graphics etc., etc., etc...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Re:Detecting bullets
« Reply #4 on: 29 Aug 2004, 11:40:35 »
As an alternative, if units were SetCaptive'd true in the safezone, AI wouldn't want to kill them.

If the problem is other players cheating, a deterrent would be to apply a 'Killed' eventhandler to each unit in the zone so that the killer can be summarily executed.

That might need to be a permanent EH - every time a unit is killed a script is called to see if the killer or the killee is in the safe zone (by position or 'Captive true').  If it's an illegal kill, the killer gets slotted in turn.  That would deter shooting from the safe zone as well as into it.

I've not done any MP scripting, though, so no guarantees as to what'll work where EHs are concerned . . .

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:Detecting bullets
« Reply #5 on: 29 Aug 2004, 13:49:38 »
Thx for the input gentlemen;

Still few taughts:

**To detect the bullets path U need very fast loops,this is impossible in MP.But this loop must already excist,the engine must check all the objects on his path,calculate dammage,..etc  ??? Isnt there a way to put an extra condition in this already existing loop?Like saying:U cant enter position [x,y,z]?Where [x,y]is your safezone and z might even be 0 (2 Dimensional)

**Do I need to detect EVERY position of the bullet?Lets reduce the prob to 2D:once I got 2 positions of the bullet,I can already calculate his path,assuming OFP bullets follow a straight line.(2D vieuw).

**The bullets have classnames.Suppose we know all the ammo allowed in a map,can a trigger (extended safezone) detect that object in his area and delete it before it enters safezone?This method dont need the path of the bullet.

**The system we use now is like ACF described:EH hit and killed check if you are shot legally/illegally.And repair the damage when illegaly shot.But this method has serious flaws:
-The slightest desync screws it up.The punishment for an illegal kill (caused due desync)is unfair and give alot of hassle.
-If U have an illegal kill done by vehicles,the gunner dies,but no one can enter that vehicle again or will die too.(Maybe somebody could try to debug this?)

I taught about a system that prevents illegaly kills,if u are in safezone u simply cant be shot,if u are out u can.Would give us less headaches and flamewars  :P  
Oh well if it is impossible,just make it possible in OFP2 ok? ;D

Thx 4 your Time.

PP

http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Detecting bullets
« Reply #6 on: 29 Aug 2004, 14:29:39 »
Quote
**To detect the bullets path U need very fast loops,this is impossible in MP.But this loop must already excist,the engine must check all the objects on his path,calculate dammage,..etc  Isnt there a way to put an extra condition in this already existing loop?Like saying:U cant enter position [x,y,z]?Where [x,y]is your safezone and z might even be 0 (2 Dimensional)
The thing you quoted on the first post is just a simplified 'explanationish' of what the engine actually does, as I doubt the original writer has the OFP source code so he/she is just assuming that that thing happens like that... ::)
That just sounds a bit too CPU stresfull way of doing it... :P
So, if you would like to monkey around with that stuff, you would need the OFP source code...

Quote
Do I need to detect EVERY position of the bullet?Lets reduce the prob to 2D:once I got 2 positions of the bullet,I can already calculate his path,assuming OFP bullets follow a straight line.(2D vieuw)
When calculating the bullets path you'd probably only need the direction in which the bullet is flying when fired... That's relatively easy... command direction comes in handy...

this addEventHandler ["fired",{[direction (nearestObject[_this select 0,_this select 4])] exec "dir.sqs"}] (syntax not guaranteed...)

Dunno if anything else would be needed though... I suck in maths :P

But, you still would need some sort of way to tell when the bullet enters safe area or get too close to the player... :P
And that position would still need to be checked very fast due to the bullets speed...

I think you would get more flamewars if you just assumed that everytime a weapon is fired to the direction where the safezone is, the bullet gets deleted... :P

Quote
The bullets have classnames.Suppose we know all the ammo allowed in a map,can a trigger (extended safezone) detect that object in his area and delete it before it enters safezone?This method dont need the path of the bullet.
Again, the bullets speed renders this useless...
Triggers check their conditions in 0.5 sec intervals, and that is waaayyyy too slow for detecting a bullets presence...

And I think a trigger wouldn't detect a bullet anyhow as bullets are 'empty' objects, and triggers can't detect those (like houses and stuff like that... afaik... correct me if I'm wrong :P )
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.