More cleanup work

This commit is contained in:
mharis001
2019-04-26 16:41:30 -04:00
parent 9fa0b8bea1
commit 5db1a8671e
19 changed files with 288 additions and 254 deletions

View File

@ -267,11 +267,11 @@ class GVAR(actions) {
medicRequired = 0;
treatmentTime = 15;
items[] = {};
condition = QUOTE(!(_patient call EFUNC(common,isAwake)) && {!(_patient getVariable [ARR_2('GVAR(receiveCPR)', false)])});
callbackSuccess = QFUNC(treatmentCPR);
callbackFailure = QFUNC(treatmentCPR_failure);
callbackProgress = QFUNC(treatmentCPR_progress);
callbackStart = QFUNC(treatmentCPR_start);
condition = QFUNC(canCPR);
callbackSuccess = QFUNC(cpr);
callbackFailure = QFUNC(cprFailure);
callbackProgress = QFUNC(cprProgress);
callbackStart = QFUNC(cprStart);
animationMedic = "AinvPknlMstpSlayW[wpn]Dnon_medic";
animationMedicProne = "AinvPpneMstpSlayW[wpn]Dnon_medic";
animationMedicSelf = "";
@ -307,7 +307,7 @@ class GVAR(actions) {
treatmentLocations = QGVAR(locationPAK);
medicRequired = QGVAR(medicPAK);
treatmentTime = QUOTE(_patient call FUNC(healTime));
callbackSuccess = QFUNC(treatmentFullHeal);
callbackSuccess = QFUNC(fullHeal);
consumeItem = QGVAR(consumePAK);
animationMedic = "AinvPknlMstpSlayW[wpn]Dnon_medicOther";
animationMedicProne = "AinvPpneMstpSlayW[wpn]Dnon_medicOther";

View File

@ -20,13 +20,13 @@ PREP(treatmentSuccess);
PREP(bandage);
PREP(bandageLocal);
PREP(treatmentCPR);
PREP(treatmentCPR_failure);
PREP(treatmentCPR_progress);
PREP(treatmentCPR_start);
PREP(treatmentCPRLocal);
PREP(treatmentFullHeal);
PREP(treatmentFullHealLocal);
PREP(cpr);
PREP(cprFailure);
PREP(cprLocal);
PREP(cprProgress);
PREP(cprStart);
PREP(fullHeal);
PREP(fullHealLocal);
PREP(ivBag);
PREP(ivBagLocal);
PREP(medication);
@ -46,6 +46,7 @@ PREP(addToTriageCard);
PREP(bodyCleanupLoop);
PREP(calculateBlood);
PREP(canBandage);
PREP(canCPR);
PREP(canStitch);
PREP(findMostEffectiveWound);
PREP(getBandageTime);

View File

@ -21,20 +21,20 @@ if (isServer) then {
["ace_placedInBodyBag", FUNC(serverRemoveBody)] call CBA_fnc_addEventHandler;
};
// treatment events
// Treatment events
[QGVAR(bandageLocal), FUNC(bandageLocal)] call CBA_fnc_addEventHandler;
[QGVAR(tourniquetLocal), FUNC(tourniquetLocal)] call CBA_fnc_addEventHandler;
[QGVAR(medicationLocal), FUNC(medicationLocal)] call CBA_fnc_addEventHandler;
[QGVAR(ivBagLocal), FUNC(ivBagLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentFullHealLocal), FUNC(treatmentFullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(cprLocal), FUNC(cprLocal)] call CBA_fnc_addEventHandler;
[QGVAR(fullHealLocal), FUNC(fullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(splintLocal), FUNC(splintLocal)] call CBA_fnc_addEventHandler;
// action events
// Action events
[QGVAR(checkPulseLocal), FUNC(checkPulseLocal)] call CBA_fnc_addEventHandler;
[QGVAR(checkBloodPressureLocal), FUNC(checkBloodPressureLocal)] call CBA_fnc_addEventHandler;
[QGVAR(actionPlaceInBodyBag), FUNC(actionPlaceInBodyBag)] call CBA_fnc_addEventHandler;
// log events
// Log events
[QGVAR(addToMedicalLog), FUNC(addToLog)] call CBA_fnc_addEventHandler;
[QGVAR(addToTriageCard), FUNC(addToTriageCard)] call CBA_fnc_addEventHandler;

View File

@ -0,0 +1,21 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Checks if CPR can be performed on the patient.
*
* Arguments:
* 0: Medic (not used) <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* Can CPR <BOOL>
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_canCPR
*
* Public: No
*/
params ["", "_patient"];
!(_patient call EFUNC(common,isAwake)) && {!(_patient getVariable [QGVAR(isReceivingCPR), false])}

View File

@ -1,11 +1,11 @@
#include "script_component.hpp"
/*
* Author: Katalam
* Prevents stitch actions from showing if the body is either fully stitched or has no open wounds.
* Checks if the patient can be stitched.
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 0: Medic (not used) <OBJECT>
* 1: Patient <OBJECT>
*
* ReturnValue:
* Can Stitch <BOOL>

View File

@ -0,0 +1,27 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Handles finishing performing CPR on the patient.
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_cpr
*
* Public: No
*/
params ["_medic", "_patient"];
_patient setVariable [QGVAR(isReceivingCPR), false, true];
_patient setVariable [VAR_HEART_RATE, 0, true];
_patient call FUNC(calculateBlood);
if (alive _patient && {IN_CRDC_ARRST(_patient)}) then {
[QGVAR(cprLocal), [_medic, _patient], _patient] call CBA_fnc_targetEvent;
};

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: Zakant
* Handles failure of the CPR treatment.
*
* Arguments:
* 0: Medic (not used) <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_cprFailure
*
* Public: No
*/
params ["", "_patient"];
if (!(_patient call EFUNC(common,isAwake)) || {IN_CRDC_ARRST(_patient)}) then {
_patient setVariable [VAR_HEART_RATE, 0, true];
};
// Patient is no longer receiving CPR
_patient setVariable [QGVAR(isReceivingCPR), false, true];
_patient call FUNC(calculateBlood);

View File

@ -0,0 +1,25 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Local callback for finishing performing CPR on the patient.
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_cprLocal
*
* Public: No
*/
params ["_medic", "_patient"];
[_patient, "activity", LSTRING(Activity_CPR), [[_medic, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
if (random 1 >= 0.6) then {
[QEGVAR(medical,CPRSucceeded), _patient] call CBA_fnc_localEvent;
};

View File

@ -0,0 +1,29 @@
#include "script_component.hpp"
/*
* Author: Zakant
* Handles the progress of the CPR treatment.
*
* Arguments:
* 0: Arguments <ARRAY>
* 0: Medic (not used) <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* Continue CPR <BOOL>
*
* Example:
* [[player, cursorObject]] call ace_medical_treatment_fnc_cprProgress
*
* Public: No
*/
params ["_args"];
_args params ["", "_patient"];
// Cancel CPR is patient wakes up
if (_patient getVariable EFUNC(common,isAwake) || {!IN_CRDC_ARRST(_patient)}) exitWith {false};
// Calculate blood volume, if there is no pulse nothing happens
_patient call FUNC(calculateBlood);
true

View File

@ -0,0 +1,29 @@
#include "script_component.hpp"
/*
* Author: Zakant
* Handles starting the CPR treatment.
*
* Arguments:
* 0: Medic (not used) <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_cprStart
*
* Public: No
*/
params ["", "_patient"];
// Prevent others from performing CPR
_patient setVariable [QGVAR(isReceivingCPR), true, true];
// Create a random pulse based on setting
if (GVAR(cprCreatesPulse) && {GET_HEART_RATE(_patient) == 0}) then {
_patient setVariable [VAR_HEART_RATE, round random [25, 30, 35], true];
};
_patient setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime, true];

View File

@ -0,0 +1,23 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Fully heals the patient.
*
* Arguments:
* 0: Medic <OBJECT>
* 1: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_medical_treatment_fnc_fullHeal
*
* Public: No
*/
params ["_medic", "_patient"];
[_patient, "activity", LSTRING(Activity_fullHeal), [[_medic, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[QGVAR(fullHealLocal), _patient, _patient] call CBA_fnc_targetEvent;

View File

@ -0,0 +1,84 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Local callback for fully healing a patient.
*
* Arguments:
* 0: Patient <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_medical_treatment_fnc_fullHealLocal
*
* Public: No
*/
params ["_patient"];
if (!alive _patient) exitWith {};
// Treatment conditions would normally limit full heal to non-unconscious units
// However, this may be called externally (through Zeus)
if IN_CRDC_ARRST(_patient) then {
TRACE_1("Exiting cardiac arrest",_patient);
[QEGVAR(medical,CPRSucceeded), _patient] call CBA_fnc_localEvent;
};
if IS_UNCONSCIOUS(_patient) then {
TRACE_1("Waking up",_patient);
// Wake patient up first or unconscious variables will be reset
[QEGVAR(medical,WakeUp), _patient] call CBA_fnc_localEvent;
};
_patient setVariable [VAR_PAIN, 0, true];
_patient setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];
// Tourniquets
_patient setVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES, true];
_patient setVariable [QGVAR(occludedMedications), nil, true];
// Wounds and Injuries
_patient setVariable [QEGVAR(medical,openWounds), [], true];
_patient setVariable [QEGVAR(medical,bandagedWounds), [], true];
_patient setVariable [QEGVAR(medical,stitchedWounds), [], true];
_patient setVariable [QEGVAR(medical,isLimping), false, true];
_patient setVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0], true];
// Update wound bleeding
[_patient] call EFUNC(medical_status,updateWoundBloodLoss);
// Vitals
_patient setVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE, true];
_patient setVariable [VAR_BLOOD_PRESS, [80, 120], true];
_patient setVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES, true];
// IVs
_patient setVariable [QEGVAR(medical,ivBags), nil, true];
// Damage storage
_patient setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true];
#ifdef DEBUG_TESTRESULTS
_patient setVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0], true];
#endif
// Generic medical admin
_patient setVariable [VAR_CRDC_ARRST, false, true];
_patient setVariable [VAR_UNCON, false, true];
_patient setVariable [VAR_HEMORRHAGE, 0, true];
_patient setVariable [VAR_IN_PAIN, false, true];
_patient setVariable [VAR_PAIN_SUPP, 0, true];
// Medication
_patient setVariable [VAR_MEDICATIONS, [], true];
// Reset triage card since medication is reset
_patient setVariable [QEGVAR(medical,triageCard), [], true];
[_patient] call EFUNC(medical_engine,updateDamageEffects);
// Reset damage
_patient setDamage 0;
[QEGVAR(medical,FullHeal), _patient] call CBA_fnc_localEvent;

