Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medical Treatment - Add Grave Digging for Corpse Disposal #9276

Merged
merged 25 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
92e2ba2
Add grave digging
Drofseh Jul 21, 2023
857b1e7
Update fnc_placeInBodyBagOrGrave.sqf
Drofseh Jul 21, 2023
43f0e09
Update fnc_placeInBodyBagOrGrave.sqf
Drofseh Jul 21, 2023
7f70a2a
Update fnc_placeInBodyBagOrGrave.sqf
Drofseh Jul 21, 2023
c09f7a5
Update addons/medical_treatment/functions/fnc_placeInBodyBag.sqf
Drofseh Jul 21, 2023
2f4ab4c
Add setting to enable/disable
Drofseh Jul 21, 2023
b42a139
improvements
Drofseh Jul 26, 2023
592fdb7
fix typo in variable
Drofseh Jul 26, 2023
63094cd
Apply suggestions from code review
Drofseh Aug 1, 2023
3c535f3
Apply suggestions from code review
Drofseh Aug 3, 2023
55427bc
add to XEH_PREP and fix event for non-local patient
Drofseh Aug 3, 2023
444ed9a
Add interaction to check name on headstone
Drofseh Aug 3, 2023
88e4d6f
Update addons/medical_treatment/XEH_postInit.sqf
Drofseh Aug 3, 2023
2e9f536
Simplify Setting
PabstMirror Aug 7, 2023
1906559
Apply suggestions from code review
Drofseh Aug 11, 2023
1a91219
Update addons/medical_treatment/stringtable.xml
Drofseh Aug 12, 2023
8b7f95e
Make placeInBodyBagOrGrave more generic and use any grave class
PabstMirror Aug 25, 2023
5c9b5cb
Update addons/medical_treatment/functions/fnc_placeInGrave.sqf
Drofseh Aug 26, 2023
35f72bb
Update medical-treatment-framework.md
PabstMirror Aug 29, 2023
2b56036
Update docs/wiki/framework/medical-treatment-framework.md
Drofseh Aug 31, 2023
883dcd7
Merge branch 'master' into add-grave-digging
LinkIsGrim Sep 23, 2023
21ee456
update docs
LinkIsGrim Sep 23, 2023
64c12af
Update addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf
LinkIsGrim Sep 23, 2023
036825d
Update addons/medical_treatment/functions/fnc_placeInGrave.sqf
LinkIsGrim Sep 23, 2023
7e3826f
fix includes
PabstMirror Sep 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added addons/medical_gui/ui/cross_grave.paa
Binary file not shown.
10 changes: 10 additions & 0 deletions addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ class GVAR(actions) {
consumeItem = 1;
litter[] = {};
};
class Grave: BodyBag {
displayName = CSTRING(DigGrave);
displayNameProgress = CSTRING(DiggingGrave);
icon = QPATHTOEF(medical_gui,ui\cross_grave.paa);
treatmentTime = QGVAR(treatmentTimeGrave);
condition = QFUNC(canDigGrave);
callbackSuccess = QFUNC(placeInGrave);
items[] = {};
consumeItem = 0;
};
class CPR: BasicBandage {
displayName = CSTRING(Actions_CPR);
displayNameProgress = CSTRING(Actions_PerformingCPR);
Expand Down
3 changes: 3 additions & 0 deletions addons/medical_treatment/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PREP(bandageLocal);
PREP(bodyCleanupLoop);
PREP(canBandage);
PREP(canCPR);
PREP(canDigGrave);
PREP(canPlaceInBodyBag);
PREP(canSplint);
PREP(canStitch);
Expand Down Expand Up @@ -47,6 +48,8 @@ PREP(medication);
PREP(medicationLocal);
PREP(onMedicationUsage);
PREP(placeInBodyBag);
PREP(placeInBodyBagOrGrave);
PREP(placeInGrave);
PREP(removeBody);
PREP(scanMedicalItems);
PREP(setTriageStatus);
Expand Down
34 changes: 33 additions & 1 deletion addons/medical_treatment/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (isServer) then {
[QGVAR(fullHealLocal), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(ivBagLocal), LINKFUNC(ivBagLocal)] call CBA_fnc_addEventHandler;
[QGVAR(medicationLocal), LINKFUNC(medicationLocal)] call CBA_fnc_addEventHandler;
[QGVAR(placeInBodyBag), LINKFUNC(placeInBodyBag)] call CBA_fnc_addEventHandler;
[QGVAR(placeInBodyBagOrGrave), LINKFUNC(placeInBodyBagOrGrave)] call CBA_fnc_addEventHandler;
[QGVAR(splintLocal), LINKFUNC(splintLocal)] call CBA_fnc_addEventHandler;
[QGVAR(tourniquetLocal), LINKFUNC(tourniquetLocal)] call CBA_fnc_addEventHandler;

Expand Down Expand Up @@ -61,3 +61,35 @@ if (isServer) then {
[_toReplace, _replacements] call EFUNC(common,registerItemReplacement);
} forEach (configProperties [configFile >> QEGVAR(medical,replacementItems), "isArray _x"]);
}] call CBA_fnc_addEventHandler;

