Skip to content

Commit

Permalink
General - Use variable for checking if medical is enabled (acemod#10063)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkIsGrim authored and blake8090 committed Aug 18, 2024
1 parent e7fcfc1 commit 29636b7
Show file tree
Hide file tree
Showing 23 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion addons/advanced_fatigue/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if (!hasInterface) exitWith {};
}, true] call CBA_fnc_addPlayerEventHandler;

// - Duty factors -------------------------------------------------------------
if (GVAR(medicalLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
[QEGVAR(medical,pain), { // 0->1.0, 0.5->1.05, 1->1.1
linearConversion [0, 1, (_this getVariable [QEGVAR(medical,pain), 0]), 1, 1.1, true];
}] call FUNC(addDutyFactor);
Expand Down
1 change: 0 additions & 1 deletion addons/advanced_fatigue/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ GVAR(dutyList) = createHashMap;
GVAR(setAnimExclusions) = [];
GVAR(inertia) = 0;
GVAR(inertiaCache) = createHashMap;
GVAR(medicalLoaded) = ["ace_medical"] call EFUNC(common,isModLoaded);

ADDON = true;
2 changes: 1 addition & 1 deletion addons/advanced_fatigue/functions/fnc_mainLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (!alive ACE_player) exitWith {


private _oxygen = 0.9; // Default AF oxygen saturation
if (GVAR(medicalLoaded) && {EGVAR(medical_vitals,simulateSpo2)}) then {
if (GETEGVAR(medical,enabled,false) && {EGVAR(medical_vitals,simulateSpo2)}) then {
_oxygen = (ACE_player getVariable [QEGVAR(medical,spo2), 97]) / 100;
};

Expand Down
2 changes: 1 addition & 1 deletion addons/common/functions/fnc_setDead.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (!local _unit) exitWith {
WARNING_1("setDead executed on non-local unit - %1",_this);
};

if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
[_unit, _reason, _source, _instigator] call EFUNC(medical_status,setDead);
} else {
// From 'ace_medical_status_fnc_setDead': Kill the unit without changing visual appearance
Expand Down
2 changes: 1 addition & 1 deletion addons/compat_sog/functions/fnc_handlePunjiTrapTrigger.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Public: No
*/
params ["_trap"];
if (!(["ace_medical"] call EFUNC(common,isModLoaded))) exitWith {};
if !(GETEGVAR(medical,enabled,false)) exitWith {};

private _radius = getNumber (configOf _trap >> "indirectHitRange");
private _affectedUnits = _trap nearEntities ["CAManBase", _radius];
Expand Down
8 changes: 5 additions & 3 deletions addons/dogtags/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
[QGVAR(getDogtagItem), LINKFUNC(getDogtagItem)] call CBA_fnc_addEventHandler;
[QGVAR(addDogtagItem), LINKFUNC(addDogtagItem)] call CBA_fnc_addEventHandler;

// Add actions and event handlers only if ace_medical is loaded
// Add actions and event handlers only if ace_medical is enabled
// - Adding actions via config would create a dependency
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
["CBA_settingsInitialized", {
if !(GETEGVAR(medical,enabled,false)) exitWith {};

if (hasInterface) then {
private _checkTagAction = [
"ACE_CheckDogtag",
Expand Down Expand Up @@ -44,7 +46,7 @@ if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
};
}] call CBA_fnc_addEventHandler;
};
};
}] call CBA_fnc_addEventHandler;

// If the arsenal is loaded, show the custom names for dog tags when in the arsenal
if (["ace_arsenal"] call EFUNC(common,isModLoaded)) then {
Expand Down
2 changes: 1 addition & 1 deletion addons/dragging/functions/fnc_dropObject_carry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (_loadCargo) then {
private _vehicles = [_cursorObject, 0, true] call EFUNC(common,nearestVehiclesFreeSeat);

if ([_cursorObject] isEqualTo _vehicles) then {
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
[_unit, _target, _cursorObject] call EFUNC(medical_treatment,loadUnit);
} else {
[_unit, _target, _cursorObject] call EFUNC(common,loadPerson);
Expand Down
2 changes: 1 addition & 1 deletion addons/field_rations/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if !(hasInterface) exitWith {};
["ace_interactMenuOpened", LINKFUNC(addWaterSourceInteractions)] call CBA_fnc_addEventHandler;

// Add status modifiers
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
[0, {
if (_this getVariable [QEGVAR(medical,isBleeding), false]) exitWith {
0.5
Expand Down
11 changes: 6 additions & 5 deletions addons/field_rations/functions/fnc_handleEffects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ if ((_thirst > 99.9 || {_hunger > 99.9}) && {random 1 < 0.5}) exitWith {
if !(_player call EFUNC(common,isAwake)) exitWith {};

// Set unit unconscious (chance based on how high thirst/hunger are)
if ((_thirst > 85 || {_hunger > 85}) && {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]}) exitWith {
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
[_player, true, 5, true] call EFUNC(medical,setUnconscious);
};
if (
GETEGVAR(medical,enabled,false) &&
{(_thirst > 85 || {_hunger > 85}) && {random 1 < linearConversion [85, 100, _thirst max _hunger, 0.05, 0.1, true]}}
) exitWith {
[_player, true, 5, true] call EFUNC(medical,setUnconscious);
};

// Make unit fall if moving fast
if ((_thirst > 93 || {_hunger > 93}) && {speed _player > 1} && {vehicle _player == _player}) exitWith {
if ((_thirst > 93 || {_hunger > 93}) && {speed _player > 1} && {isNull objectParent _player}) exitWith {
[_player, "down"] call EFUNC(common,doGesture);
};
2 changes: 1 addition & 1 deletion addons/gforces/functions/fnc_pfhUpdateGForces.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private _suitCoef = if ((uniform ACE_player) != "") then {
private _gBlackOut = MAXVIRTUALG / _classCoef + MAXVIRTUALG / _suitCoef - MAXVIRTUALG;

// Unconsciousness
if ((_average > _gBlackOut) && {["ace_medical"] call EFUNC(common,isModLoaded) && {!(ACE_player getVariable ["ACE_isUnconscious", false])}}) then {
if (_average > _gBlackOut && {GETEGVAR(medical,enabled,false) && {ACE_player call EFUNC(common,isAwake)}}) then {
[ACE_player, true, (10 + floor(random 5)), true] call EFUNC(medical,setUnconscious);
};

Expand Down
2 changes: 1 addition & 1 deletion addons/grenades/functions/fnc_flashbangExplosionEH.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ if (hasInterface && {!isNull ACE_player} && {alive ACE_player}) then {
};

// add ace_medical pain effect:
if (["ace_medical"] call EFUNC(common,isModLoaded) && {_strength > 0.1} && {isDamageAllowed _unit} && {_unit getVariable [QEGVAR(medical,allowDamage), true]}) then {
if (GETEGVAR(medical,enabled,false) && {_strength > 0.1} && {isDamageAllowed _unit} && {_unit getVariable [QEGVAR(medical,allowDamage), true]}) then {
[ACE_player, _strength / 2] call EFUNC(medical,adjustPainLevel);
};

Expand Down
2 changes: 1 addition & 1 deletion addons/interaction/functions/fnc_canPullOutBody.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
params ["_body", "_unit"];

// Defer to ACE Medical's unload patient if present
if (["ace_medical"] call EFUNC(common,isModLoaded)) exitWith {false};
if (GETEGVAR(medical,enabled,false)) exitWith {false};

private _vehicle = objectParent _body;

Expand Down
2 changes: 1 addition & 1 deletion addons/killtracker/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
if ((getText (missionconfigfile >> "CfgDebriefingSections" >> QUOTE(XADDON) >> "variable")) != QXGVAR(outputText)) exitWith {
TRACE_1("no mission debriefing config",_this);
};
if (!(["ace_medical"] call EFUNC(common,isModLoaded))) exitWith {
if !(GETEGVAR(medical,enabled,false)) exitWith {
WARNING("No ACE-Medical");
XGVAR(outputText) = "No ACE-Medical";
};
Expand Down
2 changes: 0 additions & 2 deletions addons/medical_blood/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "script_component.hpp"

GVAR(useAceMedical) = ["ace_medical"] call EFUNC(common,isModLoaded);

// To support public API regardless of component settings
[QGVAR(spurt), LINKFUNC(spurt)] call CBA_fnc_addEventHandler;

Expand Down
2 changes: 1 addition & 1 deletion addons/medical_blood/functions/fnc_isBleeding.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

params ["_unit"];

if (GVAR(useAceMedical)) exitWith {
if (GETEGVAR(medical,enabled,false)) exitWith {
IS_BLEEDING(_unit);
};

Expand Down
2 changes: 1 addition & 1 deletion addons/medical_blood/functions/fnc_onBleeding.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if !(_unit call FUNC(isBleeding)) exitWith {};
if (!isNull objectParent _unit && {!(vehicle _unit isKindOf "StaticWeapon")}) exitWith {};

if (CBA_missionTime > (_unit getVariable [QGVAR(nextTime), -10])) then {
private _bloodLoss = (if (GVAR(useAceMedical)) then {GET_BLOOD_LOSS(_unit) * 2.5} else {getDammage _unit * 2}) min 6;
private _bloodLoss = ([damage _unit * 2, GET_BLOOD_LOSS(_unit) * 2.5] select GETEGVAR(medical,enabled,false)) min 6;
_unit setVariable [QGVAR(nextTime), CBA_missionTime + 8 + random 2 - _bloodLoss];

TRACE_2("Creating blood drop for bleeding unit",_unit,_bloodLoss);
Expand Down
2 changes: 1 addition & 1 deletion addons/overpressure/functions/fnc_firedEHBB.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if (_distance < _backblastRange) then {

[_damage * 100] call BIS_fnc_bloodEffect;

if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
[_unit, _damage, "body", "backblast", _unit] call EFUNC(medical,addDamageToUnit);
} else {
_unit setDamage (damage _unit + _damage);
Expand Down
2 changes: 1 addition & 1 deletion addons/overpressure/functions/fnc_overpressureDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TRACE_3("cache",_overpressureAngle,_overpressureRange,_overpressureDamage);
[_damage * 100] call BIS_fnc_bloodEffect;
};

if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
[_x, _damage, "body", "backblast", _firer] call EFUNC(medical,addDamageToUnit);
} else {
_x setDamage (damage _x + _damage);
Expand Down
2 changes: 1 addition & 1 deletion addons/vehicle_damage/functions/fnc_medicalDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ params ["_unit", "_source", "_instigator", ["_guaranteeDeath", false]];
// Check if unit is invulnerable
if !(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]}) exitWith {};

if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
for "_i" from 0 to floor (4 + random 3) do {
[_unit, random [0, 0.66, 1], selectRandom ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"], selectRandom ["bullet", "shell", "explosive"], _instigator] call EFUNC(medical,addDamageToUnit);
};
Expand Down
2 changes: 1 addition & 1 deletion addons/zeus/functions/fnc_moduleHeal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ switch (false) do {
};

// Heal validated target
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
if (GETEGVAR(medical,enabled,false)) then {
TRACE_1("healing with ace_medical",_unit);
[QEGVAR(medical_treatment,fullHealLocal), [_unit], _unit] call CBA_fnc_targetEvent;
} else {
Expand Down
2 changes: 1 addition & 1 deletion addons/zeus/functions/fnc_moduleSetMedic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ params ["_logic"];

if !(local _logic) exitWith {};

if !(["ace_medical"] call EFUNC(common,isModLoaded)) then {
if !(GETEGVAR(medical,enabled,false)) then {
[LSTRING(RequiresAddon)] call FUNC(showMessage);
} else {
private _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]);
Expand Down
2 changes: 1 addition & 1 deletion addons/zeus/functions/fnc_moduleSetMedicalFacility.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ params ["_logic"];

if !(local _logic) exitWith {};

if !(["ace_medical"] call EFUNC(common,isModLoaded)) then {
if !(GETEGVAR(medical,enabled,false)) then {
[LSTRING(RequiresAddon)] call FUNC(showMessage);
} else {
private _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]);
Expand Down
2 changes: 1 addition & 1 deletion addons/zeus/functions/fnc_moduleSetMedicalVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ params ["_logic"];

if !(local _logic) exitWith {};

if !(["ace_medical"] call EFUNC(common,isModLoaded)) then {
if !(GETEGVAR(medical,enabled,false)) then {
[LSTRING(RequiresAddon)] call FUNC(showMessage);
} else {
private _mouseOver = GETMVAR(bis_fnc_curatorObjectPlaced_mouseOver,[""]);
Expand Down

0 comments on commit 29636b7

Please sign in to comment.