Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeus - Add medical menu module #9367

Merged
merged 14 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions addons/medical_gui/functions/fnc_canOpenMenu.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "..\script_component.hpp"
/*
* Author: Glowbal, mharis001
* Author: Glowbal, mharis001, johnb43
* Checks if the player can open the Medical Menu for the target.
*
* Arguments:
Expand All @@ -18,8 +18,14 @@

params ["_player", "_target"];

alive _player
&& {!IS_UNCONSCIOUS(_player)}
&& {!isNull _target}
&& {_player distance _target < GVAR(maxDistance) || {vehicle _player == vehicle _target}}
&& {GVAR(enableMedicalMenu) == 1 || {GVAR(enableMedicalMenu) == 2 && {vehicle _player != _player || {vehicle _target != _target}}}}
// If in Zeus
if (!isNull findDisplay 312) exitWith {
!isNull _target &&
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
{missionNamespace getVariable [QGVAR(enableZeusModule), true]} &&
{GVAR(enableMedicalMenu) > 0}
};

_player call EFUNC(common,isAwake) &&
{!isNull _target} &&
{_player distance _target < GVAR(maxDistance) || {vehicle _player == vehicle _target}} &&
{GVAR(enableMedicalMenu) == 1 || {GVAR(enableMedicalMenu) == 2 && {vehicle _player != _player || {vehicle _target != _target}}}}
3 changes: 3 additions & 0 deletions addons/medical_gui/functions/fnc_handleToggle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* Public: No
*/

// If in Zeus, ignore
if (!isNull findDisplay 312) exitWith {};

