Medical Treatment - Fix grave digging (#9455)

This commit is contained in:
PabstMirror 2023-10-02 10:05:56 -05:00 committed by GitHub
parent 3626b37c01
commit 3c9d7733e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 28 deletions

View File

@ -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;
};

View File

@ -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);

View File

@ -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);
};

View File

@ -47,6 +47,7 @@ PREP(loadUnit);
PREP(medication);
PREP(medicationLocal);
PREP(onMedicationUsage);
PREP(placeBodyBagInGrave);
PREP(placeInBodyBag);
PREP(placeInBodyBagOrGrave);
PREP(placeInGrave);

View File

@ -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;
};

View File

@ -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

View File

@ -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);

View File

@ -10,6 +10,7 @@
* 1: Resting Place Classname <STRING>
* 2: Offset <ARRAY> (default: [0,0,0])
* 3: Rotation <NUMBER> (default: 0)
* 4: Is Grave <BOOL> (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
private _restingPlace = createVehicle [_restingPlaceClass, [0, 0, 0], [], 0, "NONE"];
_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;
};

View File

@ -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)

View File

@ -5,7 +5,7 @@
* However, player bodies cannot be deleted until they respawn, so it is hidden and deleted later.
*
* Arguments:
* 0: Body <OBJECT>
* 0: Body or Bodybag <OBJECT>
*
* Return Value:
* None

View File

@ -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)