Medical - Add option to prevent scripted injuries on invulnerable units (#8599)

* Medical - Add option to prevent scripted injuries on invulnerable units

* Update docs

* Change from CBA setting to optional parameter

* Update header arguments to follow coding guidelines

Co-authored-by: jonpas <jonpas33@gmail.com>

* Update addons/medical/functions/fnc_addDamageToUnit.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Increase readibility

* Fix trace macro

* Update addons/medical/functions/fnc_addDamageToUnit.sqf

* Update addons/medical/functions/fnc_addDamageToUnit.sqf

Co-authored-by: jonpas <jonpas33@gmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>
This commit is contained in:
mjc4wilton 2021-11-08 13:03:59 -05:00 committed by GitHub
parent 422c47aae6
commit 5bad6899cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,8 @@
* 2: Body part ("Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg") <STRING>
* 3: Projectile Type <STRING>
* 4: Source <OBJECT>
* 5: Non-directional damage source array (Optional) <ARRAY>
* 5: Non-directional damage source array <ARRAY> (default: [])
* 6: Override Invulnerability <BOOL> (default: true)
*
* Return Value:
* Successful <BOOL>
@ -22,8 +23,16 @@
*/
// #define DEBUG_TESTRESULTS
params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]], ["_damageSelectionArray", [], [[]]]];
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_7("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray,_overrideInvuln);
_bodyPart = toLower _bodyPart;
private _bodyPartIndex = ALL_BODY_PARTS find _bodyPart;
@ -32,6 +41,10 @@ if (_bodyPartIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad selection %1",
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
};
// Extension is case sensitive and expects this format (different from ALL_BODY_PARTS)
_bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex;