mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #3354 from acemod/playerBodybags
Fix bagging respawning players (alt)
This commit is contained in:
commit
2930fab6c6
@ -11,7 +11,6 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
|
||||
["interactMenuClosed", {[objNull, false] call FUNC(displayPatientInformation); }] call EFUNC(common,addEventHandler);
|
||||
|
||||
//Treatment EventHandlers:
|
||||
["medical_advMedication", FUNC(treatmentAdvanced_medicationLocal)] call EFUNC(common,addEventHandler);
|
||||
["actionCheckBloodPressureLocal", DFUNC(actionCheckBloodPressureLocal)] call EFUNC(common,addEventHandler);
|
||||
["actionCheckPulseLocal", DFUNC(actionCheckPulseLocal)] call EFUNC(common,addEventHandler);
|
||||
["addToInjuredCollection", DFUNC(addToInjuredCollection)] call EFUNC(common,addEventHandler);
|
||||
@ -29,6 +28,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"];
|
||||
|
@ -66,6 +66,7 @@ PREP(onPropagateWound);
|
||||
PREP(parseConfigForInjuries);
|
||||
PREP(playInjuredSound);
|
||||
PREP(selectionNameToNumber);
|
||||
PREP(serverRemoveBody);
|
||||
PREP(setCardiacArrest);
|
||||
PREP(setDead);
|
||||
PREP(setHitPointDamage);
|
||||
|
@ -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);
|
||||
["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
|
||||
|
@ -44,7 +44,7 @@ TRACE_2("meds",_part,_delayedMedications);
|
||||
_x params ["", "", "_medPartNum"];
|
||||
if (_part == _medPartNum) then {
|
||||
TRACE_1("delayed medication call after tourniquet removeal",_x);
|
||||
["medical_advMedication", [_target], _x] call EFUNC(common,targetEvent);
|
||||
["treatmentAdvanced_medicationLocal", [_target], _x] call EFUNC(common,targetEvent);
|
||||
_delayedMedications set [_forEachIndex, -1];
|
||||
_updatedArray = true;
|
||||
};
|
||||
|
48
addons/medical/functions/fnc_serverRemoveBody.sqf
Normal file
48
addons/medical/functions/fnc_serverRemoveBody.sqf
Normal 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
|
@ -22,7 +22,7 @@ TRACE_5("params",_caller,_target,_selectionName,_className,_items);
|
||||
|
||||
private _part = [_selectionName] call FUNC(selectionNameToNumber);
|
||||
|
||||
["medical_advMedication", [_target], [_target, _className, _part]] call EFUNC(common,targetEvent);
|
||||
["treatmentAdvanced_medicationLocal", [_target], [_target, _className, _part]] call EFUNC(common,targetEvent);
|
||||
|
||||
{
|
||||
if (_x != "") then {
|
||||
|
Loading…
Reference in New Issue
Block a user