2023-09-24 19:57:08 +00:00
|
|
|
#include "..\script_component.hpp"
|
|
|
|
/*
|
|
|
|
* Author: Glowbal, drofseh
|
|
|
|
* Places a dead body inside a body bag or grave.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Arguments <ARRAY>
|
|
|
|
* - 0: Medic <OBJECT>
|
|
|
|
* - 1: Patient <OBJECT>
|
|
|
|
* 1: Resting Place Classname <STRING>
|
|
|
|
* 2: Offset <ARRAY> (default: [0,0,0])
|
|
|
|
* 3: Rotation <NUMBER> (default: 0)
|
2023-10-02 15:05:56 +00:00
|
|
|
* 4: Is Grave <BOOL> (default: false)
|
2023-09-24 19:57:08 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [[player, cursorObject], "ACE_bodyBagObject"] call ace_medical_treatment_fnc_placeInBodyBagOrGrave
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2023-10-02 15:05:56 +00:00
|
|
|
params ["_args", "_restingPlaceClass", ["_offset", [0,0,0]], ["_rotation", 0], ["_isGrave", false]];
|
2023-09-24 19:57:08 +00:00
|
|
|
_args params ["_medic", "_patient"];
|
|
|
|
TRACE_1("placeInBodyBagOrGrave",_patient);
|
|
|
|
|
2023-10-02 15:05:56 +00:00
|
|
|
private _isHuman = _patient isKindOf "CaManBase";
|
|
|
|
|
|
|
|
if (_isHuman && {!local _patient}) exitWith {
|
2023-09-24 19:57:08 +00:00
|
|
|
TRACE_1("Calling where local",local _patient);
|
|
|
|
[QGVAR(placeInBodyBagOrGrave), _this, _patient] call CBA_fnc_targetEvent;
|
|
|
|
};
|
|
|
|
|
2023-10-02 15:05:56 +00:00
|
|
|
if (_isHuman && {alive _patient}) then {
|
2023-09-24 19:57:08 +00:00
|
|
|
TRACE_1("Manually killing with setDead",_patient);
|
|
|
|
[_patient, "buried_alive", _medic] call EFUNC(medical_status,setDead);
|
|
|
|
};
|
|
|
|
|
|
|
|
private _position = getPosASL _patient;
|
2023-10-01 18:55:13 +00:00
|
|
|
private _direction = 0;
|
|
|
|
|
2023-10-02 15:05:56 +00:00
|
|
|
if (_isHuman) then {
|
2023-10-01 18:55:13 +00:00
|
|
|
private _headPos = _patient modelToWorldVisual (_patient selectionPosition "head");
|
|
|
|
private _spinePos = _patient modelToWorldVisual (_patient selectionPosition "Spine3");
|
|
|
|
_direction = (_headPos vectorFromTo _spinePos) call CBA_fnc_vectDir;
|
|
|
|
} else {
|
2023-10-02 15:05:56 +00:00
|
|
|
_direction = getDir _patient;
|
2023-10-01 18:55:13 +00:00
|
|
|
};
|
|
|
|
|
2023-09-24 19:57:08 +00:00
|
|
|
// apply adjustments
|
|
|
|
_position = _position vectorAdd _offset;
|
|
|
|
_direction = _direction + _rotation;
|
|
|
|
|
|
|
|
|
|
|
|
// Move the body away so it won't collide with the body bag object
|
|
|
|
// This setPosASL seems to need to be called where the unit is local
|
|
|
|
_patient setPosASL [-5000, -5000, 0];
|
|
|
|
|
2023-10-02 15:05:56 +00:00
|
|
|
private _restingPlace = objNull;
|
|
|
|
if (_restingPlaceClass != "") then {
|
|
|
|
// Create the body bag object, set its position to prevent it from flipping
|
|
|
|
_restingPlace = createVehicle [_restingPlaceClass, [0, 0, 0], [], 0, "NONE"];
|
|
|
|
_restingPlace setPosASL _position;
|
|
|
|
_restingPlace setDir _direction;
|
2023-10-01 18:31:38 +00:00
|
|
|
};
|
|
|
|
|
2023-09-24 19:57:08 +00:00
|
|
|
|
|
|
|
// Server will handle hiding and deleting the body
|
|
|
|
// Keep event name as body bag only to avoid breaking things for others
|
2023-10-02 15:05:56 +00:00
|
|
|
["ace_placedInBodyBag", [_patient, _restingPlace, _isGrave]] call CBA_fnc_globalEvent;
|
|
|
|
if (_isGrave) then {
|
|
|
|
["ace_placedInGrave", [_patient, _restingPlace]] call CBA_fnc_globalEvent;
|
|
|
|
};
|