General - Use variable for checking if medical is enabled (#10063)

This commit is contained in:
Grim 2024-06-17 21:07:38 -03:00 committed by GitHub
parent 421071027e
commit 95b7951919
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 30 additions and 30 deletions

View File

@ -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);

View File

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

View File

@ -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;
};

View File

@ -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

View File

@ -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];

View File

@ -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",
@ -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 {

View File

@ -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);

View File

@ -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

View File

@ -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 {
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);
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
params ["_unit"];
if (GVAR(useAceMedical)) exitWith {
if (GETEGVAR(medical,enabled,false)) exitWith {
IS_BLEEDING(_unit);
};

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

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

View File

@ -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 {

View File

@ -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,[""]);

View File

@ -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,[""]);

View File

@ -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,[""]);