2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2019-06-03 15:31:46 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal, mharis001
|
|
|
|
* Creates litter around the patient based on the treatment.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Medic <OBJECT>
|
|
|
|
* 1: Patient <OBJECT>
|
|
|
|
* 2: Body Part <STRING>
|
|
|
|
* 3: Treatment <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2020-04-25 06:41:45 +00:00
|
|
|
* [player, cursorObject, "Head", "BasicBandage"] call ace_medical_treatment_fnc_createLitter
|
2019-06-03 15:31:46 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Exit if litter creation is disabled
|
|
|
|
if (!GVAR(allowLitterCreation)) exitWith {};
|
|
|
|
|
|
|
|
params ["_medic", "_patient", "_bodyPart", "_classname"];
|
|
|
|
|
|
|
|
// Don't create litter if medic or patient are inside a vehicle
|
|
|
|
if (vehicle _medic != _medic || {vehicle _patient != _patient}) exitWith {};
|
|
|
|
|
|
|
|
// Determine if treated body part is bleeding
|
|
|
|
private _index = ALL_BODY_PARTS find toLower _bodyPart;
|
2023-06-24 05:11:56 +00:00
|
|
|
private _isBleeding = (GET_OPEN_WOUNDS(_patient) get _bodyPart) findIf {
|
|
|
|
_x params ["", "_amountOf", "_bleeding"];
|
|
|
|
_amountOf * _bleeding > 0
|
2019-06-03 15:31:46 +00:00
|
|
|
} != -1;
|
|
|
|
|
|
|
|
// Get litter config for the treatment
|
|
|
|
private _litter = getArray (configFile >> QGVAR(actions) >> _classname >> "litter");
|
|
|
|
_litter params [["_alwaysLitter", [], [[]]], ["_cleanLitter", [], [[]]], ["_bloodyLitter", [], [[]]]];
|
|
|
|
|
|
|
|
private _fnc_createLitter = {
|
|
|
|
params ["_litterOptions"];
|
|
|
|
|
|
|
|
private _position = getPosASL _patient;
|
|
|
|
|
|
|
|
// For now, don't spawn litter over water to avoid floating litter
|
|
|
|
// todo: handle carriers over water
|
|
|
|
if (surfaceIsWater _position) exitWith {};
|
|
|
|
|
|
|
|
{
|
|
|
|
if (_x isEqualType []) then {
|
|
|
|
_x = selectRandom _x;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Randomize position XY +/- 1 m
|
|
|
|
private _position = _position vectorAdd [
|
|
|
|
random 2 - 1,
|
|
|
|
random 2 - 1,
|
|
|
|
0
|
|
|
|
];
|
|
|
|
|
|
|
|
// Create litter on server which will also handle cleanup
|
|
|
|
[QGVAR(createLitterServer), [_x, _position, random 360]] call CBA_fnc_serverEvent;
|
|
|
|
} forEach _litterOptions;
|
|
|
|
};
|
|
|
|
|
|
|
|
private _conditionalLitter = [_cleanLitter, _bloodyLitter] select _isBleeding;
|
|
|
|
|
|
|
|
[_alwaysLitter] call _fnc_createLitter;
|
|
|
|
[_conditionalLitter] call _fnc_createLitter;
|