Skip to content

Instantly share code, notes, and snippets.

@diwako
Last active April 22, 2020 21:29
Show Gist options
  • Save diwako/661e98e46d09e438af5e7164b62b8e4e to your computer and use it in GitHub Desktop.
Save diwako/661e98e46d09e438af5e7164b62b8e4e to your computer and use it in GitHub Desktop.
// put this into your init.sqf like the filthy animal you are
["ace_medical_woundReceived", {
[{
params ["_unit", "_woundedHitPoint", "_receivedDamage", "", "_ammo"];
if (isPlayer _unit) exitWith {};
[_unit, _woundedHitPoint, _receivedDamage, _ammo call ace_medical_damage_fnc_getTypeOfDamage] call diw_medical_woundsHandlerAI;
},_this] call CBA_fnc_execNextFrame;
}] call CBA_fnc_addEventHandler;
diw_medical_woundsHandlerAI = {
if (ace_medical_fatalDamageSource isEqualTo 0) exitWith {};
params ["_unit", "_bodyPart", "_damage", "_typeOfDamage"];
private _bodyPartN = ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"] find toLower _bodyPart;
if (_bodyPartN < 2) exitWith {};
if ((_typeOfDamage isEqualTo "") || {isNil {ace_medical_damage_allDamageTypesData getVariable _typeOfDamage}}) then {
_typeOfDamage = "unknown";
};
private _damageTypeInfo = [ace_medical_damage_allDamageTypesData getVariable _typeOfDamage] param [0, [[], false, []]];
_damageTypeInfo params ["_thresholds"];
(_unit getVariable ["ace_medical_bodyPartDamage", [0,0,0,0,0,0]]) params ["", "", "_leftarmDamage", "_rightarmDamage", "_leftlegDamage", "_rightlegDamage"];
{
_x params ["_thresholdMinDam", "_thresholdWoundCount"];
if (_damage > _thresholdMinDam) exitWith {
private _woundDamage = _damage / (_thresholdWoundCount max 1);
private _limbThreshhold = 12 * ace_medical_AIDamageThreshold;
private _vitalDamage = ((_leftarmDamage + _rightarmDamage + _leftlegDamage + _rightlegDamage) - _limbThreshhold) max 0;
private _chanceFatal = 1 - exp -((_vitalDamage/ace_medical_const_fatalSumDamageWeibull_L)^ace_medical_const_fatalSumDamageWeibull_K);
// systemChat format["dam: %1 | chance: %2", _vitalDamage, _chanceFatal];
if (_chanceFatal > random 1) then {
["ace_medical_FatalInjury", _unit] call CBA_fnc_localEvent;
};
};
} forEach _thresholds;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment