diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 51aa83d192..587665943f 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -37,6 +37,8 @@ PREP(teatmentIV); PREP(treatmentIVLocal); PREP(treatmentTourniquet); PREP(treatmentTourniquetLocal); +PREP(addToLog); +PREP(addToTriageCard); GVAR(injuredUnitCollection) = []; call FUNC(parseConfigForInjuries); diff --git a/addons/medical/functions/fnc_addToLog.sqf b/addons/medical/functions/fnc_addToLog.sqf new file mode 100644 index 0000000000..d36be6d0aa --- /dev/null +++ b/addons/medical/functions/fnc_addToLog.sqf @@ -0,0 +1,44 @@ +/** + * fn_addActivityToLog.sqf + * @Descr: adds an item to the activity log + * @Author: Glowbal + * + * @Arguments: [unit OBJECT, type STRING, message STRING] + * @Return: + * @PublicAPI: false + */ + +#include "script_component.hpp" + +private ["_unit", "_type", "_message", "_arguments", "_lastNumber", "_moment", "_logVarName", "_log","_newLog"]; +_unit = _this select 0; +_type = _this select 1; +_message = _this select 2; +_arguments = _this select 3; + +if (!local _unit) exitwith { + [_this, QUOTE(FUNC(addToLog)), _unit] call EFUNC(common,execRemoteFnc); +}; + +_lastNumber = date select 4; +_moment = format["%1:%2",date select 3, _lastNumber]; +if (_lastNumber < 10) then { + _moment = format["%1:0%2",date select 3, _lastNumber]; +}; +_logVarName = format[QGVAR(logFile_%1), _type]; + +_log = _unit getvariable [_logVarName, []]; +if (count _log >= 8) then { + _newLog = []; + { + // ensure the first element will not be added + if (_foreachIndex > 0) then { + _newLog pushback _x; + }; + }foreach _log; + _log = _newLog; +}; +_log pushback [_message,_moment,_type, _arguments]; + +_unit setvariable [_logVarName, _log, true]; +["medical_onLogEntryAdded", [_unit, _type, _message, _arguments]] call ace_common_fnc_localEvent; diff --git a/addons/medical/functions/fnc_addToTriageCard.sqf b/addons/medical/functions/fnc_addToTriageCard.sqf new file mode 100644 index 0000000000..cc9d4c7f5e --- /dev/null +++ b/addons/medical/functions/fnc_addToTriageCard.sqf @@ -0,0 +1,41 @@ +/** + * fn_addToTriageList.sqf + * @Descr: N/A + * @Author: Glowbal + * + * @Arguments: [] + * @Return: + * @PublicAPI: false + */ + +#include "script_component.hpp" + +private ["_unit","_caller","_newItem","_log", "_inList","_amount"]; +_unit = _this select 0; +_newItem = _this select 1; + +if (!local _unit) exitwith { + [_this, QUOTE(FUNC(addToTriageList)), _unit] call EFUNC(common,execRemoteFnc); +}; + +_log = _unit getvariable [QGVAR(triageCard), []]; +_inList = false; +_amount = 1; +{ + if ((_x select 0) == _newItem) exitwith { + private "_info"; + _info = _log select _foreachIndex; + _info set [1,(_info select 1) + 1]; + _info set [2, time]; + _log set [_foreachIndex, _info]; + + _amount = (_info select 1); + _inList = true; + }; +}foreach _log; + +if (!_inList) then { + _log pushback [_newItem, 1, time]; +}; +_unit setvariable [QGVAR(triageCard), _log, true]; +["Medical_onItemAddedToTriageCard", [_unit, _newItem, _amount]] call ace_common_fnc_localEvent; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf index d3f0a41445..226159c620 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf @@ -28,6 +28,13 @@ if (count _items == 0) exitwith {}; if ([_caller, _target, _items] call FUNC(useEquipment)) then { [[_target, _className], QUOTE(FUNC(treatmentBandageLocal)), _target] call EFUNC(common,execRemoteFnc); + { + if (_x != "") then { + [_target, _x] call FUNC(addToTriageCard); + }; + }foreach _items; + + [_target, "activity", "STR_ACE_HAS_BANDAGED_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; true; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf index ccb195e32c..78a2fe8341 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf @@ -28,6 +28,13 @@ if (count _items == 0) exitwith {}; if ([_caller, _target, _items] call FUNC(useEquipment)) then { [[_target, _className], QUOTE(FUNC(treatmentMedicationLocal)), _target] call EFUNC(common,execRemoteFnc); + { + if (_x != "") then { + [_target, _x] call FUNC(addToTriageCard); + }; + }foreach _items; + + [_target, "activity", "STR_ACE_HAS_MEDICATION_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; true; diff --git a/addons/medical/functions/fnc_treatmentIV.sqf b/addons/medical/functions/fnc_treatmentIV.sqf index a6b41e4c50..8953783386 100644 --- a/addons/medical/functions/fnc_treatmentIV.sqf +++ b/addons/medical/functions/fnc_treatmentIV.sqf @@ -29,4 +29,6 @@ if (count _items == 0) exitwith {}; if ([_caller, _target, _items] call FUNC(useEquipment)) then { _removeItem = _items select 0; [[_target, _removeItem], QUOTE(FUNC(treatmentIVLocal)), _target] call EFUNC(common,execRemoteFnc); + [_target, _removeItem] call FUNC(addToTriageCard); + [_target, "activity", "STR_ACE_HAS_GIVEN_IV_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; diff --git a/addons/medical/functions/fnc_treatmentTourniquet.sqf b/addons/medical/functions/fnc_treatmentTourniquet.sqf index 2e16d73922..735ce9f589 100644 --- a/addons/medical/functions/fnc_treatmentTourniquet.sqf +++ b/addons/medical/functions/fnc_treatmentTourniquet.sqf @@ -41,6 +41,8 @@ if ((_tourniquets select _part) > 0) exitwith { if ([_caller, _target, _items] call FUNC(useEquipment)) then { _removeItem = _items select 0; [[_target, _removeItem], QUOTE(FUNC(treatmentTourniquetLocal)), _target] call EFUNC(common,execRemoteFnc); + [_target, _removeItem] call FUNC(addToTriageCard); + [_target, "activity", "STR_ACE_HAS_APPLIED_TOURNIQUET_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; true;