View File

@ -1,30 +0,0 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Callback for the CPR treatment action on success.
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 2: Body part <STRING>
* 3: Treatment class name <STRING>
*
* Return Value:
* Succesful treatment started <BOOL>
*
* Public: No
*/
params ["_caller", "_target", "_selectionName", "_className", "_items"];
_target setVariable [VAR_HEART_RATE, 0, true];
_target setVariable [QGVAR(receiveCPR), false, true]; // CPR finished
[_target] call FUNC(calculateBlood);
if (alive _target && {IN_CRDC_ARRST(_target)}) then {
[_target, "activity_view", ELSTRING(medical_treatment,Activity_cpr), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[QGVAR(treatmentCPRLocal), [_caller, _target], _target] call CBA_fnc_targetEvent;
};
true

View File

@ -1,25 +0,0 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* local Callback for the CPR treatment action on success.
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
*
* Return Value:
* Succesful treatment started <BOOL>
*
* Public: No
*/
params ["_caller", "_target"];
if ((random 1) >= 0.6) then {
[QEGVAR(medical,CPRSucceeded), _target] call CBA_fnc_localEvent;
};
[_target, "activity", ELSTRING(medical_treatment,Activity_CPR), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[_target, "activity_view", ELSTRING(medical_treatment,Activity_CPR), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message
true

View File

@ -1,22 +0,0 @@
#include "script_component.hpp"
/*
* Author: Zakant
* Handles the failure of the CPR treatment.
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
params ["_caller", "_target"];
if (!(_target call EFUNC(common,isAwake)) || {IN_CRDC_ARRST(_target)}) then {
_target setVariable [VAR_HEART_RATE, 0, true];
};
_target setVariable [QGVAR(receiveCPR), false, true];
[_target] call FUNC(calculateBlood);

View File

@ -1,28 +0,0 @@
#include "script_component.hpp"
/*
* Author: Zakant
* Handles the progress of the CPR treatment.
*
* Arguments:
* 0: Arguments <ARRAY>
* 0: Caller <OBJECT>
* 1: Target <OBJECT>
* 1: Elapsed Time <NUMBER>
* 2: Total Time <NUMBER>
*
* Return Value:
* May Treatment continue <BOOL>
*
* Public: No
*/
params ["_args", "_elapsedTime", "_totalTime"];
_args params ["_caller", "_target"];
// If the patient awakes by mysterious force, no cpr is needed!
if (_target call EFUNC(common,isAwake)) exitWith {false};
if !IN_CRDC_ARRST(_target) exitWith {false};
[_target] call FUNC(calculateBlood); // Calculate blood volume. If their is no pulse, nothing happens!
true

View File

@ -1,23 +0,0 @@
#include "script_component.hpp"
/*
* Author: Zakant
* Handles the start of the CPR treatment.
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
*
* Return Value:
* None
*
* Public: No
*/
params ["_caller", "_target"];
_target setVariable [QGVAR(receiveCPR), true, true]; // Target receives CPR
if (EGVAR(medical,CPRcreatesPulse) && {GET_HEART_RATE(_target) == 0}) then {
_target setVariable [VAR_HEART_RATE, round (30 + random [-5, 0, 5]) , true]; // And we have a (random) pulse
};
_target setVariable [QEGVAR(medical,lastTimeUpdated), CBA_missionTime, true];

View File

@ -1,26 +0,0 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Full heal treatment
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 2: Body part <STRING>
* 3: Treatment class name <STRING>
* 4: Item <STRING>
*
* Return Value:
* Succesful treatment started <BOOL>
*
* Public: No
*/
params ["_caller", "_target"];
[QGVAR(treatmentFullHealLocal), [_target], _target] call CBA_fnc_targetEvent;
[_target, "activity", ELSTRING(medical_treatment,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[_target, "activity_view", ELSTRING(medical_treatment,Activity_fullHeal), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message
true

View File

@ -1,79 +0,0 @@
#include "script_component.hpp"
/*
* Author: Glowbal
* Handles full heal of a patient.
*
* Arguments:
* 0: The patient <OBJECT>
*
* Return Value:
* Succesful treatment started <BOOL>
*
* Public: No
*/
params ["_target"];
if (!alive _target) exitWith {};
// Treatment conditions would normally limit this to non-unconc units, but treatment event may be called externally (zeus)
if (_target getVariable [QEGVAR(medical,inCardiacArrest), false]) then {
TRACE_1("exiting cardiac arrest",_target);
[QEGVAR(medical,CPRSucceeded), _target] call CBA_fnc_localEvent;
};
if (_target getVariable ["ACE_isUnconscious",false]) then {
TRACE_1("waking up",_target); // wake up first or unconc variables will be reset
[QEGVAR(medical,WakeUp), _target] call CBA_fnc_localEvent;
};
_target setVariable [VAR_PAIN, 0, true];
_target setVariable [VAR_BLOOD_VOL, DEFAULT_BLOOD_VOLUME, true];
// tourniquets
_target setVariable [VAR_TOURNIQUET, DEFAULT_TOURNIQUET_VALUES, true];
_target setVariable [QGVAR(occludedMedications), nil, true];
// wounds and injuries
_target setVariable [QEGVAR(medical,openWounds), [], true];
_target setVariable [QEGVAR(medical,bandagedWounds), [], true];
_target setVariable [QEGVAR(medical,stitchedWounds), [], true];
_target setVariable [QEGVAR(medical,isLimping), false, true];
_target setVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0], true];
// - Update wound bleeding
[_target] call EFUNC(medical_status,updateWoundBloodLoss);
// vitals
_target setVariable [VAR_HEART_RATE, DEFAULT_HEART_RATE, true];
_target setVariable [VAR_BLOOD_PRESS, [80, 120], true];
_target setVariable [VAR_PERIPH_RES, DEFAULT_PERIPH_RES, true];
// IVs
_target setVariable [QEGVAR(medical,ivBags), nil, true];
// damage storage
_target setVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0], true];
#ifdef DEBUG_TESTRESULTS
_target setVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0], true];
#endif
// generic medical admin
_target setVariable [VAR_CRDC_ARRST, false, true];
_target setVariable [VAR_UNCON, false, true];
_target setVariable [VAR_HEMORRHAGE, 0, true];
_target setVariable [VAR_IN_PAIN, false, true];
_target setVariable [VAR_PAIN_SUPP, 0, true];
// medication
_target setVariable [VAR_MEDICATIONS, [], true];
// Reset triage card since medication is all reset
_target setVariable [QEGVAR(medical,triageCard), [], true];
[_target] call EFUNC(medical_engine,updateDamageEffects);
// Resetting damage
_target setDamage 0;
[QEGVAR(medical,FullHeal), _target] call CBA_fnc_localEvent;