Jump to content
Sign in to follow this  
Hellop

Detect which bullet hit a player?

Recommended Posts

Is there any way to detect if a certain bullet type hits something and then execute a script?

The only want I can figure to do it, is to add a hit event handler to whatever object you want to be able to shoot at, and then every time it is hit, do a getNearestObject and search for the particular bullet.

Well, that seems like a roundabout way to do it, and prone to errors.  I would much rather have something in my bullet's config.cpp that was like: hit = execVM "aScript.sqf";    instead of hit = 8;

Any suggestions?  There must be a way, otherwise how can I add all the cool stuff I want to add like EMP grenades and poison darts?

Share this post


Link to post
Share on other sites

Wouldn't the bullet stop existing when it hits the object?

It may be easier to add fired EH to every unit instead, capturing the bullet as it leaves the gun, then checking if it has hit an appropriate target when the round is destroyed?

Share this post


Link to post
Share on other sites
Wouldn't the bullet stop existing when it hits the object?

It may be easier to add fired EH to every unit instead, capturing the bullet as it leaves the gun, then checking if it has hit an appropriate target when the round is destroyed?

Can you elaborate?  

1. How do you "capture the bullet as it leaves the gun."?  Get nearest object for that bullet classname?  Ok, as long as the fired event handler is only run on one client, it could work.  But, obviously, a method that didn't need to do a  "nearest Object" search would be preferred.

2. How can you detect when the round is destroyed?   That's the problem.  

3. When the bullet is destroyed, how do you tell what player it hit?

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  

×