bodybag - hide player corpse and delete later

Fix #1301
This commit is contained in:
PabstMirror 2016-02-13 17:59:11 -06:00
parent 488d24bc01
commit 44b526ab6d
4 changed files with 74 additions and 11 deletions

View File

@ -29,7 +29,10 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
["treatmentBasic_morphineLocal", DFUNC(treatmentBasic_morphineLocal)] call EFUNC(common,addEventHandler);
["treatmentIVLocal", DFUNC(treatmentIVLocal)] call EFUNC(common,addEventHandler);
["treatmentTourniquetLocal", DFUNC(treatmentTourniquetLocal)] call EFUNC(common,addEventHandler);
["actionPlaceInBodyBag", FUNC(actionPlaceInBodyBag)] call EFUNC(common,addEventHandler);
//Handle Deleting Bodies on Server:
if (isServer) then {["placedInBodyBag", FUNC(serverRemoveBody)] call EFUNC(common,addEventHandler);};
["medical_onUnconscious", {
params ["_unit", "_status"];
if (local _unit) then {

View File

@ -66,6 +66,7 @@ PREP(onPropagateWound);
PREP(parseConfigForInjuries);
PREP(playInjuredSound);
PREP(selectionNameToNumber);
PREP(serverRemoveBody);
PREP(setCardiacArrest);
PREP(setDead);
PREP(setHitPointDamage);

View File

@ -7,35 +7,46 @@
* 1: The patient <OBJECT>
*
* Return Value:
* body bag <OBJECT>
* body bag (will return objNull when run where target is not local) <OBJECT>
*
* Example:
* [player, cursorTarget] call ace_medical_fnc_actionPlaceInBodyBag
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_position", "_headPos", "_spinePos", "_dirVect", "_direction", "_bodyBag"];
params ["_caller", "_target"];
TRACE_2("params",_caller,_target);
if (!local _target) exitWith {
TRACE_1("running where local",local _target);
["medical_actionPlaceInBodyBag", [_target], [_caller, _target]] call EFUNC(common,targetEvent);
objNull
};
if (alive _target) then {
TRACE_1("manually killing with setDead",_target);
[_target, true] call FUNC(setDead);
};
_position = (getPosASL _target) vectorAdd [0, 0, 0.2];
private _position = (getPosASL _target) vectorAdd [0, 0, 0.2];
_headPos = _target modelToWorldVisual (_target selectionPosition "head");
_spinePos = _target modelToWorldVisual (_target selectionPosition "Spine3");
_dirVect = _headPos vectorFromTo _spinePos;
_direction = _dirVect call CBA_fnc_vectDir;
private _headPos = _target modelToWorldVisual (_target selectionPosition "head");
private _spinePos = _target modelToWorldVisual (_target selectionPosition "Spine3");
private _dirVect = _headPos vectorFromTo _spinePos;
private _direction = _dirVect call CBA_fnc_vectDir;
_bodyBag = createVehicle ["ACE_bodyBagObject", _position, [], 0, "CAN_COLLIDE"];
//move the body away now, so it won't physX the bodyBag object (this setPos seems to need to be called where object is local)
_target setPosASL [-5000, -5000, 0];
["placedInBodyBag", [_target, _bodyBag]] call EFUNC(common,globalEvent);
deleteVehicle _target;
private _bodyBag = createVehicle ["ACE_bodyBagObject", _position, [], 0, ""];
// prevent body bag from flipping
_bodyBag setPosASL _position;
_bodyBag setDir _direction;
["placedInBodyBag", [_target, _bodyBag]] call EFUNC(common,globalEvent); //hide and delete body on server
_bodyBag

View File

@ -0,0 +1,48 @@
/*
* Author: PabstMirror
* Removes corpse. Idealy it is just deleted the next frame,
* but player bodies cannot be deleted until they respawn, so it is hidden and deleted later.
*
* Arguments:
* 0: Mr Body <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [cursorTarget] call ace_medical_fnc_serverRemoveBody
*
* Public: No
*/
#include "script_component.hpp"
params ["_target"];
TRACE_2("",_target,isPlayer _target);
//Hide the body globaly
["hideObjectGlobal", [_target, true]] call EFUNC(common,serverEvent);
if (isNil QGVAR(bodiesToDelete)) then {GVAR(bodiesToDelete) = [];};
GVAR(bodiesToDelete) pushBack _target;
//Start up PFEH to wait for bodies to be free to delete
if ((count GVAR(bodiesToDelete)) == 1) then {
TRACE_1("starting PFEH",GVAR(bodiesToDelete));
[{
{
TRACE_2("body",_x,isPlayer _x);
if ((!isNull _x) && {!isPlayer _x}) then {deleteVehicle _x};
} forEach GVAR(bodiesToDelete);
//deleteVehicle doesn't have instant results so it won't usualy be filtered until next run
GVAR(bodiesToDelete) = GVAR(bodiesToDelete) - [objNull];
if (GVAR(bodiesToDelete) isEqualTo []) then {
TRACE_1("array emptied - rem PFEH",GVAR(bodiesToDelete));
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
}, 20, []] call CBA_fnc_addPerFrameHandler;
};
nil