// Find new target to switch to
private _target = if (
GVAR(target) == ACE_player
Expand Down
5 changes: 4 additions & 1 deletion addons/medical_gui/functions/fnc_menuPFH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
*/

// Check if menu should stay open for target
if !([ACE_player, GVAR(target), ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith) && {[ACE_player, GVAR(target)] call FUNC(canOpenMenu)}) then {
if !(
([ACE_player, GVAR(target), ["isNotInside", "isNotSwimming"]] call EFUNC(common,canInteractWith) || {!isNull findDisplay 312}) && // Allow player to look at himself when unconsious and in Zeus
{[ACE_player, GVAR(target)] call FUNC(canOpenMenu)}
) then {
closeDialog 0;
// Show hint if distance condition failed
if ((ACE_player distance GVAR(target) > GVAR(maxDistance)) && {vehicle ACE_player != vehicle GVAR(target)}) then {
Expand Down
62 changes: 37 additions & 25 deletions addons/medical_treatment/functions/fnc_canTreat.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* 3: Treatment <STRING>
*
* Return Value:
* Can Treat <BOOL>
* Can treat <BOOL>
*
* Example:
* [player, cursorObject, "Head", "SurgicalKit"] call ace_medical_treatment_fnc_canTreat
Expand All @@ -22,17 +22,14 @@ params ["_medic", "_patient", "_bodyPart", "_classname"];

private _config = configFile >> QGVAR(actions) >> _classname;

isClass _config
&& {_patient isKindOf "CAManBase"}
&& {_medic != _patient || {GET_NUMBER_ENTRY(_config >> "allowSelfTreatment") == 1}}
&& {[_medic, GET_NUMBER_ENTRY(_config >> "medicRequired")] call FUNC(isMedic)}
&& {[_medic, _patient, _config] call FUNC(canTreat_holsterCheck)}
&& {
// Conditions that apply, regardless of curator status
(
isClass _config
) && {
_patient isKindOf "CAManBase"
} && {
private _selections = getArray (_config >> "allowedSelections") apply {toLower _x};
"all" in _selections || {_bodyPart in _selections}
} && {
private _items = getArray (_config >> "items");
_items isEqualTo [] || {[_medic, _patient, _items] call FUNC(hasItem)}
} && {
GET_FUNCTION(_condition,_config >> "condition");

Expand All @@ -46,19 +43,34 @@ isClass _config

_condition
} && {
switch (GET_NUMBER_ENTRY(_config >> "treatmentLocations")) do {
case TREATMENT_LOCATIONS_ALL: {true};
case TREATMENT_LOCATIONS_VEHICLES: {
IN_MED_VEHICLE(_medic) || {IN_MED_VEHICLE(_patient)}
};
case TREATMENT_LOCATIONS_FACILITIES: {
IN_MED_FACILITY(_medic) || {IN_MED_FACILITY(_patient)}
};
case TREATMENT_LOCATIONS_VEHICLES_AND_FACILITIES: {
IN_MED_VEHICLE(_medic) || {IN_MED_VEHICLE(_patient)} || {IN_MED_FACILITY(_medic)} || {IN_MED_FACILITY(_patient)}
};
default {false};
};
} && {
((getNumber (_config >> "allowedUnderwater")) == 1) || {!([_medic] call ace_common_fnc_isSwimming)}
// If in Zeus, the rest of the condition checks can be omitted
(_medic isEqualTo player && {!isNull findDisplay 312}) || {
// Conditions that apply when not in Zeus
(
_medic != _patient || {GET_NUMBER_ENTRY(_config >> "allowSelfTreatment") == 1}
) && {
[_medic, GET_NUMBER_ENTRY(_config >> "medicRequired")] call FUNC(isMedic)
} && {
[_medic, _patient, _config] call FUNC(canTreat_holsterCheck)
} && {
private _items = getArray (_config >> "items");
_items isEqualTo [] || {[_medic, _patient, _items] call FUNC(hasItem)}
} && {
switch (GET_NUMBER_ENTRY(_config >> "treatmentLocations")) do {
case TREATMENT_LOCATIONS_ALL: {true};
case TREATMENT_LOCATIONS_VEHICLES: {
IN_MED_VEHICLE(_medic) || {IN_MED_VEHICLE(_patient)}
};
case TREATMENT_LOCATIONS_FACILITIES: {
IN_MED_FACILITY(_medic) || {IN_MED_FACILITY(_patient)}
};
case TREATMENT_LOCATIONS_VEHICLES_AND_FACILITIES: {
IN_MED_VEHICLE(_medic) || {IN_MED_VEHICLE(_patient)} || {IN_MED_FACILITY(_medic)} || {IN_MED_FACILITY(_patient)}
};
default {false};
};
} && {
!(_medic call EFUNC(common,isSwimming)) || {getNumber (_config >> "allowedUnderwater") == 1}
}
}
}
134 changes: 72 additions & 62 deletions addons/medical_treatment/functions/fnc_treatment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -54,88 +54,98 @@ private _userAndItem = if (GET_NUMBER_ENTRY(_config >> "consumeItem") == 1) then

_userAndItem params ["_itemUser", "_usedItem"];

// 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"));
};
private _isInZeus = !isNull findDisplay 312;

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"));
};

_medic setVariable [QGVAR(selectedWeaponOnTreatment), weaponState _medic];
_medic setVariable [QGVAR(selectedWeaponOnTreatment), weaponState _medic];

// 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;
// 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;

// This animation is missing, use alternative
if (_medicAnim == "AinvPknlMstpSlayWlnrDnon_medic") then {
_medicAnim = "AinvPknlMstpSlayWlnrDnon_medicOther";
};
// This animation is missing, use alternative
if (_medicAnim == "AinvPknlMstpSlayWlnrDnon_medic") then {
_medicAnim = "AinvPknlMstpSlayWlnrDnon_medicOther";
};

// Determine the animation length
private _animDuration = GVAR(animDurations) getVariable _medicAnim;
if (isNil "_animDuration") then {
WARNING_2("animation [%1] for [%2] has no duration defined",_medicAnim,_classname);
_animDuration = 10;
};
// Determine the animation length
private _animDuration = GVAR(animDurations) getVariable _medicAnim;
if (isNil "_animDuration") then {
WARNING_2("animation [%1] for [%2] has no duration defined",_medicAnim,_classname);
_animDuration = 10;
};

// These animations have transitions that take a bit longer...
if (weaponLowered _medic) then {
_animDuration = _animDuration + 0.5;
// These animations have transitions that take a bit longer...
if (weaponLowered _medic) then {
_animDuration = _animDuration + 0.5;

// Fix problems with lowered weapon transitions by raising the weapon first
if (currentWeapon _medic != "" && {_medicAnim != ""}) then {
_medic action ["WeaponInHand", _medic];
// Fix problems with lowered weapon transitions by raising the weapon first
if (currentWeapon _medic != "" && {_medicAnim != ""}) then {
_medic action ["WeaponInHand", _medic];
};
};
};

if (binocular _medic != "" && {binocular _medic == currentWeapon _medic}) then {
_animDuration = _animDuration + 1;
};
if (binocular _medic != "" && {binocular _medic == currentWeapon _medic}) then {
_animDuration = _animDuration + 1;
};

// Play treatment animation for medic and determine the ending animation
if (vehicle _medic == _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);
// Play treatment animation for medic and determine the ending animation
if (vehicle _medic == _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);

// Don't slow down animation too much to prevent it looking funny.
if (_animRatio < ANIMATION_SPEED_MIN_COEFFICIENT) then {
_animRatio = ANIMATION_SPEED_MIN_COEFFICIENT;
};
// Don't slow down animation too much to prevent it looking funny.
if (_animRatio < ANIMATION_SPEED_MIN_COEFFICIENT) then {
_animRatio = ANIMATION_SPEED_MIN_COEFFICIENT;
};

// Skip animation enitrely if progress bar too quick.
if (_animRatio > ANIMATION_SPEED_MAX_COEFFICIENT) exitWith {};
// Skip animation enitrely if progress bar too quick.
if (_animRatio > ANIMATION_SPEED_MAX_COEFFICIENT) exitWith {};

[QEGVAR(common,setAnimSpeedCoef), [_medic, _animRatio]] call CBA_fnc_globalEvent;
[QEGVAR(common,setAnimSpeedCoef), [_medic, _animRatio]] call CBA_fnc_globalEvent;

// Play animation
private _endInAnim = "AmovP[pos]MstpS[stn]W[wpn]Dnon";
// Play animation
private _endInAnim = "AmovP[pos]MstpS[stn]W[wpn]Dnon";

private _pos = ["knl", "pne"] select (stance _medic == "PRONE");
private _stn = "non";
private _pos = ["knl", "pne"] select (stance _medic == "PRONE");
private _stn = "non";

if (_wpn != "non") then {
_stn = ["ras", "low"] select (weaponLowered _medic);
};
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;
_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 EFUNC(common,doAnimation);
[_medic, _endInAnim] call EFUNC(common,doAnimation);
_medic setVariable [QGVAR(endInAnim), _endInAnim];

if (!isNil QEGVAR(advanced_fatigue,setAnimExclusions)) then {
EGVAR(advanced_fatigue,setAnimExclusions) pushBack QUOTE(ADDON);
};
};

[_medic, _medicAnim] call EFUNC(common,doAnimation);
[_medic, _endInAnim] call EFUNC(common,doAnimation);
_medic setVariable [QGVAR(endInAnim), _endInAnim];
// Play a random treatment sound globally if defined
private _soundsConfig = _config >> "sounds";

if (!isNil QEGVAR(advanced_fatigue,setAnimExclusions)) then {
EGVAR(advanced_fatigue,setAnimExclusions) pushBack QUOTE(ADDON);
if (isArray _soundsConfig) then {
(selectRandom (getArray _soundsConfig)) params ["_file", ["_volume", 1], ["_pitch", 1], ["_distance", 10]];
playSound3D [_file, objNull, false, getPosASL _medic, _volume, _pitch, _distance];
};
};

// Play a random treatment sound globally if defined
if (isArray (_config >> "sounds")) then {
selectRandom getArray (_config >> "sounds") params ["_file", ["_volume", 1], ["_pitch", 1], ["_distance", 10]];
playSound3D [_file, objNull, false, getPosASL _medic, _volume, _pitch, _distance];
if (_isInZeus) then {
_treatmentTime = _treatmentTime * GVAR(treatmentTimeCoeffZeus);
};

GET_FUNCTION(_callbackStart,_config >> "callbackStart");
Expand All @@ -156,7 +166,7 @@ if (_callbackProgress isEqualTo {}) then {
FUNC(treatmentFailure),
getText (_config >> "displayNameProgress"),
_callbackProgress,
["isNotInside", "isNotSwimming"]
["isNotInside", "isNotSwimming", "isNotInZeus"]
] call EFUNC(common,progressBar);

true
4 changes: 4 additions & 0 deletions addons/medical_treatment/functions/fnc_useItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

params ["_medic", "_patient", "_items"];

if (_medic isEqualTo player && {!isNull findDisplay 312}) exitWith {
[_medic, _items select 0]
};

scopeName "Main";

private _useOrder = [[_patient, _medic], [_medic, _patient], [_medic]] select GVAR(allowSharedEquipment);
Expand Down
8 changes: 8 additions & 0 deletions addons/medical_treatment/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@
true
] call CBA_fnc_addSetting;

[
QGVAR(treatmentTimeCoeffZeus),
"SLIDER",
[LSTRING(TreatmentTimeCoeffZeus_DisplayName), LSTRING(TreatmentTimeCoeffZeus_Description)],
[ELSTRING(medical,Category), LSTRING(SubCategory_Treatment)],
[0, 10, 1, 2]
] call CBA_fnc_addSetting;

[
QGVAR(allowBodyBagUnconscious),
"CHECKBOX",
Expand Down
6 changes: 6 additions & 0 deletions addons/medical_treatment/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4770,5 +4770,11 @@
<German>Bestimmt, wie wirksam Bandagen beim Verschließen von Wunden sind.</German>
<Korean>붕대가 상처를 치료하는 데 얼마나 효과적으로 지속되는지 결정합니다.</Korean>
</Key>
<Key ID="STR_ACE_Medical_Treatment_TreatmentTimeCoeffZeus_DisplayName">
<English>Zeus Treatment Time Coefficient</English>
</Key>
<Key ID="STR_ACE_Medical_Treatment_TreatmentTimeCoeffZeus_Description">
<English>Multiply all treatment times with this coefficient when in Zeus.</English>
</Key>
</Package>
</Project>
7 changes: 7 additions & 0 deletions addons/zeus/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ class CfgVehicles {
function = QFUNC(moduleBurn);
icon = QPATHTOF(ui\Icon_Module_Zeus_Burn_ca.paa);
};
class GVAR(moduleMedicalMenu): GVAR(moduleBase) {
curatorCanAttach = 1;
category = QGVAR(Medical);
displayName = CSTRING(ModuleMedicalMenu_DisplayName);
function = QFUNC(moduleMedicalMenu);
icon = QPATHTOF(UI\Icon_Module_Zeus_Medic_ca.paa);
};

class Man;
class CAManBase: Man {
Expand Down
9 changes: 5 additions & 4 deletions addons/zeus/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ PREP(bi_moduleRemoteControl);
PREP(canCreateModule);
PREP(getModuleDestination);
PREP(handleZeusUnitAssigned);
PREP(moduleAddArsenal);
PREP(moduleAddAceArsenal);
PREP(moduleAddArsenal);
PREP(moduleAddOrRemoveFRIES);
PREP(moduleAddSpareTrack);
PREP(moduleAddSpareWheel);
PREP(moduleAddOrRemoveFRIES);
PREP(moduleBurn);
PREP(moduleCaptive);
PREP(moduleCargoParadrop);
Expand All @@ -23,13 +23,14 @@ PREP(moduleGroupSide);
PREP(moduleHeal);
PREP(moduleLayTrench);
PREP(moduleLoadIntoCargo);
PREP(moduleRemoveArsenal);
PREP(moduleMedicalMenu);
PREP(moduleRemoveAceArsenal);
PREP(moduleRemoveArsenal);
PREP(moduleSearchNearby);
PREP(moduleSetEngineer);
PREP(moduleSetMedic);
PREP(moduleSetMedicalVehicle);
PREP(moduleSetMedicalFacility);
PREP(moduleSetMedicalVehicle);
PREP(moduleSetRepairFacility);
PREP(moduleSetRepairVehicle);
PREP(moduleSimulation);
Expand Down
3 changes: 2 additions & 1 deletion addons/zeus/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class CfgPatches {
QGVAR(moduleUnconscious),
QGVAR(moduleSetMedic),
QGVAR(moduleSetMedicalVehicle),
QGVAR(moduleSetMedicalFacility)
QGVAR(moduleSetMedicalFacility),
QGVAR(moduleMedicalMenu)
};
};
class GVAR(cargo): ADDON {
Expand Down
Loading