Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 14 commits into from
Nov 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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