ACE3/addons/medical_treatment/functions/fnc_medicationLocal.sqf

79 lines
3.7 KiB
Plaintext
Raw Normal View History

Medical Treatment - Modernize and Cleanup (#6933) * Modernize and cleanup medical_treatment * One line for each old public function * Fix litterCleanupDelay name * Improve adjustment calcs / wound blood loss / medications fix func descriptions Calc wound blood loss on events reorder includes so scritpmacroMed has global effect trivial optimization for getCardiacOutput Fix var Fix wounds not reopening (nil _category) Fix surgical kit inherting canBandage conditional debug hitpoints Update ACE_Medical_Treatment_Actions.hpp Use woundBleeding for IS_BLEEDING macro rework medication vars comments Reset var in init / fullHeal Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * Change wound data array Drop unique id and merge classId and category * Splinting and treatment and gui * Add arm fractures and aim effects * localizations and event * fix * fix merge for renamed files * Fixes and code review changes * Move medical logs clearing to treatment * More cleanup work * cleanup * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * formating, rename bone images * Fix args for setDead call in actionPlaceInBodyBag * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * disable calls to extension * Update fnc_onMedicationUsage.sqf * Medical - Skip unneeded setVars on initUnit (#6949) * Medical - Transfer state machine state on locality (#6950) * Medical - Transfer state machine state on locality * Fix feedback isUnconscious var * Exclude AI * Make UAV excludes consistant, formating * Update fnc_treatmentFullHealLocal.sqf * reset fractures on respawn * Fix merge * Add PAK time coefficient setting * Fix medication * Add ace_medical_replacementItems config array * checkItems performance improvement * Treatment - cap max animation speed (#6995) * Treatment - cap max animation speed and add lock to prevent AF from reseting anim * Update fnc_getBandageTime.sqf * Use local version of setAnimSpeedCoef * Revert "Use local version of setAnimSpeedCoef" This reverts commit 36c22a90473fd0670ab97f3a373e4ae08493ff52. * Move replacementItems compiling to preInit * Improve replacementItems compiling * Cleanup splint functions, use macros for fractures * Rename splintCondition to canSplint * Add cprCreatesPulse setting * Cleanup remaining functions * Capitalize stringtable entry names * getStitchTime function and fix treatment locations * Update addons/medical_treatment/functions/fnc_getHealTime.sqf Co-Authored-By: SilentSpike <silentspike100+Github@gmail.com>
2019-06-03 15:31:46 +00:00
#include "script_component.hpp"
/*
* Author: Glowbal, mharis001
* Local callback for administering medication to a patient.
*
* Arguments:
* 0: Patient <OBJECT>
* 1: Body Part <STRING>
* 2: Treatment <STRING>
*
* Return Value:
* None
*
* Example:
* [player, "RightArm", "Morphine"] call ace_medical_treatment_fnc_medicationLocal
*
* Public: No
*/
// todo: move this macro to script_macros_medical.hpp?
#define MORPHINE_PAIN_SUPPRESSION 0.6
params ["_patient", "_bodyPart", "_classname"];
TRACE_3("medicationLocal",_patient,_bodyPart,_classname);
// Medication has no effects on dead units
if (!alive _patient) exitWith {};
// Exit with basic medication handling if advanced medication not enabled
if (!GVAR(advancedMedication)) exitWith {
switch (_classname) do {
case "Morphine": {
private _painSuppress = GET_PAIN_SUPPRESS(_patient);
_patient setVariable [VAR_PAIN_SUPP, (_painSuppress + MORPHINE_PAIN_SUPPRESSION) min 1, true];
};
case "Epinephrine": {
[QEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent;
};
};
};
TRACE_1("Running treatmentMedicationLocal with Advanced configuration for",_patient);
Medical Treatment - Modernize and Cleanup (#6933) * Modernize and cleanup medical_treatment * One line for each old public function * Fix litterCleanupDelay name * Improve adjustment calcs / wound blood loss / medications fix func descriptions Calc wound blood loss on events reorder includes so scritpmacroMed has global effect trivial optimization for getCardiacOutput Fix var Fix wounds not reopening (nil _category) Fix surgical kit inherting canBandage conditional debug hitpoints Update ACE_Medical_Treatment_Actions.hpp Use woundBleeding for IS_BLEEDING macro rework medication vars comments Reset var in init / fullHeal Update addons/medical_treatment/functions/fnc_onMedicationUsage.sqf Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * Change wound data array Drop unique id and merge classId and category * Splinting and treatment and gui * Add arm fractures and aim effects * localizations and event * fix * fix merge for renamed files * Fixes and code review changes * Move medical logs clearing to treatment * More cleanup work * cleanup * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * formating, rename bone images * Fix args for setDead call in actionPlaceInBodyBag * Apply suggestions from code review Co-Authored-By: PabstMirror <pabstmirror@gmail.com> * disable calls to extension * Update fnc_onMedicationUsage.sqf * Medical - Skip unneeded setVars on initUnit (#6949) * Medical - Transfer state machine state on locality (#6950) * Medical - Transfer state machine state on locality * Fix feedback isUnconscious var * Exclude AI * Make UAV excludes consistant, formating * Update fnc_treatmentFullHealLocal.sqf * reset fractures on respawn * Fix merge * Add PAK time coefficient setting * Fix medication * Add ace_medical_replacementItems config array * checkItems performance improvement * Treatment - cap max animation speed (#6995) * Treatment - cap max animation speed and add lock to prevent AF from reseting anim * Update fnc_getBandageTime.sqf * Use local version of setAnimSpeedCoef * Revert "Use local version of setAnimSpeedCoef" This reverts commit 36c22a90473fd0670ab97f3a373e4ae08493ff52. * Move replacementItems compiling to preInit * Improve replacementItems compiling * Cleanup splint functions, use macros for fractures * Rename splintCondition to canSplint * Add cprCreatesPulse setting * Cleanup remaining functions * Capitalize stringtable entry names * getStitchTime function and fix treatment locations * Update addons/medical_treatment/functions/fnc_getHealTime.sqf Co-Authored-By: SilentSpike <silentspike100+Github@gmail.com>
2019-06-03 15:31:46 +00:00
// Handle tourniquet on body part blocking blood flow at injection site
private _partIndex = ALL_BODY_PARTS find toLower _bodyPart;
if (HAS_TOURNIQUET_APPLIED_ON(_patient,_partIndex)) exitWith {
TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets);
private _occludedMedications = _patient getVariable [QEGVAR(medical,occludedMedications), []];
_occludedMedications pushBack [_partIndex, _classname];
_patient setVariable [QEGVAR(medical,occludedMedications), _occludedMedications, true];
};
// Get adjustment attributes for used medication
private _defaultConfig = configFile >> QUOTE(ADDON) >> "Medication";
private _medicationConfig = _defaultConfig >> _classname;
private _painReduce = GET_NUMBER(_medicationConfig >> "painReduce",getNumber (_defaultConfig >> "painReduce"));
private _timeInSystem = GET_NUMBER(_medicationConfig >> "timeInSystem",getNumber (_defaultConfig >> "timeInSystem"));
private _timeTillMaxEffect = GET_NUMBER(_medicationConfig >> "timeTillMaxEffect",getNumber (_defaultConfig >> "timeTillMaxEffect"));
private _maxDose = GET_NUMBER(_medicationConfig >> "maxDose",getNumber (_defaultConfig >> "maxDose"));
private _viscosityChange = GET_NUMBER(_medicationConfig >> "viscosityChange",getNumber (_defaultConfig >> "viscosityChange"));
private _hrIncreaseLow = GET_ARRAY(_medicationConfig >> "hrIncreaseLow",getArray (_defaultConfig >> "hrIncreaseLow"));
private _hrIncreaseNormal = GET_ARRAY(_medicationConfig >> "hrIncreaseNormal",getArray (_defaultConfig >> "hrIncreaseNormal"));
private _hrIncreaseHigh = GET_ARRAY(_medicationConfig >> "hrIncreaseHigh",getArray (_defaultConfig >> "hrIncreaseHigh"));
private _incompatibleMedication = GET_ARRAY(_medicationConfig >> "incompatibleMedication",getArray (_defaultConfig >> "incompatibleMedication"));
private _heartRate = GET_HEART_RATE(_patient);
private _hrIncrease = [_hrIncreaseLow, _hrIncreaseNormal, _hrIncreaseHigh] select (floor ((0 max _heartRate min 110) / 55));
_hrIncrease params ["_minIncrease", "_maxIncrease"];
private _heartRateChange = _minIncrease + random (_maxIncrease - _minIncrease);
// Adjust the medication effects and add the medication to the list
TRACE_3("adjustments",_heartRateChange,_painReduce,_viscosityChange);
[_patient, _className, _timeTillMaxEffect, _timeInSystem, _heartRateChange, _painReduce, _viscosityChange] call EFUNC(medical_status,addMedicationAdjustment);
// Check for medication compatiblity
[_patient, _className, _maxDose, _incompatibleMedication] call FUNC(onMedicationUsage);