Medical - epiBoostsSpontaneousWakeUp (#7076)

* Medical - epiBoostsSpontaneousWakeUp

* Update initSettings.sqf

* Move setting, add strings

* Update initSettings.sqf

* Update addons/medical/stringtable.xml

Co-Authored-By: mharis001 <34453221+mharis001@users.noreply.github.com>
This commit is contained in:
PabstMirror 2019-09-28 16:11:32 -05:00 committed by GitHub
parent c426103f23
commit d6507cf119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 78 additions and 33 deletions

View File

@ -127,17 +127,11 @@ GVAR(dev_watchVariableRunning) = true;
private _hrTargetAdjustment = 0;
private _painSupressAdjustment = 0;
private _peripheralResistanceAdjustment = 0;
private _medicationCounts = [];
private _uniqueMedications = [];
private _rawMedications = (_unit getVariable [VAR_MEDICATIONS, []]) apply {
_x params ["_medication", "_timeAdded", "_timeTillMaxEffect", "_maxTimeInSystem", "_hrAdjust", "_painAdjust", "_flowAdjust"];
_uniqueMedications pushBackUnique _medication;
private _timeInSystem = CBA_missionTime - _timeAdded;
private _index = _medicationCounts find _medication;
if (_index < 0) then {
_index = _medicationCounts pushBack _medication;
_medicationCounts pushBack 0
};
_medicationCounts set [(_index + 1), (_medicationCounts select (_index + 1)) + linearConversion [_timeTillMaxEffect, _maxTimeInSystem, _timeInSystem, 1, 0, true]];
private _effectRatio = (((_timeInSystem / _timeTillMaxEffect) ^ 2) min 1) * (_maxTimeInSystem - _timeInSystem) / _maxTimeInSystem;
_hrTargetAdjustment = _hrTargetAdjustment + _hrAdjust * _effectRatio;
_painSupressAdjustment = _painSupressAdjustment + _painAdjust * _effectRatio;
@ -145,9 +139,11 @@ GVAR(dev_watchVariableRunning) = true;
format ["%1 [%2 / %3][%4][%5,%6,%7]",_medication,_timeInSystem toFixed 0,_maxTimeInSystem toFixed 0, _effectRatio toFixed 2, _hrAdjust toFixed 1, _painAdjust toFixed 2, _flowAdjust toFixed 1];
};
_return pushBack format ["Adjusts: [HR %1][PS %2][PR %3]", _hrTargetAdjustment toFixed 2, _painSupressAdjustment toFixed 2, _peripheralResistanceAdjustment toFixed 2];
for "_i" from 0 to (count _medicationCounts) - 1 step 2 do {
_return pushBack format ["-%1: %2", _medicationCounts select _i, _medicationCounts select _i + 1];
};
{
private _medicationCount = [_unit, _x, true] call EFUNC(medical_status,getMedicationCount);
private _medicationEffectiveness = [_unit, _x, false] call EFUNC(medical_status,getMedicationCount);
_return pushBack format ["-%1: C: %2 - E: %3", _x, _medicationCount toFixed 2, _medicationEffectiveness toFixed 2];
} forEach _uniqueMedications;
_return pushBack "------- Medications Raw: -------";
_return append _rawMedications;

View File

@ -28,3 +28,12 @@
[0, 1, 0.05, 2],
true
] call CBA_settings_fnc_init;
[
QGVAR(spontaneousWakeUpEpinephrineBoost),
"SLIDER",
[LSTRING(spontaneousWakeUpEpinephrineBoost_DisplayName), LSTRING(spontaneousWakeUpEpinephrineBoost_Description)],
LSTRING(Category),
[1, 30, 1, 1],
true
] call CBA_settings_fnc_init;

View File

@ -33,6 +33,12 @@
<French>La probabilité pour qu'une unité en état stable puisse reprendre conscience (état vérifié toutes les 15 secondes).</French>
<Portuguese>A probabilidade que uma unidade com vitais estabilizados possa recuperar consciências (verificado a cada 15 segundos)</Portuguese>
</Key>
<Key ID="STR_ACE_Medical_spontaneousWakeUpEpinephrineBoost_DisplayName">
<English>Epinephrine Increases Wake Up Chance</English>
</Key>
<Key ID="STR_ACE_Medical_spontaneousWakeUpEpinephrineBoost_Description">
<English>Increases how often spontaneous wake up checks happen when patient has Epinephrine in their system.</English>
</Key>
<Key ID="STR_ACE_Medical_Limping_DisplayName">
<English>Limping</English>
<Russian>Хромота</Russian>

View File

