From 8bf0772558fe94e3da8e739214e54c8c8cefe466 Mon Sep 17 00:00:00 2001 From: Drofseh Date: Sun, 1 Oct 2023 11:55:13 -0700 Subject: [PATCH] Medical Treatement - Add Grave Digging To Body Bags (#9442) * add grave digging to body bags * move buryBodyBag action to config, change grave ui icon to headstone * improvements from code review * switch direction check to man instead of bodybag, nominally allowing anything to be buried --------- Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> --- addons/medical_gui/ui/grave.paa | Bin 0 -> 5625 bytes .../ACE_Medical_Treatment_Actions.hpp | 2 +- addons/medical_treatment/CfgVehicles.hpp | 6 ++++ addons/medical_treatment/XEH_postInit.sqf | 17 ++++++---- .../functions/fnc_placeBodyBagInGrave.sqf | 30 ++++++++++++++++++ .../functions/fnc_placeInBodyBagOrGrave.sqf | 13 ++++++-- .../functions/fnc_placeInGrave.sqf | 1 - 7 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 addons/medical_gui/ui/grave.paa create mode 100644 addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf diff --git a/addons/medical_gui/ui/grave.paa b/addons/medical_gui/ui/grave.paa new file mode 100644 index 0000000000000000000000000000000000000000..ccd786d73c867343793e8e35c9f4a61822bfe9e6 GIT binary patch literal 5625 zcmeHLK}-`t6#ZM-NDrhnx?BvQi5v_@Pll`87+NtjF4!@6D;ICAwE}CnlHx zXrU#o3^XtU8Vt<#cxQV!2Vkt9osT&24JUp@Vx~XK5boGOqCajj z1lD!EQMn;|7=Bf~anStqqyA>hKhk&t_#?hQ%|G>H_^tRGQ~>V$7p)Pd@~@cxn)^GA zBcUx`-UU24{&oK4U|~=CqZ-J11E*h^t-4plf9m@mhIOL)uX6O18d~w6&He9`rn}0l zn16ibrS+z1jEP0IxF5XhEDsktIFZYojj8l90OM1QhG(H`TM#t>zJU^O8e#unHSBb}L zj-Qc-x0F7(LVCT1Q9LcG|j{HniE{K{Uv z{9t49k9=z0<+ctpxb4gMFf5c32Ah(9uBcx(pF1Fccf~<(fNuC4|p+fOkj5C#AM literal 0 HcmV?d00001 diff --git a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp index 9ed1b2998e..b7fd0ac3bd 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp @@ -256,7 +256,7 @@ class GVAR(actions) { class Grave: BodyBag { displayName = CSTRING(DigGrave); displayNameProgress = CSTRING(DiggingGrave); - icon = QPATHTOEF(medical_gui,ui\cross_grave.paa); + icon = QPATHTOEF(medical_gui,ui\grave.paa); treatmentTime = QGVAR(treatmentTimeGrave); condition = QFUNC(canDigGrave); callbackSuccess = QFUNC(placeInGrave); diff --git a/addons/medical_treatment/CfgVehicles.hpp b/addons/medical_treatment/CfgVehicles.hpp index c3e119b90c..27e4617b0a 100644 --- a/addons/medical_treatment/CfgVehicles.hpp +++ b/addons/medical_treatment/CfgVehicles.hpp @@ -29,6 +29,12 @@ class CfgVehicles { statement = ""; icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa"; selection = ""; + class GVAR(buryBodyBag) { + displayName = CSTRING(DigGrave); + condition = QUOTE([_this#1] call FUNC(canDigGrave)); + statement = QUOTE(_this call FUNC(placeBodyBagInGrave)); + icon = QPATHTOEF(medical_gui,ui\grave.paa); + }; }; }; }; diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index edab6121cc..70d45e991c 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -67,20 +67,17 @@ if (["ace_trenches"] call EFUNC(common,isModLoaded)) then { private _checkHeadstoneAction = [ QGVAR(checkHeadstone), LLSTRING(checkHeadstoneName), - QPATHTOEF(medical_gui,ui\cross_grave.paa), + QPATHTOEF(medical_gui,ui\grave.paa), { [ [_target getVariable QGVAR(headstoneData)], true ] call CBA_fnc_notify; }, - {!isNil {_target getVariable QGVAR(headstoneData)}}, - {}, - [], - [1.05, 0.02, 0.3] //position in centre of cross + {!isNil {_target getVariable QGVAR(headstoneData)}} ] call EFUNC(interact_menu,createAction); - ["ACE_Grave", 0, [], _checkHeadstoneAction] call EFUNC(interact_menu,addActionToClass); + [missionNameSpace getVariable [QGVAR(graveClassname), "ACE_Grave"], 0, [], _checkHeadstoneAction] call EFUNC(interact_menu,addActionToClass); }; if (isServer) then { @@ -88,7 +85,13 @@ if (["ace_trenches"] call EFUNC(common,isModLoaded)) then { params ["_target", "_restingPlace"]; TRACE_2("ace_placedInBodyBag eh",_target,_restingPlace); - private _targetName = [_target, false, true] call EFUNC(common,getName); + private _targetName = ""; + if (_target isKindOf "ACE_bodyBagObject") then { + _targetName = _target getVariable [QGVAR(headstoneData), ""]; + } else { + _targetName = [_target, false, true] call EFUNC(common,getName); + }; + _restingPlace setVariable [QGVAR(headstoneData), _targetName, true]; }] call CBA_fnc_addEventHandler; }; diff --git a/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf b/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf new file mode 100644 index 0000000000..87a80a45e3 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_placeBodyBagInGrave.sqf @@ -0,0 +1,30 @@ +#include "..\script_component.hpp" +/* + * Author: drofseh + * Places a body bag inside a grave. + * + * Arguments: + * 0: Medic + * 1: Patient + * + * Return Value: + * None + * + * Example: + * [cursorObject, player] call ace_medical_treatment_fnc_placeBodyBagInGrave + * + * Public: No + */ + +params ["_bodybag"]; +TRACE_1("placeBodyBagInGrave",_bodybag); + +[ + QGVAR(treatmentTimeGrave), + _this, + { + [[_this#1, _this#0], missionNameSpace getVariable [QGVAR(graveClassname), "ACE_Grave"], [0,0,0], missionNameSpace getVariable [QGVAR(graveRotation), 0]] call FUNC(placeInBodyBagOrGrave); + }, + {}, + LLSTRING(DiggingGrave) +] call EFUNC(common,progressBar); diff --git a/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf b/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf index 850850e631..40fb8afabd 100644 --- a/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf +++ b/addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf @@ -34,10 +34,17 @@ if (alive _patient) then { [_patient, "buried_alive", _medic] call EFUNC(medical_status,setDead); }; -private _headPos = _patient modelToWorldVisual (_patient selectionPosition "head"); -private _spinePos = _patient modelToWorldVisual (_patient selectionPosition "Spine3"); -private _direction = (_headPos vectorFromTo _spinePos) call CBA_fnc_vectDir; private _position = getPosASL _patient; +private _direction = 0; + +if (_patient isKindOf "CaManBase") 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; +}; + // apply adjustments _position = _position vectorAdd _offset; _direction = _direction + _rotation; diff --git a/addons/medical_treatment/functions/fnc_placeInGrave.sqf b/addons/medical_treatment/functions/fnc_placeInGrave.sqf index b0c8fc3699..8ba67f5172 100644 --- a/addons/medical_treatment/functions/fnc_placeInGrave.sqf +++ b/addons/medical_treatment/functions/fnc_placeInGrave.sqf @@ -23,7 +23,6 @@ if ((alive _patient) && {GVAR(allowGraveDigging) < 2}) exitWith { [LSTRING(bodybagWhileStillAlive)] call EFUNC(common,displayTextStructured); }; - private _graveClassname = ""; if (GVAR(graveDiggingMarker)) then { _graveClassname = missionNamespace getVariable [QGVAR(graveClassname), "ACE_Grave"];