From 5613ec5d5a5b988d51c8d75df43fcdc9d5192dcf Mon Sep 17 00:00:00 2001 From: commy2 Date: Thu, 6 Oct 2016 00:54:57 +0200 Subject: [PATCH] treatment functions and unconsciousness rework --- addons/common/XEH_PREP.hpp | 1 + addons/common/functions/fnc_doAnimation.sqf | 17 +--- addons/common/functions/fnc_getAwakeAnim.sqf | 49 ++++++++++ addons/dragging/XEH_postInit.sqf | 10 +- .../functions/fnc_handleUnconscious.sqf | 14 ++- addons/medical/ACE_Settings.hpp | 7 -- addons/medical/XEH_PREP.hpp | 3 +- addons/medical/XEH_postInit.sqf | 1 + .../medical/functions/fnc_addDamageToUnit.sqf | 20 ++-- addons/medical/functions/fnc_handleLocal.sqf | 2 +- .../functions/fnc_hasTourniquetAppliedTo.sqf | 7 +- .../functions/fnc_selectionNameToNumber.sqf | 16 ---- .../medical/functions/fnc_setUnconscious.sqf | 92 +++++++------------ addons/medical/script_component.hpp | 2 + addons/medical/stringtable.xml | 23 ----- addons/medical_ai/XEH_postInit.sqf | 4 +- addons/medical_ai/functions/fnc_healSelf.sqf | 4 +- addons/medical_ai/functions/fnc_healUnit.sqf | 4 +- addons/medical_ai/script_component.hpp | 2 + addons/medical_blood/script_component.hpp | 2 +- .../functions/fnc_airwayHandler.sqf | 11 +-- .../functions/fnc_fracturesHandler.sqf | 24 ++--- .../functions/fnc_internalInjuriesHandler.sqf | 8 +- .../functions/fnc_woundsHandler.sqf | 4 - .../functions/fnc_woundsHandlerSQF.sqf | 13 +-- addons/medical_damage/script_component.hpp | 2 +- .../medical_engine/CfgExtendedAnimation.hpp | 10 ++ addons/medical_engine/CfgMoves.hpp | 10 +- addons/medical_engine/XEH_PREP.hpp | 1 + addons/medical_engine/XEH_postInit.sqf | 10 ++ addons/medical_engine/config.cpp | 1 + .../functions/fnc_setUnconsciousAnim.sqf | 55 +++++++++++ .../functions/fnc_collectActions.sqf | 8 +- .../functions/fnc_collectActions3D.sqf | 22 ++--- addons/medical_menu/script_component.hpp | 2 + .../ACE_Medical_Treatment_Actions.hpp | 44 ++++----- addons/medical_treatment/XEH_PREP.hpp | 55 ++++++----- addons/medical_treatment/XEH_postInit.sqf | 15 ++- .../functions/fnc_actionRemoveTourniquet.sqf | 16 ++-- .../functions/fnc_canTreat.sqf | 8 +- .../functions/fnc_treatment.sqf | 2 + .../fnc_treatmentAdvanced_fullHeal.sqf | 21 ----- ...d_bandage.sqf => fnc_treatmentBandage.sqf} | 19 ++-- ...ocal.sqf => fnc_treatmentBandageLocal.sqf} | 45 +++++---- .../functions/fnc_treatmentBasic_bloodbag.sqf | 25 ----- .../functions/fnc_treatmentBloodbag.sqf | 21 +++++ ...cal.sqf => fnc_treatmentBloodbagLocal.sqf} | 0 ...tAdvanced_CPR.sqf => fnc_treatmentCPR.sqf} | 13 +-- ...CPRLocal.sqf => fnc_treatmentCPRLocal.sqf} | 5 +- ...sic_epipen.sqf => fnc_treatmentEpipen.sqf} | 6 +- .../functions/fnc_treatmentFullHeal.sqf | 23 +++++ ...cal.sqf => fnc_treatmentFullHealLocal.sqf} | 21 +++-- ...=> fnc_treatmentFullHealTreatmentTime.sqf} | 8 +- .../functions/fnc_treatmentIV.sqf | 7 +- .../functions/fnc_treatmentIVLocal.sqf | 1 + ...cation.sqf => fnc_treatmentMedication.sqf} | 16 ++-- ...l.sqf => fnc_treatmentMedicationLocal.sqf} | 16 +++- ...morphine.sqf => fnc_treatmentMorphine.sqf} | 12 +-- ...cal.sqf => fnc_treatmentMorphineLocal.sqf} | 5 +- ...> fnc_treatmentSurgicalKit_onProgress.sqf} | 2 +- .../functions/fnc_treatmentTourniquet.sqf | 28 +++--- .../fnc_treatmentTourniquetLocal.sqf | 9 +- .../functions/fnc_treatment_success.sqf | 10 +- addons/medical_treatment/script_component.hpp | 5 +- 64 files changed, 495 insertions(+), 424 deletions(-) create mode 100644 addons/common/functions/fnc_getAwakeAnim.sqf delete mode 100644 addons/medical/functions/fnc_selectionNameToNumber.sqf create mode 100644 addons/medical_engine/CfgExtendedAnimation.hpp create mode 100644 addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf delete mode 100644 addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHeal.sqf rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_bandage.sqf => fnc_treatmentBandage.sqf} (58%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_bandageLocal.sqf => fnc_treatmentBandageLocal.sqf} (83%) delete mode 100644 addons/medical_treatment/functions/fnc_treatmentBasic_bloodbag.sqf create mode 100644 addons/medical_treatment/functions/fnc_treatmentBloodbag.sqf rename addons/medical_treatment/functions/{fnc_treatmentBasic_bloodbagLocal.sqf => fnc_treatmentBloodbagLocal.sqf} (100%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_CPR.sqf => fnc_treatmentCPR.sqf} (67%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_CPRLocal.sqf => fnc_treatmentCPRLocal.sqf} (96%) rename addons/medical_treatment/functions/{fnc_treatmentBasic_epipen.sqf => fnc_treatmentEpipen.sqf} (72%) create mode 100644 addons/medical_treatment/functions/fnc_treatmentFullHeal.sqf rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_fullHealLocal.sqf => fnc_treatmentFullHealLocal.sqf} (92%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_fullHealTreatmentTime.sqf => fnc_treatmentFullHealTreatmentTime.sqf} (63%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_medication.sqf => fnc_treatmentMedication.sqf} (65%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_medicationLocal.sqf => fnc_treatmentMedicationLocal.sqf} (95%) rename addons/medical_treatment/functions/{fnc_treatmentBasic_morphine.sqf => fnc_treatmentMorphine.sqf} (51%) rename addons/medical_treatment/functions/{fnc_treatmentBasic_morphineLocal.sqf => fnc_treatmentMorphineLocal.sqf} (91%) rename addons/medical_treatment/functions/{fnc_treatmentAdvanced_surgicalKit_onProgress.sqf => fnc_treatmentSurgicalKit_onProgress.sqf} (91%) diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 1f6086b24e..14dc760a9e 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -45,6 +45,7 @@ PREP(fixFloating); PREP(fixLoweredRifleAnimation); PREP(fixPosition); PREP(getAllDefinedSetVariables); +PREP(getAwakeAnim); PREP(getDeathAnim); PREP(getDefaultAnim); PREP(getDefinedVariable); diff --git a/addons/common/functions/fnc_doAnimation.sqf b/addons/common/functions/fnc_doAnimation.sqf index 720518d003..d63526aee2 100644 --- a/addons/common/functions/fnc_doAnimation.sqf +++ b/addons/common/functions/fnc_doAnimation.sqf @@ -9,7 +9,6 @@ * 0 = PlayMove * 1 = PlayMoveNow * 2 = SwitchMove (no transitional animation, doesn't overwrite priority 1) - * 3: Force overwritting unconscious (default: false) * * Return Value: * None @@ -21,14 +20,8 @@ */ #include "script_component.hpp" -params ["_unit", "_animation", ["_priority", 0], ["_force", false]]; -TRACE_4("params",_unit,_animation,_priority,_force); - -// don't overwrite more important animations -if (_unit getVariable ["ACE_isUnconscious", false] && {(_animation != "Unconscious")} && {!_force}) exitWith {}; - -// don't go unconscious if the unit isn't unconscious -if (_animation == "Unconscious" && {!((_unit getVariable ["ACE_isUnconscious", false]) || (_unit getVariable ["ACE_isDead", false]))}) exitWith {}; +params ["_unit", "_animation", ["_priority", 0]]; +TRACE_4("params",_unit,_animation,_priority); // switchMove "" no longer works in dev 1.37 if (_animation == "") then { @@ -43,7 +36,7 @@ switch (_priority) do { if (_unit == vehicle _unit) then { [QGVAR(playMove), [_unit, _animation], _unit] call CBA_fnc_targetEvent; } else { - // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles. + // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have local effects when executed on remote machines inside vehicles. [QGVAR(playMove), [_unit, _animation]] call CBA_fnc_globalEvent; }; }; @@ -51,7 +44,7 @@ switch (_priority) do { if (_unit == vehicle _unit) then { [QGVAR(playMoveNow), [_unit, _animation], _unit] call CBA_fnc_targetEvent; } else { - // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles. + // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have local effects when executed on remote machines inside vehicles. [QGVAR(playMoveNow), [_unit, _animation]] call CBA_fnc_globalEvent; }; }; @@ -60,7 +53,7 @@ switch (_priority) do { if (_unit == vehicle _unit) then { [QGVAR(playMoveNow), [_unit, _animation], _unit] call CBA_fnc_targetEvent; } else { - // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have no global effects when executed on remote machines inside vehicles. + // Execute on all machines. PlayMove and PlayMoveNow are bugged: They have local effects when executed on remote machines inside vehicles. [QGVAR(playMoveNow), [_unit, _animation]] call CBA_fnc_globalEvent; }; diff --git a/addons/common/functions/fnc_getAwakeAnim.sqf b/addons/common/functions/fnc_getAwakeAnim.sqf new file mode 100644 index 0000000000..086be2106e --- /dev/null +++ b/addons/common/functions/fnc_getAwakeAnim.sqf @@ -0,0 +1,49 @@ +/* + * Author: commy2 + * Report awake animation of unit inside vehicle. + * + * Arguments: + * 0: The unit + * + * ReturnValue: + * The animtaion + * + * Example: + * player call ace_common_fnc_getAwakeAnim + * + * Public: no + */ +#include "script_component.hpp" + +params ["_unit"]; + +private _vehicle = vehicle _unit; + +// --- on foot +if (_vehicle isEqualTo _unit) exitWith {""}; + +// --- driver +private _config = configFile >> "CfgVehicles" >> typeOf _vehicle; + +if (_unit == driver _vehicle) exitWith { + getText (configFile >> "CfgMovesBasic" >> "ManActions" >> getText (_config >> "driverAction")) // return +}; + +// --- turret +private _turret = _unit call CBA_fnc_turretPath; + +if !(_turret isEqualTo []) exitWith { + private _turretConfig = [_vehicle, _turret] call CBA_fnc_getTurret; + + getText (configFile >> "CfgMovesBasic" >> "ManActions" >> getText (_turretConfig >> "gunnerAction")) // return +}; + +// --- cargo +private _cargoIndex = _vehicle getCargoIndex _unit; + +if (_cargoIndex != -1) exitWith { + getText (configFile >> "CfgMovesBasic" >> "ManActions" >> getArray (_config >> "cargoAction") select _cargoIndex) // return +}; + +// --- default +"" diff --git a/addons/dragging/XEH_postInit.sqf b/addons/dragging/XEH_postInit.sqf index 2dbf47f3cc..f2cb60c646 100644 --- a/addons/dragging/XEH_postInit.sqf +++ b/addons/dragging/XEH_postInit.sqf @@ -30,8 +30,7 @@ if (isNil "ACE_maxWeightCarry") then { //@todo Captivity? //Add Keybind: -["ACE3 Common", QGVAR(drag), (localize LSTRING(DragKeybind)), -{ +["ACE3 Common", QGVAR(drag), (localize LSTRING(DragKeybind)), { if (!alive ACE_player) exitWith {false}; if !([ACE_player, objNull, ["isNotDragging", "isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false}; @@ -51,7 +50,6 @@ if (isNil "ACE_maxWeightCarry") then { [ACE_player, _cursor] call FUNC(startDrag); false -}, -{false}, -[-1, [false, false, false]]] call CBA_fnc_addKeybind; // UNBOUND - +}, { + false +}, [-1, [false, false, false]]] call CBA_fnc_addKeybind; // UNBOUND diff --git a/addons/dragging/functions/fnc_handleUnconscious.sqf b/addons/dragging/functions/fnc_handleUnconscious.sqf index 2e891b01c6..387fe0a52b 100644 --- a/addons/dragging/functions/fnc_handleUnconscious.sqf +++ b/addons/dragging/functions/fnc_handleUnconscious.sqf @@ -29,10 +29,9 @@ if (_player getVariable [QGVAR(isDragging), false]) then { }; // handle waking up dragged unit - //if (_unit == _draggedObject) then { - // [_player, _draggedObject] call FUNC(dropObject); - //}; - + if (_unit == _draggedObject) then { + [_player, _draggedObject] call FUNC(dropObject); + }; }; if (_player getVariable [QGVAR(isCarrying), false]) then { @@ -45,8 +44,7 @@ if (_player getVariable [QGVAR(isCarrying), false]) then { }; // handle waking up dragged unit - //if (_unit == _carriedObject) then { - // [_player, _carriedObject] call FUNC(dropObject_carry); - //}; - + if (_unit == _carriedObject) then { + [_player, _carriedObject] call FUNC(dropObject_carry); + }; }; diff --git a/addons/medical/ACE_Settings.hpp b/addons/medical/ACE_Settings.hpp index 871607dcab..83496ab255 100644 --- a/addons/medical/ACE_Settings.hpp +++ b/addons/medical/ACE_Settings.hpp @@ -271,11 +271,4 @@ class ACE_Settings { values[] = {CSTRING(useSelection), CSTRING(useRadial), "Disabled"}; isClientSettable = 1; }; - class GVAR(delayUnconCaptive) { - category = CSTRING(Category_Medical); - displayName = CSTRING(MedicalSettings_delayUnconCaptive_DisplayName); - description = CSTRING(MedicalSettings_delayUnconCaptive_Description); - typeName = "SCALAR"; - value = 3; - }; }; diff --git a/addons/medical/XEH_PREP.hpp b/addons/medical/XEH_PREP.hpp index 2253bc32b5..c89997807c 100644 --- a/addons/medical/XEH_PREP.hpp +++ b/addons/medical/XEH_PREP.hpp @@ -15,7 +15,6 @@ PREP(isInMedicalVehicle); PREP(isInStableCondition); PREP(isMedic); PREP(isMedicalVehicle); -PREP(selectionNameToNumber); PREP(setHitPointDamage); PREP(setStructuralDamage); PREP(stateEvent); @@ -29,3 +28,5 @@ PREP(handleStateUnconscious); PREP(handleUnitVitals); PREP(handleMedications); // PREP(handleStateRevive); + +PREP(setUnconscious); diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 5e01a649da..0d0ad05c7e 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -14,6 +14,7 @@ if (isServer) then { ["ace_unconscious", { params ["_unit", "_status"]; + if (local _unit) then { if (_status) then { _unit setVariable ["tf_voiceVolume", 0, true]; diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index 1c3d06d215..a35f2a22fb 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -6,14 +6,14 @@ * Arguments: * 0: The Unit * 1: Damage to Add - * 2: Selection ("head", "body", "hand_l", "hand_r", "leg_l", "leg_r") + * 2: Body part ("Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg") * 3: Projectile Type * * Return Value: * HandleDamage's return * * Example: - * [player, 0.8, "leg_r", "bullet"] call ace_medical_fnc_addDamageToUnit + * [player, 0.8, "rightleg", "bullet"] call ace_medical_fnc_addDamageToUnit * [cursorTarget, 1, "body", "stab"] call ace_medical_fnc_addDamageToUnit * * Public: Yes @@ -22,16 +22,16 @@ // #define DEBUG_TESTRESULTS #include "script_component.hpp" -params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_selection", "", [""]], ["_typeOfDamage", "", [""]]]; -TRACE_4("params",_unit,_damageToAdd,_selection,_typeOfDamage); +params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]]]; +TRACE_4("params",_unit,_damageToAdd,_bodyPart,_typeOfDamage); -_selection = toLower _selection; -if ((isNull _unit) || {!local _unit} || {!alive _unit}) exitWith {ERROR_1("addDamageToUnit - badUnit %1", _this); -1}; +_bodyPart = toLower _bodyPart; +if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_1("addDamageToUnit - badUnit %1", _this); -1}; if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); -1}; -if (!(_selection in GVAR(SELECTIONS))) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); -1}; +if !(_bodyPart in ALL_BODY_PARTS) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); -1}; //Get the hitpoint and the index -private _hitpoint = [_unit, _selection, true] call ace_medical_fnc_translateSelections; +private _hitpoint = [_unit, _bodyPart, true] call ace_medical_fnc_translateSelections; (getAllHitPointsDamage _unit) params [["_allHitPoints", []]]; private _hitpointIndex = -1; { //case insensitive find @@ -43,7 +43,7 @@ private _currentDamage = _unit getHitIndex _hitpointIndex; #ifdef DEBUG_TESTRESULTS private _checkAtFrame = diag_frameno + 5; -private _partNumber = [_selection] call FUNC(selectionNameToNumber); +private _partNumber = ALL_BODY_PARTS find _bodyPart; private _startDmg = (_unit getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]) select _partNumber; private _debugCode = { params ["", "_unit", "_startDmg", "_damageToAdd", "_partNumber"]; @@ -57,7 +57,7 @@ private _debugCode = { [{diag_frameno > (_this select 0)}, _debugCode, [_checkAtFrame, _unit, _startDmg, _damageToAdd, _partNumber]] call CBA_fnc_waitUntilAndExecute; #endif -private _return = [_unit, _selection, (_currentDamage + _damageToAdd), _unit, _typeOfDamage, _hitpointIndex, objNull] call FUNC(handleDamage); +private _return = [_unit, _bodyPart, (_currentDamage + _damageToAdd), _unit, _typeOfDamage, _hitpointIndex, objNull] call FUNC(handleDamage); TRACE_1("handleDamage called",_return); _return diff --git a/addons/medical/functions/fnc_handleLocal.sqf b/addons/medical/functions/fnc_handleLocal.sqf index 56a1afca5c..fcb9227b64 100644 --- a/addons/medical/functions/fnc_handleLocal.sqf +++ b/addons/medical/functions/fnc_handleLocal.sqf @@ -26,7 +26,7 @@ if (_local) then { private _arguments = (_unit getVariable [QGVAR(unconsciousArguments), []]); _arguments set [2, CBA_missionTime]; - [DFUNC(unconsciousPFH), 0.1, _arguments ] call CBA_fnc_addPerFrameHandler; + //[DFUNC(unconsciousPFH), 0.1, _arguments ] call CBA_fnc_addPerFrameHandler; _unit setVariable [QGVAR(unconsciousArguments), nil, true]; }; diff --git a/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf b/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf index abbe512d74..b62e2b8416 100644 --- a/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf +++ b/addons/medical/functions/fnc_hasTourniquetAppliedTo.sqf @@ -4,16 +4,15 @@ * * Arguments: * 0: The Unit - * 1: SelectionName + * 1: Body Part * * ReturnValue: * Has tourniquet applied * * Public: Yes */ - #include "script_component.hpp" -params ["_target", "_selectionName"]; +params ["_target", "_bodyPart"]; -(((_target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]) select ([_selectionName] call FUNC(selectionNameToNumber))) > 0); +((_target getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]) select (ALL_BODY_PARTS find toLower _bodyPart)) > 0 diff --git a/addons/medical/functions/fnc_selectionNameToNumber.sqf b/addons/medical/functions/fnc_selectionNameToNumber.sqf deleted file mode 100644 index 1e8d79183f..0000000000 --- a/addons/medical/functions/fnc_selectionNameToNumber.sqf +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Author: Glowbal - * Get the number representation of a selection name. - * - * Arguments: - * 0: The selection name of a unit - * - * ReturnValue: - * Number representation. -1 if invalid. - * - * Public: yes - */ - -#include "script_component.hpp" - -(["head","body","hand_l","hand_r","leg_l","leg_r"] find (_this select 0)); diff --git a/addons/medical/functions/fnc_setUnconscious.sqf b/addons/medical/functions/fnc_setUnconscious.sqf index a697ae091a..369ca894d2 100644 --- a/addons/medical/functions/fnc_setUnconscious.sqf +++ b/addons/medical/functions/fnc_setUnconscious.sqf @@ -26,104 +26,82 @@ if !(EGVAR(common,settingsInitFinished)) exitWith { EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(setUnconscious), _this]; }; -private ["_animState", "_originalPos", "_startingTime", "_isDead"]; -params ["_unit", ["_set", true], ["_minWaitingTime", DEFAULT_DELAY], ["_force", false]]; +params ["_unit", ["_set", true], ["_minUnconsciousTime", DEFAULT_DELAY], ["_force", false]]; -// No change, fuck off. (why is there no xor?) if (_set isEqualTo (_unit getVariable ["ACE_isUnconscious", false])) exitWith {}; if !(_set) exitWith { _unit setVariable ["ACE_isUnconscious", false, true]; + if (_unit getVariable [QGVAR(inReviveState), false]) then { _unit setVariable [QGVAR(inReviveState), nil, true]; }; + + [_unit, false] call EFUNC(medical_engine,setUnconsciousAnim); + + ["ace_unconscious", [_unit, false]] call CBA_fnc_globalEvent; }; -if !(!(isNull _unit) && {(_unit isKindOf "CAManBase") && ([_unit] call EFUNC(common,isAwake))}) exitWith{}; +if (isNull _unit || {!(_unit isKindOf "CAManBase")}) exitWith {}; if (!local _unit) exitWith { - [QGVAR(setUnconscious), [_unit, _set, _minWaitingTime, _force], _unit] call CBA_fnc_targetEvent; + [QGVAR(setUnconscious), [_unit, _set, _minUnconsciousTime, _force], _unit] call CBA_fnc_targetEvent; }; _unit setVariable ["ACE_isUnconscious", true, true]; if (_unit == ACE_player) then { if (visibleMap) then {openMap false}; + while {dialog} do { closeDialog 0; }; }; // if we have unconsciousness for AI disabled, we will kill the unit instead -_isDead = false; +private _isDead = false; + if (!([_unit, GVAR(remoteControlledAI)] call EFUNC(common,isPlayer)) && !_force) then { _enableUncon = _unit getVariable [QGVAR(enableUnconsciousnessAI), GVAR(enableUnconsciousnessAI)]; + if (_enableUncon == 0 or {_enableUncon == 1 and (random 1) < 0.5}) then { [_unit, true] call FUNC(setDead); _isDead = true; }; }; + if (_isDead) exitWith {}; -// If a unit has the launcher out, it will sometimes start selecting the primairy weapon while unconscious, -// therefor we force it to select the primairy weapon before going unconscious -if ((vehicle _unit) isKindOf "StaticWeapon") then { - [_unit] call EFUNC(common,unloadPerson); -}; -if (animationState _unit in ["ladderriflestatic","laddercivilstatic"]) then { - _unit action ["ladderOff", (nearestBuilding _unit)]; -}; -if (vehicle _unit == _unit) then { - if (primaryWeapon _unit == "") then { - _unit addWeapon "ACE_FakePrimaryWeapon"; - }; - _unit selectWeapon (primaryWeapon _unit); -}; - -// We are storing the current animation, so we can use it later on when waking the unit up inside a vehicle -if (vehicle _unit != _unit) then { - _unit setVariable [QGVAR(vehicleAwakeAnim), [(vehicle _unit), (animationState _unit)]]; -}; - -//Save current stance: -_originalPos = unitPos _unit; - -_unit setUnitPos "DOWN"; -[_unit, true] call EFUNC(common,disableAI); - // So the AI does not get stuck, we are moving the unit to a temp group on its own. -//Unconscious units shouldn't be put in another group #527: +// Unconscious units shouldn't be put in another group #527: if (GVAR(moveUnitsFromGroupOnUnconscious)) then { [_unit, true, "ACE_isUnconscious", side group _unit] call EFUNC(common,switchToGroupSide); }; + // Delay Unconscious so the AI dont instant stop shooting on the unit #3121 -if (GVAR(delayUnconCaptive) == 0) then { - [_unit, "setCaptive", "ace_unconscious", true] call EFUNC(common,statusEffect_set); -} else { - [{ - params ["_unit"]; - if (_unit getVariable ["ACE_isUnconscious", false]) then { - [_unit, "setCaptive", "ace_unconscious", true] call EFUNC(common,statusEffect_set); - }; - },[_unit], GVAR(delayUnconCaptive)] call CBA_fnc_waitAndExecute; -}; - -_anim = [_unit] call EFUNC(common,getDeathAnim); -[_unit, _anim, 1, true] call EFUNC(common,doAnimation); [{ - params ["_unit", "_anim"]; - if ((_unit getVariable "ACE_isUnconscious") and (animationState _unit != _anim)) then { - [_unit, _anim, 2, true] call EFUNC(common,doAnimation); - }; -}, [_unit, _anim], 0.5, 0] call CBA_fnc_waitAndExecute; + params ["_unit"]; -_startingTime = CBA_missionTime; + if (_unit getVariable ["ACE_isUnconscious", false]) then { + [_unit, "setCaptive", "ace_unconscious", true] call EFUNC(common,statusEffect_set); + }; +}, _unit, 3] call CBA_fnc_waitAndExecute; + +[_unit, true] call EFUNC(medical_engine,setUnconsciousAnim); [_unit, "Unconscious", []] call FUNC(stateEvent); -[DFUNC(unconsciousPFH), 0.1, [_unit, _originalPos, _startingTime, _minWaitingTime, false, vehicle _unit isKindOf "ParachuteBase"] ] call CBA_fnc_addPerFrameHandler; - -// unconscious can't talk -[_unit, "isUnconscious"] call EFUNC(common,muteUnit); - ["ace_unconscious", [_unit, true]] call CBA_fnc_globalEvent; + +// auto wake up, testing @todo +[{ + params ["_unit", "_time"]; + + !(_unit getVariable ["ACE_isUnconscious", false]) || {CBA_missionTime > _time} +}, { + params ["_unit"]; + + if (_unit getVariable ["ACE_isUnconscious", false]) then { + [_unit, false] call FUNC(setUnconscious); + }; +}, [_unit, CBA_missionTime + _minUnconsciousTime]] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/medical/script_component.hpp b/addons/medical/script_component.hpp index a24bf0b53a..8e9cc6b5fa 100644 --- a/addons/medical/script_component.hpp +++ b/addons/medical/script_component.hpp @@ -16,6 +16,8 @@ #include "\z\ace\addons\main\script_macros.hpp" +#define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] + // scale received pain to 0-2 level to select type of scream // below 0.33: 0, from 0.34 to 0.66: 1, more than 0.67: 2 #define PAIN_TO_MOAN(pain) (floor (3 * pain) min 2) diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 7696be9485..fa5d6349ba 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -4019,28 +4019,5 @@ Будет ли объект считаться медицинским транспортом. どれでも、またはオブジェクトを医療車両として割り当てます。 - - Delay cease fire of AI while player is unconscious for medical reasons. - Verzögert das Ende des KI-Beschusses auf einen Spieler, wenn dieser aus medizinischen Gründen bewustlos wird. - Ritarda il cessate il fuoco dell'IA quando il giocatore è svenuto per motivi medici. - Prodleva zastavení palby pro AI, pokud je hráč v bezvědomí ze zdravotních důvodů. - Atraso durante cessar fogo da AI durante inconsciência médica - Délai de cessez le feu pour l'IA pendant que le joueur est inconscient pour des raisons médicales - Задержка прекращения огня ботами, когда игрок теряет сознание по медицинским причинам. - AI はプレイヤーが医療的な理由で気絶している場合にかぎり、撃つのをためらいます。 - Opóźnij stan wstrzymania ognia u AI kiedy gracz jest nieprzytomny z powodów medycznych. - - - Delay cease fire of AI for unconsciousness - Verzögert Ende des KI-Beschusses bei medizinischer Bewustlosigkeit - Demora antes de volverse neutral al caer inconsciente - Opóźnij wstrzymanie ognia AI dla nieprzytomnych osób - Ritarda il cessate il fuoco dell'IA quando si è svenuti - Prodleva zastavení palby AI na bezvědomé - Atraso durante cessar fogo da AI durante inconsciência - Délai de cessez le feu de l'IA pour la perte de conscience - Задержка прекращения огня ботами при потере сознания - AI は気絶している人へ、ためらってから射撃します - diff --git a/addons/medical_ai/XEH_postInit.sqf b/addons/medical_ai/XEH_postInit.sqf index b84238dc64..cdd1ff1c3e 100644 --- a/addons/medical_ai/XEH_postInit.sqf +++ b/addons/medical_ai/XEH_postInit.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" -["ace_settingsInitialized", { +/*["ace_settingsInitialized", { TRACE_1("settingsInitialized", GVAR(enabledFor)); if (GVAR(enabledFor) == 0) exitWith {}; // 0: disabled if ((GVAR(enabledFor) == 1) && {!isServer} && {hasInterface}) exitWith {}; // 1: Don't Run on non-hc Clients @@ -32,4 +32,4 @@ }; GVAR(statemachine) = [configFile >> "ACE_Medical_AI_StateMachine"] call CBA_statemachine_fnc_createFromConfig; -}] call CBA_fnc_addEventHandler; +}] call CBA_fnc_addEventHandler;*/ diff --git a/addons/medical_ai/functions/fnc_healSelf.sqf b/addons/medical_ai/functions/fnc_healSelf.sqf index 7d495cb8c7..0ca186b7f6 100644 --- a/addons/medical_ai/functions/fnc_healSelf.sqf +++ b/addons/medical_ai/functions/fnc_healSelf.sqf @@ -32,8 +32,8 @@ switch (true) do { _index }; } forEach _openWounds; - private _selection = ["head","body","hand_l","hand_r","leg_l","leg_r"] select _partIndex; - [_this, "Bandage", _selection] call EFUNC(medical_treatment,treatmentAdvanced_bandageLocal); + private _selection = ALL_BODY_PARTS select _partIndex; + [_this, "Bandage", _selection] call EFUNC(medical_treatment,treatmentBandageLocal); #ifdef DEBUG_MODE_FULL systemChat format ["%1 is bandaging selection %2", _this, _selection]; diff --git a/addons/medical_ai/functions/fnc_healUnit.sqf b/addons/medical_ai/functions/fnc_healUnit.sqf index 99636bf5f5..984e7376d1 100644 --- a/addons/medical_ai/functions/fnc_healUnit.sqf +++ b/addons/medical_ai/functions/fnc_healUnit.sqf @@ -61,8 +61,8 @@ switch (true) do { _index }; } forEach _openWounds; - private _selection = ["head","body","hand_l","hand_r","leg_l","leg_r"] select _partIndex; - [_target, "Bandage", _selection] call EFUNC(medical_treatment,treatmentAdvanced_bandageLocal); + private _selection = ALL_BODY_PARTS select _partIndex; + [_target, "Bandage", _selection] call EFUNC(medical_treatment,treatmentBandageLocal); #ifdef DEBUG_MODE_FULL systemChat format ["%1 is bandaging selection %2 on %3", _this, _selection, _target]; diff --git a/addons/medical_ai/script_component.hpp b/addons/medical_ai/script_component.hpp index cd0c047751..b83ce1b5e9 100644 --- a/addons/medical_ai/script_component.hpp +++ b/addons/medical_ai/script_component.hpp @@ -15,3 +15,5 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + +#define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] diff --git a/addons/medical_blood/script_component.hpp b/addons/medical_blood/script_component.hpp index ce811bdd9a..d94019a080 100644 --- a/addons/medical_blood/script_component.hpp +++ b/addons/medical_blood/script_component.hpp @@ -2,7 +2,7 @@ #define COMPONENT_BEAUTIFIED Medical Blood #include "\z\ace\addons\main\script_mod.hpp" -#define DEBUG_ENABLED_MEDICAL_BLOOD +// #define DEBUG_ENABLED_MEDICAL_BLOOD #define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/medical_damage/functions/fnc_airwayHandler.sqf b/addons/medical_damage/functions/fnc_airwayHandler.sqf index a34615d8c0..1d9dfdce25 100644 --- a/addons/medical_damage/functions/fnc_airwayHandler.sqf +++ b/addons/medical_damage/functions/fnc_airwayHandler.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Unit That Was Hit - * 1: Name Of Hit Selection + * 1: Name Of Body Part * 2: Amount Of Damage * 3: Shooter or source of the damage * 4: Type of the damage done @@ -14,14 +14,13 @@ * * Public: No */ - #include "script_component.hpp" -private "_bodyPartn"; -params ["_unit", "_selectionName", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage"]; -_bodyPartn = [_selectionName] call EFUNC(medical,selectionNameToNumber); +params ["_unit", "_bodyPart", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage"]; -if (_bodyPartn > 1) exitWith {}; +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; + +if (_partIndex > 1) exitWith {}; if (_amountOfDamage > 0.5) then { if (random(1) >= 0.8) then { diff --git a/addons/medical_damage/functions/fnc_fracturesHandler.sqf b/addons/medical_damage/functions/fnc_fracturesHandler.sqf index ee89b4ac74..137bdc3962 100644 --- a/addons/medical_damage/functions/fnc_fracturesHandler.sqf +++ b/addons/medical_damage/functions/fnc_fracturesHandler.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Unit That Was Hit - * 1: Name Of Hit Selection + * 1: Name Of Body Part * 2: Amount Of Damage * 3: Shooter or source of the damage * 4: Type of the damage done @@ -14,16 +14,15 @@ * * Public: No */ - #include "script_component.hpp" -private ["_bodyPartn", "_fractures", "_fractureType"]; -params ["_unit", "_selectionName", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage"]; -_bodyPartn = [_selectionName] call EFUNC(medical,selectionNameToNumber); +params ["_unit", "_bodyPart", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage"]; + +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; + +private _fractureType = 1; -_fractureType = 1; if (_amountOfDamage > 0.05) then { - // TODO specify fractures based off typeOfInjury details better. switch (_typeOfDamage) do { case "Bullet": { @@ -58,13 +57,14 @@ if (_amountOfDamage > 0.05) then { }; }; - private ["_fractures", "_fractureID", "_amountOf"]; - _fractures = _unit getVariable[QGVAR(fractures), []]; - _fractureID = 1; - _amountOf = count _fractures; + private _fractures = _unit getVariable[QGVAR(fractures), []]; + private _fractureID = 1; + private _amountOf = count _fractures; + if (_amountOf > 0) then { _fractureID = (_fractures select (_amountOf - 1) select 0) + 1; }; - _fractures pushBack [_fractureID, _fractureType, _bodyPartn, 1 /* percentage treated */]; + + _fractures pushBack [_fractureID, _fractureType, _partIndex, 1 /* percentage treated */]; _unit setVariable [QGVAR(fractures), _fractures, true]; }; diff --git a/addons/medical_damage/functions/fnc_internalInjuriesHandler.sqf b/addons/medical_damage/functions/fnc_internalInjuriesHandler.sqf index 582ffc2635..c6e4501685 100644 --- a/addons/medical_damage/functions/fnc_internalInjuriesHandler.sqf +++ b/addons/medical_damage/functions/fnc_internalInjuriesHandler.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Unit That Was Hit - * 1: Name Of Hit Selection + * 1: Name Of Body Part * 2: Amount Of Damage * 3: Shooter or source of the damage * 4: Type of the damage done @@ -17,7 +17,7 @@ #include "script_component.hpp" -private "_bodyPartn"; -params ["_unit", "_selectionName", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage"]; -// _bodyPartn = [_selectionName] call EFUNC(medical,selectionNameToNumber); +params ["_unit", "_bodyPart", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage"]; + +// private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; // TODO implement internal injuries diff --git a/addons/medical_damage/functions/fnc_woundsHandler.sqf b/addons/medical_damage/functions/fnc_woundsHandler.sqf index 62c696bbb0..fe7f5f9952 100644 --- a/addons/medical_damage/functions/fnc_woundsHandler.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandler.sqf @@ -19,10 +19,6 @@ params ["_unit", "_bodyPart", "_damage", "_typeOfProjectile", "_typeOfDamage"]; TRACE_5("start",_unit,_bodyPart,_damage,_typeOfProjectile,_typeOfDamage); -///// DELETE THIS AFTER EXTENSION HAS BEEN UPDATED -_bodyPart = EGVAR(medical,SELECTIONS) select (ALL_BODY_PARTS find _bodyPart); -///// - if (_typeOfDamage isEqualTo "") then { _typeOfDamage = "unknown"; }; diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 6c584565bf..7e11f09864 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -20,7 +20,7 @@ params ["_unit", "_bodyPart", "_damage", "_typeOfProjectile", "_typeOfDamage"]; TRACE_5("start",_unit,_bodyPart,_damage,_typeOfProjectile,_typeOfDamage); // Convert the selectionName to a number and ensure it is a valid selection. -private _bodyPartN = ALL_BODY_PARTS find _bodyPart; +private _bodyPartN = ALL_BODY_PARTS find toLower _bodyPart; if (_bodyPartN < 0) exitWith {}; if (_typeOfDamage isEqualTo "") then { @@ -69,7 +69,7 @@ private _allPossibleInjuries = []; if (_highestPossibleSpot < 0) exitWith {}; // Administration for open wounds and ids -private _openWounds = _unit getVariable [QGVAR(openWounds), []]; +private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []]; private _woundID = _unit getVariable [QGVAR(lastUniqueWoundID), 1]; private _painToAdd = 0; @@ -126,16 +126,17 @@ private _woundsCreated = []; }; } forEach _thresholds; -_unit setVariable [QGVAR(openWounds), _openWounds, true]; +_unit setVariable [QEGVAR(medical,openWounds), _openWounds, true]; // Only update if new wounds have been created if (count _woundsCreated > 0) then { _unit setVariable [QGVAR(lastUniqueWoundID), _woundID, true]; }; -private _painLevel = _unit getVariable [QGVAR(pain), 0]; -_unit setVariable [QGVAR(pain), _painLevel + _painToAdd]; +// TODO use medical add pain function instead +private _painLevel = _unit getVariable [QEGVAR(medical,pain), 0]; +_unit setVariable [QEGVAR(medical,pain), _painLevel + _painToAdd]; [_unit, "hit", PAIN_TO_SCREAM(_painToAdd)] call EFUNC(medical_engine,playInjuredSound); -TRACE_6("exit",_unit, _painLevel, _painToAdd, _unit getVariable QGVAR(pain), _unit getVariable QGVAR(openWounds),_woundsCreated); +TRACE_6("exit",_unit, _painLevel, _painToAdd, _unit getVariable QEGVAR(medical,pain), _unit getVariable QEGVAR(medical,openWounds),_woundsCreated); diff --git a/addons/medical_damage/script_component.hpp b/addons/medical_damage/script_component.hpp index c0f6967c93..cab6ac28a0 100644 --- a/addons/medical_damage/script_component.hpp +++ b/addons/medical_damage/script_component.hpp @@ -21,7 +21,7 @@ #define GET_STRING(config,default) (if (isText (config)) then {getText (config)} else {default}) #define GET_ARRAY(config,default) (if (isArray (config)) then {getArray (config)} else {default}) -#define ALL_BODY_PARTS ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] +#define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] // scale received pain to 0-2 level to select type of scream // below 0.25: 0, from 0.25 to 0.5: 1, more than 0.5: 2 diff --git a/addons/medical_engine/CfgExtendedAnimation.hpp b/addons/medical_engine/CfgExtendedAnimation.hpp new file mode 100644 index 0000000000..8f9525f0a5 --- /dev/null +++ b/addons/medical_engine/CfgExtendedAnimation.hpp @@ -0,0 +1,10 @@ + +// we want the face down animation every time +class CfgExtendedAnimation { + class Revive { + left = "Unconscious"; + right = "Unconscious"; + front = "Unconscious"; + back = "Unconscious"; + }; +}; diff --git a/addons/medical_engine/CfgMoves.hpp b/addons/medical_engine/CfgMoves.hpp index 7c9f891c71..7dcd2cb2d3 100644 --- a/addons/medical_engine/CfgMoves.hpp +++ b/addons/medical_engine/CfgMoves.hpp @@ -1,5 +1,8 @@ -class CfgMovesBasic; +class CfgMovesBasic { + class Default; +}; + class CfgMovesMaleSdr: CfgMovesBasic { class States { // fixes hand being stuck at rifle which is on the back @@ -7,5 +10,10 @@ class CfgMovesMaleSdr: CfgMovesBasic { class AinvPknlMstpSlayWnonDnon_medicOther: AmovPknlMstpSrasWrflDnon_AinvPknlMstpSlayWrflDnon { weaponIK = 0; }; + + // wake me up inside + class Unconscious: Default { + InterpolateTo[] = {"DeadState",0.1,"AmovPpneMstpSnonWnonDnon",0.2}; + }; }; }; diff --git a/addons/medical_engine/XEH_PREP.hpp b/addons/medical_engine/XEH_PREP.hpp index 0a0c2c3fd2..2c949d9360 100644 --- a/addons/medical_engine/XEH_PREP.hpp +++ b/addons/medical_engine/XEH_PREP.hpp @@ -5,3 +5,4 @@ PREP(damageBodyPart); PREP(setLimping); PREP(setPainSway); PREP(setStructuralDamage); +PREP(setUnconsciousAnim); diff --git a/addons/medical_engine/XEH_postInit.sqf b/addons/medical_engine/XEH_postInit.sqf index 9b2919e7e7..1546ef280d 100644 --- a/addons/medical_engine/XEH_postInit.sqf +++ b/addons/medical_engine/XEH_postInit.sqf @@ -41,3 +41,13 @@ ]; }] call CBA_fnc_waitUntilAndExecute; #endif + +// this handles moving units into vehicles via load functions or zeus +// needed, because the vanilla INCAPACITATED state does not handle vehicles +["CAManBase", "GetInMan", { + params ["_unit"]; + + if (lifeState _unit == "INCAPACITATED") then { + [_unit, true] call FUNC(setUnconsciousAnim); + }; +}] call CBA_fnc_addClassEventHandler; diff --git a/addons/medical_engine/config.cpp b/addons/medical_engine/config.cpp index ff8c4aa996..34399b6840 100644 --- a/addons/medical_engine/config.cpp +++ b/addons/medical_engine/config.cpp @@ -18,6 +18,7 @@ class CfgPatches { #include "CfgActions.hpp" #include "CfgMoves.hpp" +#include "CfgExtendedAnimation.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" #include "CfgInGameUI.hpp" diff --git a/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf b/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf new file mode 100644 index 0000000000..b52948a9c4 --- /dev/null +++ b/addons/medical_engine/functions/fnc_setUnconsciousAnim.sqf @@ -0,0 +1,55 @@ +/* + * Author: commy2 + * Force local unit into ragdoll / unconsciousness animation. + * + * Arguments: + * 0: Unit + * 1: Is unconscious (optional, default: true) + * + * Return Value: + * None + * + * Example: + * player call ace_medical_engine_fnc_setUnconsciousAnim + * + * Public: No + */ +#include "script_component.hpp" + +params [["_unit", objNull, [objNull]], ["_isUnconscious", true, [false]]]; + +if (!local _unit) exitWith { + ERROR("Unit not local or null"); +}; + +_unit setUnconscious _isUnconscious; + +if (_isUnconscious) then { + // eject from static weapon + if (vehicle _unit isKindOf "StaticWeapon") then { + [_unit] call EFUNC(common,unloadPerson); + }; + + // set animation inside vehicles + if (vehicle _unit != _unit) then { + private _unconAnim = _unit call EFUNC(common,getDeathAnim); + [_unit, _unconAnim] call EFUNC(common,doAnimation); + }; +} else { + // reset animation inside vehicles + if (vehicle _unit != _unit) then { + private _awakeAnim = _unit call EFUNC(common,getAwakeAnim); + [_unit, _awakeAnim, 2] call EFUNC(common,doAnimation); + } else { + // and on foot + [_unit, "AmovPpneMstpSnonWnonDnon"] call EFUNC(common,doAnimation); + + [{ + params ["_unit"]; + + if (animationState _unit == "unconscious" && {lifeState _unit != "INCAPACITATED"}) then { + [_unit, "AmovPpneMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); + }; + }, _unit] call CBA_fnc_execNextFrame; + }; +}; diff --git a/addons/medical_menu/functions/fnc_collectActions.sqf b/addons/medical_menu/functions/fnc_collectActions.sqf index e028fea3ee..ce513f7ffd 100644 --- a/addons/medical_menu/functions/fnc_collectActions.sqf +++ b/addons/medical_menu/functions/fnc_collectActions.sqf @@ -15,8 +15,8 @@ */ #include "script_component.hpp" -private _configBasic = (configFile >> "ACE_Medical_Treatment_Actions" >> "Basic"); -private _configAdvanced = (configFile >> "ACE_Medical_Treatment_Actions" >> "Advanced"); +private _configBasic = (configFile >> QEGVAR(medical_treatment,actions) >> "Basic"); +private _configAdvanced = (configFile >> QEGVAR(medical_treatment,actions) >> "Advanced"); private _fnc_compileActionsLevel = { params ["_config"]; @@ -26,8 +26,8 @@ private _fnc_compileActionsLevel = { if (isClass _x) then { private _displayName = getText (_x >> "displayName"); private _category = getText (_x >> "category"); - private _condition = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical_treatment,canTreatCached)), configName _x]; - private _statement = format[QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), EGVAR(medical,SELECTIONS) select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical_treatment,treatment)), configName _x]; + private _condition = format [QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), %2 select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical_treatment,canTreatCached)), configName _x, ALL_BODY_PARTS]; + private _statement = format [QUOTE([ARR_4(ACE_player, GVAR(INTERACTION_TARGET), %2 select GVAR(selectedBodyPart), '%1')] call DEFUNC(medical_treatment,treatment)), configName _x, ALL_BODY_PARTS]; _actions pushBack [_displayName, _category, compile _condition, compile _statement]; diag_log format["ACTION: %1", [_displayName, _category, compile _condition, compile _statement]]; }; diff --git a/addons/medical_menu/functions/fnc_collectActions3D.sqf b/addons/medical_menu/functions/fnc_collectActions3D.sqf index 5ab1a354b0..5f6dfea9cf 100644 --- a/addons/medical_menu/functions/fnc_collectActions3D.sqf +++ b/addons/medical_menu/functions/fnc_collectActions3D.sqf @@ -15,8 +15,7 @@ */ #include "script_component.hpp" -private _actionsConfig = [nil, configFile >> "ACE_Medical_Treatment_Actions" >> "Basic", configFile >> "ACE_Medical_Treatment_Actions" >> "Advanced"] select EGVAR(medical,level); -private _allAllowedSelections = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"]; +private _actionsConfig = [nil, configFile >> QEGVAR(medical_treatment,actions) >> "Basic", configFile >> QEGVAR(medical_treatment,actions) >> "Advanced"] select EGVAR(medical,level); private _actionPaths = ["ACE_Head", "ACE_Torso", "ACE_ArmLeft", "ACE_ArmRight", "ACE_LegLeft", "ACE_LegRight"]; private _actionPathTexts = [ localize ELSTRING(interaction,Head), localize ELSTRING(interaction,Torso), @@ -38,25 +37,24 @@ private _actionPathPositions = ["spine3", "pilot", "LeftForeArm", "RightForeArm" default {""}; }; - private _allowedSelections = getArray (_config >> "allowedSelections"); - _allowedSelections = _allowedSelections apply {toLower _x}; + private _allowedBodyParts = getArray (_config >> "allowedSelections") apply {toLower _x}; - if (_allowedSelections isEqualTo ["all"]) then { - _allowedSelections = _allAllowedSelections; + if (_allowedBodyParts isEqualTo ["all"]) then { + _allowedBodyParts = ALL_BODY_PARTS apply {toLower _x}; }; { - private _selection = _x; - private _actionPath = _actionPaths select (_allAllowedSelections find _selection); + private _bodyPart = _x; + private _actionPath = _actionPaths select (ALL_BODY_PARTS find toLower _bodyPart); - private _statement = {[_player, _target, _selection, _this select 2] call EFUNC(medical_treatment,treatment)}; - private _condition = {[_player, _target, _selection, _this select 2] call EFUNC(medical_treatment,canTreatCached)}; + private _statement = {[_player, _target, _this select 2 select 0, _this select 2 select 1] call EFUNC(medical_treatment,treatment)}; + private _condition = {[_player, _target, _this select 2 select 0, _this select 2 select 1] call EFUNC(medical_treatment,canTreatCached)}; private _action = [ - _actionName, _displayName, _icon, _statement, _condition, {}, configName _config, [0, 0, 0], 2, [false, true, false, false, false] + _actionName, _displayName, _icon, _statement, _condition, {}, [_bodyPart, configName _config], [0, 0, 0], 2, [false, true, false, false, false] ] call EFUNC(interact_menu,createAction); diag_log formatText ["ACTIONS LOL: %1", [_actionName, _displayName, _icon, _statement, _condition]]; ["CAManBase", 0, [_actionPath], _action, true] call EFUNC(interact_menu,addActionToClass); ["CAManBase", 1, ["ACE_SelfActions", "Medical", _actionPath], _action, true] call EFUNC(interact_menu,addActionToClass); - } forEach _allowedSelections; + } forEach _allowedBodyParts; } forEach configProperties [_actionsConfig, "isClass _x"]; diff --git a/addons/medical_menu/script_component.hpp b/addons/medical_menu/script_component.hpp index e789ee48e7..afd49a6920 100644 --- a/addons/medical_menu/script_component.hpp +++ b/addons/medical_menu/script_component.hpp @@ -15,3 +15,5 @@ #endif #include "\z\ace\addons\main\script_macros.hpp" + +#define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] diff --git a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp index e5b0358153..c9652beeb2 100644 --- a/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp +++ b/addons/medical_treatment/ACE_Medical_Treatment_Actions.hpp @@ -15,7 +15,7 @@ class GVAR(Actions) { condition = ""; patientStateCondition = 0; itemConsumed = 1; - callbackSuccess = QFUNC(treatmentAdvanced_bandage); + callbackSuccess = QFUNC(treatmentBandage); callbackFailure = ""; callbackProgress = ""; @@ -34,12 +34,12 @@ class GVAR(Actions) { class Morphine: Bandage { displayName = ECSTRING(medical,Inject_Morphine); displayNameProgress = ECSTRING(medical,Injecting_Morphine); - allowedSelections[] = {"hand_l", "hand_r", "leg_l", "leg_r"}; + allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; allowSelfTreatment = 1; category = "medication"; treatmentTime = 8; items[] = {"ACE_morphine"}; - callbackSuccess = QFUNC(treatmentBasic_morphine); + callbackSuccess = QFUNC(treatmentMorphine); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; litter[] = { {"All", "", {"ACE_MedicalLitter_morphine"}} }; sounds[] = {{QPATHTO_R(sounds\Inject.ogg),1,1,50}}; @@ -49,21 +49,21 @@ class GVAR(Actions) { displayNameProgress = ECSTRING(medical,Injecting_Epinephrine); requiredMedic = QEGVAR(medical,medicSetting_basicEpi); items[] = {"ACE_epinephrine"}; - callbackSuccess = QFUNC(treatmentBasic_epipen); + callbackSuccess = QFUNC(treatmentEpipen); litter[] = { {"All", "", {"ACE_MedicalLitter_epinephrine"}} }; treatmentLocations[] = {QGVAR(useLocation_basicEpi)}; }; class BloodIV: Bandage { displayName = ECSTRING(medical,Transfuse_Blood); displayNameProgress = ECSTRING(medical,Transfusing_Blood); - allowedSelections[] = {"hand_l", "hand_r", "leg_l", "leg_r"}; + allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; allowSelfTreatment = 0; category = "advanced"; requiredMedic = 1; treatmentTime = 12; items[] = {"ACE_bloodIV"}; - // callbackSuccess = QFUNC(treatmentBasic_bloodbag); - callbackSuccess = QFUNC(treatmentIV); + callbackSuccess = QFUNC(treatmentBloodbag); + // callbackSuccess = QFUNC(treatmentIV); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; litter[] = {}; }; @@ -82,7 +82,7 @@ class GVAR(Actions) { treatmentLocations[] = {"All"}; requiredMedic = 0; treatmentTime = 15; - items[] = {"ACE_bodyBag"}; + items[] = {"ACE_BodyBag"}; condition = "!alive _target"; callbackSuccess = QFUNC(actionPlaceInBodyBag); callbackFailure = ""; @@ -97,7 +97,7 @@ class GVAR(Actions) { displayNameProgress = ECSTRING(medical,Actions_Diagnosing); category = "examine"; treatmentLocations[] = {"All"}; - allowedSelections[] = {"head", "body"}; + allowedSelections[] = {"Head", "Body"}; requiredMedic = 0; treatmentTime = 1; items[] = {}; @@ -114,13 +114,13 @@ class GVAR(Actions) { displayNameProgress = ECSTRING(medical,Actions_PerformingCPR); category = "advanced"; treatmentLocations[] = {"All"}; - allowedSelections[] = {"body"}; + allowedSelections[] = {"Body"}; allowSelfTreatment = 0; requiredMedic = 0; treatmentTime = 15; items[] = {}; condition = QUOTE(!(_target call EFUNC(common,isAwake)) && EGVAR(medical,enableRevive) > 0); - callbackSuccess = QFUNC(treatmentAdvanced_CPR); + callbackSuccess = QFUNC(treatmentCPR); callbackFailure = ""; callbackProgress = QUOTE((_this select 0 select 1) call EFUNC(common,isAwake)); animationPatient = ""; @@ -152,7 +152,7 @@ class GVAR(Actions) { condition = ""; patientStateCondition = 0; // Callbacks - callbackSuccess = QFUNC(treatmentAdvanced_bandage); + callbackSuccess = QFUNC(treatmentBandage); callbackFailure = ""; callbackProgress = ""; itemConsumed = 1; @@ -193,7 +193,7 @@ class GVAR(Actions) { class Tourniquet: fieldDressing { displayName = ECSTRING(medical,Apply_Tourniquet); displayNameProgress = ECSTRING(medical,Applying_Tourniquet); - allowedSelections[] = {"hand_l", "hand_r", "leg_l", "leg_r"}; + allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; items[] = {"ACE_tourniquet"}; treatmentTime = 4; callbackSuccess = QFUNC(treatmentTourniquet); @@ -203,11 +203,11 @@ class GVAR(Actions) { class Morphine: fieldDressing { displayName = ECSTRING(medical,Inject_Morphine); displayNameProgress = ECSTRING(medical,Injecting_Morphine); - allowedSelections[] = {"hand_l", "hand_r", "leg_l", "leg_r"}; + allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; category = "medication"; items[] = {"ACE_morphine"}; treatmentTime = 3; - callbackSuccess = QFUNC(treatmentAdvanced_medication); + callbackSuccess = QFUNC(treatmentMedication); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; litter[] = { {"All", "", {"ACE_MedicalLitter_morphine"}} }; sounds[] = {{QPATHTO_R(sounds\Inject.ogg),1,1,50}}; @@ -233,7 +233,7 @@ class GVAR(Actions) { class BloodIV: fieldDressing { displayName = ECSTRING(medical,Actions_Blood4_1000); displayNameProgress = ECSTRING(medical,Transfusing_Blood); - allowedSelections[] = {"hand_l", "hand_r", "leg_l", "leg_r"}; + allowedSelections[] = {"LeftArm", "RightArm", "LeftLeg", "RightLeg"}; allowSelfTreatment = 0; category = "advanced"; items[] = {"ACE_bloodIV"}; @@ -290,7 +290,7 @@ class GVAR(Actions) { patientStateCondition = QEGVAR(medical,useCondition_SurgicalKit); treatmentTime = QUOTE(count (_target getVariable [ARR_2('EGVAR(medical,bandagedWounds)',[])]) * 5); callbackSuccess = ""; - callbackProgress = QFUNC(treatmentAdvanced_surgicalKit_onProgress); + callbackProgress = QFUNC(treatmentSurgicalKit_onProgress); itemConsumed = QEGVAR(medical,consumeItem_SurgicalKit); animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; litter[] = { {"All", "", {"ACE_MedicalLitter_gloves"} }}; @@ -304,8 +304,8 @@ class GVAR(Actions) { allowSelfTreatment = 0; requiredMedic = QEGVAR(medical,medicSetting_PAK); patientStateCondition = QEGVAR(medical,useCondition_PAK); - treatmentTime = QUOTE(_target call FUNC(treatmentAdvanced_fullHealTreatmentTime)); - callbackSuccess = QFUNC(treatmentAdvanced_fullHeal); + treatmentTime = QUOTE(_target call FUNC(treatmentFullHealTreatmentTime)); + callbackSuccess = QFUNC(treatmentFullHeal); itemConsumed = QEGVAR(medical,consumeItem_PAK); animationPatient = ""; animationPatientUnconscious = "AinjPpneMstpSnonWrflDnon_rolltoback"; @@ -362,13 +362,13 @@ class GVAR(Actions) { displayNameProgress = ECSTRING(medical,Actions_PerformingCPR); category = "advanced"; treatmentLocations[] = {"All"}; - allowedSelections[] = {"body"}; + allowedSelections[] = {"Body"}; allowSelfTreatment = 0; requiredMedic = 0; treatmentTime = 15; items[] = {}; condition = QUOTE(!(_target call EFUNC(common,isAwake))); - callbackSuccess = QFUNC(treatmentAdvanced_CPR); + callbackSuccess = QFUNC(treatmentCPR); callbackFailure = ""; callbackProgress = QUOTE((_this select 0 select 1) call EFUNC(common,isAwake)); animationPatient = ""; @@ -388,7 +388,7 @@ class GVAR(Actions) { allowSelfTreatment = 0; requiredMedic = 0; treatmentTime = 15; - items[] = {"ACE_bodyBag"}; + items[] = {"ACE_BodyBag"}; condition = "!alive _target"; callbackSuccess = QFUNC(actionPlaceInBodyBag); callbackFailure = ""; diff --git a/addons/medical_treatment/XEH_PREP.hpp b/addons/medical_treatment/XEH_PREP.hpp index 44451d2b6d..558a56a0d6 100644 --- a/addons/medical_treatment/XEH_PREP.hpp +++ b/addons/medical_treatment/XEH_PREP.hpp @@ -13,47 +13,52 @@ PREP(addToLog); PREP(addToTriageCard); PREP(addUnloadPatientActions); PREP(canAccessMedicalEquipment); -PREP(canTreat); -PREP(canTreatCached); PREP(displayPatientInformation); PREP(displayTriageCard); PREP(dropDownTriageCard); PREP(getTriageStatus); PREP(handleBandageOpening); -PREP(hasItem); -PREP(hasItems); PREP(isBeingCarried); PREP(isBeingDragged); PREP(medicationEffectLoop); PREP(modifyMedicalAction); PREP(onMedicationUsage); + +// treaments +PREP(canTreat); +PREP(canTreatCached); PREP(treatment); -PREP(treatmentAdvanced_CPR); -PREP(treatmentAdvanced_CPRLocal); -PREP(treatmentAdvanced_bandage); -PREP(treatmentAdvanced_bandageLocal); -PREP(treatmentAdvanced_fullHeal); -PREP(treatmentAdvanced_fullHealLocal); -PREP(treatmentAdvanced_fullHealTreatmentTime); -PREP(treatmentAdvanced_medication); -PREP(treatmentAdvanced_medicationLocal); -PREP(treatmentAdvanced_surgicalKit_onProgress); -PREP(treatmentBasic_bloodbag); -PREP(treatmentBasic_bloodbagLocal); -PREP(treatmentBasic_epipen); -PREP(treatmentBasic_morphine); -PREP(treatmentBasic_morphineLocal); -PREP(treatmentIV); -PREP(treatmentIVLocal); +PREP(treatment_success); +PREP(treatment_failure); + +PREP(treatmentBandage); +PREP(treatmentBandageLocal); PREP(treatmentTourniquet); PREP(treatmentTourniquetLocal); -PREP(treatment_failure); -PREP(treatment_success); +PREP(treatmentMorphine); +PREP(treatmentMorphineLocal); +PREP(treatmentEpipen); +//PREP(treatmentEpipenLocal); +PREP(treatmentMedication); +PREP(treatmentMedicationLocal); +PREP(treatmentBloodbag); +PREP(treatmentBloodbagLocal); +PREP(treatmentIV); +PREP(treatmentIVLocal); +PREP(treatmentCPR); +PREP(treatmentCPRLocal); +PREP(treatmentFullHeal); +PREP(treatmentFullHealLocal); +PREP(treatmentFullHealTreatmentTime); +PREP(treatmentSurgicalKit_onProgress); + +// items +PREP(checkItems); +PREP(hasItem); +PREP(hasItems); PREP(useItem); PREP(useItems); -PREP(checkItems); - // litter PREP(litterCreate); PREP(litterHandleCreate); diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index f144592183..e3020fd5c6 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -1,11 +1,18 @@ #include "script_component.hpp" -[QEGVAR(medical,initialized), { - params ["_unit"]; - _unit call FUNC(checkItems); -}] call CBA_fnc_addEventHandler; +[QEGVAR(medical,initialized), FUNC(checkItems)] call CBA_fnc_addEventHandler; if (isServer) then { [QGVAR(createLitterServer), FUNC(litterHandleCreate)] call CBA_fnc_addEventHandler; }; + +// treatment events +[QGVAR(treatmentBandageLocal), FUNC(treatmentBandageLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentMorphineLocal), FUNC(treatmentMorphineLocal)] call CBA_fnc_addEventHandler; +//[QGVAR(treatmentEpipenLocal), FUNC(treatmentEpipenLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentMedicationLocal), FUNC(treatmentMedicationLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentBloodbagLocal), FUNC(treatmentBloodbagLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentIVLocal), FUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler; +[QGVAR(treatmentFullHealLocal), FUNC(treatmentFullHealLocal)] call CBA_fnc_addEventHandler; diff --git a/addons/medical_treatment/functions/fnc_actionRemoveTourniquet.sqf b/addons/medical_treatment/functions/fnc_actionRemoveTourniquet.sqf index 0a905a6c54..ac51fa26f3 100644 --- a/addons/medical_treatment/functions/fnc_actionRemoveTourniquet.sqf +++ b/addons/medical_treatment/functions/fnc_actionRemoveTourniquet.sqf @@ -5,7 +5,7 @@ * Arguments: * 0: The medic * 1: The patient - * 2: SelectionName + * 2: Body part * * Return Value: * None @@ -15,20 +15,20 @@ #include "script_component.hpp" -params ["_caller", "_target", "_selectionName"]; -TRACE_3("params",_caller,_target,_selectionName); +params ["_caller", "_target", "_bodyPart"]; +TRACE_3("params",_caller,_target,_bodyPart); // grab the required data -private _part = [_selectionName] call EFUNC(medical,selectionNameToNumber); +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; // Check if there is a tourniquet on this bodypart -if ((_tourniquets select _part) == 0) exitWith { +if ((_tourniquets select _partIndex) == 0) exitWith { [QEGVAR(common,displayTextStructured), [ELSTRING(medical,noTourniquetOnBodyPart), 1.5, _caller], [_caller]] call CBA_fnc_targetEvent; }; // Removing the tourniquet -_tourniquets set [_part, 0]; +_tourniquets set [_partIndex, 0]; _target setVariable [QEGVAR(medical,tourniquets), _tourniquets, true]; // Adding the tourniquet item to the caller @@ -37,10 +37,10 @@ _caller addItem "ACE_tourniquet"; //Handle all injected medications now that blood is flowing: private _delayedMedications = _target getVariable [QGVAR(occludedMedications), []]; private _updatedArray = false; -TRACE_2("meds",_part,_delayedMedications); +TRACE_2("meds",_partIndex,_delayedMedications); { _x params ["", "", "_medPartNum"]; - if (_part == _medPartNum) then { + if (_partIndex == _medPartNum) then { TRACE_1("delayed medication call after tourniquet removeal",_x); [QGVAR(treatmentAdvanced_medicationLocal), _x, [_target]] call CBA_fnc_targetEvent; _delayedMedications set [_forEachIndex, -1]; diff --git a/addons/medical_treatment/functions/fnc_canTreat.sqf b/addons/medical_treatment/functions/fnc_canTreat.sqf index c4421bf385..b2b237c3f4 100644 --- a/addons/medical_treatment/functions/fnc_canTreat.sqf +++ b/addons/medical_treatment/functions/fnc_canTreat.sqf @@ -44,9 +44,9 @@ if (isNumber (_config >> "requiredMedic")) then { if !([_caller, _medicRequired] call EFUNC(medical,isMedic)) exitWith {false}; // check selection -private _allowedSelections = getArray (_config >> "allowedSelections"); +private _allowedSelections = getArray (_config >> "allowedSelections") apply {toLower _x}; -if !("All" in _allowedSelections || {(_selectionName in _allowedSelections)}) exitWith {false}; +if !("all" in _allowedSelections || {(_selectionName in _allowedSelections)}) exitWith {false}; // check item private _items = getArray (_config >> "items"); @@ -88,9 +88,9 @@ if (isNumber (_config >> "patientStateCondition")) then { if (_patientStateCondition == 1 && {!([_target] call EFUNC(medical,isInStableCondition))}) exitWith {false}; // check allowed locations -private _locations = getArray (_config >> "treatmentLocations"); +private _locations = getArray (_config >> "treatmentLocations") apply {toLower _x}; -if ("All" in _locations) then { +if ("all" in _locations) then { _locations = true; } else { private _medFacility = {([_caller] call EFUNC(medical,isInMedicalFacility)) || ([_target] call EFUNC(medical,isInMedicalFacility))}; diff --git a/addons/medical_treatment/functions/fnc_treatment.sqf b/addons/medical_treatment/functions/fnc_treatment.sqf index dfa354dba1..39cb82e8b9 100644 --- a/addons/medical_treatment/functions/fnc_treatment.sqf +++ b/addons/medical_treatment/functions/fnc_treatment.sqf @@ -21,8 +21,10 @@ params ["_caller", "_target", "_selectionName", "_className"]; if (uiNamespace getVariable [QEGVAR(interact_menu,cursorMenuOpened), false]) exitWith { [DFUNC(treatment), _this] call CBA_fnc_execNextFrame; }; +TRACE_1("banana",_this); if !([_caller, _target, _selectionName, _className] call FUNC(canTreat)) exitWith {false}; +TRACE_1("can treat",_this); private _config = configFile >> QGVAR(Actions) >> CUR_LEVEL >> _className; diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHeal.sqf b/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHeal.sqf deleted file mode 100644 index 18bd0468d2..0000000000 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHeal.sqf +++ /dev/null @@ -1,21 +0,0 @@ -/** - * fn_heal.sqf - * @Descr: N/A - * @Author: Glowbal - * - * @Arguments: [] - * @Return: - * @PublicAPI: false - */ - -#include "script_component.hpp" - -params ["_caller", "_target", "_selectionName", "_className", "_items"]; - -if (local _target) then { - [QGVAR(treatmentAdvanced_fullHealLocal), [_caller, _target]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentAdvanced_fullHealLocal), [_caller, _target], _target] call CBA_fnc_targetEvent; -}; - -true; diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_bandage.sqf b/addons/medical_treatment/functions/fnc_treatmentBandage.sqf similarity index 58% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_bandage.sqf rename to addons/medical_treatment/functions/fnc_treatmentBandage.sqf index d0bf3ef2fe..71ebeae779 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_bandage.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentBandage.sqf @@ -5,8 +5,8 @@ * Arguments: * 0: The medic * 1: The patient - * 2: SelectionName - * 3: Treatment classname + * 2: Body part + * 3: Treatment class name * 4: Item * 5: specific Spot (default: -1) * @@ -15,24 +15,19 @@ * * Public: Yes */ - #include "script_component.hpp" -params ["_caller", "_target", "_selectionName", "_className", "_items", "", ["_specificSpot", -1]]; +params ["_caller", "_target", "_bodyPart", "_className", "_items", "", ["_specificSpot", -1]]; [_target, "activity", ELSTRING(medical,Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); [_target, "activity_view", ELSTRING(medical,Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message -if (local _target) then { - [QGVAR(treatmentAdvanced_bandageLocal), [_target, _className, _selectionName, _specificSpot]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentAdvanced_bandageLocal), [_target, _className, _selectionName, _specificSpot], _target] call CBA_fnc_targetEvent; -}; +[QGVAR(treatmentBandageLocal), [_target, _className, _bodyPart, _specificSpot], _target] call CBA_fnc_targetEvent; -/* { +/*{ if (_x != "") then { [_target, _x] call FUNC(addToTriageCard); }; -}forEach _items;*/ +} forEach _items;*/ -true; +true diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_bandageLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf similarity index 83% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_bandageLocal.sqf rename to addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf index 2d0c13ebb4..7c2814f5d5 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_bandageLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf @@ -5,35 +5,38 @@ * Arguments: * 0: The patient * 1: Treatment classname - * + * 2: Body part * * Return Value: * Succesful treatment started * * Public: No */ - #include "script_component.hpp" -params ["_target", "_bandage", "_selectionName", ["_specificClass", -1]]; +params ["_target", "_bandage", "_bodyPart", ["_specificClass", -1]]; // Ensure it is a valid bodypart -private _part = [_selectionName] call EFUNC(medical,selectionNameToNumber); -if (_part < 0) exitWith {false}; +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; +if (_partIndex < 0) exitWith {false}; // Get the open wounds for this unit private _openWounds = _target getVariable [QEGVAR(medical,openWounds), []]; if (count _openWounds == 0) exitWith {false}; // nothing to do here! // Get the default effectiveness for the used bandage -private _config = (configFile >> "ace_medical_treatment" >> "Bandaging"); +private _config = configFile >> "ace_medical_treatment" >> "Bandaging"; private _effectiveness = getNumber (_config >> "effectiveness"); + if (isClass (_config >> _bandage)) then { - systemchat "using class: " + _bandage; + systemchat ("using class: " + _bandage); _config = (_config >> _bandage); - if (isNumber (_config >> "effectiveness")) then { _effectiveness = getNumber (_config >> "effectiveness");}; + + if (isNumber (_config >> "effectiveness")) then { + _effectiveness = getNumber (_config >> "effectiveness"); + }; } else { - systemChat format["No bandage avialable"]; + systemChat "No bandage avialable"; }; // Figure out which injury for this bodypart is the best choice to bandage @@ -42,11 +45,13 @@ private _mostEffectiveSpot = 0; private _effectivenessFound = -1; private _mostEffectiveInjury = _openWounds select 0; private _exit = false; + { - _x params ["", "_classID", "_partX"]; + _x params ["", "_classID", "_partIndexN"]; TRACE_2("OPENWOUND: ", _target, _x); + // Only parse injuries that are for the selected bodypart. - if (_partX == _part) then { + if (_partIndexN == _partIndex) then { private _woundEffectiveness = _effectiveness; // Select the classname from the wound classname storage @@ -55,7 +60,8 @@ private _exit = false; // Check if this wound type has attributes specified for the used bandage if (isClass (_config >> _className)) then { // Collect the effectiveness from the used bandage for this wound type - private _woundTreatmentConfig = (_config >> _className); + private _woundTreatmentConfig = _config >> _className; + if (isNumber (_woundTreatmentConfig >> "effectiveness")) then { _woundEffectiveness = getNumber (_woundTreatmentConfig >> "effectiveness"); }; @@ -81,6 +87,7 @@ private _exit = false; _mostEffectiveInjury = _x; }; }; + if (_exit) exitWith {}; } forEach _openWounds; @@ -89,15 +96,15 @@ if (_effectivenessFound == -1) exitWith {}; // Seems everything is patched up on // TODO refactor this part // Find the impact this bandage has and reduce the amount this injury is present -private _impact = if ((_mostEffectiveInjury select 3) >= _effectivenessFound) then {_effectivenessFound} else { (_mostEffectiveInjury select 3) }; -_mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _impact) max 0]; +private _impact = if (_mostEffectiveInjury select 3 >= _effectivenessFound) then {_effectivenessFound} else { _mostEffectiveInjury select 3 }; +_mostEffectiveInjury set [3, ((_mostEffectiveInjury select 3) - _impact) max 0]; _openWounds set [_mostEffectiveSpot, _mostEffectiveInjury]; _target setVariable [QEGVAR(medical,openWounds), _openWounds, true]; // Handle the reopening of bandaged wounds if (_impact > 0 && {EGVAR(medical,level) >= 2} && {EGVAR(medical,enableAdvancedWounds)}) then { - [_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening); + [_target, _impact, _partIndex, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening); }; // If all wounds to a body part have been bandaged, reset damage to that body part to zero @@ -118,13 +125,13 @@ if (EGVAR(medical,healHitPointAfterAdvBandage) || {EGVAR(medical,level) < 2}) th // Loop through all current wounds and add up the number of unbandaged wounds on each body part. { - _x params ["", "", "_bodyPart", "_numOpenWounds", "_bloodLoss"]; + _x params ["", "", "_partIndex", "_numOpenWounds", "_bloodLoss"]; // Use switch/case for early termination if wounded limb is found before all six are checked. // Number of wounds multiplied by blood loss will return zero for a fully // bandaged body part, not incrementing the wound counter; or it will return // some other number which will increment the wound counter. - switch (_bodyPart) do { + switch (_partIndex) do { // Head case 0: { _headWounds = _headWounds + (_numOpenWounds * _bloodLoss); @@ -157,7 +164,7 @@ if (EGVAR(medical,healHitPointAfterAdvBandage) || {EGVAR(medical,level) < 2}) th }; } forEach _currentWounds; - // ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"] + // ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] private _bodyStatus = _target getVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0]]; // Any body part that has no wounds is healed to full health @@ -185,4 +192,4 @@ if (EGVAR(medical,healHitPointAfterAdvBandage) || {EGVAR(medical,level) < 2}) th [_target] call EFUNC(medical_damage,setDamage); }; -true; +true diff --git a/addons/medical_treatment/functions/fnc_treatmentBasic_bloodbag.sqf b/addons/medical_treatment/functions/fnc_treatmentBasic_bloodbag.sqf deleted file mode 100644 index 6989ac14b8..0000000000 --- a/addons/medical_treatment/functions/fnc_treatmentBasic_bloodbag.sqf +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Author: KoffeinFlummi - * Callback when the bloodbag treatment is complete - * - * Arguments: - * 0: The medic - * 1: The patient - * 2: Selection Name - * 3: Treatment classname - * - * Return Value: - * None - * - * Public: No - */ - -#include "script_component.hpp" - -params ["_caller", "_target", "_treatmentClassname"]; - -if (local _target) then { - [QGVAR(treatmentBasic_bloodbagLocal), [_target, _treatmentClassname]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentBasic_bloodbagLocal), [_target, _treatmentClassname], _target] call CBA_fnc_targetEvent; -}; diff --git a/addons/medical_treatment/functions/fnc_treatmentBloodbag.sqf b/addons/medical_treatment/functions/fnc_treatmentBloodbag.sqf new file mode 100644 index 0000000000..3d718e7a84 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentBloodbag.sqf @@ -0,0 +1,21 @@ +/* + * Author: KoffeinFlummi + * Callback when the bloodbag treatment is complete + * + * Arguments: + * 0: The medic + * 1: The patient + * 2: Body part + * 3: Treatment class name + * + * Return Value: + * None + * + * Public: No + */ + +#include "script_component.hpp" + +params ["_caller", "_target", "_treatmentClassname"]; + +[QGVAR(treatmentBloodbagLocal), [_target, _treatmentClassname], _target] call CBA_fnc_targetEvent; diff --git a/addons/medical_treatment/functions/fnc_treatmentBasic_bloodbagLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentBloodbagLocal.sqf similarity index 100% rename from addons/medical_treatment/functions/fnc_treatmentBasic_bloodbagLocal.sqf rename to addons/medical_treatment/functions/fnc_treatmentBloodbagLocal.sqf diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_CPR.sqf b/addons/medical_treatment/functions/fnc_treatmentCPR.sqf similarity index 67% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_CPR.sqf rename to addons/medical_treatment/functions/fnc_treatmentCPR.sqf index a634aa55a5..9ae5657490 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_CPR.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentCPR.sqf @@ -5,8 +5,8 @@ * Arguments: * 0: The medic * 1: The patient - * 2: SelectionName - * 3: Treatment classname + * 2: Body part + * 3: Treatment class name * * Return Value: * Succesful treatment started @@ -21,10 +21,7 @@ params ["_caller", "_target", "_selectionName", "_className", "_items"]; if (alive _target && {(_target getVariable [QEGVAR(medical,inCardiacArrest), false] || _target getVariable [QEGVAR(medical,inReviveState), false])}) then { [_target, "activity_view", ELSTRING(medical,Activity_cpr), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); - if (local _target) then { - [QGVAR(treatmentAdvanced_CPRLocal), [_caller, _target]] call CBA_fnc_localEvent; - } else { - [QGVAR(treatmentAdvanced_CPRLocal), [_caller, _target], _target] call CBA_fnc_targetEvent; - }; + [QGVAR(treatmentCPRLocal), [_caller, _target], _target] call CBA_fnc_targetEvent; }; -true; + +true diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_CPRLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentCPRLocal.sqf similarity index 96% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_CPRLocal.sqf rename to addons/medical_treatment/functions/fnc_treatmentCPRLocal.sqf index 4e9ce5929f..dc61546101 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_CPRLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentCPRLocal.sqf @@ -14,10 +14,11 @@ #include "script_component.hpp" -params ["_caller","_target"]; +params ["_caller", "_target"]; if (_target getVariable [QEGVAR(medical,inReviveState), false]) then { private _reviveStartTime = _target getVariable [QEGVAR(medical,reviveStartTime),0]; + if (_reviveStartTime > 0) then { _target setVariable [QEGVAR(medical,reviveStartTime), (_reviveStartTime + random(20)) min CBA_missionTime]; }; @@ -32,4 +33,4 @@ if (EGVAR(medical,level) > 1 && {(random 1) >= 0.6}) then { [_target, "activity", ELSTRING(medical,Activity_CPR), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); [_target, "activity_view", ELSTRING(medical,Activity_CPR), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message -true; +true diff --git a/addons/medical_treatment/functions/fnc_treatmentBasic_epipen.sqf b/addons/medical_treatment/functions/fnc_treatmentEpipen.sqf similarity index 72% rename from addons/medical_treatment/functions/fnc_treatmentBasic_epipen.sqf rename to addons/medical_treatment/functions/fnc_treatmentEpipen.sqf index e65a3fe483..3dae4dc811 100644 --- a/addons/medical_treatment/functions/fnc_treatmentBasic_epipen.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentEpipen.sqf @@ -5,8 +5,8 @@ * Arguments: * 0: The medic * 1: The patient - * 2: Selection Name - * 3: Treatment classname + * 2: Body part + * 3: Treatment class name * * Return Value: * None @@ -15,6 +15,6 @@ */ #include "script_component.hpp" -params ["_caller", "_target","_className"]; +params ["_caller", "_target"]; [_target, false] call EFUNC(medical,setUnconscious); diff --git a/addons/medical_treatment/functions/fnc_treatmentFullHeal.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHeal.sqf new file mode 100644 index 0000000000..0b0428c2d9 --- /dev/null +++ b/addons/medical_treatment/functions/fnc_treatmentFullHeal.sqf @@ -0,0 +1,23 @@ +/* + * Author: Glowbal + * Full heal treatment + * + * Arguments: + * 0: The medic + * 1: The patient + * 2: Body part + * 3: Treatment class name + * 4: Item + * + * Return Value: + * Succesful treatment started + * + * Public: Yes + */ +#include "script_component.hpp" + +params ["_caller", "_target"]; + +[QGVAR(treatmentFullHealLocal), [_caller, _target], _target] call CBA_fnc_targetEvent; + +true diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHealLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf similarity index 92% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHealLocal.sqf rename to addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf index 01e656c83f..b177e026b9 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHealLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf @@ -1,19 +1,21 @@ -/** - * fn_healLocal.sqf - * @Descr: N/A - * @Author: Glowbal +/* + * Author: Glowbal + * Handles full heal of a patient. * - * @Arguments: [] - * @Return: - * @PublicAPI: false + * Arguments: + * 0: The medic + * 1: The patient + * + * Return Value: + * Succesful treatment started + * + * Public: No */ - #include "script_component.hpp" params ["_caller", "_target"]; if (alive _target) exitWith { - _target setVariable [QEGVAR(medical,pain), 0, true]; _target setVariable [QEGVAR(medical,morphine), 0, true]; _target setVariable [QEGVAR(medical,bloodVolume), 100, true]; @@ -58,6 +60,7 @@ if (alive _target) exitWith { // medication private _allUsedMedication = _target getVariable [QEGVAR(medical,allUsedMedication), []]; + { _target setVariable [_x select 0, nil]; } forEach _allUsedMedication; diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHealTreatmentTime.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHealTreatmentTime.sqf similarity index 63% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHealTreatmentTime.sqf rename to addons/medical_treatment/functions/fnc_treatmentFullHealTreatmentTime.sqf index 9e55a5c9db..a1f8159139 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_fullHealTreatmentTime.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentFullHealTreatmentTime.sqf @@ -9,16 +9,18 @@ * treatment time * * Example: - * [_target] call ace_medical_fnc_treatmentAdvanced_fullHealTreatmentTime + * [_target] call ace_medical_treatment_fnc_treatmentFullHealTreatmentTime * * Public: No */ #include "script_component.hpp" +params ["_unit"]; + private _totalDamage = 0; { _totalDamage = _totalDamage + _x; -} forEach (_this getVariable [QEGVAR(medical,bodyPartStatus), []]); +} forEach (_unit getVariable [QEGVAR(medical,bodyPartStatus), []]); -(10 max (_totalDamage * 10) min 120) +10 max (_totalDamage * 10) min 120 diff --git a/addons/medical_treatment/functions/fnc_treatmentIV.sqf b/addons/medical_treatment/functions/fnc_treatmentIV.sqf index 7bfd2b1e76..20d3797420 100644 --- a/addons/medical_treatment/functions/fnc_treatmentIV.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentIV.sqf @@ -21,11 +21,8 @@ params ["_caller", "_target", "_selectionName", "_className", "_items"]; if (_items isEqualTo []) exitWith {false}; _items params ["_removeItem"]; -if (local _target) then { - [QGVAR(treatmentIVLocal), [_target, _className]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentIVLocal), [_target, _className], _target] call CBA_fnc_targetEvent; -}; + +[QGVAR(treatmentIVLocal), [_target, _className], _target] call CBA_fnc_targetEvent; [_target, _removeItem] call FUNC(addToTriageCard); [_target, "activity", ELSTRING(medical,Activity_gaveIV), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); diff --git a/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf index 65a0b3e633..2e2687b7d1 100644 --- a/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentIVLocal.sqf @@ -18,6 +18,7 @@ params ["_target", "_treatmentClassname"]; private _bloodVolume = _target getVariable [QEGVAR(medical,bloodVolume), 100]; + if (_bloodVolume >= 100) exitWith {}; // Find the proper attributes for the used IV diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_medication.sqf b/addons/medical_treatment/functions/fnc_treatmentMedication.sqf similarity index 65% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_medication.sqf rename to addons/medical_treatment/functions/fnc_treatmentMedication.sqf index b9b236f1dc..10cb74a7fa 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_medication.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentMedication.sqf @@ -5,8 +5,8 @@ * Arguments: * 0: The medic * 1: The patient - * 2: SelectionName - * 3: Treatment classname + * 2: Body part + * 3: Treatment class name * 4: Items Used * * Return Value: @@ -14,15 +14,14 @@ * * Public: Yes */ - #include "script_component.hpp" -params ["_caller", "_target", "_selectionName", "_className", "_items"]; -TRACE_5("params",_caller,_target,_selectionName,_className,_items); +params ["_caller", "_target", "_bodyPart", "_className", "_items"]; +TRACE_5("params",_caller,_target,_bodyPart,_className,_items); -private _part = [_selectionName] call EFUNC(medical,selectionNameToNumber); +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; -[QGVAR(treatmentAdvanced_medicationLocal), [_target, _className, _part], [_target]] call CBA_fnc_targetEvent; +[QGVAR(treatmentMedicationLocal), [_target, _className, _partIndex], [_target]] call CBA_fnc_targetEvent; { if (_x != "") then { @@ -32,5 +31,4 @@ private _part = [_selectionName] call EFUNC(medical,selectionNameToNumber); }; } forEach _items; - -true; +true diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_medicationLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf similarity index 95% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_medicationLocal.sqf rename to addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf index 85b5505544..ef7876406b 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_medicationLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentMedicationLocal.sqf @@ -12,23 +12,25 @@ * * Public: Yes */ - #include "script_component.hpp" params ["_target", "_className", "_partNumber"]; TRACE_3("params",_target,_className,_partNumber); private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; -if ((_tourniquets select _partNumber) > 0) exitWith { + +if (_tourniquets select _partNumber > 0) exitWith { TRACE_1("unit has tourniquets blocking blood flow on injection site",_tourniquets); private _delayedMedications = _target getVariable [QGVAR(occludedMedications), []]; + _delayedMedications pushBack _this; _target setVariable [QGVAR(occludedMedications), _delayedMedications, true]; + true }; // We have added a new dose of this medication to our system, so let's increase it -private _varName = format[QGVAR(%1_inSystem), _className]; +private _varName = format [QGVAR(%1_inSystem), _className]; private _currentInSystem = _target getVariable [_varName, 0]; _target setVariable [_varName, _currentInSystem + 1]; @@ -44,6 +46,7 @@ private _viscosityChange = getNumber (_medicationConfig >> "viscosityChange"); private _hrCallback = getText (_medicationConfig >> "hrCallback"); private _inCompatableMedication = []; + if (isClass (_medicationConfig >> _className)) then { _medicationConfig = (_medicationConfig >> _className); if (isNumber (_medicationConfig >> "painReduce")) then { _painReduce = getNumber (_medicationConfig >> "painReduce");}; @@ -56,15 +59,20 @@ if (isClass (_medicationConfig >> _className)) then { if (isNumber (_medicationConfig >> "viscosityChange")) then { _viscosityChange = getNumber (_medicationConfig >> "viscosityChange"); }; if (isText (_medicationConfig >> "hrCallback")) then { _hrCallback = getText (_medicationConfig >> "hrCallback"); }; }; + if (isNil _hrCallback) then { _hrCallback = compile _hrCallback; } else { _hrCallback = missionNamespace getVariable _hrCallback; }; -if (!(_hrCallback isEqualType {})) then {_hrCallback = {TRACE_1("callback was NOT code",_hrCallback)};}; + +if !(_hrCallback isEqualType {}) then { + _hrCallback = {TRACE_1("callback was NOT code",_hrCallback)}; +}; // Adjust the heart rate based upon config entry private _heartRate = _target getVariable [QEGVAR(medical,heartRate), 70]; + if (alive _target) then { if (_heartRate > 0) then { if (_heartRate <= 45) then { diff --git a/addons/medical_treatment/functions/fnc_treatmentBasic_morphine.sqf b/addons/medical_treatment/functions/fnc_treatmentMorphine.sqf similarity index 51% rename from addons/medical_treatment/functions/fnc_treatmentBasic_morphine.sqf rename to addons/medical_treatment/functions/fnc_treatmentMorphine.sqf index f704a67042..3a396a2bc9 100644 --- a/addons/medical_treatment/functions/fnc_treatmentBasic_morphine.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentMorphine.sqf @@ -5,22 +5,18 @@ * Arguments: * 0: The medic * 1: The patient - * 2: Selection Name - * 3: Treatment classname + * 2: Body part + * 3: Treatment class name * * Return Value: * None * * Public: No */ - #include "script_component.hpp" + #define MORPHINEHEAL 0.4 params ["_caller", "_target"]; -if (local _target) then { - [QGVAR(treatmentBasic_morphineLocal), [_target]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentBasic_morphineLocal), [_target], _target] call CBA_fnc_targetEvent; -}; +[QGVAR(treatmentMorphineLocal), [_target], _target] call CBA_fnc_targetEvent; diff --git a/addons/medical_treatment/functions/fnc_treatmentBasic_morphineLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf similarity index 91% rename from addons/medical_treatment/functions/fnc_treatmentBasic_morphineLocal.sqf rename to addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf index 89429d4247..15b0e543f3 100644 --- a/addons/medical_treatment/functions/fnc_treatmentBasic_morphineLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentMorphineLocal.sqf @@ -3,16 +3,15 @@ * Local callback when the morphine treatment is complete * * Arguments: - * 0: The medic - * 1: The patient + * 0: The patient * * Return Value: * None * * Public: No */ - #include "script_component.hpp" + #define MORPHINEHEAL 0.4 params ["_target"]; diff --git a/addons/medical_treatment/functions/fnc_treatmentAdvanced_surgicalKit_onProgress.sqf b/addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf similarity index 91% rename from addons/medical_treatment/functions/fnc_treatmentAdvanced_surgicalKit_onProgress.sqf rename to addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf index 37dd7c1e74..1a6357b25f 100644 --- a/addons/medical_treatment/functions/fnc_treatmentAdvanced_surgicalKit_onProgress.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf @@ -25,7 +25,7 @@ private _bandagedWounds = _target getVariable [QEGVAR(medical,bandagedWounds), [ if (count _bandagedWounds == 0) exitWith { false }; //Has enough time elapsed that we can close another wound? -if ((_totalTime - _elapsedTime) <= (((count _bandagedWounds) - 1) * 5)) then { +if (_totalTime - _elapsedTime <= (count _bandagedWounds - 1) * 5) then { _bandagedWounds deleteAt 0; _target setVariable [QEGVAR(medical,bandagedWounds), _bandagedWounds, true]; }; diff --git a/addons/medical_treatment/functions/fnc_treatmentTourniquet.sqf b/addons/medical_treatment/functions/fnc_treatmentTourniquet.sqf index 89b94375c4..1adbb5a5d4 100644 --- a/addons/medical_treatment/functions/fnc_treatmentTourniquet.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentTourniquet.sqf @@ -5,41 +5,35 @@ * Arguments: * 0: The medic * 1: The patient - * 2: SelectionName - * 3: Treatment classname - * + * 2: Body part + * 3: Treatment class name * * Return Value: * Succesful treatment started * * Public: No */ - #include "script_component.hpp" -params ["_caller", "_target", "_selectionName", "_className", "_items"]; +params ["_caller", "_target", "_bodyPart", "_className", "_items"]; if (count _items == 0) exitWith {false}; -private _part = [_selectionName] call EFUNC(medical,selectionNameToNumber); -if (_part == 0 || _part == 1) exitWith { - // [QEGVAR(common,displayTextStructured), ["You cannot apply a CAT on this body part!"], [_caller]] call CBA_fnc_targetEvent; - false; -}; +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; + +if (_partIndex == 0 || _partIndex == 1) exitWith {false}; private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; -if ((_tourniquets select _part) > 0) exitWith { + +if (_tourniquets select _partIndex > 0) exitWith { _output = "There is already a tourniquet on this body part!"; // TODO localization [QEGVAR(common,displayTextStructured), [_output, 1.5, _caller], [_caller]] call CBA_fnc_targetEvent; - false; + false }; private _removeItem = _items select 0; -if (local _target) then { - [QGVAR(treatmentTourniquetLocal), [_target, _removeItem, _selectionName]] call CBA_fnc_localEvent; -} else { - [QGVAR(treatmentTourniquetLocal), [_target, _removeItem, _selectionName], _target] call CBA_fnc_targetEvent; -}; + +[QGVAR(treatmentTourniquetLocal), [_target, _removeItem, _selectionName], _target] call CBA_fnc_targetEvent; [_target, _removeItem] call FUNC(addToTriageCard); [_target, "activity", ELSTRING(medical,Activity_appliedTourniquet), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); diff --git a/addons/medical_treatment/functions/fnc_treatmentTourniquetLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentTourniquetLocal.sqf index cf886b292a..26118ed880 100644 --- a/addons/medical_treatment/functions/fnc_treatmentTourniquetLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentTourniquetLocal.sqf @@ -5,6 +5,7 @@ * Arguments: * 0: The patient * 1: Item used classname + * 2: Body part * * Return Value: * None @@ -13,14 +14,16 @@ */ #include "script_component.hpp" -params ["_target", "_tourniquetItem", "_selectionName"]; +params ["_target", "_tourniquetItem", "_bodyPart"]; //If we're not already tracking vitals, start: [_target] call EFUNC(medical,addVitalLoop); -private _part = [_selectionName] call EFUNC(medical,selectionNameToNumber); +private _partIndex = ALL_BODY_PARTS find toLower _bodyPart; // Place a tourniquet on the bodypart private _tourniquets = _target getVariable [QEGVAR(medical,tourniquets), [0,0,0,0,0,0]]; -_tourniquets set [_part, CBA_missionTime]; + +_tourniquets set [_partIndex, CBA_missionTime]; + _target setVariable [QEGVAR(medical,tourniquets), _tourniquets, true]; diff --git a/addons/medical_treatment/functions/fnc_treatment_success.sqf b/addons/medical_treatment/functions/fnc_treatment_success.sqf index e69ae9e272..a7d6278f1e 100644 --- a/addons/medical_treatment/functions/fnc_treatment_success.sqf +++ b/addons/medical_treatment/functions/fnc_treatment_success.sqf @@ -5,7 +5,7 @@ * Arguments: * 0: The medic * 1: The patient - * 2: SelectionName + * 2: Body part * 3: Treatment classname * 4: Items available > * @@ -17,7 +17,7 @@ #include "script_component.hpp" params ["_args"]; -_args params ["_caller", "_target", "_selectionName", "_className", "_items", "_usersOfItems"]; +_args params ["_caller", "_target", "_bodyPart", "_className", "_items", "_usersOfItems"]; // switch to end anim immediately private _endInAnim = _caller getVariable QGVAR(endInAnim); @@ -50,10 +50,10 @@ if !(_callback isEqualType {}) then { //Get current blood loose on limb (for "bloody" litter) private _bloodLossOnSelection = 0; -private _partNumber = ([_selectionName] call EFUNC(medical,selectionNameToNumber)) max 0; +private _partNumber = (ALL_BODY_PARTS find toLower _bodyPart) max 0; // Add all bleeding from wounds on selection -private _openWounds = _target getvariable [QGVAR(openWounds), []]; +private _openWounds = _target getvariable [QEGVAR(medical,openWounds), []]; { _x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"]; if (_selectionX == _partNumber) then { @@ -71,4 +71,4 @@ if (!(_target getVariable [QGVAR(addedToUnitLoop),false])) then { [_target] call FUNC(addVitalLoop); }; -["ace_treatmentSucceded", [_caller, _target, _selectionName, _className]] call CBA_fnc_localEvent; +["ace_treatmentSucceded", [_caller, _target, _bodyPart, _className]] call CBA_fnc_localEvent; diff --git a/addons/medical_treatment/script_component.hpp b/addons/medical_treatment/script_component.hpp index cfc16518f8..e8bd99ded7 100644 --- a/addons/medical_treatment/script_component.hpp +++ b/addons/medical_treatment/script_component.hpp @@ -2,9 +2,8 @@ #define COMPONENT_BEAUTIFIED Medical Treatment #include "\z\ace\addons\main\script_mod.hpp" -// #define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL #define DISABLE_COMPILE_CACHE -// #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_MEDICAL_TREATMENT @@ -17,4 +16,6 @@ #include "\z\ace\addons\main\script_macros.hpp" +#define ALL_BODY_PARTS ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] + #define CUR_LEVEL (["Basic", "Advanced"] select (EGVAR(medical,level) >= 2))