diff --git a/addons/common/functions/fnc_arithmeticGetResult.sqf b/addons/common/functions/fnc_arithmeticGetResult.sqf index 418d510d66..e54f44fd27 100644 --- a/addons/common/functions/fnc_arithmeticGetResult.sqf +++ b/addons/common/functions/fnc_arithmeticGetResult.sqf @@ -6,7 +6,7 @@ * Arguments: * 0: Namespace * 1: Number Set ID - * 2: Operation (sum, product, min, max, avg) + * 2: Operation (sum, product, min, max, avg) (Case Sensitive) * * Return Value: * Value @@ -19,11 +19,19 @@ */ params ["_namespace", "_setID", "_op"]; -TRACE_3("params",_namespace,_setID,_op); +TRACE_3("arithmeticGetResult",_namespace,_setID,_op); private _data = (_namespace getVariable _setID) param [2, []]; switch (_op) do { + case ("max"): { + private _result = -1e99; + { + _result = _result max (call _x); + nil + } count _data; + _result // return + }; case ("sum"): { private _result = 0; { @@ -48,14 +56,6 @@ switch (_op) do { } count _data; _result // return }; - case ("max"): { - private _result = -1e99; - { - _result = _result max (call _x); - nil - } count _data; - _result // return - }; case ("avg"): { private _result = 0; { diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index 5dd19195e8..c2d202f567 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -6,9 +6,7 @@ if (!hasInterface) exitWith {}; [missionNamespace, "ACE_setCustomAimCoef", QUOTE(ADDON), { - private _pain = GET_PAIN_PERCEIVED(ACE_player); - - linearConversion [0, 1, _pain, 1, 5, true]; + (linearConversion [0, 1, GET_PAIN_PERCEIVED(ACE_player), 1, 5, true]) + (ACE_player getVariable [QEGVAR(medical_engine,aimFracture), 0]) }] call EFUNC(common,arithmeticSetSource); #ifdef DEBUG_MODE_FULL diff --git a/addons/medical/dev/watchVariable.sqf b/addons/medical/dev/watchVariable.sqf index c14d52649e..4eeee668b0 100644 --- a/addons/medical/dev/watchVariable.sqf +++ b/addons/medical/dev/watchVariable.sqf @@ -144,6 +144,10 @@ _return pushBack "------- Medications Raw: -------"; _return append _rawMedications; + if (_unit isEqualTo ACE_player) then { + _return pushBack format ["ACE_setCustomAimCoef: %1", [missionNamespace, "ACE_setCustomAimCoef", "max"] call ace_common_fnc_arithmeticGetResult]; + }; + // Footer: _return pushBack ""; diff --git a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf index 410a49fa8c..c6eeab01e9 100644 --- a/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf +++ b/addons/medical_damage/functions/fnc_woundsHandlerSQF.sqf @@ -67,7 +67,7 @@ if (_highestPossibleSpot < 0) exitWith { TRACE_2("no wounds possible",_damage,_h // Administration for open wounds and ids private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []]; -private _updateLimping = false; +private _updateDamageEffects = false; private _painLevel = 0; private _critialDamage = false; private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]; @@ -133,16 +133,16 @@ private _bodyPartVisParams = [_unit, false, false, false, false]; // params arra [QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent; }; }; - case (_causeFracture && {EGVAR(medical,fractures) > 0} && {_bodyPartNToAdd > 3} && {_woundDamage > FRACTURE_DAMAGE_THRESHOLD}): { // ToDo: Arm fractures? - TRACE_1("fracture",_bodyPartNToAdd); + case (_causeFracture && {EGVAR(medical,fractures) > 0} && {_bodyPartNToAdd > 1} && {_woundDamage > FRACTURE_DAMAGE_THRESHOLD}): { + TRACE_1("limb fracture",_bodyPartNToAdd); // todo: play sound? private _fractures = _unit getVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0]]; _fractures set [_bodyPartNToAdd, 1]; _unit setVariable [QEGVAR(medical,fractures), _fractures, true]; - _updateLimping = true; + _updateDamageEffects = true; }; case (_causeLimping && {EGVAR(medical,limping) > 0} && {_bodyPartNToAdd > 3} && {_woundDamage > LIMPING_DAMAGE_THRESHOLD}): { - _updateLimping = true; + _updateDamageEffects = true; }; }; @@ -175,8 +175,8 @@ private _bodyPartVisParams = [_unit, false, false, false, false]; // params arra }; } forEach _thresholds; -if (_updateLimping) then { - [_unit] call EFUNC(medical_engine,setLimping); +if (_updateDamageEffects) then { + [_unit] call EFUNC(medical_engine,updateDamageEffects); }; _unit setVariable [QEGVAR(medical,openWounds), _openWounds, true]; diff --git a/addons/medical_engine/XEH_PREP.hpp b/addons/medical_engine/XEH_PREP.hpp index 3c7872c515..0bacdd97e7 100644 --- a/addons/medical_engine/XEH_PREP.hpp +++ b/addons/medical_engine/XEH_PREP.hpp @@ -1,6 +1,6 @@ PREP(handleDamage); PREP(damageBodyPart); PREP(updateBodyPartVisuals); -PREP(setLimping); +PREP(updateDamageEffects); PREP(setStructuralDamage); PREP(setUnconsciousAnim); diff --git a/addons/medical_engine/XEH_postInit.sqf b/addons/medical_engine/XEH_postInit.sqf index f4f9f746c7..18703e7358 100644 --- a/addons/medical_engine/XEH_postInit.sqf +++ b/addons/medical_engine/XEH_postInit.sqf @@ -1,5 +1,12 @@ #include "script_component.hpp" +[QGVAR(updateDamageEffects), LINKFUNC(updateDamageEffects)] call CBA_fnc_addEventHandler; +["unit", { + params ["_new"]; + [_new] call FUNC(updateDamageEffects); // Run on new controlled unit to update QGVAR(aimFracture) +}, true] call CBA_fnc_addPlayerEventHandler; + + ["CAManBase", "init", { params ["_unit"]; diff --git a/addons/medical_engine/functions/fnc_setLimping.sqf b/addons/medical_engine/functions/fnc_updateDamageEffects.sqf similarity index 66% rename from addons/medical_engine/functions/fnc_setLimping.sqf rename to addons/medical_engine/functions/fnc_updateDamageEffects.sqf index 6cb7c067d7..dffe7f2ebc 100644 --- a/addons/medical_engine/functions/fnc_setLimping.sqf +++ b/addons/medical_engine/functions/fnc_updateDamageEffects.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* - * Author: commy2 - * Forces a unit to limp or not. + * Author: commy2, PabstMirror + * Updates damage effects for limping and fractures * * Arguments: * 0: Unit @@ -11,7 +11,7 @@ * None * * Example: - * [player] call ace_medical_engine_fnc_setLimping + * [player] call ace_medical_engine_fnc_updateDamageEffects * * Public: No */ @@ -24,24 +24,31 @@ private _isLimping = false; if (EGVAR(medical,fractures) > 0) then { private _fractures = _unit getVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0]]; + TRACE_1("",_fractures); if (((_fractures select 4) == 1) || {(_fractures select 5) == 1}) then { TRACE_1("limping because of fracture",_fractures); _isLimping = true; }; + private _aimFracture = 0; + if ((_fractures select 2) == 1) then { _aimFracture = _aimFracture + 4; }; + if ((_fractures select 3) == 1) then { _aimFracture = _aimFracture + 4; }; - if (EGVAR(medical,fractures) == 2) then { // block sprinting if we have a leg splint on - private _isSprintBlocked = ((_fractures select 4) == -1) || {(_fractures select 5) == -1}; - TRACE_2("",_isSprintBlocked,_fractures); + if (EGVAR(medical,fractures) == 2) then { // the limp with a splint will still cause effects + private _isSprintBlocked = ((_fractures select 4) == -1) || {(_fractures select 5) == -1}; // block sprinting if we have a leg splint on if (_isSprintBlocked || {!isSprintAllowed _unit}) then { // only update status effect if we need to + TRACE_1("updating status effect",_isSprintBlocked); [_unit, "blockSprint", QEGVAR(medical,fracture), _isSprintBlocked] call EFUNC(common,statusEffect_set); }; + if ((_fractures select 2) == 1) then { _aimFracture = _aimFracture + 2; }; + if ((_fractures select 3) == 1) then { _aimFracture = _aimFracture + 2; }; }; + _unit setVariable [QGVAR(aimFracture), _aimFracture, false]; // local only var, used in ace_medical's postInit to set ACE_setCustomAimCoef }; if (!_isLimping && {EGVAR(medical,limping) > 0}) then { private _woundsToCheck = _unit getVariable [QEGVAR(medical,openWounds), []]; if (EGVAR(medical,limping) == 2) then { - _woundsToCheck = _woundsToCheck + (_unit getVariable [QEGVAR(medical,bandagedWounds), []]); // append will break things + _woundsToCheck = _woundsToCheck + (_unit getVariable [QEGVAR(medical,bandagedWounds), []]); // do not append }; { _x params ["_xClassID", "_xBodyPartN", "_xAmountOf", "", "_xDamage"]; diff --git a/addons/medical_gui/data/body_image/arm_left_bonel.paa b/addons/medical_gui/data/body_image/arm_left_bonel.paa new file mode 100644 index 0000000000..9d4cefd89b Binary files /dev/null and b/addons/medical_gui/data/body_image/arm_left_bonel.paa differ diff --git a/addons/medical_gui/data/body_image/arm_right_boner.paa b/addons/medical_gui/data/body_image/arm_right_boner.paa new file mode 100644 index 0000000000..c5ae90dcbf Binary files /dev/null and b/addons/medical_gui/data/body_image/arm_right_boner.paa differ diff --git a/addons/medical_gui/functions/fnc_updateBodyImage.sqf b/addons/medical_gui/functions/fnc_updateBodyImage.sqf index b6f82f9c30..5488e6d055 100644 --- a/addons/medical_gui/functions/fnc_updateBodyImage.sqf +++ b/addons/medical_gui/functions/fnc_updateBodyImage.sqf @@ -68,8 +68,8 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0]; } forEach [ [IDC_BODY_HEAD], [IDC_BODY_TORSO], - [IDC_BODY_ARMLEFT, IDC_BODY_ARMLEFT_T], - [IDC_BODY_ARMRIGHT, IDC_BODY_ARMRIGHT_T], + [IDC_BODY_ARMLEFT, IDC_BODY_ARMLEFT_T, IDC_BODY_ARMLEFT_B], + [IDC_BODY_ARMRIGHT, IDC_BODY_ARMRIGHT_T, IDC_BODY_ARMRIGHT_B], [IDC_BODY_LEGLEFT, IDC_BODY_LEGLEFT_T, IDC_BODY_LEGLEFT_B], [IDC_BODY_LEGRIGHT, IDC_BODY_LEGRIGHT_T, IDC_BODY_LEGRIGHT_B] ]; diff --git a/addons/medical_gui/gui.hpp b/addons/medical_gui/gui.hpp index 379d86195b..ca441853d4 100644 --- a/addons/medical_gui/gui.hpp +++ b/addons/medical_gui/gui.hpp @@ -45,6 +45,24 @@ class GVAR(BodyImage): RscControlsGroupNoScrollbars { idc = IDC_BODY_LEGRIGHT; text = QPATHTOF(data\body_image\leg_right.paa); }; + class ArmLeftB: Background { + idc = IDC_BODY_ARMLEFT_B; + text = QPATHTOF(data\body_image\arm_left_bonel.paa); + colorText[] = {0, 0, 0.8, 1}; + show = 0; + }; + class ArmRightB: ArmLeftB { + idc = IDC_BODY_ARMRIGHT_B; + text = QPATHTOF(data\body_image\arm_right_boner.paa); + }; + class LegLeftB: ArmLeftB { + idc = IDC_BODY_LEGLEFT_B; + text = QPATHTOF(data\body_image\leg_left_bonel.paa); + }; + class LegRightB: ArmLeftB { + idc = IDC_BODY_LEGRIGHT_B; + text = QPATHTOF(data\body_image\leg_right_boner.paa); + }; class ArmLeftT: Background { idc = IDC_BODY_ARMLEFT_T; text = QPATHTOF(data\body_image\arm_left_t.paa); @@ -55,14 +73,6 @@ class GVAR(BodyImage): RscControlsGroupNoScrollbars { idc = IDC_BODY_ARMRIGHT_T; text = QPATHTOF(data\body_image\arm_right_t.paa); }; - class LegLeftB: ArmLeftT { - idc = IDC_BODY_LEGLEFT_B; - text = QPATHTOF(data\body_image\leg_left_bonel.paa); - }; - class LegRightB: ArmLeftT { - idc = IDC_BODY_LEGRIGHT_B; - text = QPATHTOF(data\body_image\leg_right_boner.paa); - }; class LegLeftT: ArmLeftT { idc = IDC_BODY_LEGLEFT_T; text = QPATHTOF(data\body_image\leg_left_t.paa); @@ -557,11 +567,11 @@ class RscTitles { w = POS_W(8.5); h = POS_H(8.5); }; - class ArmLeftT: ArmLeftT { + class ArmLeftB: ArmLeftB { w = POS_W(8.5); h = POS_H(8.5); }; - class ArmRightT: ArmRightT { + class ArmRightB: ArmRightB { w = POS_W(8.5); h = POS_H(8.5); }; @@ -573,6 +583,14 @@ class RscTitles { w = POS_W(8.5); h = POS_H(8.5); }; + class ArmLeftT: ArmLeftT { + w = POS_W(8.5); + h = POS_H(8.5); + }; + class ArmRightT: ArmRightT { + w = POS_W(8.5); + h = POS_H(8.5); + }; class LegLeftT: LegLeftT { w = POS_W(8.5); h = POS_H(8.5); diff --git a/addons/medical_gui/script_component.hpp b/addons/medical_gui/script_component.hpp index 30674ad69f..c4c7aafcd8 100644 --- a/addons/medical_gui/script_component.hpp +++ b/addons/medical_gui/script_component.hpp @@ -67,8 +67,10 @@ #define IDC_BODY_ARMRIGHT_T 6040 #define IDC_BODY_LEGLEFT_T 6045 #define IDC_BODY_LEGRIGHT_T 6050 -#define IDC_BODY_LEGRIGHT_B 6055 -#define IDC_BODY_LEGLEFT_B 6060 +#define IDC_BODY_ARMLEFT_B 6055 +#define IDC_BODY_ARMRIGHT_B 6060 +#define IDC_BODY_LEGRIGHT_B 6065 +#define IDC_BODY_LEGLEFT_B 6070 #define IDC_TRIAGE_STATUS 7000 #define IDC_TRIAGE_SELECT 7100 diff --git a/addons/medical_treatment/XEH_postInit.sqf b/addons/medical_treatment/XEH_postInit.sqf index 77b99aa6fb..05d78e97d9 100644 --- a/addons/medical_treatment/XEH_postInit.sqf +++ b/addons/medical_treatment/XEH_postInit.sqf @@ -16,7 +16,6 @@ if (isServer) then { [QGVAR(treatmentIVLocal), FUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentFullHealLocal), FUNC(treatmentFullHealLocal)] call CBA_fnc_addEventHandler; - [QGVAR(treatmentSplintLocal), FUNC(splintLocal)] call CBA_fnc_addEventHandler; // action events diff --git a/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf b/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf index 2c87b23949..2c8b46b76e 100644 --- a/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf +++ b/addons/medical_treatment/functions/fnc_handleBandageOpening.sqf @@ -120,7 +120,7 @@ if (random 1 <= _reopeningChance) then { // Check if we gained limping from this wound re-opening if ((EGVAR(medical,limping) == 1) && {_bodyPartN > 3}) then { - [_target] call EFUNC(medical_engine,setLimping); + [_target] call EFUNC(medical_engine,updateDamageEffects); }; }; } else { diff --git a/addons/medical_treatment/functions/fnc_splintLocal.sqf b/addons/medical_treatment/functions/fnc_splintLocal.sqf index 003adc073c..1996e8321a 100644 --- a/addons/medical_treatment/functions/fnc_splintLocal.sqf +++ b/addons/medical_treatment/functions/fnc_splintLocal.sqf @@ -26,6 +26,6 @@ _fractures set [_bodyPartNum, -1]; _target setVariable [QEGVAR(medical,fractures), _fractures, true]; // Check if we fixed limping from this treatment -[_target] call EFUNC(medical_engine,setLimping); +[_target] call EFUNC(medical_engine,updateDamageEffects); // toDo: AddToLog: diff --git a/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf index 9b362954bd..94ab425b00 100644 --- a/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentBandageLocal.sqf @@ -47,8 +47,8 @@ if (_impact > 0 && {GVAR(advancedBandages) && {GVAR(woundReopening)}}) then { }; // Check if we fixed limping from this treatment -if ((EGVAR(medical,limping) == 1) && {_amountOf <= 0} && {_target getVariable [QEGVAR(medical,isLimping), false]}) then { - [_target] call EFUNC(medical_engine,setLimping); +if ((EGVAR(medical,limping) == 1) && {_partIndex > 3} && {_amountOf <= 0} && {_target getVariable [QEGVAR(medical,isLimping), false]}) then { + [_target] call EFUNC(medical_engine,updateDamageEffects); }; true diff --git a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf index 7369eb57aa..014b102834 100644 --- a/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentFullHealLocal.sqf @@ -71,7 +71,7 @@ _target setVariable [VAR_MEDICATIONS, [], true]; // Reset triage card since medication is all reset _target setVariable [QEGVAR(medical,triageCard), [], true]; -[_target] call EFUNC(medical_engine,setLimping); +[_target] call EFUNC(medical_engine,updateDamageEffects); // Resetting damage _target setDamage 0; diff --git a/addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf b/addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf index a49560ac01..66d2373804 100644 --- a/addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf +++ b/addons/medical_treatment/functions/fnc_treatmentSurgicalKit_onProgress.sqf @@ -39,8 +39,10 @@ if (_totalTime - _elapsedTime <= (count _bandagedWounds - 1) * 5) then { // Check if we fixed limping from this treatment if ((EGVAR(medical,limping) == 2) && {_target getVariable [QEGVAR(medical,isLimping), false]}) then { _treatedWound params ["", "_partN"]; - if (_partN < 4) exitWith {}; - [_target] call EFUNC(medical_engine,setLimping); + if (_partN > 3) then { // only for LEG wounds + TRACE_3("updating damage effects",_target,_partN,local _target); + [QEGVAR(medical_engine,updateDamageEffects), [_target], _target] call CBA_fnc_targetEvent; + }; }; };