mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Minor performance improvements
Before avg: 0.0858495ms After avg: 0.0701045ms
This commit is contained in:
parent
0bf32bfb3a
commit
082ab5155e
@ -34,18 +34,8 @@ if (_selectionName in _hitSelections) then {
|
|||||||
_newDamage = _damage - (_unit getHitPointDamage (_hitPoints select (_hitSelections find _selectionName)));
|
_newDamage = _damage - (_unit getHitPointDamage (_hitPoints select (_hitSelections find _selectionName)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// we want to move damage to another selection; have to do it ourselves.
|
|
||||||
// this is only the case for limbs, so this will not impact the killed EH.
|
|
||||||
if (_selectionName != (_this select 1)) then {
|
|
||||||
_unit setHitPointDamage [_hitPoints select (_hitSelections find _selectionName), _damage + _newDamage];
|
|
||||||
_newDamage = 0;
|
|
||||||
};
|
|
||||||
// ??????
|
|
||||||
_damage = _damage + _newDamage;
|
|
||||||
|
|
||||||
// Check for vehicle crash
|
// Check for vehicle crash
|
||||||
if (vehicle _unit != _unit && !(vehicle _unit isKindOf "StaticWeapon") && {isNull _source} && {_projectile == ""} && {_selectionName == ""}) then {
|
if (vehicle _unit != _unit && {!(vehicle _unit isKindOf "StaticWeapon")} && {isNull _source} && {_projectile == ""} && {_selectionName == ""}) then {
|
||||||
if (missionNamespace getvariable [QGVAR(allowVehicleCrashDamage), true]) then {
|
if (missionNamespace getvariable [QGVAR(allowVehicleCrashDamage), true]) then {
|
||||||
_selectionName = _hitSelections select (floor(random(count _hitSelections)));
|
_selectionName = _hitSelections select (floor(random(count _hitSelections)));
|
||||||
_projectile = "vehiclecrash";
|
_projectile = "vehiclecrash";
|
||||||
@ -54,10 +44,11 @@ if (vehicle _unit != _unit && !(vehicle _unit isKindOf "StaticWeapon") && {isNul
|
|||||||
|
|
||||||
// From AGM medical:
|
// From AGM medical:
|
||||||
// Exclude falling damage to everything other than legs; reduce structural damage.
|
// Exclude falling damage to everything other than legs; reduce structural damage.
|
||||||
if (((velocity _unit) select 2 < -5) && (vehicle _unit == _unit)) then {
|
if (((velocity _unit) select 2 < -5) && {(vehicle _unit == _unit)}) then {
|
||||||
_unit setVariable [QGVAR(isFalling), True];
|
_unit setVariable [QGVAR(isFalling), True];
|
||||||
};
|
};
|
||||||
if (_unit getVariable [QGVAR(isFalling), false] && !(_selectionName in ["", "leg_l", "leg_r"])) exitWith {};
|
|
||||||
|
if (_unit getVariable [QGVAR(isFalling), false] && {!(_selectionName in ["", "leg_l", "leg_r"])}) exitWith {};
|
||||||
if (_unit getVariable [QGVAR(isFalling), false]) then {
|
if (_unit getVariable [QGVAR(isFalling), false]) then {
|
||||||
_newDamage = _newDamage * 0.7;
|
_newDamage = _newDamage * 0.7;
|
||||||
};
|
};
|
||||||
@ -69,21 +60,14 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t
|
|||||||
|
|
||||||
// handle the cached damages 3 frames later
|
// handle the cached damages 3 frames later
|
||||||
[{
|
[{
|
||||||
private ["_args","_unit","_frameNo"];
|
private "_args";
|
||||||
_args = _this select 0;
|
_args = _this select 0;
|
||||||
_unit = _args select 0;
|
|
||||||
_frameNo = _args select 1;
|
|
||||||
|
|
||||||
if (diag_frameno > _frameNo + 2) then {
|
if (diag_frameno > (_args select 1) + 2) then {
|
||||||
_cache_projectiles = _unit getVariable [QGVAR(cachedProjectiles), []];
|
_cache_params = (_args select 0) getVariable [QGVAR(cachedHandleDamageParams), []];
|
||||||
_cache_hitpoints = _unit getVariable [QGVAR(cachedHitPoints), []];
|
|
||||||
_cache_damages = _unit getVariable [QGVAR(cachedDamages), []];
|
|
||||||
_cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []];
|
|
||||||
{
|
{
|
||||||
if (typeName _x == typeName "") then {
|
_x call FUNC(handleDamage_advanced);
|
||||||
(_cache_params select _foreachIndex) call FUNC(handleDamage_advanced);
|
}foreach _cache_params;
|
||||||
};
|
|
||||||
}foreach _cache_projectiles;
|
|
||||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
}, 0, [_unit, diag_frameno] ] call CBA_fnc_addPerFrameHandler;
|
}, 0, [_unit, diag_frameno] ] call CBA_fnc_addPerFrameHandler;
|
||||||
@ -102,40 +86,32 @@ _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams);
|
|||||||
|
|
||||||
// Caching of the damage events
|
// Caching of the damage events
|
||||||
if (_selectionName != "") then {
|
if (_selectionName != "") then {
|
||||||
|
private ["_index","_otherDamage"];
|
||||||
|
_index = _cache_projectiles find _projectile;
|
||||||
// Check if the current projectile has already been handled once
|
// Check if the current projectile has already been handled once
|
||||||
if (_projectile in _cache_projectiles) then {
|
if (_index >= 0) exitwith {
|
||||||
private ["_index","_otherDamage"];
|
|
||||||
// if it has been handled, find the index in the cache
|
|
||||||
_index = _cache_projectiles find _projectile;
|
|
||||||
|
|
||||||
// Find the previous damage this projectile has done
|
// Find the previous damage this projectile has done
|
||||||
_otherDamage = (_cache_damages select _index);
|
_otherDamage = (_cache_damages select _index);
|
||||||
|
|
||||||
// Take the highest damage of the two
|
// Take the highest damage of the two
|
||||||
if (_otherDamage > _newDamage) then {
|
if (_newDamage > _otherDamage) then {
|
||||||
_newDamage = 0;
|
|
||||||
} else {
|
|
||||||
private ["_hitPoint", "_restore"];
|
private ["_hitPoint", "_restore"];
|
||||||
// Restore the damage before the previous damage was processed
|
// Restore the damage before the previous damage was processed
|
||||||
_hitPoint = _cache_hitpoints select _index;
|
_hitPoint = _cache_hitpoints select _index;
|
||||||
_restore = ((_unit getHitPointDamage _hitPoint) - _otherDamage) max 0;
|
_restore = ((_unit getHitPointDamage _hitPoint) - _otherDamage) max 0;
|
||||||
_unit setHitPointDamage [_hitPoint, _restore];
|
_unit setHitPointDamage [_hitPoint, _restore];
|
||||||
|
|
||||||
// Make entry unfindable and add the new damage cache
|
_cache_hitpoints set [_index, (_hitPoints select (_hitSelections find _selectionName))];
|
||||||
_cache_projectiles set [_index, objNull];
|
_cache_damages set [_index, _newDamage];
|
||||||
_cache_projectiles pushBack _projectile;
|
_cache_params set[_index, _this];
|
||||||
_cache_hitpoints pushBack (_hitPoints select (_hitSelections find _selectionName));
|
|
||||||
_cache_damages pushBack _newDamage;
|
|
||||||
_cache_params pushBack [_unit, _selectionName, _damage, _source, _projectile];
|
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
// This is an unhandled projectile
|
|
||||||
_cache_projectiles pushBack _projectile;
|
|
||||||
_cache_hitpoints pushBack (_hitPoints select (_hitSelections find _selectionName));
|
|
||||||
_cache_damages pushBack _newDamage;
|
|
||||||
_cache_params pushBack [_unit, _selectionName, _damage, _source, _projectile];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This is an unhandled projectile
|
||||||
|
_cache_projectiles pushBack _projectile;
|
||||||
|
_cache_hitpoints pushBack (_hitPoints select (_hitSelections find _selectionName));
|
||||||
|
_cache_damages pushBack _newDamage;
|
||||||
|
_cache_params pushBack _this;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Store the new cached values
|
// Store the new cached values
|
||||||
|
Loading…
Reference in New Issue
Block a user