mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
356a8f640a
Conflicts: addons/medical/functions/fnc_actionCheckBloodPressure.sqf addons/medical/functions/fnc_actionCheckBloodPressureLocal.sqf addons/medical/functions/fnc_actionCheckPulse.sqf addons/medical/functions/fnc_actionCheckPulseLocal.sqf addons/medical/functions/fnc_actionDiagnose.sqf addons/medical/functions/fnc_actionRemoveTourniquet.sqf addons/medical/functions/fnc_addHeartRateAdjustment.sqf addons/medical/functions/fnc_addToInjuredCollection.sqf addons/medical/functions/fnc_addUnconsciousCondition.sqf addons/medical/functions/fnc_addVitalLoop.sqf addons/medical/functions/fnc_canTreat.sqf addons/medical/functions/fnc_copyDeadBody.sqf addons/medical/functions/fnc_createLitter.sqf addons/medical/functions/fnc_determineIfFatal.sqf addons/medical/functions/fnc_getBloodLoss.sqf addons/medical/functions/fnc_getBloodPressure.sqf addons/medical/functions/fnc_getBloodVolumeChange.sqf addons/medical/functions/fnc_getCardiacOutput.sqf addons/medical/functions/fnc_getHeartRateChange.sqf addons/medical/functions/fnc_getTriageStatus.sqf addons/medical/functions/fnc_getUnconsciousCondition.sqf addons/medical/functions/fnc_handleBandageOpening.sqf addons/medical/functions/fnc_handleCollisionDamage.sqf addons/medical/functions/fnc_handleDamage.sqf addons/medical/functions/fnc_handleDamage_advanced.sqf addons/medical/functions/fnc_handleDamage_advancedSetDamage.sqf addons/medical/functions/fnc_handleDamage_airway.sqf addons/medical/functions/fnc_handleDamage_caching.sqf addons/medical/functions/fnc_handleDamage_fractures.sqf addons/medical/functions/fnc_handleDamage_internalInjuries.sqf addons/medical/functions/fnc_handleDamage_wounds.sqf addons/medical/functions/fnc_handleDamage_woundsOld.sqf addons/medical/functions/fnc_hasMedicalEnabled.sqf addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf addons/medical/functions/fnc_isInStableCondition.sqf addons/medical/functions/fnc_isMedicalVehicle.sqf addons/medical/functions/fnc_itemCheck.sqf addons/medical/functions/fnc_medicationEffectLoop.sqf addons/medical/functions/fnc_modifyMedicalAction.sqf addons/medical/functions/fnc_moduleAdvancedMedicalSettings.sqf addons/medical/functions/fnc_moduleAssignMedicalFacility.sqf addons/medical/functions/fnc_moduleBasicMedicalSettings.sqf addons/medical/functions/fnc_moduleReviveSettings.sqf addons/medical/functions/fnc_parseConfigForInjuries.sqf addons/medical/functions/fnc_playInjuredSound.sqf addons/medical/functions/fnc_reviveStateLoop.sqf addons/medical/functions/fnc_selectionNameToNumber.sqf addons/medical/functions/fnc_setDead.sqf addons/medical/functions/fnc_setHitPointDamage.sqf addons/medical/functions/fnc_setStructuralDamage.sqf addons/medical/functions/fnc_setUnconscious.sqf addons/medical/functions/fnc_showBloodEffect.sqf addons/medical/functions/fnc_treatment.sqf addons/medical/functions/fnc_treatmentAdvanced_CPR.sqf addons/medical/functions/fnc_treatmentAdvanced_CPRLocal.sqf addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf addons/medical/functions/fnc_treatmentAdvanced_fullHeal.sqf addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf addons/medical/functions/fnc_treatmentAdvanced_medication.sqf addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf addons/medical/functions/fnc_treatmentBasic_bloodbag.sqf addons/medical/functions/fnc_treatmentBasic_bloodbagLocal.sqf addons/medical/functions/fnc_treatmentBasic_epipen.sqf addons/medical/functions/fnc_treatmentBasic_morphine.sqf addons/medical/functions/fnc_treatmentBasic_morphineLocal.sqf addons/medical/functions/fnc_treatmentIV.sqf addons/medical/functions/fnc_treatmentIVLocal.sqf addons/medical/functions/fnc_treatmentTourniquet.sqf addons/medical/functions/fnc_treatmentTourniquetLocal.sqf addons/medical/functions/fnc_treatment_failure.sqf addons/medical/functions/fnc_treatment_success.sqf addons/medical/functions/fnc_unconsciousPFH.sqf addons/medical/functions/fnc_useItem.sqf addons/medical/functions/fnc_vitalLoop.sqf addons/medical_blood/functions/fnc_hit.sqf addons/medical_treatment/functions/fnc_hasItem.sqf addons/medical_treatment/functions/fnc_useItems.sqf
124 lines
4.4 KiB
Plaintext
124 lines
4.4 KiB
Plaintext
/*
|
|
* Author: Glowbal
|
|
* Updates the vitals. Called from the statemachine's onState functions.
|
|
*
|
|
* Arguments:
|
|
* 0: The Unit <OBJECT>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [bob] call ACE_medical_fnc_handleUnitVitals
|
|
*
|
|
* Example:
|
|
* [player] call ace_medical_fnc_handleUnitVitals
|
|
*
|
|
* Public: No
|
|
*/
|
|
// #define DEBUG_MODE_FULL
|
|
#include "script_component.hpp"
|
|
|
|
params ["_unit"];
|
|
|
|
private _lastTimeUpdated = _unit getVariable [QGVAR(lastTimeUpdated), 0];
|
|
private _deltaT = (CBA_missionTime - _lastTimeUpdated) min 10;
|
|
if (_deltaT < 1) exitWith {}; // state machines could be calling this very rapidly depending on number of local units
|
|
|
|
BEGIN_COUNTER(Vitals);
|
|
|
|
_unit setVariable [QGVAR(lastTimeUpdated), CBA_missionTime];
|
|
private _lastTimeValuesSynced = _unit getVariable [QGVAR(lastMomentValuesSynced), 0];
|
|
private _syncValues = (CBA_missionTime - _lastTimeValuesSynced) >= (10 + floor(random(10)));
|
|
|
|
if (_syncValues) then {
|
|
_unit setVariable [QGVAR(lastMomentValuesSynced), CBA_missionTime];
|
|
};
|
|
|
|
private _bloodVolume = (_unit getVariable [QGVAR(bloodVolume), DEFAULT_BLOOD_VOLUME]) + ([_unit, _deltaT, _syncValues] call FUNC(getBloodVolumeChange));
|
|
_bloodVolume = 0 max _bloodVolume min DEFAULT_BLOOD_VOLUME;
|
|
|
|
// @todo: replace this and the rest of the setVariable with EFUNC(common,setApproximateVariablePublic)
|
|
_unit setVariable [QGVAR(bloodVolume), _bloodVolume, _syncValues];
|
|
|
|
// Set variables for synchronizing information across the net
|
|
if (_bloodVolume < BLOOD_VOLUME_CLASS_1_HEMORRHAGE) then {
|
|
if (_bloodVolume < BLOOD_VOLUME_CLASS_3_HEMORRHAGE) then {
|
|
if (_unit getVariable [QGVAR(hasLostBlood), 0] != 2) then {
|
|
_unit setVariable [QGVAR(hasLostBlood), 2, true];
|
|
};
|
|
} else {
|
|
if (_unit getVariable [QGVAR(hasLostBlood), 0] != 1) then {
|
|
_unit setVariable [QGVAR(hasLostBlood), 1, true];
|
|
};
|
|
};
|
|
} else {
|
|
if (_unit getVariable [QGVAR(hasLostBlood), 0] != 0) then {
|
|
_unit setVariable [QGVAR(hasLostBlood), 0, true];
|
|
};
|
|
};
|
|
|
|
private _bloodLoss = _unit call FUNC(getBloodLoss);
|
|
if (_bloodLoss > 0) then {
|
|
_unit setVariable [QGVAR(bloodloss), _bloodLoss, _syncValues];
|
|
|
|
[QGVAR(Injury), _unit] call CBA_fnc_localEvent;
|
|
|
|
if !(_unit getVariable [QGVAR(isBleeding), false]) then {
|
|
_unit setVariable [QGVAR(isBleeding), true, true];
|
|
};
|
|
} else {
|
|
if (_unit getVariable [QGVAR(isBleeding), false]) then {
|
|
_unit setVariable [QGVAR(isBleeding), false, true];
|
|
};
|
|
};
|
|
|
|
private _painLevel = [_unit] call FUNC(getPainLevel);
|
|
if (_painLevel > 0) then {
|
|
if !(_unit getVariable [QGVAR(hasPain), false]) then {
|
|
_unit setVariable [QGVAR(hasPain), true, true];
|
|
};
|
|
} else {
|
|
if (_unit getVariable [QGVAR(hasPain), false]) then {
|
|
_unit setVariable [QGVAR(hasPain), false, true];
|
|
};
|
|
};
|
|
|
|
// Handle pain due tourniquets, that have been applied more than 120 s ago
|
|
private _tourniquetPain = 0;
|
|
private _tourniquets = _unit getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]];
|
|
{
|
|
if (_x > 0 && {CBA_missionTime - _x > 120}) then {
|
|
_tourniquetPain = _tourniquetPain max (CBA_missionTime - _x - 120) * 0.001;
|
|
};
|
|
} forEach _tourniquets;
|
|
[_unit, _tourniquetPain] call FUNC(adjustPainLevel);
|
|
|
|
private _heartRate = [_unit, _deltaT, _syncValues] call FUNC(updateHeartRate);
|
|
[_unit, _deltaT, _syncValues] call FUNC(updatePainSuppress);
|
|
[_unit, _deltaT, _syncValues] call FUNC(updatePeripheralResistance);
|
|
|
|
private _bloodPressure = [_unit] call FUNC(getBloodPressure);
|
|
_unit setVariable [QGVAR(bloodPressure), _bloodPressure, _syncValues];
|
|
|
|
private _cardiacOutput = [_unit] call FUNC(getCardiacOutput);
|
|
if (_bloodLoss > BLOOD_LOSS_KNOCK_OUT_THRESHOLD * _cardiacOutput) then {
|
|
[QGVAR(CriticalVitals), _unit] call CBA_fnc_localEvent;
|
|
};
|
|
|
|
#ifdef DEBUG_MODE_FULL
|
|
if (!isPlayer _unit) then {
|
|
hintSilent format["blood volume: %1, blood loss: [%2, %3]\nhr: %4, bp: %5, pain: %6", round(_bloodVolume * 100) / 100, round(_bloodLoss * 1000) / 1000, round((_bloodLoss / (0.001 max _cardiacOutput)) * 100) / 100, round(_heartRate), _bloodPressure, round(_painLevel * 100) / 100];
|
|
};
|
|
#endif
|
|
|
|
_bloodPressure params ["_bloodPressureL", "_bloodPressureH"];
|
|
if (_bloodPressureL < 40 || {_heartRate < 30}) then {
|
|
[QGVAR(CriticalVitals), _unit] call CBA_fnc_localEvent;
|
|
};
|
|
if ((_heartRate < 20) || {_heartRate > 220} || {_bloodPressureH < 50}) then {
|
|
[QGVAR(FatalVitals), _unit] call CBA_fnc_localEvent;
|
|
};
|
|
|
|
END_COUNTER(Vitals);
|