Jump to content
Sign in to follow this  
dmarkwick

What killed who?

Recommended Posts

Is there any method available of telling what killed a soldier? I don't mean who, I mean what. i.e. I'd like to identify soldiers killed either by grenade or shell, any explosion basically.

Share this post


Link to post
Share on other sites

Try the HIT or KILLED event handlers, they return the object which caused the hit or kill. I can't test them atm, would be interesting to see what is returned for a projectile spawned with createVehicle...

Share this post


Link to post
Share on other sites
Try the HIT or KILLED event handlers, they return the object which caused the hit or kill. I can't test them atm, would be interesting to see what is returned for a projectile spawned with createVehicle...

As far as I can tell, Hit and Killed only return the object that fired the projectile, not the projectile itself smile_o.gif

Share this post


Link to post
Share on other sites

Hmmm, AFAIK there is no way to tell what weapon a unit has in its hand either, other than using FIRED EV...

What are you trying to achieve?

I had an OFP mod that made bodies explode when hit by a large explosions. I seem to remember that it detected this condition by checking the velocity of the killed unit.

Share this post


Link to post
Share on other sites
Hmmm, AFAIK there is no way to tell what weapon a unit has in its hand either, other than using FIRED EV...

What are you trying to achieve?

I had an OFP mod that made bodies explode when hit by a large explosions. I seem to remember that it detected this condition by checking the velocity of the killed unit.

I thought I might expand on my little smoke addon and have short-lasting little puffs of smoke appear on recently dead bodies IF they had been hit by shrapnel. Just very little ones you probably would only see close up.

Share this post


Link to post
Share on other sites

You could add a fired eventhandler to those units that have shrapnel weapons (soldiers with nades, tanks, rpgs, etc.).

In the script called by the fired eventhandler, test to see if the weapon/muzzle fired was a shrapnel weapon. If not exit script. If it was, record unit who fired and time fired in global variables. You would have to create an array of shrapnel weapon/muzzle names to compare against. See Arma weapons list in biki.

Then, using Killed eventhandlers, call a killed script. The killed script would compare the killer to the global variable of who fired a shrapnel weapon. If the shrapnel shooter is the same as the killer, and if the global variable of time fired is close enough to time of death (say less than a second), then you can conclude that the victim was killed by a shrapnel weapon.

Its alot of trouble, but it could work.

I like the idea of the smoking bodies. As a player, I love being surprised by something unexpected like this.

When you get a working example, you should post it over at OFPEC mission scripts beta board:

http://www.ofpec.com/index.p....rd=83.0

Then others can benefit from your cool idea. Plus this board is good at offering improvements to your script.

Share this post


Link to post
Share on other sites
You could add a fired eventhandler to those units that have shrapnel weapons (soldiers with nades, tanks, rpgs, etc.).

In the script called by the fired eventhandler, test to see if the weapon/muzzle fired was a shrapnel weapon. If not exit script. If it was, record unit who fired and time fired in global variables. You would have to create an array of shrapnel weapon/muzzle names to compare against. See Arma weapons list in biki.

Then, using Killed eventhandlers, call a killed script. The killed script would compare the killer to the global variable of who fired a shrapnel weapon. If the shrapnel shooter is the same as the killer, and if the global variable of time fired is close enough to time of death (say less than a second), then you can conclude that the victim was killed by a shrapnel weapon.

Its alot of trouble, but it could work.

I like the idea of the smoking bodies. As a player, I love being surprised by something unexpected like this.

When you get a working example, you should post it over at OFPEC mission scripts beta board:

http://www.ofpec.com/index.p....rd=83.0

Then others can benefit from your cool idea. Plus this board is good at offering improvements to your script.

Will do smile_o.gif

I wonder if instead of doing all the work you suggested above, it might be more efficient to check the current weapon of the killer? That way I could still use the eventhandler I already have for tanks & helos anyway and bend it to work for soldiers based on what weapon the killer currently has?

Only problem I can foresee right now is if the killer has just used his last grenade and is in the process of switching weapons. Anyone know if that switch is logically instantaneous? I guess 5 seconds from grenade lob to explosion/death might mean the killer is now holding a different weapon.

Share this post


Link to post
Share on other sites

As I said, AFAIK there is no command to find the currently selected weapon of a unit. You can find what weapons he has, but not which one is in his hand.

Share this post


Link to post
Share on other sites
Quote[/b] ]In the script called by the fired eventhandler, test to see if the weapon/muzzle fired was a shrapnel weapon. If not exit script. If it was, record unit who fired and time fired in global variables. You would have to create an array of shrapnel weapon/muzzle names to compare against. See Arma weapons list in biki.

Suggestion for further refinement of this approach:

The who_fired/time_fired variables should be an array, so if two different guys chuck nades at nearly the same time, they are both recorded in the global array as potential shrapnel killers. And the fired script should clean up the array. Every time its called, before adding the new who_fired/time_fired to the array, remove any entries whose time_fired is > 1 or 2 seconds.

Good hunting!

Share this post


Link to post
Share on other sites
Quote[/b] ]In the script called by the fired eventhandler, test to see if the weapon/muzzle fired was a shrapnel weapon. If not exit script. If it was, record unit who fired and time fired in global variables. You would have to create an array of shrapnel weapon/muzzle names to compare against. See Arma weapons list in biki.

Suggestion for further refinement of this approach:

The who_fired/time_fired variables should be an array, so if two different guys chuck nades at nearly the same time, they are both recorded in the global array as potential shrapnel killers. And the fired script should clean up the array. Every time its called, before adding the new who_fired/time_fired to the array, remove any entries whose time_fired is > 1 or 2 seconds.

Good hunting!

Hmm yes. Looks like I'll need to implement a "first in last out" rolling array that I'll need to interrogate for each soldier death yes? And if one of the most recent matches the killer variable from the killed eventhandler then apply the smoking code to the killed unit?

So is there an easy way to tell if a fired weapon is a shrapnel weapon or will I just need to check for the class name for each shrapnel type weapon?

Share this post


Link to post
Share on other sites
As I said, AFAIK there is no command to find the currently selected weapon of a unit. You can find what weapons he has, but not which one is in his hand.

This might be a problem biggrin_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]So is there an easy way to tell if a fired weapon is a shrapnel weapon or will I just need to check for the class name for each shrapnel type weapon?

I believe there is no easy way, so you will need the list. But its won't be too big (twenty or so I think?). Start with a few grenades and ATs, and when you get the concept working, go through the ARMA weapons list and add all the rest to your array.

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  

×