From 4e6a5ddb240aa9700b3ea1672f25b6037a622389 Mon Sep 17 00:00:00 2001 From: mjc4wilton Date: Sat, 23 Oct 2021 23:45:09 -0400 Subject: [PATCH 1/9] Medical - Add option to prevent scripted injuries on invulnerable units --- addons/medical/functions/fnc_addDamageToUnit.sqf | 1 + addons/medical/initSettings.sqf | 8 ++++++++ addons/medical/stringtable.xml | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index f571d27726c..d87744bb70a 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -31,6 +31,7 @@ if (_bodyPartIndex < 0) then { _bodyPartIndex = ALL_SELECTIONS find _bodyPart; } if (_bodyPartIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); false}; if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_2("addDamageToUnit - badUnit %1 [local %2]", _this, local _unit); false}; if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); false}; +if (!GVAR(allowInvulnDamage) && {!(isDamageAllowed _unit)} && {!(_unit getVariable [QEGVAR(medical,allowDamage), true])}) exitWith {ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false}; // Extension is case sensitive and expects this format (different from ALL_BODY_PARTS) _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex; diff --git a/addons/medical/initSettings.sqf b/addons/medical/initSettings.sqf index 3c54f47cee1..9fb47c6b519 100644 --- a/addons/medical/initSettings.sqf +++ b/addons/medical/initSettings.sqf @@ -46,3 +46,11 @@ [1, 30, 1, 1], true ] call CBA_fnc_addSetting; + +[ + QGVAR(allowInvulnDamage), + "CHECKBOX", + [LSTRING(allowInvulnDamage_DisplayName), LSTRING(allowInvulnDamage_Description)], + LSTRING(Category), + true +] call CBA_fnc_addSetting; diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 6c61ce2ee4b..76c4255c14f 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -76,6 +76,12 @@ Увеличивает частоту проверок на спонтанное пробуждение, когда пациент под действием адреналина. Hastanın sisteminde Epinefrin olduğunda rasgele uyanma kontrollerinin ne sıklıkla gerçekleştiğini artırır. + + Allow Damage to Invulnerable Units + + + Allows scripts to damage to invulnerable units + Limping Хромота From 789ee283d2cd30761920c702a2f42633d20e1ca7 Mon Sep 17 00:00:00 2001 From: mjc4wilton Date: Sat, 23 Oct 2021 23:53:43 -0400 Subject: [PATCH 2/9] Update docs --- docs/wiki/feature/medical-system.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/wiki/feature/medical-system.md b/docs/wiki/feature/medical-system.md index 67c239b92a9..4c05f921b5c 100644 --- a/docs/wiki/feature/medical-system.md +++ b/docs/wiki/feature/medical-system.md @@ -47,6 +47,10 @@ Fatal damage is now controlled by either "Large hits to vital organs", "Sum of t Two sliders that dictate how much damage players and ai can take before going unconscious or dying if Sum of Trauma is enabled. Set to higher values to make units stronger, lower to make them weaker. +##### 1.1.1.6 Allow Damage to Invulnerable Units + +Checkbox that enables scripts to apply ACE medical damage types to units which are invulnerable via calling the "ace_medical_fnc_addDamageToUnit" function. Units need to be made invulnerable via both the "allowDamage" command and "ace_medical_allowDamage" variable on the unit in order to prevent script-induced damage. + #### 1.1.2 AI ##### 1.1.2.1 Medic AI From 071f2c3382b137bdf454d3f5c8cf7568d1a4e662 Mon Sep 17 00:00:00 2001 From: mjc4wilton Date: Sun, 24 Oct 2021 16:06:50 -0400 Subject: [PATCH 3/9] Change from CBA setting to optional parameter --- addons/medical/functions/fnc_addDamageToUnit.sqf | 5 +++-- addons/medical/initSettings.sqf | 8 -------- addons/medical/stringtable.xml | 6 ------ docs/wiki/feature/medical-system.md | 4 ---- 4 files changed, 3 insertions(+), 20 deletions(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index d87744bb70a..cebaefd17be 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -10,6 +10,7 @@ * 3: Projectile Type * 4: Source * 5: Non-directional damage source array (Optional) + * 6: Override Invulnerability (Optional, Default: true) * * Return Value: * Successful @@ -22,7 +23,7 @@ */ // #define DEBUG_TESTRESULTS -params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]], ["_damageSelectionArray", [], [[]]]]; +params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]], ["_damageSelectionArray", [], [[]]], ["_overrideInvuln", true]]; TRACE_6("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray); _bodyPart = toLower _bodyPart; @@ -31,7 +32,7 @@ if (_bodyPartIndex < 0) then { _bodyPartIndex = ALL_SELECTIONS find _bodyPart; } if (_bodyPartIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); false}; if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_2("addDamageToUnit - badUnit %1 [local %2]", _this, local _unit); false}; if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); false}; -if (!GVAR(allowInvulnDamage) && {!(isDamageAllowed _unit)} && {!(_unit getVariable [QEGVAR(medical,allowDamage), true])}) exitWith {ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false}; +if (!_overrideInvuln && {!(isDamageAllowed _unit)} && {!(_unit getVariable [QEGVAR(medical,allowDamage), true])}) exitWith {ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false}; // Extension is case sensitive and expects this format (different from ALL_BODY_PARTS) _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex; diff --git a/addons/medical/initSettings.sqf b/addons/medical/initSettings.sqf index 9fb47c6b519..3c54f47cee1 100644 --- a/addons/medical/initSettings.sqf +++ b/addons/medical/initSettings.sqf @@ -46,11 +46,3 @@ [1, 30, 1, 1], true ] call CBA_fnc_addSetting; - -[ - QGVAR(allowInvulnDamage), - "CHECKBOX", - [LSTRING(allowInvulnDamage_DisplayName), LSTRING(allowInvulnDamage_Description)], - LSTRING(Category), - true -] call CBA_fnc_addSetting; diff --git a/addons/medical/stringtable.xml b/addons/medical/stringtable.xml index 76c4255c14f..6c61ce2ee4b 100644 --- a/addons/medical/stringtable.xml +++ b/addons/medical/stringtable.xml @@ -76,12 +76,6 @@ Увеличивает частоту проверок на спонтанное пробуждение, когда пациент под действием адреналина. Hastanın sisteminde Epinefrin olduğunda rasgele uyanma kontrollerinin ne sıklıkla gerçekleştiğini artırır. - - Allow Damage to Invulnerable Units - - - Allows scripts to damage to invulnerable units - Limping Хромота diff --git a/docs/wiki/feature/medical-system.md b/docs/wiki/feature/medical-system.md index 4c05f921b5c..67c239b92a9 100644 --- a/docs/wiki/feature/medical-system.md +++ b/docs/wiki/feature/medical-system.md @@ -47,10 +47,6 @@ Fatal damage is now controlled by either "Large hits to vital organs", "Sum of t Two sliders that dictate how much damage players and ai can take before going unconscious or dying if Sum of Trauma is enabled. Set to higher values to make units stronger, lower to make them weaker. -##### 1.1.1.6 Allow Damage to Invulnerable Units - -Checkbox that enables scripts to apply ACE medical damage types to units which are invulnerable via calling the "ace_medical_fnc_addDamageToUnit" function. Units need to be made invulnerable via both the "allowDamage" command and "ace_medical_allowDamage" variable on the unit in order to prevent script-induced damage. - #### 1.1.2 AI ##### 1.1.2.1 Medic AI From 9273e29faaf2ce10f87e950d1a4b6281d42c790e Mon Sep 17 00:00:00 2001 From: mjc4wilton Date: Sun, 24 Oct 2021 17:56:01 -0400 Subject: [PATCH 4/9] Update header arguments to follow coding guidelines Co-authored-by: jonpas --- addons/medical/functions/fnc_addDamageToUnit.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index cebaefd17be..668a1535ae4 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -9,8 +9,8 @@ * 2: Body part ("Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg") * 3: Projectile Type * 4: Source - * 5: Non-directional damage source array (Optional) - * 6: Override Invulnerability (Optional, Default: true) + * 5: Non-directional damage source array (default: []) + * 6: Override Invulnerability (default: true) * * Return Value: * Successful From d367afc4dd791e8df5aac55578f530cf6e357e00 Mon Sep 17 00:00:00 2001 From: mjc4wilton Date: Sun, 24 Oct 2021 19:00:57 -0400 Subject: [PATCH 5/9] Update addons/medical/functions/fnc_addDamageToUnit.sqf Co-authored-by: PabstMirror --- addons/medical/functions/fnc_addDamageToUnit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index 668a1535ae4..ff685426ca8 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -32,7 +32,7 @@ if (_bodyPartIndex < 0) then { _bodyPartIndex = ALL_SELECTIONS find _bodyPart; } if (_bodyPartIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); false}; if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_2("addDamageToUnit - badUnit %1 [local %2]", _this, local _unit); false}; if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); false}; -if (!_overrideInvuln && {!(isDamageAllowed _unit)} && {!(_unit getVariable [QEGVAR(medical,allowDamage), true])}) exitWith {ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false}; +if (!_overrideInvuln && {!((isDamageAllowed _unit) && {_unit getVariable [QEGVAR(medical,allowDamage), true]})}) exitWith {ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false}; // Extension is case sensitive and expects this format (different from ALL_BODY_PARTS) _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex; From 84274d392116ed248a6bcca4ad4e5952f6080db0 Mon Sep 17 00:00:00 2001 From: mjc4wilton Date: Sun, 31 Oct 2021 17:45:38 -0400 Subject: [PATCH 6/9] Increase readibility --- addons/medical/functions/fnc_addDamageToUnit.sqf | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index cebaefd17be..2950a6f3a6c 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -23,8 +23,16 @@ */ // #define DEBUG_TESTRESULTS -params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]], ["_damageSelectionArray", [], [[]]], ["_overrideInvuln", true]]; -TRACE_6("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray); +params [ + ["_unit", objNull, [objNull]], + ["_damageToAdd", -1, [0]], + ["_bodyPart", "", [""]], + ["_typeOfDamage", "", [""]], + ["_instigator", objNull, [objNull]], + ["_damageSelectionArray", [], [[]]], + ["_overrideInvuln", true, [true]] +]; +TRACE_6("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray,_overrideInvuln); _bodyPart = toLower _bodyPart; private _bodyPartIndex = ALL_BODY_PARTS find _bodyPart; @@ -32,7 +40,9 @@ if (_bodyPartIndex < 0) then { _bodyPartIndex = ALL_SELECTIONS find _bodyPart; } if (_bodyPartIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); false}; if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_2("addDamageToUnit - badUnit %1 [local %2]", _this, local _unit); false}; if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); false}; -if (!_overrideInvuln && {!(isDamageAllowed _unit)} && {!(_unit getVariable [QEGVAR(medical,allowDamage), true])}) exitWith {ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false}; +if (!_overrideInvuln && {!(isDamageAllowed _unit)} && {!(_unit getVariable [QEGVAR(medical,allowDamage), true])}) exitWith { + ERROR_1("addDamageToUnit - unit invulnerable %1", _this); false +}; // Extension is case sensitive and expects this format (different from ALL_BODY_PARTS) _bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex; From 1c9e71bbfb73058883a048dc4fb67f61bc8afda0 Mon Sep 17 00:00:00 2001 From: BaerMitUmlaut Date: Sun, 31 Oct 2021 22:55:44 +0100 Subject: [PATCH 7/9] Fix trace macro --- addons/medical/functions/fnc_addDamageToUnit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index 43068d57ec0..93cf2b44d8c 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -32,7 +32,7 @@ params [ ["_damageSelectionArray", [], [[]]], ["_overrideInvuln", true, [true]] ]; -TRACE_6("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray,_overrideInvuln); +TRACE_7("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray,_overrideInvuln); _bodyPart = toLower _bodyPart; private _bodyPartIndex = ALL_BODY_PARTS find _bodyPart; From d0d9032e68384f0d80b321bcd7b234ef1e2e88f3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 8 Nov 2021 00:17:17 +0100 Subject: [PATCH 8/9] Update addons/medical/functions/fnc_addDamageToUnit.sqf --- addons/medical/functions/fnc_addDamageToUnit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index 93cf2b44d8c..1c2ceb6a827 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -10,7 +10,7 @@ * 3: Projectile Type * 4: Source * 5: Non-directional damage source array (default: []) - * 6: Override Invulnerability (default: true) + * 6: Override Invulnerability (default: true) * * Return Value: * Successful From 7b7025614cdb1eacf29dd56df5b2d3fdbe95cb33 Mon Sep 17 00:00:00 2001 From: jonpas Date: Mon, 8 Nov 2021 00:17:30 +0100 Subject: [PATCH 9/9] Update addons/medical/functions/fnc_addDamageToUnit.sqf --- addons/medical/functions/fnc_addDamageToUnit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/medical/functions/fnc_addDamageToUnit.sqf b/addons/medical/functions/fnc_addDamageToUnit.sqf index 1c2ceb6a827..e7d25536ae8 100644 --- a/addons/medical/functions/fnc_addDamageToUnit.sqf +++ b/addons/medical/functions/fnc_addDamageToUnit.sqf @@ -10,7 +10,7 @@ * 3: Projectile Type * 4: Source * 5: Non-directional damage source array (default: []) - * 6: Override Invulnerability (default: true) + * 6: Override Invulnerability (default: true) * * Return Value: * Successful