diff --git a/addons/medical/functions/fnc_treatment.sqf b/addons/medical/functions/fnc_treatment.sqf index 18f3406df26..b8498f756bc 100644 --- a/addons/medical/functions/fnc_treatment.sqf +++ b/addons/medical/functions/fnc_treatment.sqf @@ -156,7 +156,7 @@ if (_caller == _target) then { _callerAnim = [getText (_config >> "animationCallerSelf"), getText (_config >> "animationCallerSelfProne")] select (stance _caller == "PRONE"); }; -_caller setvariable [QGVAR(selectedWeaponOnTreatment), currentWeapon _caller]; +_caller setvariable [QGVAR(selectedWeaponOnTreatment), (weaponState _caller)]; // Cannot use secondairy weapon for animation if (currentWeapon _caller == secondaryWeapon _caller) then { diff --git a/addons/medical/functions/fnc_treatment_failure.sqf b/addons/medical/functions/fnc_treatment_failure.sqf index dd49729686f..8a5d7843010 100644 --- a/addons/medical/functions/fnc_treatment_failure.sqf +++ b/addons/medical/functions/fnc_treatment_failure.sqf @@ -44,9 +44,14 @@ if (vehicle _caller == _caller) then { }; _caller setvariable [QGVAR(treatmentPrevAnimCaller), nil]; -_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), ""]); -if (_weaponSelect != "") then { - _caller selectWeapon _weaponSelect; +_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), []]); +if ((_weaponSelect params [["_previousWeapon", ""]]) && {(_previousWeapon != "") && {_previousWeapon in (weapons _caller)}}) then { + for "_index" from 0 to 99 do { + _caller action ["SwitchWeapon", _caller, _caller, _index]; + //Just check weapon, muzzle and mode (ignore ammo in case they were reloading) + if (((weaponState _caller) select [0,3]) isEqualTo (_weaponSelect select [0,3])) exitWith {TRACE_1("Restoring", (weaponState _caller));}; + if ((weaponState _caller) isEqualTo ["","","","",0]) exitWith {ERROR("weaponState not found");}; + }; } else { _caller action ["SwitchWeapon", _caller, _caller, 99]; }; diff --git a/addons/medical/functions/fnc_treatment_success.sqf b/addons/medical/functions/fnc_treatment_success.sqf index 931a45847fa..ba6b667b33d 100644 --- a/addons/medical/functions/fnc_treatment_success.sqf +++ b/addons/medical/functions/fnc_treatment_success.sqf @@ -42,9 +42,14 @@ if (vehicle _caller == _caller) then { }; _caller setvariable [QGVAR(treatmentPrevAnimCaller), nil]; -_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), ""]); -if (_weaponSelect != "") then { - _caller selectWeapon _weaponSelect; +_weaponSelect = (_caller getvariable [QGVAR(selectedWeaponOnTreatment), []]); +if ((_weaponSelect params [["_previousWeapon", ""]]) && {(_previousWeapon != "") && {_previousWeapon in (weapons _caller)}}) then { + for "_index" from 0 to 99 do { + _caller action ["SwitchWeapon", _caller, _caller, _index]; + //Just check weapon, muzzle and mode (ignore ammo in case they were reloading) + if (((weaponState _caller) select [0,3]) isEqualTo (_weaponSelect select [0,3])) exitWith {TRACE_1("Restoring", (weaponState _caller));}; + if ((weaponState _caller) isEqualTo ["","","","",0]) exitWith {ERROR("weaponState not found");}; + }; } else { _caller action ["SwitchWeapon", _caller, _caller, 99]; };