if (["ace_trenches"] call EFUNC(common,isModLoaded)) then {
if (hasInterface) then {
private _checkHeadstoneAction = [
QGVAR(checkHeadstone),
LLSTRING(checkHeadstoneName),
QPATHTOEF(medical_gui,ui\cross_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
] call EFUNC(interact_menu,createAction);

["Land_Grave_dirt_F", 0, [], _checkHeadstoneAction] call EFUNC(interact_menu,addActionToClass);
};

if (isServer) then {
["ace_placedInBodyBag", {
params ["_target", "_restingPlace"];
TRACE_2("ace_placedInBodyBag eh",_target,_restingPlace);

private _targetName = [_target, false, true] call EFUNC(common,getName);
_restingPlace setVariable [QGVAR(headstoneData), _targetName, true];
}] call CBA_fnc_addEventHandler;
};
};
23 changes: 23 additions & 0 deletions addons/medical_treatment/functions/fnc_canDigGrave.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "..\script_component.hpp"
/*
* Author: Ruthberg, commy2, esteldunedain, drofseh
* Checks if a unit can dig a grave at the position of the patient.
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* Can dig <BOOL>
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_canDigGrave
*
* Public: No
*/

params ["_medic", "_patient"];

if !(["ace_trenches"] call EFUNC(common,isModLoaded)) exitWith {false};

(GVAR(allowGraveDigging) > 0) && {_patient call EFUNC(common,canDig)} && {_medic call EFUNC(trenches,hasEntrenchingTool)}
31 changes: 3 additions & 28 deletions addons/medical_treatment/functions/fnc_placeInBodyBag.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author: Glowbal
* Author: Glowbal, drofseh
* Places a dead body inside a body bag.
*
* Arguments:
Expand All @@ -24,30 +24,5 @@ if ((alive _patient) && {!GVAR(allowBodyBagUnconscious)}) exitWith {
[LSTRING(bodybagWhileStillAlive)] call EFUNC(common,displayTextStructured);
};

if (!local _patient) exitWith {
TRACE_1("Calling where local",local _patient);
[QGVAR(placeInBodyBag), [nil, _patient], _patient] call CBA_fnc_targetEvent;
};

if (alive _patient) then {
TRACE_1("Manually killing with setDead",_patient);
[_patient, "buried_alive", _medic] call EFUNC(medical_status,setDead);
};

private _position = (getPosASL _patient) vectorAdd [0, 0, 0.2];

private _headPos = _patient modelToWorldVisual (_patient selectionPosition "head");
private _spinePos = _patient modelToWorldVisual (_patient selectionPosition "Spine3");
private _direction = (_headPos vectorFromTo _spinePos) call CBA_fnc_vectDir;

// 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];

// Create the body bag object, set its position to prevent it from flipping
private _bodyBag = createVehicle ["ACE_bodyBagObject", [0, 0, 0], [], 0, "NONE"];
_bodyBag setPosASL _position;
_bodyBag setDir _direction;

// Server will handle hiding and deleting the body
["ace_placedInBodyBag", [_patient, _bodyBag]] call CBA_fnc_globalEvent;
// Body bag needs to be a little higher to prevent it from flipping
[_this, "ACE_bodyBagObject", [0, 0, 0.2]] call FUNC(placeInBodyBagOrGrave);
57 changes: 57 additions & 0 deletions addons/medical_treatment/functions/fnc_placeInBodyBagOrGrave.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#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)
*
* Return Value:
* None
*
* Example:
* [[player, cursorObject], "ACE_bodyBagObject"] call ace_medical_treatment_fnc_placeInBodyBagOrGrave
*
* Public: No
*/

params ["_args", "_restingPlaceClass", ["_offset", [0,0,0]], ["_rotation", 0]];
_args params ["_medic", "_patient"];
TRACE_1("placeInBodyBagOrGrave",_patient);

if (!local _patient) exitWith {
TRACE_1("Calling where local",local _patient);
[QGVAR(placeInBodyBagOrGrave), _this, _patient] call CBA_fnc_targetEvent;
};

if (alive _patient) then {
TRACE_1("Manually killing with setDead",_patient);
[_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;
// 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];
Drofseh marked this conversation as resolved.
Show resolved Hide resolved

// 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;
31 changes: 31 additions & 0 deletions addons/medical_treatment/functions/fnc_placeInGrave.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "..\script_component.hpp"
/*
* Author: Glowbal, drofseh
* Places a dead body inside a grave.
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_placeInGrave
*
* Public: No
*/

params ["_medic", "_patient"];
TRACE_1("placeInGrave",_patient);

if ((alive _patient) && {GVAR(allowGraveDigging) < 2}) exitWith {
[LSTRING(bodybagWhileStillAlive)] call EFUNC(common,displayTextStructured);
};

private _graveClassname = missionNameSpace getVariable [QGVAR(graveClassname), "Land_Grave_dirt_F"];
// Land_Grave_dirt_F needs to be rotated 90 degrees to line up with the body
private _graveRotation = missionNameSpace getVariable [QGVAR(graveRotation), 90];

[_this, _graveClassname, [0,0,0], _graveRotation] call FUNC(placeInBodyBagOrGrave);
Drofseh marked this conversation as resolved.
Show resolved Hide resolved

18 changes: 18 additions & 0 deletions addons/medical_treatment/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@
true
] call CBA_fnc_addSetting;

[
QGVAR(treatmentTimeGrave),
"SLIDER",
[LSTRING(TreatmentTimeGrave_DisplayName), LSTRING(TreatmentTimeGrave_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory_Treatment)],
[0.1, 120, 30, 1],
true
] call CBA_fnc_addSetting;

[
QGVAR(medicEpinephrine),
"LIST",
Expand Down Expand Up @@ -305,6 +314,15 @@
true
] call CBA_fnc_addSetting;

[
QGVAR(allowGraveDigging),
"LIST",
[LSTRING(AllowGaveDigging_DisplayName), LSTRING(AllowGaveDigging_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory_Treatment)],
[[0, 1, 2], [ELSTRING(common,Disabled), LSTRING(AllowGaveDigging_graveOnlyDead), ELSTRING(common,Yes)], 1],
true
] call CBA_fnc_addSetting;

[
QGVAR(holsterRequired),
"LIST",
Expand Down
24 changes: 24 additions & 0 deletions addons/medical_treatment/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@
<Chinesesimp>装入裹尸袋时间</Chinesesimp>
<Korean>초 단위로 시체 운반용 부대를 사용하는데 걸리는 시간을 정합니다.</Korean>
</Key>
<Key ID="STR_ACE_Medical_Treatment_TreatmentTimeGrave_DisplayName">
<English>Grave Digging Time</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_TreatmentTimeGrave_Description">
<English>Time, in seconds, required to dig a grave for a body.</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_MedicEpinephrine_DisplayName">
<English>Allow Epinephrine</English>
<German>Erlaube Epiniphrin</German>
Expand Down Expand Up @@ -825,6 +831,15 @@
<Chinesesimp>能够将昏迷的伤员装入尸袋中。</Chinesesimp>
<Korean>기절상태의 인원을 시체운반용부대에 옮겨 담을 수 있는지를 정합니다.</Korean>
</Key>
<Key ID="STR_ACE_Medical_Treatment_AllowGaveDigging_DisplayName">
<English>Allow Grave Digging</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_AllowGaveDigging_Description">
<English>Enables digging graves to dispose of corpses.</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_AllowGaveDigging_graveOnlyDead">
<English>Only if dead</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_MedicIV_DisplayName">
<English>Allow IV Transfusion</English>
<German>Erlaube Bluttransfusionen</German>
Expand Down Expand Up @@ -4445,6 +4460,12 @@
<Chinese>將屍體放入屍袋中...</Chinese>
<Turkish>Vücut, ceset torbasına yerleştiriliyor...</Turkish>
</Key>
<Key ID="STR_ACE_Medical_Treatment_DigGrave">
<English>Dig grave for body</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_DiggingGrave">
<English>Digging grave for body...</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_Activity_bandagedPatient">
<English>%1 has bandaged patient</English>
<Spanish>%1 has vendado al paciente</Spanish>
Expand Down Expand Up @@ -4686,6 +4707,9 @@
<Chinesesimp>身体抽搐了一下,可能还没死!</Chinesesimp>
<Korean>꿈틀대는걸 보니 죽은 것 같지는 않습니다!</Korean>
</Key>
<Key ID="STR_ACE_Medical_Treatment_checkHeadstoneName">
<English>Check name on headstone</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_bandageRollover_DisplayName">
<English>Bandage Rollover</English>
<Polish>Bandażowanie Wielu Ran</Polish>
Expand Down
14 changes: 14 additions & 0 deletions docs/wiki/framework/medical-treatment-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ class ACE_Medical_Treatment_Actions {
};
};
```

## 2. Mission Variables

### 2.1 Grave Digging Object Configuration

The object created when digging a grave can be modified by setting the `ace_medical_treatment_graveClassname` variable.
```sqf
ace_medical_treatment_graveClassname = "Land_Grave_11_F"; // classname, e.g. unmarked gravel (no headstone OR check actions)
```

The object's rotation can also be modified, if necessary.
```sqf
ace_medical_treatment_graveRotation = 0; // rotation angle (will depend on model classname)
```