Jump to content
dreadedentity

[CODE SNIPPET] Pull dead bodies out of vehicles

Recommended Posts

Hey guys, been a while since I did a code snippet, so here's a new one. There's a lot of room for improvement, to be honest, I couldn't find a lot of the answers that I've been looking for in the configs for the past few days. Anyway, here's a video and the code is below that:

VERSION 2:

this addAction ["Remove Dead (TESTING)",
{
_veh = _this select 0;
_vehPos = getPos _veh;

_posDriverExit = _veh selectionPosition ("pos driver");
_posCommanderExit = _veh selectionPosition ("pos codriver");
_posCargoExit = _veh selectionPosition ("pos driver");

_posDriver = (driver _veh) worldToModel _vehPos;
_posCommander = (commander _veh) worldToModel _vehPos;
_posCargo = ((crew _veh ) select 0) worldToModel _vehPos;

_driverExitOffset = (_posDriverExit select 0) - (_posDriver select 0);

{
	if !(alive _x) then
	{
		_deadPos = _x worldToModel _vehPos;
		if ((_deadPos select 0) > 0) then
		{
			_deadPos set [0, (_deadPos select 0) + (abs _driverExitOffset)];
		}else
		{
			_deadPos set [0, (_deadPos select 0) + (_driverExitOffset)];
		};
		_deadExitPos = _x modelToWorld _deadPos;
		_deadExitPos set [1, (getPos _x) select 1];
		_x setPos _deadExitPos;
	};
} forEach (crew _veh);
}, nil, 6, true, true, "({!alive _x} count (crew _target) > 0)"];

The condition in the action is still not working as I intended but I am incapable of caring any less about that.

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

Nice one, Dreaded!

Just brainstorming, but this could use a different approach:

  • check if there's dead in a vehicle < 5 meters from you; check if you're to any specific veh's crew position (you can't remove a body from front passenger's pos if you're near the driver's door)
  • getDeadPositions of a vehicle; drawIcon3D above each (over the rooftop or somewhere else - visible)
  • when player's / unit's cursorTarget equals the drawIcon3D's created bounding-box (or smth), call the action
  • remove the dead body from a position which is associated with the particular activated drawIcon3D of a position

I guess this won't be of much help, I'm just disturbing myself :D

With this approach, you'll know the exact vehicle position you want to clear.

Share this post


Link to post
Share on other sites

Hey Inlesco, thanks for the feedback. I'll look into the method you described, I am exploring a few options at the moment. In fact, I've just written some new code and made a new video demonstrating it. It still has it's own kinks to smooth out, but I feel that progress is actually being made. Check the original post!

Share this post


Link to post
Share on other sites

SetPos command isn't working for me on any dead players in vehicles, but it works when they're out of vehicles.

I've got the position calculations correct, and if I replace _x with player, when executing the command, the player moves to the location where the body should be ejected to.

I've also used } forEach allDeadMen; as for my loop, and checked if the dead man is inside the crew so the object being selected is the dead body, and not the respawned player...

 

The problem I have is, I cannot move the dead body... anyone able to help?

Share this post


Link to post
Share on other sites
13 minutes ago, fn_Quiksilver said:

only way is to move another AI into the seat to push it out

 

So how do I create an invisible unit that gets in the vehicle and pushes the other players' corpses out?

Share this post


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

only way is to move another AI into the seat to push it out

@fn_Quiksilver is correct.  See my short Fall From Vehicles script which does exactly that.

 

Here's the relevant snippet from that script.  _cvictim is the dead unit to be removed from vehicle.

            _cargoIndex = _veh getCargoIndex _cvictim;
            _grp = createGroup CIVILIAN;
            _invisibleDude = objnull;
            _invisibleDude = _grp createUnit ["C_man_polo_2_F_afro",[100,0,0],[],0,"NONE"];
            hideObjectGlobal _invisibleDude;
            _invisibleDude allowDamage False;
            _invisibleDude setCaptive True;
            
            _invisibleDude moveInCargo [_veh, _cargoIndex];
            deleteVehicle _invisibleDude;

 

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

×