mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
73a7dbdc1e
- Add stackable wound handler system for easy 3rd party extensibility and overriding of default wound handler. - Change mapping from wound type -> damage types, to damage type -> wound types. Improves the semantics and makes configuration easier to reason about. - Allow damage types to influence wound properties (bleed, size, etc.) with configurable variance parameters. - Allow configuration of wound type variance per damage type. Enabling more logically driven variance for sensible but still varied end results. - Improve handling of non-selection-specific damage events. The wound handler now receives all incoming damages and may apply damage to multiple selections (previously only ever one) if the damage type is not configured to be selection specific (with new config property `selectionSpecific`). - Add debug script for testing explosion damage events at varied ranges. - Add custom fire wound handler.
79 lines
3.3 KiB
Plaintext
79 lines
3.3 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: PabstMirror
|
|
* Manually Apply Damage to a unit (can cause lethal damage)
|
|
*
|
|
* Arguments:
|
|
* 0: The Unit <OBJECT>
|
|
* 1: Damage to Add <NUMBER>
|
|
* 2: Body part ("Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg") <STRING>
|
|
* 3: Projectile Type <STRING>
|
|
* 4: Source <OBJECT>
|
|
* 5: Unused parameter maintained for backwards compatibility <ARRAY> (default: [])
|
|
* 6: Override Invulnerability <BOOL> (default: true)
|
|
*
|
|
* Return Value:
|
|
* Successful <BOOL>
|
|
*
|
|
* Example:
|
|
* [player, 0.8, "rightleg", "bullet"] call ace_medical_fnc_addDamageToUnit
|
|
* [cursorTarget, 1, "body", "stab", player] call ace_medical_fnc_addDamageToUnit
|
|
*
|
|
* Public: Yes
|
|
*/
|
|
// #define DEBUG_TESTRESULTS
|
|
|
|
params [
|
|
["_unit", objNull, [objNull]],
|
|
["_damageToAdd", -1, [0]],
|
|
["_bodyPart", "", [""]],
|
|
["_typeOfDamage", "", [""]],
|
|
["_instigator", objNull, [objNull]],
|
|
"",
|
|
["_overrideInvuln", true, [true]]
|
|
];
|
|
TRACE_7("addDamageToUnit",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator,_damageSelectionArray,_overrideInvuln);
|
|
|
|
_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) 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};
|
|
|
|
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;
|
|
|
|
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), [0,0,0,0,0,0]]);
|
|
private _startPain = GET_PAIN(_unit);
|
|
#endif
|
|
|
|
[QEGVAR(medical,woundReceived), [_unit, [[_damageToAdd, _bodyPart, _damageToAdd]], _instigator, _typeOfDamage]] call CBA_fnc_localEvent;
|
|
|
|
#ifdef DEBUG_TESTRESULTS
|
|
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;
|
|
private _selectionSpecific = true;
|
|
if (isClass _config) then {
|
|
_selectionSpecific = (getNumber (_config >> "selectionSpecific")) == 1;
|
|
} else {
|
|
WARNING_2("Damage type not in config [%1:%2]", _typeOfDamage, _config);
|
|
};
|
|
INFO_4("Debug AddDamageToUnit: Type [%1] - Selection Specific [%2] - HitPoint [%3 -> %4]",_typeOfDamage,_selectionSpecific,_startDmg select _bodyPartIndex,_endDmg select _bodyPartIndex);
|
|
INFO_4("Pain Change [%1 -> %2] - BodyPartDamage Change [%3 -> %4]",_startPain,_endPain,_startDmg,_endDmg);
|
|
#endif
|
|
|
|
true
|