diff --git a/addons/cargo/XEH_postInit.sqf b/addons/cargo/XEH_postInit.sqf index 5ade83b41c..6146f2c862 100644 --- a/addons/cargo/XEH_postInit.sqf +++ b/addons/cargo/XEH_postInit.sqf @@ -153,7 +153,8 @@ private _objectClassesAddClassEH = call (uiNamespace getVariable [QGVAR(objectCl if (isServer) then { ["ace_placedInBodyBag", { - params ["_target", "_bodyBag"]; + params ["_target", "_bodyBag", "_isGrave"]; + if (_isGrave) exitWith {}; // assume graves aren't cargo _bodyBag setVariable [QGVAR(customName), [_target, false, true] call EFUNC(common,getName), true]; }] call CBA_fnc_addEventHandler; }; diff --git a/addons/dogtags/XEH_postInit.sqf b/addons/dogtags/XEH_postInit.sqf index d7476345c9..ea8e9bbd38 100644 --- a/addons/dogtags/XEH_postInit.sqf +++ b/addons/dogtags/XEH_postInit.sqf @@ -32,7 +32,8 @@ if (["ACE_Medical"] call EFUNC(common,isModLoaded)) then { if (isServer) then { ["ace_placedInBodyBag", { - params ["_target", "_bodyBag"]; + params ["_target", "_bodyBag", "_isGrave"]; + if (_isGrave) exitWith {}; TRACE_2("ace_placedInBodyBag eh",_target,_bodyBag); private _dogTagData = [_target] call FUNC(getDogtagData); diff --git a/addons/medical_gui/ui/cross_grave.paa b/addons/medical_gui/ui/cross_grave.paa deleted file mode 100644 index ca18f3d081..0000000000 Binary files a/addons/medical_gui/ui/cross_grave.paa and /dev/null differ diff --git a/addons/medical_treatment/CfgVehicles.hpp b/addons/medical_treatment/CfgVehicles.hpp index 27e4617b0a..ea9e47cb91 100644 --- a/addons/medical_treatment/CfgVehicles.hpp +++ b/addons/medical_treatment/CfgVehicles.hpp @@ -31,7 +31,7 @@ class CfgVehicles { selection = ""; class GVAR(buryBodyBag) { displayName = CSTRING(DigGrave); - condition = QUOTE([_this#1] call FUNC(canDigGrave)); + condition = QUOTE([ARR_2(_this#1, _this#0)] call FUNC(canDigGrave)); statement = QUOTE(_this call FUNC(placeBodyBagInGrave)); icon = QPATHTOEF(medical_gui,ui\grave.paa); }; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index 11fabc5440..9222b0bd8b 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -47,6 +47,7 @@ PREP(loadUnit); PREP(medication); PREP(medicationLocal); PREP(onMedicationUsage); +PREP(placeBodyBagInGrave); PREP(placeInBodyBag); PREP(placeInBodyBagOrGrave); PREP(placeInGrave); diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index 70d45e991c..4c7a780fc3 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -84,6 +84,7 @@ if (["ace_trenches"] call EFUNC(common,isModLoaded)) then { ["ace_placedInBodyBag", { params ["_target", "_restingPlace"]; TRACE_2("ace_placedInBodyBag eh",_target,_restingPlace); + if (isNull _restingPlace) exitWith {}; private _targetName = ""; if (_target isKindOf "ACE_bodyBagObject") then { @@ -92,6 +93,7 @@ if (["ace_trenches"] call EFUNC(common,isModLoaded)) then { _targetName = [_target, false, true] call EFUNC(common,getName); }; + if (_targetName == "") exitWith {}; _restingPlace setVariable [QGVAR(headstoneData), _targetName, true]; }] call CBA_fnc_addEventHandler; }; diff --git a/addons/medical_treatment/functions/fnc_bodyCleanupLoop.sqf b/addons/medical_treatment/functions/fnc_bodyCleanupLoop.sqf index e66513a19d..d35dcc452c 100644 --- a/addons/medical_treatment/functions/fnc_bodyCleanupLoop.sqf +++ b/addons/medical_treatment/functions/fnc_bodyCleanupLoop.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: Glowbal, esteldunedain - * Handles cleaning up bodies that were replaced by body bags. + * Handles cleaning up bodies or body bags that were replaced by body bags or put in grave. * * Arguments: * None diff --git a/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf b/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf index 87a80a45e3..82cd2bc080 100644 --- a/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf +++ b/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf @@ -16,15 +16,24 @@ * Public: No */ -params ["_bodybag"]; -TRACE_1("placeBodyBagInGrave",_bodybag); +params ["_bodybag", "_medic"]; +TRACE_2("placeBodyBagInGrave",_bodybag,_medic); [ - QGVAR(treatmentTimeGrave), + GVAR(treatmentTimeGrave), _this, { - [[_this#1, _this#0], missionNameSpace getVariable [QGVAR(graveClassname), "ACE_Grave"], [0,0,0], missionNameSpace getVariable [QGVAR(graveRotation), 0]] call FUNC(placeInBodyBagOrGrave); + TRACE_1("finished",_this); + (_this#0) params ["_bodybag","_medic"]; + private _graveClassname = ""; + if (GVAR(graveDiggingMarker)) then { + _graveClassname = missionNamespace getVariable [QGVAR(graveClassname), "ACE_Grave"]; + }; + private _graveRotation = missionNameSpace getVariable [QGVAR(graveRotation), 0]; + + [[_medic, _bodybag], _graveClassname, [0,0,0], _graveRotation, true] call FUNC(placeInBodyBagOrGrave); }, - {}, + {TRACE_1("failed",_this);}, LLSTRING(DiggingGrave) + // ToDo: check FUNC(canDigGrave)? - what if body dragged/burried by someone else ] call EFUNC(common,progressBar); diff --git a/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf b/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf index 40fb8afabd..f1900108c6 100644 --- a/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf +++ b/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf @@ -10,6 +10,7 @@ * 1: Resting Place Classname * 2: Offset (default: [0,0,0]) * 3: Rotation (default: 0) + * 4: Is Grave (default: false) * * Return Value: * None @@ -20,16 +21,18 @@ * Public: No */ -params ["_args", "_restingPlaceClass", ["_offset", [0,0,0]], ["_rotation", 0]]; +params ["_args", "_restingPlaceClass", ["_offset", [0,0,0]], ["_rotation", 0], ["_isGrave", false]]; _args params ["_medic", "_patient"]; TRACE_1("placeInBodyBagOrGrave",_patient); -if (!local _patient) exitWith { +private _isHuman = _patient isKindOf "CaManBase"; + +if (_isHuman && {!local _patient}) exitWith { TRACE_1("Calling where local",local _patient); [QGVAR(placeInBodyBagOrGrave), _this, _patient] call CBA_fnc_targetEvent; }; -if (alive _patient) then { +if (_isHuman && {alive _patient}) then { TRACE_1("Manually killing with setDead",_patient); [_patient, "buried_alive", _medic] call EFUNC(medical_status,setDead); }; @@ -37,12 +40,12 @@ if (alive _patient) then { private _position = getPosASL _patient; private _direction = 0; -if (_patient isKindOf "CaManBase") then { +if (_isHuman) then { private _headPos = _patient modelToWorldVisual (_patient selectionPosition "head"); private _spinePos = _patient modelToWorldVisual (_patient selectionPosition "Spine3"); _direction = (_headPos vectorFromTo _spinePos) call CBA_fnc_vectDir; } else { - _direction getDir _patient; + _direction = getDir _patient; }; // apply adjustments @@ -54,17 +57,18 @@ _direction = _direction + _rotation; // This setPosASL seems to need to be called where the unit is local _patient setPosASL [-5000, -5000, 0]; -if (_restingPlaceClass == "") exitWith { - [_patient, objNull] +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; }; -// Create the body bag object, set its position to prevent it from flipping -private _restingPlace = createVehicle [_restingPlaceClass, [0, 0, 0], [], 0, "NONE"]; -_restingPlace setPosASL _position; -_restingPlace setDir _direction; // Server will handle hiding and deleting the body // Keep event name as body bag only to avoid breaking things for others -["ace_placedInBodyBag", [_patient, _restingPlace]] call CBA_fnc_globalEvent; - -[_patient, _restingPlace] +["ace_placedInBodyBag", [_patient, _restingPlace, _isGrave]] call CBA_fnc_globalEvent; +if (_isGrave) then { + ["ace_placedInGrave", [_patient, _restingPlace]] call CBA_fnc_globalEvent; +}; diff --git a/addons/medical_treatment/functions/fnc_placeInGrave.sqf b/addons/medical_treatment/functions/fnc_placeInGrave.sqf index 8ba67f5172..6bea5c6db9 100644 --- a/addons/medical_treatment/functions/fnc_placeInGrave.sqf +++ b/addons/medical_treatment/functions/fnc_placeInGrave.sqf @@ -29,6 +29,5 @@ if (GVAR(graveDiggingMarker)) then { }; private _graveRotation = missionNameSpace getVariable [QGVAR(graveRotation), 0]; -["ace_placedInGrave", - [_this, _graveClassname, [0,0,0], _graveRotation] call FUNC(placeInBodyBagOrGrave) -] call CBA_fnc_globalEvent; +[_this, _graveClassname, [0,0,0], _graveRotation, true] call FUNC(placeInBodyBagOrGrave) + diff --git a/addons/medical_treatment/functions/fnc_removeBody.sqf b/addons/medical_treatment/functions/fnc_removeBody.sqf index 5380b7e8f1..7be154e89c 100644 --- a/addons/medical_treatment/functions/fnc_removeBody.sqf +++ b/addons/medical_treatment/functions/fnc_removeBody.sqf @@ -5,7 +5,7 @@ * However, player bodies cannot be deleted until they respawn, so it is hidden and deleted later. * * Arguments: - * 0: Body + * 0: Body or Bodybag * * Return Value: * None diff --git a/docs/wiki/framework/events-framework.md b/docs/wiki/framework/events-framework.md index a2d7f491c5..7244271520 100644 --- a/docs/wiki/framework/events-framework.md +++ b/docs/wiki/framework/events-framework.md @@ -36,7 +36,7 @@ The vehicle events will also have the following local variables available `_gunn | Event Key | Parameters | Locality | Type | Description | |----------|---------|---------|---------|---------|---------| |`ace_unconscious` | [_unit, _state(BOOL)] | Global | Listen | Unit's unconscious state changed -|`ace_placedInBodyBag` | [_target, _bodyBag] | Global | Listen | Target placed into a bodybag Note: (Target will soon be deleted) +|`ace_placedInBodyBag` | [_target, _bodyBag, _isGrave] | Global | Listen | Target placed into a bodybag Note: (Target will soon be deleted, target could be a bodybag) |`ace_placedInGrave` | [_target, _grave] | Global | Listen | Target placed into a grave, _grave will be objNull if `Create Grave Markers` is disabled Note: (Target will soon be deleted) |`ace_treatmentStarted` | [_caller, _target, _selectionName, _className, _itemUser, _usedItem] | Local | Listen | Treatment action has started (local on the _caller) |`ace_treatmentSucceded` | [_caller, _target, _selectionName, _className, _itemUser, _usedItem] | Local | Listen | Treatment action is completed (local on the _caller)