diff --git a/addons/medical/XEH_preInit.sqf b/addons/medical/XEH_preInit.sqf index 41171c2da3..08b2ce0e0b 100644 --- a/addons/medical/XEH_preInit.sqf +++ b/addons/medical/XEH_preInit.sqf @@ -16,6 +16,7 @@ PREP(addToTriageCard); PREP(addUnconsciousCondition); PREP(canAccessMedicalEquipment); PREP(canTreat); +PREP(determineIfFatal); PREP(getBloodLoss); PREP(getBloodPressure); PREP(getBloodVolumeChange); @@ -24,6 +25,7 @@ PREP(getTypeOfDamage); PREP(getUnconsciousCondition); PREP(handleDamage); PREP(handleDamage_advanced); +PREP(handleDamage_advancedSetDamage); PREP(handleDamage_airway); PREP(handleDamage_basic); PREP(handleDamage_caching); @@ -40,6 +42,7 @@ PREP(isInMedicalFacility); PREP(isMedic); PREP(isMedicalVehicle); PREP(onMedicationUsage); +PREP(onTreatmentCompleted); PREP(parseConfigForInjuries); PREP(playInjuredSound); PREP(reactionToDamage); @@ -48,7 +51,6 @@ PREP(setCardiacArrest); PREP(setDead); PREP(setHitPointDamage); PREP(setUnconscious); -PREP(treatmentIV); PREP(treatment); PREP(treatment_failure); PREP(treatment_success); @@ -64,6 +66,7 @@ PREP(treatmentBasic_bandage); PREP(treatmentBasic_bloodbag); PREP(treatmentBasic_epipen); PREP(treatmentBasic_morphine); +PREP(treatmentIV); PREP(treatmentIVLocal); PREP(treatmentTourniquet); PREP(treatmentTourniquetLocal); diff --git a/addons/medical/functions/fnc_addToInjuredCollection.sqf b/addons/medical/functions/fnc_addToInjuredCollection.sqf index f09e40922a..71eec5a522 100644 --- a/addons/medical/functions/fnc_addToInjuredCollection.sqf +++ b/addons/medical/functions/fnc_addToInjuredCollection.sqf @@ -24,9 +24,9 @@ if !(_unit getvariable[QGVAR(addedToUnitLoop),false]) then{ }; if ([_unit] call FUNC(hasMedicalEnabled)) then { - [{ - private "_unit"; - _unit = (_this select 0) select 0; + [{ + private "_unit"; + _unit = (_this select 0) select 0; if (!alive _unit || !local _unit) then { [_this select 1] call CBA_fnc_removePerFrameHandler; } else { @@ -41,5 +41,5 @@ if ([_unit] call FUNC(hasMedicalEnabled)) then { [_unit] call FUNC(playInjuredSound); }; }; - }, 1, [_unit]] call CBA_fnc_addPerFrameHandler; + }, 1, [_unit]] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/medical/functions/fnc_canTreat.sqf b/addons/medical/functions/fnc_canTreat.sqf index 550aa34ca0..2260a2750b 100644 --- a/addons/medical/functions/fnc_canTreat.sqf +++ b/addons/medical/functions/fnc_canTreat.sqf @@ -24,7 +24,7 @@ _className = _this select 3; _config = (ConfigFile >> "ACE_Medical_Treatments" >> "Basic" >> _className); if (GVAR(level)>=1) then { - _config = (ConfigFile >> "ACE_Medical_Treatments" >> "Advanced" >> _className); + _config = (ConfigFile >> "ACE_Medical_Treatments" >> "Advanced" >> _className); }; if !(isClass _config) exitwith {false}; @@ -40,9 +40,9 @@ if ("All" in _locations) exitwith {true}; _return = false; { - if (_x == "field") exitwith {_return = true;}; - if (_x == "MedicalFacility" && {[_caller, _target] call FUNC(inMedicalFacility)}) exitwith {_return = true;}; - if (_x == "MedicalVehicle" && {[_caller, _target] call FUNC(inMedicalVehicle)}) exitwith {_return = true;}; + if (_x == "field") exitwith {_return = true;}; + if (_x == "MedicalFacility" && {[_caller, _target] call FUNC(inMedicalFacility)}) exitwith {_return = true;}; + if (_x == "MedicalVehicle" && {[_caller, _target] call FUNC(inMedicalVehicle)}) exitwith {_return = true;}; }foreach _locations; _return; diff --git a/addons/medical/functions/fnc_determineIfFatal.sqf b/addons/medical/functions/fnc_determineIfFatal.sqf new file mode 100644 index 0000000000..2c0d3c3e51 --- /dev/null +++ b/addons/medical/functions/fnc_determineIfFatal.sqf @@ -0,0 +1,42 @@ +/** + * fn_determineIfFatal.sqf + * @Descr: N/A + * @Author: Glowbal + * + * @Arguments: [] + * @Return: + * @PublicAPI: false + */ + +#include "script_component.hpp" + +private ["_unit","_part","_damageThreshold", "_withDamage"]; +_unit = _this select 0; +_part = _this select 1; +_withDamage = if (count _this > 2) then { _this select 2} else {0}; + +if (!alive _unit) exitwith {true}; + +if ((vehicle _unit != _unit) && {!alive (vehicle _unit)}) exitwith { true }; + +// Find the correct Damage threshold for unit. +_damageThreshold = [1,1,1]; +if (isPlayer _unit) then { + _damageThreshold =_unit getvariable[QGVAR(unitDamageThreshold), [GVAR(damageThreshold_Players), GVAR(damageThreshold_Players), GVAR(damageThreshold_Players) * 1.7]]; +} else { + _damageThreshold =_unit getvariable[QGVAR(unitDamageThreshold), [GVAR(damageThreshold_AI), GVAR(damageThreshold_AI), GVAR(damageThreshold_AI) * 1.7]]; +}; + +_damageBodyPart = ((_unit getvariable [QGVAR(bodyPartStatus),[0,0,0,0,0,0]]) select _part) + _withDamage; + +// Check if damage to body part is higher as damage head +if (_part == 0) exitwith { + (_damageBodyPart >= (_damageThreshold select 0) && {(random(1) > 0.2)}); +}; + +// Check if damage to body part is higher as damage torso +if (_part == 1) exitwith { + (_damageBodyPart >= (_damageThreshold select 1) && {(random(1) > 0.2)}); +}; +// Check if damage to body part is higher as damage limbs +(_damageBodyPart >= (_damageThreshold select 2) && {(random(1) > 0.95)}); diff --git a/addons/medical/functions/fnc_getBloodLoss.sqf b/addons/medical/functions/fnc_getBloodLoss.sqf index 685da08a25..d91ab15d52 100644 --- a/addons/medical/functions/fnc_getBloodLoss.sqf +++ b/addons/medical/functions/fnc_getBloodLoss.sqf @@ -19,27 +19,27 @@ _totalBloodLoss = 0; // Advanced medical bloodloss handling if (GVAR(level) >= 1) then { - _tourniquets = _this getvariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; - _openWounds = _this getvariable [QGVAR(openWounds), []]; - //_cardiacOutput = [_this] call FUNC(getCardiacOutput); + _tourniquets = _this getvariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; + _openWounds = _this getvariable [QGVAR(openWounds), []]; + //_cardiacOutput = [_this] call FUNC(getCardiacOutput); - { - if ((_tourniquets select (_x select 2)) < 1) then { - // total bleeding ratio * percentage of injury left - _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); + { + if ((_tourniquets select (_x select 2)) < 1) then { + // total bleeding ratio * percentage of injury left + _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); - // (((BLOODLOSS_SMALL_WOUNDS * (_x select 0))) + ((BLOODLOSS_MEDIUM_WOUNDS * (_x select 1))) + ((BLOODLOSS_LARGE_WOUNDS * (_x select 2))) * (_cardiacOutput / DEFAULT_CARDIAC_OUTPUT)); - }; - }foreach _openWounds; + // (((BLOODLOSS_SMALL_WOUNDS * (_x select 0))) + ((BLOODLOSS_MEDIUM_WOUNDS * (_x select 1))) + ((BLOODLOSS_LARGE_WOUNDS * (_x select 2))) * (_cardiacOutput / DEFAULT_CARDIAC_OUTPUT)); + }; + }foreach _openWounds; - _internalWounds = _this getvariable [QGVAR(internalWounds), []]; - { - _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); - }foreach _internalWounds; + _internalWounds = _this getvariable [QGVAR(internalWounds), []]; + { + _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); + }foreach _internalWounds; - // cap the blood loss to be no greater as the current cardiac output - //(_totalBloodLoss min _cardiacOutput); + // cap the blood loss to be no greater as the current cardiac output + //(_totalBloodLoss min _cardiacOutput); } else { - // TODO basic medical + // TODO basic medical }; _totalBloodLoss; diff --git a/addons/medical/functions/fnc_handleDamage.sqf b/addons/medical/functions/fnc_handleDamage.sqf index 7003c97771..0febbcc752 100644 --- a/addons/medical/functions/fnc_handleDamage.sqf +++ b/addons/medical/functions/fnc_handleDamage.sqf @@ -1,5 +1,5 @@ /* - * Author: KoffeinFlummi + * Author: KoffeinFlummi, Glowbal * Main HandleDamage EH function. * * Arguments: @@ -26,7 +26,7 @@ _projectile = _this select 4; if !(local _unit) exitWith {nil}; -if !([_unit] call FUNC(hasMedicalEnabled)) exitwith {}; +if !([_unit] call FUNC(hasMedicalEnabled)) exitwith {systemChat format["Has no medical enabled: %1", _unit];}; if (typeName _projectile == "OBJECT") then { _projectile = typeOf _projectile; @@ -47,12 +47,22 @@ if (GVAR(level) == 0) then { if (_damageReturn < 0.01) exitWith {0}; if (GVAR(level) >= 1) then { - [_unit, _selectionName, _damage, _source, _projectile, _damageReturn] call FUNC(handleDamage_caching); + [_unit, _selectionName, _damage, _source, _projectile, _damageReturn] call FUNC(handleDamage_caching); - // TODO check if this should would have killed the unit.. - if (_damageReturn > 0.9) then { - _damageReturn = 0.9; - }; + if (_damageReturn > 0.9) then { + _hitPoints = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"]; + _newDamage = _damage - (damage _unit); + if (_selectionName in _hitSelections) then { + _newDamage = _damage - (_unit getHitPointDamage (_hitPoints select (_hitSelections find _selectionName))); + }; + if ([_unit, [_selectionName] call FUNC(selectionNameToNumber), _newDamage] call FUNC(determineIfFatal)) then { + if ([_unit] call FUNC(setDead)) then { + _damageReturn = 1; + }; + } else { + _damageReturn = 0.89; + }; + }; }; if (_unit getVariable [QGVAR(preventDeath), false] && {_damageReturn >= 0.9} && {_selection in ["", "head", "body"]}) exitWith { diff --git a/addons/medical/functions/fnc_handleDamage_advanced.sqf b/addons/medical/functions/fnc_handleDamage_advanced.sqf index 5fe0f59fb1..559c52709e 100644 --- a/addons/medical/functions/fnc_handleDamage_advanced.sqf +++ b/addons/medical/functions/fnc_handleDamage_advanced.sqf @@ -19,33 +19,39 @@ #include "script_component.hpp" -private ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"]; +private ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage", "_part", "_damageBodyParts", "_newDamage", "_hitPoints"]; _unit = _this select 0; _selectionName = _this select 1; _amountOfDamage = _this select 2; _sourceOfDamage = _this select 3; _typeOfProjectile = _this select 4; _returnDamage = _this select 5; + _typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage); +_part = [_selectionName] call FUNC(selectionNameToNumber); +_hitPoints = ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"]; +// Sorting out the damage +_damageBodyParts = _unit getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]; +_newDamage = _amountOfDamage - (_unit getHitPointDamage (_hitPoints select _part)); +_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage]; +_unit setvariable [QGVAR(bodyPartStatus), _damageBodyParts, true]; +[_unit] call FUNC(handleDamage_advancedSetDamage); -// TODO parse for new damage -// TODO parse for kill injuries - -[_unit, _selectionName, _amountOfDamage, _typeOfProjectile, _typeOfDamage] call FUNC(handleDamage_wounds); +[_unit, _selectionName, _newDamage, _typeOfProjectile, _typeOfDamage] call FUNC(handleDamage_wounds); if (GVAR(enableAirway)) then { - [_unit,_selectionName,_amountOfDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_airway); + [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_airway); }; if (GVAR(enableFractures)) then { - [_unit,_selectionName,_amountOfDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_fractures); + [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_fractures); }; if (GVAR(enableInternalBleeding)) then { - [_unit,_selectionName,_amountOfDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_internalInjuries); + [_unit,_selectionName,_newDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_internalInjuries); }; if (alive _unit && {!(_unit getvariable ["ACE_isUnconscious", false])}) then { - [_unit, _amountOfDamage] call FUNC(reactionToDamage); + [_unit, _newDamage] call FUNC(reactionToDamage); }; _returnDamage; diff --git a/addons/medical/functions/fnc_handleDamage_advancedSetDamage.sqf b/addons/medical/functions/fnc_handleDamage_advancedSetDamage.sqf new file mode 100644 index 0000000000..74db6029d2 --- /dev/null +++ b/addons/medical/functions/fnc_handleDamage_advancedSetDamage.sqf @@ -0,0 +1,56 @@ +/* + * Author: Glowbal + * Sets the hitpoint damage for au nit to the correct values + * + * Arguments: + * 0: Unit for which the hitpoint damage will be sorted out + * + * Return Value: + * nil + * + * Public: No + */ + +#include "script_component.hpp" + +private ["_unit", "_bodyStatus", "_headDamage", "_torsoDamage", "_handsDamage", "_legsDamage"]; +_unit = _this select 0; + +if (!local _unit) exitwith { + // execute only local +}; + +_bodyStatus = _unit getvariable [QGVAR(bodyPartStatus),[0,0,0,0,0,0]]; +// ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"] +_headDamage = _bodyStatus select 0; +if (_headDamage > 0.95) then { + _unit setHitPointDamage ["hitHead", 0.95]; +} else { + _unit setHitPointDamage ["hitHead", _headDamage]; +}; + +_torsoDamage = _bodyStatus select 1; +if (_torsoDamage > 0.95) then { + _unit setHitPointDamage ["hitBody", 0.95]; +} else { + _unit setHitPointDamage ["hitBody", _torsoDamage]; +}; + + +_handsDamage = (_bodyStatus select 2) + (_bodyStatus select 3); +if (_handsDamage > 0.95) then { + _unit setHitPointDamage ["hitHands", 0.95]; +} else { + _unit setHitPointDamage ["hitHands", _handsDamage]; +}; + +_legsDamage = (_bodyStatus select 4) + (_bodyStatus select 5); +if (_legsDamage > 0.95) then { + _unit setHitPointDamage ["hitLegs", 0.95]; +} else { + _unit setHitPointDamage ["hitLegs", _legsDamage]; +}; + +if ({_x > 0} count _bodyStatus == 0) then { + _unit setDamage 0; +}; diff --git a/addons/medical/functions/fnc_handleDamage_airway.sqf b/addons/medical/functions/fnc_handleDamage_airway.sqf index 0fb7daeed4..a1357e95a8 100644 --- a/addons/medical/functions/fnc_handleDamage_airway.sqf +++ b/addons/medical/functions/fnc_handleDamage_airway.sqf @@ -30,8 +30,8 @@ if (_bodyPartn != 0) exitwith {}; if (_amountOfDamage > 0.4) then { if (random(1) >= 0.8) then { - if !(_unit getvariable[QGVAR(airwayCollapsed), false]) then { - _unit setvariable [QGVAR(airwayCollapsed), true, true]; - }; + if !(_unit getvariable[QGVAR(airwayCollapsed), false]) then { + _unit setvariable [QGVAR(airwayCollapsed), true, true]; + }; }; }; diff --git a/addons/medical/functions/fnc_hasItems.sqf b/addons/medical/functions/fnc_hasItems.sqf index 4bae508ecf..ea16edebc4 100644 --- a/addons/medical/functions/fnc_hasItems.sqf +++ b/addons/medical/functions/fnc_hasItems.sqf @@ -22,13 +22,13 @@ _items = _this select 2; _return = true; { - // - if (typeName _x == "ARRAY" && {({[_medic, _patient, _x] call FUNC(hasItem)}count _x == 0)}) exitwith { - _return = false; - }; - if (typeName _x == "STRING" && {!([_medic, _patient, _x] call FUNC(hasItem))}) exitwith { - _return = false; - }; + // + if (typeName _x == "ARRAY" && {({[_medic, _patient, _x] call FUNC(hasItem)}count _x == 0)}) exitwith { + _return = false; + }; + if (typeName _x == "STRING" && {!([_medic, _patient, _x] call FUNC(hasItem))}) exitwith { + _return = false; + }; }foreach _items; _return; diff --git a/addons/medical/functions/fnc_init.sqf b/addons/medical/functions/fnc_init.sqf index 28704d8e0f..a783c25c92 100644 --- a/addons/medical/functions/fnc_init.sqf +++ b/addons/medical/functions/fnc_init.sqf @@ -31,8 +31,7 @@ _unit setVariable [QGVAR(internalWounds), [], true]; // vitals _unit setVariable [QGVAR(heartRate), 80]; _unit setvariable [QGVAR(heartRateAdjustments), []]; -// _unit setvariable [QGVAR(bloodPressure), _bloodPressure]; @todo for glowbal -_unit setvariable [QGVAR(bloodPressure), 0]; +_unit setvariable [QGVAR(bloodPressure), [80, 120]]; _unit setVariable [QGVAR(peripheralResistance), 100]; // fractures @@ -57,7 +56,7 @@ _unit setvariable [QGVAR(airwayCollapsed), true, true]; // generic medical admin _unit setvariable [QGVAR(addedToUnitLoop), false, true]; -_unit setvariable [QGVAR(inCardiacArrest), true,true]; +_unit setvariable [QGVAR(inCardiacArrest), true, true]; _unit setVariable [QGVAR(isUnconscious), false, true]; _unit setvariable [QGVAR(hasLostBlood), true, true]; _unit setvariable [QGVAR(isBleeding), false, true]; @@ -72,6 +71,7 @@ _unit setVariable [QGVAR(allUsedMedication), []]; _logs = _unit getvariable [QGVAR(allLogs), []]; { - _unit setvariable [_x, nil, true]; + _unit setvariable [_x, nil, true]; } foreach _logs; + _unit setvariable [_x, nil, true]; _unit setvariable [QGVAR(allLogs), [], true]; diff --git a/addons/medical/functions/fnc_isMedic.sqf b/addons/medical/functions/fnc_isMedic.sqf index d3d4b51e7e..872777e8c6 100644 --- a/addons/medical/functions/fnc_isMedic.sqf +++ b/addons/medical/functions/fnc_isMedic.sqf @@ -24,9 +24,9 @@ if (isnil QGVAR(setting_advancedMedicRoles)) exitwith { if (GVAR(setting_advancedMedicRoles)) then { _class = _unit getvariable [QGVAR(medicClass), 0]; - if (_class >= _medicN) then { - _return = true; - }; + if (_class >= _medicN) then { + _return = true; + }; } else { _return = true; }; diff --git a/addons/medical/functions/fnc_onMedicationUsage.sqf b/addons/medical/functions/fnc_onMedicationUsage.sqf index 88fb3acb64..185ec28961 100644 --- a/addons/medical/functions/fnc_onMedicationUsage.sqf +++ b/addons/medical/functions/fnc_onMedicationUsage.sqf @@ -16,6 +16,8 @@ * Public: No */ +#include "script_component.hpp" + private ["_target", "_className", "_variable", "_maxDosage", "_timeInSystem", "_incompatabileMeds", "_foundEntry", "_allUsedMedication","_allMedsFromClassname", "_usedMeds", "_hasOverDosed", "_med", "_limit", "_classNamesUsed", "_decreaseAmount"]; _target = _this select 0; _className = _this select 1; diff --git a/addons/medical/functions/fnc_parseConfigForInjuries.sqf b/addons/medical/functions/fnc_parseConfigForInjuries.sqf index 7e4843ca2e..6ab5a482b2 100644 --- a/addons/medical/functions/fnc_parseConfigForInjuries.sqf +++ b/addons/medical/functions/fnc_parseConfigForInjuries.sqf @@ -20,54 +20,54 @@ _allTypes = ["stab", "grenade", "bullet", "explosive", "shell", "punch", "vehicl _allFoundDamageTypes = []; _configDamageTypes = (_injuryRouteConfig >> "damageTypes"); for "_i" from 0 to (count _configDamageTypes -1) /* step +1 */ do { - if (isClass(_configDamageTypes select _i)) then { - _allFoundDamageTypes pushback (configName (_configDamageTypes select _i)); - }; + if (isClass(_configDamageTypes select _i)) then { + _allFoundDamageTypes pushback (configName (_configDamageTypes select _i)); + }; }; GVAR(allAvailableDamageTypes) = _allFoundDamageTypes; _parseForSubClassWounds = { - _subClass = _this select 0; - if (isClass (_entry >> _subClass)) exitwith { - _subClassConfig = (_entry >> _subClass); - _subClasstype = _classType + (configName _subClassConfig); - _subClassselections = if (isArray(_subClassConfig >> "selections")) then { getArray(_subClassConfig >> "selections");} else { _selections }; - _subClassbloodLoss = if (isNumber(_subClassConfig >> "bleedingRate")) then { getNumber(_subClassConfig >> "bleedingRate");} else { _bloodLoss }; - _subClasspain = if (isNumber(_subClassConfig >> "pain")) then { getNumber(_subClassConfig >> "pain");} else { _pain }; - _subClassminDamage = if (isNumber(_subClassConfig >> "minDamage")) then { getNumber(_subClassConfig >> "minDamage");} else { _minDamage }; - _subClasscauses = if (isArray(_subClassConfig >> "causes")) then { getArray(_subClassConfig >> "causes");} else { _causes }; - if (count _selections > 0 && count _causes > 0) then { - _allWoundClasses pushback [_subClasstype, _subClassselections, _subClassbloodLoss, _subClasspain, _subClassminDamage, _subClasscauses]; - }; - true; - }; - false; + _subClass = _this select 0; + if (isClass (_entry >> _subClass)) exitwith { + _subClassConfig = (_entry >> _subClass); + _subClasstype = _classType + (configName _subClassConfig); + _subClassselections = if (isArray(_subClassConfig >> "selections")) then { getArray(_subClassConfig >> "selections");} else { _selections }; + _subClassbloodLoss = if (isNumber(_subClassConfig >> "bleedingRate")) then { getNumber(_subClassConfig >> "bleedingRate");} else { _bloodLoss }; + _subClasspain = if (isNumber(_subClassConfig >> "pain")) then { getNumber(_subClassConfig >> "pain");} else { _pain }; + _subClassminDamage = if (isNumber(_subClassConfig >> "minDamage")) then { getNumber(_subClassConfig >> "minDamage");} else { _minDamage }; + _subClasscauses = if (isArray(_subClassConfig >> "causes")) then { getArray(_subClassConfig >> "causes");} else { _causes }; + if (count _selections > 0 && count _causes > 0) then { + _allWoundClasses pushback [_subClasstype, _subClassselections, _subClassbloodLoss, _subClasspain, _subClassminDamage, _subClasscauses]; + }; + true; + }; + false; }; // TODO classTypes are strings currently. Convert them to unqiue IDs instead. _woundsConfig = (_injuriesRootConfig >> "wounds"); _allWoundClasses = []; if (isClass _woundsConfig) then { - _amountOf = count _woundsConfig; - for "_i" from 0 to (_amountOf -1) /* step +1 */ do { - _entry = _woundsConfig select _i; - if (isClass _entry) then { - _classType = (ConfigName _entry); - _selections = if (isArray(_entry >> "selections")) then { getArray(_entry >> "selections");} else {[]}; - _bloodLoss = if (isNumber(_entry >> "bleedingRate")) then { getNumber(_entry >> "bleedingRate");} else {0}; - _pain = if (isNumber(_entry >> "pain")) then { getNumber(_entry >> "pain");} else {0}; - _minDamage = if (isNumber(_entry >> "minDamage")) then { getNumber(_entry >> "minDamage");} else {0}; - _causes = if (isArray(_entry >> "causes")) then { getArray(_entry >> "causes");} else {[]}; + _amountOf = count _woundsConfig; + for "_i" from 0 to (_amountOf -1) /* step +1 */ do { + _entry = _woundsConfig select _i; + if (isClass _entry) then { + _classType = (ConfigName _entry); + _selections = if (isArray(_entry >> "selections")) then { getArray(_entry >> "selections");} else {[]}; + _bloodLoss = if (isNumber(_entry >> "bleedingRate")) then { getNumber(_entry >> "bleedingRate");} else {0}; + _pain = if (isNumber(_entry >> "pain")) then { getNumber(_entry >> "pain");} else {0}; + _minDamage = if (isNumber(_entry >> "minDamage")) then { getNumber(_entry >> "minDamage");} else {0}; + _causes = if (isArray(_entry >> "causes")) then { getArray(_entry >> "causes");} else {[]}; - if (["Minor"] call _parseForSubClassWounds || ["Medium"] call _parseForSubClassWounds || ["Large"] call _parseForSubClassWounds) exitwith {}; // continue to the next one + if (["Minor"] call _parseForSubClassWounds || ["Medium"] call _parseForSubClassWounds || ["Large"] call _parseForSubClassWounds) exitwith {}; // continue to the next one - // There were no subclasses, so we will add this one instead. - if (count _selections > 0 && count _causes > 0) then { - _allWoundClasses pushback [_classType, _selections, _bloodLoss, _pain, _minDamage, _causes]; - }; - true; - }; - }; + // There were no subclasses, so we will add this one instead. + if (count _selections > 0 && count _causes > 0) then { + _allWoundClasses pushback [_classType, _selections, _bloodLoss, _pain, _minDamage, _causes]; + }; + true; + }; + }; }; GVAR(AllWoundInjuryTypes) = _allWoundClasses; @@ -76,19 +76,20 @@ _thresholds = getArray(_damageTypesConfig >> "thresholds"); _selectionSpecific = getNumber(_damageTypesConfig >> "selectionSpecific"); { - _varName = format[QGVAR(woundInjuryType_%1),_x]; - _woundTypes = []; - _type = _x; - { - if (_type in (_x select 4)) then { - _woundTypes pushback _x; - }; - }foreach _allWoundClasses; - _typeThresholds = _thresholds; - _selectionSpecificType = _selectionSpecific; - if (isClass(_damageTypesConfig >> _x)) then { - if (isArray(_damageTypesConfig >> _x >> "thresholds")) then { _typeThresholds = getArray(_damageTypesConfig >> _x >> "thresholds");}; - if (isNumber(_damageTypesConfig >> _x >> "selectionSpecific")) then { _selectionSpecificType = getNumber(_damageTypesConfig >> _x >> "selectionSpecific");}; - }; - missionNamespace setvariable [_varName, [_typeThresholds, _selectionSpecificType > 0, _woundTypes]]; + _varName = format[QGVAR(woundInjuryType_%1),_x]; + _woundTypes = []; + _type = _x; + { + // Check if this type is in the causes of a wound class, if so, we will store the wound types for this damage type + if (_type in (_x select 5)) then { + _woundTypes pushback _x; + }; + }foreach _allWoundClasses; + _typeThresholds = _thresholds; + _selectionSpecificType = _selectionSpecific; + if (isClass(_damageTypesConfig >> _x)) then { + if (isArray(_damageTypesConfig >> _x >> "thresholds")) then { _typeThresholds = getArray(_damageTypesConfig >> _x >> "thresholds");}; + if (isNumber(_damageTypesConfig >> _x >> "selectionSpecific")) then { _selectionSpecificType = getNumber(_damageTypesConfig >> _x >> "selectionSpecific");}; + }; + missionNamespace setvariable [_varName, [_typeThresholds, _selectionSpecificType > 0, _woundTypes]]; }foreach _allTypes; diff --git a/addons/medical/functions/fnc_treatment.sqf b/addons/medical/functions/fnc_treatment.sqf index 518cf35282..939cda68b4 100644 --- a/addons/medical/functions/fnc_treatment.sqf +++ b/addons/medical/functions/fnc_treatment.sqf @@ -99,4 +99,17 @@ if (_iconDisplayed != "") then { [QGVAR(treatmentActionIcon), true, _iconDisplayed, [1,1,1,1], getNumber(_config >> "actionIconDisplayTime")] call EFUNC(common,displayIcon); }; +// handle display of text/hints +_displayText = ""; +if (_target != _caller) then { + _displayText = getText(_config >> "displayTextOther"); +} else { + _displayText = getText(_config >> "displayTextSelf"); +}; + +if (_displayText != "") then { + ["displayTextStructured", [_caller], [[_displayText, [_caller] call EFUNC(common,getName), [_target] call EFUNC(common,getName)], 1.5, _caller]] call EFUNC(common,targetEvent); +}; + + true; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf index 61d68757ed..c5c86422b6 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf @@ -29,13 +29,13 @@ if (count _items == 0) exitwith {}; if ([_caller, _target, _items] call FUNC(useItems)) then { [[_target, _className], QUOTE(DFUNC(treatmentBandageLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ { - if (_x != "") then { - [_target, _x] call FUNC(addToTriageCard); - }; - }foreach _items; + if (_x != "") then { + [_target, _x] call FUNC(addToTriageCard); + }; + }foreach _items; - ["Medical_treatmentCompleted", [_caller, _target, _selectionName, _className, true]] call ace_common_fnc_localEvent; - [_target, "activity", "STR_ACE_HAS_BANDAGED_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); + ["Medical_treatmentCompleted", [_caller, _target, _selectionName, _className, true]] call ace_common_fnc_localEvent; + [_target, "activity", "STR_ACE_HAS_BANDAGED_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; true; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf index 9ddc167aa8..b8ac6999ea 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf @@ -10,7 +10,7 @@ #include "script_component.hpp" -private ["_unit", "_caller"]; +private ["_unit", "_caller", "_allUsedMedication"]; _unit = _this select 0; _caller = _this select 1; @@ -30,7 +30,7 @@ if (alive _unit) exitwith { // vitals _unit setVariable [QGVAR(heartRate), 80]; _unit setvariable [QGVAR(heartRateAdjustments), []]; - _unit setvariable [QGVAR(bloodPressure), _bloodPressure]; + _unit setvariable [QGVAR(bloodPressure), [80, 120]]; _unit setVariable [QGVAR(peripheralResistance), 100]; // fractures @@ -51,22 +51,18 @@ if (alive _unit) exitwith { // generic medical admin _unit setvariable [QGVAR(addedToUnitLoop), false, true]; - _unit setvariable [QGVAR(inCardiacArrest), true,true]; + _unit setvariable [QGVAR(inCardiacArrest), true, true]; _unit setVariable [QGVAR(isUnconscious), false, true]; _unit setvariable [QGVAR(hasLostBlood), true, true]; _unit setvariable [QGVAR(isBleeding), false, true]; _unit setvariable [QGVAR(hasPain), false, true]; // medication - _allUsedMedication = _target getVariable [QGVAR(allUsedMedication), []]; + _allUsedMedication = _unit getVariable [QGVAR(allUsedMedication), []]; { _unit setvariable [_x select 0, nil]; }foreach _allUsedMedication; // Resetting damage _unit setDamage 0; - ["Medical_onFullyHealed", [_unit, true]] call ace_common_fnc_localEvent; - [format["Completed healLocal %1", _this]] call EFUNC(common,debug); }; - -["Medical_onFullyHealed", [_unit, false]] call ace_common_fnc_localEvent; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf index aa632626f1..415996d025 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medication.sqf @@ -29,13 +29,13 @@ if (count _items == 0) exitwith {}; if ([_caller, _target, _items] call FUNC(useItems)) then { [[_target, _className], QUOTE(DFUNC(treatmentMedicationLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ { - if (_x != "") then { - [_target, _x] call FUNC(addToTriageCard); - }; - }foreach _items; + if (_x != "") then { + [_target, _x] call FUNC(addToTriageCard); + }; + }foreach _items; - ["Medical_treatmentCompleted", [_caller, _target, _selectionName, _className, true]] call ace_common_fnc_localEvent; - [_target, "activity", "STR_ACE_HAS_MEDICATION_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); + ["Medical_treatmentCompleted", [_caller, _target, _selectionName, _className, true]] call ace_common_fnc_localEvent; + [_target, "activity", "STR_ACE_HAS_MEDICATION_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; true; diff --git a/addons/medical/functions/fnc_treatmentIV.sqf b/addons/medical/functions/fnc_treatmentIV.sqf index 9f4f99f1e1..2581c1f0d2 100644 --- a/addons/medical/functions/fnc_treatmentIV.sqf +++ b/addons/medical/functions/fnc_treatmentIV.sqf @@ -31,5 +31,5 @@ if ([_caller, _target, _items] call FUNC(useItems)) then { [[_target, _removeItem], QUOTE(DFUNC(treatmentIVLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ ["Medical_treatmentCompleted", [_caller, _target, _selectionName, _className, true]] call ace_common_fnc_localEvent; [_target, _removeItem] call FUNC(addToTriageCard); - [_target, "activity", "STR_ACE_HAS_GIVEN_IV_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); + [_target, "activity", "STR_ACE_HAS_GIVEN_IV_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; diff --git a/addons/medical/functions/fnc_treatmentTourniquet.sqf b/addons/medical/functions/fnc_treatmentTourniquet.sqf index 7a30e67db8..cd1e9f72e7 100644 --- a/addons/medical/functions/fnc_treatmentTourniquet.sqf +++ b/addons/medical/functions/fnc_treatmentTourniquet.sqf @@ -44,7 +44,7 @@ if ([_caller, _target, _items] call FUNC(useItems)) then { [[_target, _removeItem], QUOTE(DFUNC(treatmentTourniquetLocal)), _target] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ ["Medical_treatmentCompleted", [_caller, _target, _selectionName, _className, true]] call ace_common_fnc_localEvent; [_target, _removeItem] call FUNC(addToTriageCard); - [_target, "activity", "STR_ACE_HAS_APPLIED_TOURNIQUET_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); + [_target, "activity", "STR_ACE_HAS_APPLIED_TOURNIQUET_ACTIVITY", [[_caller] call EFUNC(common,getName)]] call FUNC(addToLog); }; true; diff --git a/addons/medical/functions/fnc_useItems.sqf b/addons/medical/functions/fnc_useItems.sqf index adb4bcea1d..4feb234e8c 100644 --- a/addons/medical/functions/fnc_useItems.sqf +++ b/addons/medical/functions/fnc_useItems.sqf @@ -21,15 +21,15 @@ _patient = _this select 1; _items = _this select 2; { - // handle a one of type use item - if (typeName _x == "ARRAY") then { - { - if ([_medic, _patient, _x] call FUNC(useItem)) exitwith {}; - }foreach _x; - }; + // handle a one of type use item + if (typeName _x == "ARRAY") then { + { + if ([_medic, _patient, _x] call FUNC(useItem)) exitwith {}; + }foreach _x; + }; - // handle required item - if (typeName _x == "STRING") then { - [_medic, _patient, _x] call FUNC(useItem); - }; + // handle required item + if (typeName _x == "STRING") then { + [_medic, _patient, _x] call FUNC(useItem); + }; }foreach _items;