Vehicle Damage - Fix applying medical damage to non-local and invulnerable units (#9988)

* Make medical damage apply to non-local units

* Update addons/vehicle_damage/functions/fnc_medicalDamage.sqf

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

* Update addons/vehicle_damage/functions/fnc_medicalDamage.sqf

* Update fnc_medicalDamage.sqf

* Specify reason for death

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
johnb432 2024-05-31 22:15:46 +02:00 committed by GitHub
parent 9f2ee9fb6f
commit dc56cdbd8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 47 additions and 10 deletions

View File

@ -11,3 +11,4 @@ PREP(knockOut);
PREP(addDamage); PREP(addDamage);
PREP(handleDamageEjectIfDestroyed); PREP(handleDamageEjectIfDestroyed);
PREP(blowOffTurret); PREP(blowOffTurret);
PREP(medicalDamage);

View File

@ -3,6 +3,8 @@
["ace_settingsInitialized", { ["ace_settingsInitialized", {
TRACE_1("settings init",GVAR(enabled)); TRACE_1("settings init",GVAR(enabled));
if (GVAR(enabled)) then { if (GVAR(enabled)) then {
[QGVAR(medicalDamage), LINKFUNC(medicalDamage)] call CBA_fnc_addEventHandler;
[QGVAR(bailOut), { [QGVAR(bailOut), {
params ["_center", "_crewman", "_vehicle"]; params ["_center", "_crewman", "_vehicle"];
TRACE_3("bailOut",_center,_crewman,_vehicle); TRACE_3("bailOut",_center,_crewman,_vehicle);

View File

@ -27,9 +27,6 @@ if (_vehicleAmmo isEqualTo []) then {
if ((_vehicleAmmo select 1) > 0) then { if ((_vehicleAmmo select 1) > 0) then {
{ {
// random amount of injuries [QGVAR(medicalDamage), [_x, _injurer, _injurer], _x] call CBA_fnc_targetEvent;
for "_i" from 0 to random 5 do { } forEach (crew _vehicle);
[_x, random 1 , selectRandom ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"], selectRandom ["bullet", "shell", "explosive"], _injurer] call EFUNC(medical,addDamageToUnit);
};
} forEach crew _vehicle;
}; };

View File

@ -0,0 +1,39 @@
#include "..\script_component.hpp"
/*
* Author: johnb43
* Applies medical damage to a unit.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Source <OBJECT>
* 2: Instigator <OBJECT>
* 3: Guarantee death? <BOOL> (default: false)
*
* Return Value:
* None
*
* Example:
* [cursorObject, player, player] call ace_vehicle_damage_fnc_medicalDamage;
*
* Public: No
*/
params ["_unit", "_source", "_instigator", ["_guaranteeDeath", false]];
// Check if unit is invulnerable
if !(isDamageAllowed _unit && {_unit getVariable [QEGVAR(medical,allowDamage), true]}) exitWith {};
if (["ace_medical"] call EFUNC(common,isModLoaded)) then {
for "_i" from 0 to floor (4 + random 3) do {
[_unit, random [0, 0.66, 1], selectRandom ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"], selectRandom ["bullet", "shell", "explosive"], _instigator] call EFUNC(medical,addDamageToUnit);
};
} else {
{
_unit setHitPointDamage [_x, (_unit getHitPointDamage _x) + random [0, 0.66, 1], true, _source, _instigator];
} forEach ["HitFace", "HitNeck", "HitHead", "HitPelvis", "HitAbdomen", "HitDiaphragm", "HitChest", "HitBody", "HitArms", "HitHands", "HitLegs"];
};
// If guaranteed death is wished
if (_guaranteeDeath && {alive _unit}) then {
[_unit, QGVAR(medicalDamage), _source, _instigator] call EFUNC(common,setDead);
};

View File

@ -37,12 +37,10 @@ if (_newDamage >= 15) exitWith {
TRACE_2("immediate destruction - high damage",_newDamage,_currentPartDamage); TRACE_2("immediate destruction - high damage",_newDamage,_currentPartDamage);
[_vehicle] call FUNC(knockOut); [_vehicle] call FUNC(knockOut);
[_vehicle, 1] call FUNC(handleDetonation); [_vehicle, 1] call FUNC(handleDetonation);
// kill everyone inside for very insane damage // Kill everyone inside for very insane damage
{ {
_x setDamage 1; [QGVAR(medicalDamage), [_x, _injurer, _injurer, true], _x] call CBA_fnc_targetEvent;
_x setVariable [QEGVAR(medical,lastDamageSource), _injurer]; } forEach (crew _vehicle);
_x setVariable [QEGVAR(medical,lastInstigator), _injurer];
} forEach crew _vehicle;
_vehicle setDamage 1; _vehicle setDamage 1;
_return = false; _return = false;
_return _return