Medical - optimize handle damage caching (#6657)

* optimize handle damage caching

* delete some rogue code

* it was 2 all along

* add calls
This commit is contained in:
commy2 2018-11-01 19:05:56 +01:00 committed by PabstMirror
parent 25b6e73985
commit 8541716bee

View File

@ -78,11 +78,10 @@ if (_unit getVariable [QGVAR(isFalling), false]) then {
if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) then {
_unit setVariable [QGVAR(frameNo_damageCaching), diag_frameno];
// handle the cached damages 3 frames later
// handle the cached damages 2 frames later
[{
params ["_args", "_idPFH"];
_args params ["_unit", "_frameno"];
if (diag_frameno >= _frameno + 2) then {
[{
params ["_unit"];
_unit setDamage 0;
private _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []];
private _cache_damages = _unit getVariable QGVAR(cachedDamages);
@ -90,9 +89,8 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t
(_x + [_cache_damages select _forEachIndex]) call FUNC(handleDamage_advanced);
} forEach _cache_params;
[_unit] call FUNC(handleDamage_advancedSetDamage);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
}, 0, [_unit, diag_frameno] ] call CBA_fnc_addPerFrameHandler;
}, _this] call CBA_fnc_execNextFrame;
}, _unit] call CBA_fnc_execNextFrame;
_unit setVariable [QGVAR(cachedProjectiles), []];
_unit setVariable [QGVAR(cachedHitPoints), []];