@ -39,7 +39,13 @@ if (EGVAR(medical,spontaneousWakeUpChance) > 0) then {
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime];
};
if (CBA_missionTime - _lastWakeUpCheck > SPONTANEOUS_WAKE_UP_INTERVAL) then {
private _wakeUpCheckInterval = SPONTANEOUS_WAKE_UP_INTERVAL;
if (EGVAR(medical,spontaneousWakeUpEpinephrineBoost) > 1) then {
private _epiEffectiveness = [_unit, "Epinephrine", false] call EFUNC(medical_status,getMedicationCount);
_wakeUpCheckInterval = _wakeUpCheckInterval * linearConversion [0, 1, _epiEffectiveness, 1, 1 / EGVAR(medical,spontaneousWakeUpEpinephrineBoost), true];
TRACE_2("epiBoost",_epiEffectiveness,_wakeUpCheckInterval);
};
if (CBA_missionTime - _lastWakeUpCheck > _wakeUpCheckInterval) then {
TRACE_2("Checking for wake up",_unit,EGVAR(medical,spontaneousWakeUpChance));
_unit setVariable [QEGVAR(medical,lastWakeUpCheck), CBA_missionTime];

View File

@ -4,6 +4,7 @@ PREP(getBloodLoss);
PREP(getBloodPressure);
PREP(getBloodVolumeChange);
PREP(getCardiacOutput);
PREP(getMedicationCount);
PREP(handleKilled);
PREP(hasStableVitals);
PREP(initUnit);

View File

@ -0,0 +1,39 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Gets effective count of medications in a unit's system
* (each medication dose is scaled from 0..1 based on time till max effect and max time in system)
*
* Arguments:
* 0: The patient <OBJECT>
* 1: Medication (not case sensitive) <STRING>
* 2: Get raw count (true) or effect ratio (false) <BOOL>(default: true)
*
* Return Value:
* Medication count (float) <NUMBER>
*
* Example:
* [player, "Epinephrine"] call ace_medical_status_fnc_getMedicationCount
*
* Public: No
*/
params ["_target", "_medication", ["_getCount", true]];
private _return = 0;
{
_x params ["_xMed", "_timeAdded", "_timeTillMaxEffect", "_maxTimeInSystem"];
if (_xMed == _medication) then {
private _timeInSystem = CBA_missionTime - _timeAdded;
if (_getCount) then {
// just return effective count, a medication will always start at 1 and only drop after reaching timeTilMaxEffect
_return = _return + linearConversion [_timeTillMaxEffect, _maxTimeInSystem, _timeInSystem, 1, 0, true];
} else {
// as used in handleUnitVitals, a medication effectiveness will start low, ramp up to timeTillMaxEffect, and then drop off
_return = _return + (((_timeInSystem / _timeTillMaxEffect) ^ 2) min 1) * (_maxTimeInSystem - _timeInSystem) / _maxTimeInSystem;
};
};
} forEach (_target getVariable [VAR_MEDICATIONS, []]);
TRACE_4("getMedicationCount",_target,_medication,_getCount,_return);
_return

View File

@ -38,7 +38,7 @@ if (!GVAR(advancedMedication)) exitWith {
};
};
};
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for", _target);
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for",_patient);
// Handle tourniquet on body part blocking blood flow at injection site

View File

@ -6,7 +6,7 @@
* Arguments:
* 0: The patient <OBJECT>
* 1: Medication Treatment classname <STRING>
* 2: Max dosage <NUMBER>
* 2: Max dosage (0 to ignore) <NUMBER>
* 3: Incompatable medication <ARRAY<STRING>>
*
* Return Value:
@ -21,33 +21,21 @@
params ["_target", "_className", "_maxDosage", "_incompatibleMedication"];
TRACE_4("onMedicationUsage",_target,_className,_maxDosage,_incompatibleMedication);
private _fnc_getMedicationCount = {
params ["_target", "_medication"];
private _return = 0;
{
_x params ["_xMed", "_timeAdded", "_timeTillMaxEffect", "_maxTimeInSystem"];
if (_xMed == _medication) then {
private _timeInSystem = CBA_missionTime - _timeAdded;
_return = _return + linearConversion [_timeTillMaxEffect, _maxTimeInSystem, _timeInSystem, 1, 0, true];
};
} forEach (_target getVariable [VAR_MEDICATIONS, []]);
TRACE_2("getMedicationCount",_medication,_return);
_return
};
private _overdosedMedications = [];
// Check for overdose from current medication
private _currentDose = [_target, _className] call _fnc_getMedicationCount;
if (_currentDose >= floor (_maxDosage + round(random(2))) && {_maxDosage >= 1}) then {
TRACE_1("exceeded max dose",_currentDose);
_overdosedMedications pushBackUnique _className;
if (_maxDosage > 0) then {
private _currentDose = [_target, _className] call EFUNC(medical_status,getMedicationCount);
if (_currentDose >= floor (_maxDosage + round(random(2)))) then {
TRACE_1("exceeded max dose",_currentDose);
_overdosedMedications pushBackUnique _className;
};
};
// Check incompatible medication (format [med,limit])
{
_x params ["_xMed", "_xLimit"];
private _inSystem = [_target, _xMed] call _fnc_getMedicationCount;
private _inSystem = [_target, _xMed] call EFUNC(medical_status,getMedicationCount);
if (_inSystem> _xLimit) then {
_overdosedMedications pushBackUnique _xMed;
};