Skip to content

Commit

Permalink
Medical - Add option to prevent scripted injuries on invulnerable uni…
Browse files Browse the repository at this point in the history
…ts (acemod#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>
  • Loading branch information
4 people authored and AndreasBrostrom committed Dec 3, 2021
1 parent 05edad9 commit 8f651d4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions addons/medical/functions/fnc_addDamageToUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit 8f651d4

Please sign in to comment.