diff --git a/addons/gui/CfgFunctions.hpp b/addons/gui/CfgFunctions.hpp index a9e6c4cd1..751d0352a 100644 --- a/addons/gui/CfgFunctions.hpp +++ b/addons/gui/CfgFunctions.hpp @@ -2,9 +2,6 @@ class CfgFunctions { class overwrite_medical_gui { tag = "ace_medical_gui"; class ace_medical_gui { - class menuPFH { - file = QPATHTOF(functions\fnc_menuPFH.sqf); - }; class onMenuClose { file = QPATHTOF(functions\fnc_onMenuClose.sqf); }; diff --git a/addons/gui/functions/fnc_menuPFH.sqf b/addons/gui/functions/fnc_menuPFH.sqf deleted file mode 100644 index 947dddd57..000000000 --- a/addons/gui/functions/fnc_menuPFH.sqf +++ /dev/null @@ -1,59 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: mharis001 - * Handles updating the Medical Menu UI for the current target. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Example: - * [] call ace_medical_gui_fnc_menuPFH - * - * Public: No - * - * THIS IS MODYFIED TO ALLOW THE "CHECK UNIT MEDICAL MENU" ZEUS MODULE TO WORK - */ - -// Check if menu should stay open for target -if(isNull findDisplay 312) then { - if !([ACE_player, ACEGVAR(medical_gui,target), ["isNotInside", "isNotSwimming"]] call ACEFUNC(common,canInteractWith) && {[ACE_player, ACEGVAR(medical_gui,target)] call ACEFUNC(medical_gui,canOpenMenu)}) then { - closeDialog 0; - // Show hint if distance condition failed - if ((ACE_player distance ACEGVAR(medical_gui,target) > ACEGVAR(medical_gui,maxDistance)) && {vehicle ACE_player != vehicle ACEGVAR(medical_gui,target)}) then { - [[ACELLSTRING(medical,DistanceToFar), ACEGVAR(medical_gui,target) call ACEFUNC(common,getName)], 2] call ACEFUNC(common,displayTextStructured); - }; - }; -}; - -// Get the Medical Menu display -private _display = uiNamespace getVariable [QACEGVAR(medical_gui,menuDisplay), displayNull]; -if (isNull _display) exitWith {}; - -// Update treatment category buttons -[_display] call ACEFUNC(medical_gui,updateCategories); - -// Update treatment actions for current category -[_display] call ACEFUNC(medical_gui,updateActions); - -// Update injury list -private _ctrlInjuries = _display displayCtrl IDC_INJURIES; -[_ctrlInjuries, ACEGVAR(medical_gui,target), ACEGVAR(medical_gui,selectedBodyPart)] call ACEFUNC(medical_gui,updateInjuryList); - -// Update body image -private _ctrlBodyImage = _display displayCtrl IDC_BODY_GROUP; -[_ctrlBodyImage, ACEGVAR(medical_gui,target), ACEGVAR(medical_gui,selectedBodyPart)] call ACEFUNC(medical_gui,updateBodyImage); - -// Update activity and quick view logs -private _ctrlActivityLog = _display displayCtrl IDC_ACTIVITY; -private _activityLog = ACEGVAR(medical_gui,target) getVariable [MED_LOG_VARNAME("activity"), []]; -[_ctrlActivityLog, _activityLog] call ACEFUNC(medical_gui,updateLogList); - -private _ctrlQuickView = _display displayCtrl IDC_QUICKVIEW; -private _quickView = ACEGVAR(medical_gui,target) getVariable [MED_LOG_VARNAME("quick_view"), []]; -[_ctrlQuickView, _quickView] call ACEFUNC(medical_gui,updateLogList); - -// Update triage status -[_display, ACEGVAR(medical_gui,target)] call ACEFUNC(medical_gui,updateTriageStatus); diff --git a/addons/misc/functions/fnc_treatment.sqf b/addons/misc/functions/fnc_treatment.sqf index 749b2e90a..dd3a927cb 100644 --- a/addons/misc/functions/fnc_treatment.sqf +++ b/addons/misc/functions/fnc_treatment.sqf @@ -20,7 +20,7 @@ * Public: No */ -params ["_medic", "_patient", "_bodyPart", "_classname", "_bandageEffectiveness", ["_extraArgs",[]]]; +params ["_medic", "_patient", "_bodyPart", "_classname", "_extraArgs"]; // Delay by a frame if cursor menu is open to prevent progress bar failing if (uiNamespace getVariable [QACEGVAR(interact_menu,cursorMenuOpened), false]) exitWith { @@ -54,16 +54,6 @@ private _userAndItem = if (GET_NUMBER_ENTRY(_config >> "consumeItem") == 1) then [objNull, ""]; // Treatment does not require items to be consumed }; -_userAndItem params ["_itemUser", "_usedItem", ["_magazineCount", -1]]; - -if (((_classname call BIS_fnc_itemType) select 0) isEqualTo "Magazine") then { - if (count _extraArgs > 0) then { - _extraArgs pushBack _magazineCount; - } else { - _extraArgs =[-1,_magazineCount]; - }; -}; - // Patient Animation Added from Old Ace if (alive _patient) then { private _patientAnim = getText (_config >> "animationPatient"); @@ -83,97 +73,107 @@ if (alive _patient) then { }; //Old Ace Ending here -// Get treatment animation for the medic -private _medicAnim = if (_medic isEqualTo _patient) then { - getText (_config >> ["animationMedicSelf", "animationMedicSelfProne"] select (stance _medic == "PRONE")); -} else { - getText (_config >> ["animationMedic", "animationMedicProne"] select (stance _medic == "PRONE")); -}; +_userAndItem params ["_itemUser", "_usedItem", "_createLitter"]; -_medic setVariable [QACEGVAR(medical_treatment,selectedWeaponOnTreatment), weaponState _medic]; +private _isInZeus = !isNull findDisplay 312; -// Adjust animation based on the current weapon of the medic -private _wpn = ["non", "rfl", "lnr", "pst"] param [["", primaryWeapon _medic, secondaryWeapon _medic, handgunWeapon _medic] find currentWeapon _medic, "non"]; -_medicAnim = [_medicAnim, "[wpn]", _wpn] call CBA_fnc_replace; +if (_medic isNotEqualTo player || {!_isInZeus}) then { + // Get treatment animation for the medic + private _medicAnim = if (_medic isEqualTo _patient) then { + getText (_config >> ["animationMedicSelf", "animationMedicSelfProne"] select (stance _medic == "PRONE")); + } else { + getText (_config >> ["animationMedic", "animationMedicProne"] select (stance _medic == "PRONE")); + }; -// This animation is missing, use alternative -if (_medicAnim == "AinvPknlMstpSlayWlnrDnon_medic") then { - _medicAnim = "AinvPknlMstpSlayWlnrDnon_medicOther"; -}; + _medic setVariable [QACEGVAR(medical_treatment,selectedWeaponOnTreatment), weaponState _medic]; -// Determine the animation length -private _animDuration = ACEGVAR(medical_treatment,animDurations) getVariable _medicAnim; -if (isNil "_animDuration") then { - WARNING_2("animation [%1] for [%2] has no duration defined",_medicAnim,_classname); - _animDuration = 10; -}; + // Adjust animation based on the current weapon of the medic + private _wpn = ["non", "rfl", "lnr", "pst"] param [["", primaryWeapon _medic, secondaryWeapon _medic, handgunWeapon _medic] find currentWeapon _medic, "non"]; + _medicAnim = [_medicAnim, "[wpn]", _wpn] call CBA_fnc_replace; -// These animations have transitions that take a bit longer... -if (weaponLowered _medic) then { - _animDuration = _animDuration + 0.5; + // This animation is missing, use alternative + if (_medicAnim == "AinvPknlMstpSlayWlnrDnon_medic") then { + _medicAnim = "AinvPknlMstpSlayWlnrDnon_medicOther"; + }; - // Fix problems with lowered weapon transitions by raising the weapon first - if (currentWeapon _medic != "" && {_medicAnim != ""}) then { - _medic action ["WeaponInHand", _medic]; + // Determine the animation length + private _animDuration = ACEGVAR(medical_treatment,animDurations) getVariable _medicAnim; + if (isNil "_animDuration") then { + WARNING_2("animation [%1] for [%2] has no duration defined",_medicAnim,_classname); + _animDuration = 10; }; -}; -if (binocular _medic != "" && {binocular _medic == currentWeapon _medic}) then { - _animDuration = _animDuration + 1; -}; + // These animations have transitions that take a bit longer... + if (weaponLowered _medic) then { + _animDuration = _animDuration + 0.5; -// Play treatment animation for medic and determine the ending animation -if (isNull objectParent _medic && {_medicAnim != ""}) then { - // Speed up animation based on treatment time (but cap max to prevent odd animiations/cam shake) - private _animRatio = _animDuration / _treatmentTime; - TRACE_3("setAnimSpeedCoef",_animRatio,_animDuration,_treatmentTime); + // Fix problems with lowered weapon transitions by raising the weapon first + if (currentWeapon _medic != "" && {_medicAnim != ""}) then { + _medic action ["WeaponInHand", _medic]; + }; + }; - // Don't slow down animation too much to prevent it looking funny. - if (_animRatio < ANIMATION_SPEED_MIN_COEFFICIENT) then { - _animRatio = ANIMATION_SPEED_MIN_COEFFICIENT; + if (binocular _medic != "" && {binocular _medic == currentWeapon _medic}) then { + _animDuration = _animDuration + 1; }; - // Skip animation enitrely if progress bar too quick. - if (_animRatio > ANIMATION_SPEED_MAX_COEFFICIENT) exitWith {}; + // Play treatment animation for medic and determine the ending animation + if (isNull objectParent _medic && {_medicAnim != ""}) then { + // Speed up animation based on treatment time (but cap max to prevent odd animiations/cam shake) + private _animRatio = _animDuration / _treatmentTime; + TRACE_3("setAnimSpeedCoef",_animRatio,_animDuration,_treatmentTime); - [QACEGVAR(common,setAnimSpeedCoef), [_medic, _animRatio]] call CBA_fnc_globalEvent; + // Don't slow down animation too much to prevent it looking funny. + if (_animRatio < ANIMATION_SPEED_MIN_COEFFICIENT) then { + _animRatio = ANIMATION_SPEED_MIN_COEFFICIENT; + }; - // Play animation - private _endInAnim = "AmovP[pos]MstpS[stn]W[wpn]Dnon"; + // Skip animation enitrely if progress bar too quick. + if (_animRatio > ANIMATION_SPEED_MAX_COEFFICIENT) exitWith {}; - private _pos = ["knl", "pne"] select (stance _medic == "PRONE"); - private _stn = "non"; + [QACEGVAR(common,setAnimSpeedCoef), [_medic, _animRatio]] call CBA_fnc_globalEvent; - if (_wpn != "non") then { - _stn = ["ras", "low"] select (weaponLowered _medic); - }; + // Play animation + private _endInAnim = "AmovP[pos]MstpS[stn]W[wpn]Dnon"; - _endInAnim = [_endInAnim, "[pos]", _pos] call CBA_fnc_replace; - _endInAnim = [_endInAnim, "[stn]", _stn] call CBA_fnc_replace; - _endInAnim = [_endInAnim, "[wpn]", _wpn] call CBA_fnc_replace; + private _pos = ["knl", "pne"] select (stance _medic == "PRONE"); + private _stn = "non"; - [_medic, _medicAnim] call ACEFUNC(common,doAnimation); - [_medic, _endInAnim] call ACEFUNC(common,doAnimation); - _medic setVariable [QACEGVAR(medical_treatment,endInAnim), _endInAnim]; + if (_wpn != "non") then { + _stn = ["ras", "low"] select (weaponLowered _medic); + }; + + _endInAnim = [_endInAnim, "[pos]", _pos] call CBA_fnc_replace; + _endInAnim = [_endInAnim, "[stn]", _stn] call CBA_fnc_replace; + _endInAnim = [_endInAnim, "[wpn]", _wpn] call CBA_fnc_replace; + + [_medic, _medicAnim] call ACEFUNC(common,doAnimation); + [_medic, _endInAnim] call ACEFUNC(common,doAnimation); + _medic setVariable [QACEGVAR(medical_treatment,endInAnim), _endInAnim]; + + if (!isNil QACEGVAR(advanced_fatigue,setAnimExclusions)) then { + ACEGVAR(advanced_fatigue,setAnimExclusions) pushBack "ace_medical_treatment"; + }; + }; - if (!isNil QACEGVAR(advanced_fatigue,setAnimExclusions)) then { - ACEGVAR(advanced_fatigue,setAnimExclusions) pushBack "ace_medical_treatment"; + // Play a random treatment sound globally if defined + // Don't attempt to play if sounds array is empty + if (isArray (_config >> "sounds") && count getArray (_config >> "sounds") != 0) then { + selectRandom getArray (_config >> "sounds") params ["_file", ["_volume", 1], ["_pitch", 1], ["_distance", 10]]; + GVAR(TreatmentSound) = playSound3D [_file, objNull, false, getPosASL _medic, _volume, _pitch, _distance]; + + [{ + !dialog; + }, { + stopSound GVAR(TreatmentSound); + }, [], _treatmentTime, { + GVAR(TreatmentSound) = nil; + }] call CBA_fnc_waitUntilAndExecute; }; }; -// Play a random treatment sound globally if defined -// Don't attempt to play if sounds array is empty -if (isArray (_config >> "sounds") && count getArray (_config >> "sounds") != 0) then { - selectRandom getArray (_config >> "sounds") params ["_file", ["_volume", 1], ["_pitch", 1], ["_distance", 10]]; - GVAR(TreatmentSound) = playSound3D [_file, objNull, false, getPosASL _medic, _volume, _pitch, _distance]; - - [{ - !dialog; - }, { - stopSound GVAR(TreatmentSound); - }, [], _treatmentTime, { - GVAR(TreatmentSound) = nil; - }] call CBA_fnc_waitUntilAndExecute; +if (_isInZeus) then { + _treatmentTime = _treatmentTime * ACEGVAR(medical_treatment,treatmentTimeCoeffZeus); }; GET_FUNCTION(_callbackStart,_config >> "callbackStart"); @@ -183,18 +183,18 @@ if (_callbackProgress isEqualTo {}) then { _callbackProgress = {true}; }; -[_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _bandageEffectiveness, _extraArgs] call _callbackStart; +[_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _createLitter, _extraArgs] call _callbackStart; -["ace_treatmentStarted", [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _bandageEffectiveness, _extraArgs]] call CBA_fnc_localEvent; +["ace_treatmentStarted", [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _createLitter, _extraArgs]] call CBA_fnc_localEvent; [ _treatmentTime, - [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _bandageEffectiveness, _extraArgs], + [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _createLitter, _extraArgs], ACEFUNC(medical_treatment,treatmentSuccess), ACEFUNC(medical_treatment,treatmentFailure), getText (_config >> "displayNameProgress"), _callbackProgress, - ["isNotInside", "isNotSwimming"] + ["isNotInside", "isNotSwimming", "isNotInZeus"] ] call ACEFUNC(common,progressBar); true diff --git a/addons/misc/functions/fnc_treatmentSuccess.sqf b/addons/misc/functions/fnc_treatmentSuccess.sqf index 1894048de..48bb87b61 100644 --- a/addons/misc/functions/fnc_treatmentSuccess.sqf +++ b/addons/misc/functions/fnc_treatmentSuccess.sqf @@ -12,7 +12,9 @@ * 3: Treatment * 4: Item User * 5: Used Item - * 6: Extra Arguments + * 6: Create Litter + * 7: Bandage Effectiveness + * 8: Extra Arguments * * Return Value: * None @@ -21,7 +23,7 @@ */ params ["_args"]; -_args params ["_medic", "_patient", "_bodyPart", "_classname", "_itemUser", "_usedItem", "_bandageEffectiveness", ["_extraArgs",[]]]; +_args params ["_medic", "_patient", "_bodyPart", "_classname", "_itemUser", "_usedItem", "_createLitter", "_extraArgs"]; // Switch medic to end animation immediately private _endInAnim = _medic getVariable QACEGVAR(medical_treatment,endInAnim); @@ -64,7 +66,7 @@ GET_FUNCTION(_callbackSuccess,configFile >> QACEGVAR(medical_treatment,actions) _args call _callbackSuccess; // Call litter creation handler -_args call ACEFUNC(medical_treatment,createLitter); +if (_createLitter) then { _args call ACEFUNC(medical_treatment,createLitter); }; // Emit local event for medical API -["ace_treatmentSucceded", [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _bandageEffectiveness, _extraArgs]] call CBA_fnc_localEvent; +["ace_treatmentSucceded", [_medic, _patient, _bodyPart, _classname, _itemUser, _usedItem, _createLitter, _extraArgs]] call CBA_fnc_localEvent; diff --git a/addons/misc/functions/fnc_useItem.sqf b/addons/misc/functions/fnc_useItem.sqf index 12e1add9b..05dd798e3 100644 --- a/addons/misc/functions/fnc_useItem.sqf +++ b/addons/misc/functions/fnc_useItem.sqf @@ -20,6 +20,10 @@ params ["_medic", "_patient", "_items"]; +if (_medic isEqualTo player && {!isNull findDisplay 312}) exitWith { + [_medic, _items select 0] +}; + scopeName "Main"; private _sharedUseOrder = [[_patient, _medic], [_medic, _patient], [_medic]] select ACEGVAR(medical_treatment,allowSharedEquipment);