diff --git a/addons/ophthalmology/ACE_Medical_Treatment_Actions.hpp b/addons/ophthalmology/ACE_Medical_Treatment_Actions.hpp index 75dc19155..be2f5876c 100644 --- a/addons/ophthalmology/ACE_Medical_Treatment_Actions.hpp +++ b/addons/ophthalmology/ACE_Medical_Treatment_Actions.hpp @@ -54,4 +54,13 @@ class ACE_Medical_Treatment_Actions { condition = QFUNC(eyeShieldCondition); callbackSuccess = QFUNC(treatmentAdvanced_eyeShield); }; + class RemoveEyeShield: EyeWash { + displayName = CSTRING(eyeshieldRemove_display); + displayNameProgress = CSTRING(eyeshieldRemove_action); + medicRequired = 0; + treatmentTime = QGVAR(eyeshield_treatment_time); + items[] = {}; + condition = QFUNC(eyeShieldRemoveCondition); + callbackSuccess = QFUNC(treatmentAdvanced_eyeShieldRemove); + }; }; diff --git a/addons/ophthalmology/XEH_PREP.hpp b/addons/ophthalmology/XEH_PREP.hpp index 797a41393..a77983b4e 100644 --- a/addons/ophthalmology/XEH_PREP.hpp +++ b/addons/ophthalmology/XEH_PREP.hpp @@ -1,9 +1,14 @@ PREP(eyeShieldCondition); +PREP(eyeShieldRemoveCondition); PREP(fullHealLocal); PREP(gui_updateInjuryListPart); PREP(handleDustInjury); PREP(handleExplosion); PREP(handleRespawn); PREP(init); +PREP(severeEyeInjuryPFH); PREP(treatmentAdvanced_eyeShield); +PREP(treatmentAdvanced_eyeShieldLocal); +PREP(treatmentAdvanced_eyeShieldRemove); +PREP(treatmentAdvanced_eyeShieldRemoveLocal); PREP(treatmentAdvanced_eyewash); diff --git a/addons/ophthalmology/XEH_postInit.sqf b/addons/ophthalmology/XEH_postInit.sqf index 3c6291c17..e4493f11f 100644 --- a/addons/ophthalmology/XEH_postInit.sqf +++ b/addons/ophthalmology/XEH_postInit.sqf @@ -13,6 +13,9 @@ if (!hasInterface) exitWith {}; }] call CBA_fnc_addEventHandler; +[QGVAR(eyeShield), LINKFUNC(treatmentAdvanced_eyeShieldLocal)] call CBA_fnc_addEventHandler; +[QGVAR(eyeShieldRemove), LINKFUNC(treatmentAdvanced_eyeShieldRemoveLocal)] call CBA_fnc_addEventHandler; + [QACEGVAR(medical_treatment,fullHealLocalMod), LINKFUNC(fullHealLocal)] call CBA_fnc_addEventHandler; [QACEGVAR(medical_gui,updateInjuryListPart), LINKFUNC(gui_updateInjuryListPart)] call CBA_fnc_addEventHandler; [QEGVAR(misc,handleRespawn), LINKFUNC(handleRespawn)] call CBA_fnc_addEventHandler; diff --git a/addons/ophthalmology/functions/fnc_eyeShieldCondition.sqf b/addons/ophthalmology/functions/fnc_eyeShieldCondition.sqf index 7df3d2dac..8d2121909 100644 --- a/addons/ophthalmology/functions/fnc_eyeShieldCondition.sqf +++ b/addons/ophthalmology/functions/fnc_eyeShieldCondition.sqf @@ -17,7 +17,7 @@ params ["_medic", "_patient"]; private _eyeInjuries = _patient getVariable [QGVAR(eyeInjuries), [1, 1]]; private _eyeInjurySevere = _patient getVariable [QGVAR(eyeInjurySevere), false]; -if (_eyeInjurySevere && (({_x == 0} count _eyeInjuries) == 1)) exitWith { +if (_eyeInjurySevere && (({_x != 1} count _eyeInjuries) == 1)) exitWith { true }; diff --git a/addons/ophthalmology/functions/fnc_eyeShieldRemoveCondition.sqf b/addons/ophthalmology/functions/fnc_eyeShieldRemoveCondition.sqf new file mode 100644 index 000000000..d67302f71 --- /dev/null +++ b/addons/ophthalmology/functions/fnc_eyeShieldRemoveCondition.sqf @@ -0,0 +1,21 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Sets condition for the Eye Shield + * + * Return Value: + * Boolean + * + * Example: + * [bob, patient] call kat_ophthalmology_fnc_eyeShieldCondition + * + * Public: No + */ + +params ["_medic", "_patient"]; + +if ((hmd _patient == "kat_eyecovers_left") || (hmd _patient == "kat_eyecovers_right")) exitWith { + true +}; + +false diff --git a/addons/ophthalmology/functions/fnc_severeEyeInjuryPFH.sqf b/addons/ophthalmology/functions/fnc_severeEyeInjuryPFH.sqf new file mode 100644 index 000000000..5067f4829 --- /dev/null +++ b/addons/ophthalmology/functions/fnc_severeEyeInjuryPFH.sqf @@ -0,0 +1,58 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Handles severe eye damage + * + * Return Value: + * None + * + * Example: + * [patient] call kat_ophthalmology_fnc_treatmentAdvanced_severeEyeInjuryPFH + * + * Public: No + */ + +params ["_patient"]; + +// Approximately 8 minutes to fully re-heal a damaged eye using the eyeshield +[{ + params ["_args", "_pfhID"]; + _args params ["_patient", "_activeEye", "_shieldItem"]; + + private _active = false; + private _activeEye = 0; + + #define IDC_LEFT_EYE_CONTROL 17103 + #define IDC_RIGHT_EYE_CONTROL 17102 + + if ((hmd _patient) == "kat_eyecovers_left") then { + _active = true; + private _display = uiNamespace getVariable ["KAT_EyeShield", displayNull]; + private _activeEye = _display displayCtrl IDC_LEFT_EYE_CONTROL; + + _activeEye ctrlShow true; + _activeEye ctrlCommit 0; + }; + + if ((hmd _patient) == "kat_eyecovers_right") then { + _active = true; + _activeEye = 1; + private _display = uiNamespace getVariable ["KAT_EyeShield", displayNull]; + private _activeEye = _display displayCtrl IDC_RIGHT_EYE_CONTROL; + + _activeEye ctrlShow true; + _activeEye ctrlCommit 0; + }; + + if (_active) then { + private _eyeInjury = _patient getVariable [QGVAR(eyeInjuries), [1, 1]]; + _eyeInjury set [_activeEye, ((_eyeInjury select _activeEye) + 0.002)]; + _patient setVariable [QGVAR(eyeInjuries), _eyeInjury, true]; + } else { + "KAT_EyeShield" cutText ["","PLAIN",0,true]; + }; +}, 1, [ + _patient, + _activeEye, + _shieldItem +]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShield.sqf b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShield.sqf index 663203f07..504a37f10 100644 --- a/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShield.sqf +++ b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShield.sqf @@ -11,57 +11,7 @@ * * Public: No */ - -params ["_medic", "_patient"]; - -private _eyeInjuries = _patient getVariable [QGVAR(eyeInjuries), [1, 1]]; - -#define IDC_LEFT_EYE_CONTROL 17103 -#define IDC_RIGHT_EYE_CONTROL 17102 - -"KAT_EyeShield" cutRsc ["KAT_EyeShield", "PLAIN", 0, true]; - - -private _fnc_applyEyeCover = { - params ["_patient", "_shieldItem", "_eyeDisplay"]; - // If patient has NVGs on, move them to the patient's inventory - if (hmd _patient != "") then { - _patient addItem (hmd _patient); - }; - - private _display = uiNamespace getVariable ["KAT_EyeShield", displayNull]; - private _activeEye = _display displayCtrl _eyeDisplay; - - _patient linkItem _shieldItem; - - _activeEye ctrlShow true; - _activeEye ctrlCommit 0; - - // Approximately 8 minutes to fully re-heal a damaged eye using the eyeshield - [{ - params ["_args", "_pfhID"]; - _args params ["_patient", "_activeEye", "_shieldItem"]; - - if ((hmd _patient) != _shieldItem) exitWith { - _pfhID call CBA_fnc_removePerFrameHandler; - "KAT_EyeShield" cutText ["","PLAIN",0,true]; - }; - - private _eyeInjury = _patient getVariable [QGVAR(eyeInjuries), [1, 1]]; - _patient setVariable [QGVAR(eyeInjuries), [(((_eyeInjury select 0) + 0.002) min 1), (_eyeInjury select 1)], true]; - }, 1, [ - _patient, - _activeEye, - _shieldItem - ]] call CBA_fnc_addPerFrameHandler; -}; - -if ((_eyeInjuries select 0) == 0) then { - [_patient, "kat_eyecovers_left", IDC_LEFT_EYE_CONTROL] call _fnc_applyEyeCover; -} else { - [_patient, "kat_eyecovers_right", IDC_RIGHT_EYE_CONTROL] call _fnc_applyEyeCover; -}; +params ["_medic", "_patient"]; -[_patient, LLSTRING(eyeshield_item)] call ACEFUNC(medical_treatment,addToTriageCard); -[_patient, "activity", ACELSTRING(medical_treatment,Activity_usedItem), [[_medic] call ACEFUNC(common,getName), LLSTRING(eyeshield_item)]] call ACEFUNC(medical_treatment,addToLog); +[QGVAR(eyeShield), [_medic, _patient], _patient] call CBA_fnc_targetEvent; diff --git a/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldLocal.sqf b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldLocal.sqf new file mode 100644 index 000000000..24f90eb81 --- /dev/null +++ b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldLocal.sqf @@ -0,0 +1,67 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Handles the placement of the eye shield + * + * Return Value: + * None + * + * Example: + * [bob, patient] call kat_ophthalmology_fnc_treatmentAdvanced_eyeShieldLocal + * + * Public: No + */ + +params ["_medic", "_patient"]; + +private _eyeInjuries = _patient getVariable [QGVAR(eyeInjuries), [1, 1]]; + +#define IDC_LEFT_EYE_CONTROL 17103 +#define IDC_RIGHT_EYE_CONTROL 17102 + +"KAT_EyeShield" cutRsc ["KAT_EyeShield", "PLAIN", 0, true]; + + +private _fnc_applyEyeCover = { + params ["_patient", "_shieldItem", "_eyeDisplay"]; + + // If patient has NVGs on, move them to the patient's inventory + if (hmd _patient != "") then { + _patient addItem (hmd _patient); + }; + + private _display = uiNamespace getVariable ["KAT_EyeShield", displayNull]; + private _activeEye = _display displayCtrl _eyeDisplay; + + _patient linkItem _shieldItem; + + _activeEye ctrlShow true; + _activeEye ctrlCommit 0; + + // Approximately 8 minutes to fully re-heal a damaged eye using the eyeshield + [{ + params ["_args", "_pfhID"]; + _args params ["_patient", "_activeEye", "_shieldItem"]; + + if ((hmd _patient) != _shieldItem) exitWith { + _pfhID call CBA_fnc_removePerFrameHandler; + "KAT_EyeShield" cutText ["","PLAIN",0,true]; + }; + + private _eyeInjury = _patient getVariable [QGVAR(eyeInjuries), [1, 1]]; + _patient setVariable [QGVAR(eyeInjuries), [(((_eyeInjury select 0) + 0.002) min 1), (_eyeInjury select 1)], true]; + }, 1, [ + _patient, + _activeEye, + _shieldItem + ]] call CBA_fnc_addPerFrameHandler; +}; + +if ((_eyeInjuries select 0) == 0) then { + [_patient, "kat_eyecovers_left", IDC_LEFT_EYE_CONTROL] call _fnc_applyEyeCover; +} else { + [_patient, "kat_eyecovers_right", IDC_RIGHT_EYE_CONTROL] call _fnc_applyEyeCover; +}; + +[_patient, LLSTRING(eyeshield_item)] call ACEFUNC(medical_treatment,addToTriageCard); +[_patient, "activity", ACELSTRING(medical_treatment,Activity_usedItem), [[_medic] call ACEFUNC(common,getName), LLSTRING(eyeshield_item)]] call ACEFUNC(medical_treatment,addToLog); diff --git a/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldRemove.sqf b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldRemove.sqf new file mode 100644 index 000000000..e03ea022c --- /dev/null +++ b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldRemove.sqf @@ -0,0 +1,17 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Handles the placement of the eye shield + * + * Return Value: + * None + * + * Example: + * [bob, patient] call kat_ophthalmology_fnc_treatmentAdvanced_eyeShield + * + * Public: No + */ + +params ["_medic", "_patient"]; + +[QGVAR(eyeShieldRemove), [_medic, _patient], _patient] call CBA_fnc_targetEvent; diff --git a/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldRemoveLocal.sqf b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldRemoveLocal.sqf new file mode 100644 index 000000000..ea489f361 --- /dev/null +++ b/addons/ophthalmology/functions/fnc_treatmentAdvanced_eyeShieldRemoveLocal.sqf @@ -0,0 +1,17 @@ +#include "..\script_component.hpp" +/* + * Author: Mazinski + * Removes the eye shield from a patient + * + * Return Value: + * None + * + * Example: + * [bob, patient] call kat_ophthalmology_fnc_treatmentAdvanced_eyeShieldRemoveLocal + * + * Public: No + */ + +params ["_medic", "_patient"]; + +_patient unassignItem (hmd _patient);