mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Medical - Fix hanging when vehicle crew receive fatal damage (#9681)
* fix undefined var in trace * fix high damage hang * update comment * Update fnc_woundsHandlerVehiclehit.sqf
This commit is contained in:
parent
5458fdfe83
commit
1b6b0aaf0b
@ -26,12 +26,21 @@ if (count _allDamages > 1) exitWith {_this};
|
||||
// damage to structural is low unless it's a very large explosion, in which case it is typically >= 1
|
||||
private _damageToApply = (abs (_allDamages select 0 select 0));
|
||||
|
||||
private _newDamages = [];
|
||||
private _damageMap = createHashMap;
|
||||
private _bodyPart = "";
|
||||
private _allBodyParts = ALL_BODY_PARTS; // micro-optimization here and above, don't recreate this array every time
|
||||
|
||||
// hitpoints are randomized, more damage means more wounds in different body parts
|
||||
// use a hashmap so we only create one entry in _newDamages per body part
|
||||
for "_i" from 1 to (_damageToApply * 6) do {
|
||||
_newDamages pushBack [_damageToApply, selectRandom ALL_BODY_PARTS, _damageToApply]
|
||||
_bodyPart = selectRandom _allBodyParts;
|
||||
_damageMap set [_bodyPart, (_damageMap getOrDefault [_bodyPart, 0]) + _damageToApply];
|
||||
};
|
||||
|
||||
private _newDamages = [];
|
||||
{
|
||||
_newDamages pushBack [_damageMap get _x, _x, _damageToApply];
|
||||
} forEach (keys _damageMap); // micro-optimization again, two 'get's is still faster than iterating over a hashmap
|
||||
|
||||
TRACE_1("Vehicle explosion handled, passing damage", _newDamages);
|
||||
[_unit, _newDamages, _typeOfDamage] //return
|
||||
|
@ -89,7 +89,7 @@ if (
|
||||
{GET_NUMBER(_ammoCfg >> "indirectHit", 0) > 0}
|
||||
}
|
||||
) exitwith {
|
||||
TRACE_6("Vehicle hit",_unit,_shooter,_instigator,_damage,_newDamage,_damages);
|
||||
TRACE_5("Vehicle hit",_unit,_shooter,_instigator,_damage,_newDamage);
|
||||
|
||||
_unit setVariable [QEGVAR(medical,lastDamageSource), _shooter];
|
||||
_unit setVariable [QEGVAR(medical,lastInstigator), _instigator];
|
||||
|
Loading…
Reference in New Issue
Block a user