mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Medical - Fix addDamageToUnit (#7247)
This commit is contained in:
parent
c37783de0b
commit
f9d181c72e
@ -2,7 +2,6 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Manually Apply Damage to a unit (can cause lethal damage)
|
||||
* NOTE: because of caching, this will not have instant effects (~3 frame delay)
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Unit <OBJECT>
|
||||
@ -10,6 +9,7 @@
|
||||
* 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>
|
||||
*
|
||||
* Return Value:
|
||||
* Successful <BOOL>
|
||||
@ -22,12 +22,12 @@
|
||||
*/
|
||||
// #define DEBUG_TESTRESULTS
|
||||
|
||||
params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]]];
|
||||
TRACE_5("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator);
|
||||
params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]], ["_damageSelectionArray", [], [[]]]];
|
||||
TRACE_6("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray);
|
||||
|
||||
_bodyPart = toLower _bodyPart;
|
||||
private _bodyPartIndex = ALL_BODY_PARTS find _bodyPart;
|
||||
if (_bodyPartIndex < 0) then { _bodyPartIndex = ALL_SELECTIONS find _bodyPart; }; // 2nd attempt with selection names ("hand_l", "hand_r", "leg_l", "leg_r")
|
||||
if (_bodyPartIndex < 0) then { _bodyPartIndex = ALL_SELECTIONS find _bodyPart; }; // 2nd attempt with selection names ("hand_l", "hand_r", "leg_l", "leg_r")
|
||||
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};
|
||||
@ -35,20 +35,24 @@ if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this
|
||||
// Extension is case sensitive and expects this format (different from ALL_BODY_PARTS)
|
||||
_bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex;
|
||||
|
||||
if (_damageSelectionArray isEqualTo []) then { // this will only be used if damage type is not location specific
|
||||
_damageSelectionArray = [HITPOINT_INDEX_HEAD, 1, HITPOINT_INDEX_BODY, 1, HITPOINT_INDEX_LARM, 1, HITPOINT_INDEX_RARM, 1, HITPOINT_INDEX_LLEG, 1, HITPOINT_INDEX_RLEG, 1];
|
||||
};
|
||||
|
||||
if (!isNull _instigator) then {
|
||||
_unit setVariable [QEGVAR(medical,lastDamageSource), _instigator];
|
||||
_unit setVariable [QEGVAR(medical,lastInstigator), _instigator];
|
||||
};
|
||||
|
||||
#ifdef DEBUG_TESTRESULTS
|
||||
private _startDmg = +(_unit getVariable [QEGVAR(medical,bodyPartDamage), [-1]]);
|
||||
private _startDmg = +(_unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]]);
|
||||
private _startPain = GET_PAIN(_unit);
|
||||
#endif
|
||||
|
||||
[QEGVAR(medical,woundReceived), [_unit, _bodyPart, _damageToAdd, _instigator, _typeOfDamage]] call CBA_fnc_localEvent;
|
||||
[QEGVAR(medical,woundReceived), [_unit, _bodyPart, _damageToAdd, _instigator, _typeOfDamage, _damageSelectionArray]] call CBA_fnc_localEvent;
|
||||
|
||||
#ifdef DEBUG_TESTRESULTS
|
||||
private _endDmg = _unit getVariable [QEGVAR(medical,bodyPartDamage), [-1]];
|
||||
private _endDmg = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
|
||||
private _endPain = GET_PAIN(_unit);
|
||||
private _typeOfDamageAdj = _typeOfDamage call EFUNC(medical_damage,getTypeOfDamage);
|
||||
private _config = configFile >> "ACE_Medical_Injuries" >> "damageTypes" >> _typeOfDamageAdj;
|
||||
|
@ -118,10 +118,10 @@ if (_hitPoint isEqualTo "ace_hdbracket") exitWith {
|
||||
*/
|
||||
if (_shooter == _unit && {(velocity _unit select 2) < -2}) then {
|
||||
_ammo = "#falling"; // non-selectionSpecific so only _damageSelectionArray matters
|
||||
_damageSelectionArray = [4, 1, 5, 1]; // selectRandom ["RightLeg", "LeftLeg"];
|
||||
_damageSelectionArray = [HITPOINT_INDEX_RLEG, 1, HITPOINT_INDEX_LLEG, 1];
|
||||
TRACE_5("Fall",_unit,_shooter,_instigator,_damage,_receivedDamage);
|
||||
} else {
|
||||
_damageSelectionArray = [2, 1, 3, 1, 4, 1, 5, 1]; // selectRandom ["RightArm", "LeftArm", "RightLeg", "LeftLeg"];
|
||||
_damageSelectionArray = [HITPOINT_INDEX_RARM, 1, HITPOINT_INDEX_LARM, 1, HITPOINT_INDEX_LLEG, 1, HITPOINT_INDEX_RLEG, 1];
|
||||
TRACE_5("Collision",_unit,_shooter,_instigator,_damage,_receivedDamage);
|
||||
};
|
||||
|
||||
@ -138,7 +138,7 @@ if (_hitPoint isEqualTo "ace_hdbracket") exitWith {
|
||||
};
|
||||
} else {
|
||||
// Anything else is almost guaranteed to be fire damage
|
||||
_damageSelectionArray = [1, 1, 4, 1, 5, 1]; // selectRandom ["Body", "LeftLeg", "RightLeg"];
|
||||
_damageSelectionArray = [HITPOINT_INDEX_BODY, 1, HITPOINT_INDEX_LLEG, 1, HITPOINT_INDEX_RLEG, 1];;
|
||||
_ammo = "#unknown"; // non-selectionSpecific so only _damageSelectionArray matters
|
||||
|
||||
// Fire damage can occur as lots of minor damage events
|
||||
|
@ -52,7 +52,7 @@ if (_distance < _backblastRange) then {
|
||||
[_damage * 100] call BIS_fnc_bloodEffect;
|
||||
|
||||
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then {
|
||||
[_unit, _damage, "body", "backblast"] call EFUNC(medical,addDamageToUnit);
|
||||
[_unit, _damage, "body", "backblast", _unit] call EFUNC(medical,addDamageToUnit);
|
||||
} else {
|
||||
TRACE_1("",isDamageAllowed _unit);
|
||||
if (!isDamageAllowed _unit) exitWith {}; // Skip damage if not allowed
|
||||
|
@ -57,7 +57,7 @@ TRACE_3("cache",_overpressureAngle,_overpressureRange,_overpressureDamage);
|
||||
if (_x == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect};
|
||||
|
||||
if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then {
|
||||
[_x, _damage, "body", "backblast"] call EFUNC(medical,addDamageToUnit);
|
||||
[_x, _damage, "body", "backblast", _firer] call EFUNC(medical,addDamageToUnit);
|
||||
} else {
|
||||
TRACE_1("",isDamageAllowed _x);
|
||||
if (!isDamageAllowed _x) exitWith {}; // Skip damage if not allowed
|
||||
|
Loading…
Reference in New Issue
Block a user