Jump to content
johnnyboy

find nearest dead body weapon holder

Recommended Posts

Upon dying, a unit is replaced with a weaponHolder object that looks like a dead body.  You can find weapon holders with this command:

nearestObjects [getPos player, ["WeaponHolderSimulated", "GroundWeaponHolder", "Default"], 4]

But this returns any type of weapon holder.  I want to find the ones that are dead bodies, and exclude  a weapon lying on the ground or any other kind of holder.

 

Share this post


Link to post
Share on other sites
2 hours ago, johnnyboy said:

Upon dying, a unit is replaced with a weaponHolder object that looks like a dead body. 

 

I'm not sure that's true. At least, dead bodies aren't returned when searching for weaponHolders.

 

8Jdrfs9.png

  • Thanks 1

Share this post


Link to post
Share on other sites

The Community WIKI states that a dead unit and a weapon holder are different things, but there is an association between them.

See, for example, getCorpse.
See also: vehicles.

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
17 minutes ago, Ibragim A said:

 

Interesting!

 

So, you could filter weaponHolders for associated corpses. Of course, since this is the case, you could just find the corpses instead. 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks gents, a combo of that info should probably solve this for me.

Share this post


Link to post
Share on other sites

getCorpse is for version 2.12

 

It seems to me a killed unit always lead to a "WeaponHolderSimulated", nothing more for dropped weapons, one or (two in case of launcher).

 

Anyway, if you need to get a corpse near player, think about allDeadMen:

_corpse = allDeadMen select {_x distance2D player < 5} select 0;

 

  • Like 1

Share this post


Link to post
Share on other sites
39 minutes ago, pierremgi said:

a killed unit always lead to a "WeaponHolderSimulated"

 

Only if they are carrying a rifle/launcher.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks guys.  My purpose for this question is I want to attach a recently killed unit to a moving object.  But the problem is, once dead, they no longer attach to anything.  If they are attached before being killed, they are immediately detached when killed.  And never can be attached thereafter.

 

So my workaround will be to use allDeadmen to find them, or an OnKilled EventHandler.   Then create a dummy live unit that I disableSimulation on, put into a death animation, give him same loadout, uniform, headgear,etc., delete dead guy and attach new dummy unit.   Ugh.

  • Like 1

Share this post


Link to post
Share on other sites

Download and look how this script is made, it shows how dead units can be attached to moving objects and then detached.

I used this script a long time ago, it is possible that now it may contain some errors.

 

Drag Dead Body Script

Share this post


Link to post
Share on other sites
1 hour ago, Ibragim A said:

Download and look how this script is made, it shows how dead units can be attached to moving objects and then detached.

I used this script a long time ago, it is possible that now it may contain some errors.

 

Drag Dead Body Script

Good find.  Looked at it and its overkill for my needs.  Uses EachFrame to continually setPos the dead unit. A lot of code.  I appreciate you looking it up for me though.

Share this post


Link to post
Share on other sites
2 hours ago, johnnyboy said:

My purpose for this question

 

What's our johnnyboy cooking up now...🤔

  • Haha 1

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

×