2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-05-03 16:12:47 +00:00
|
|
|
/*
|
|
|
|
* Author: commy2
|
|
|
|
* Recalculate the units loadCoef to emulate a mass added to uniform, vest or backpack.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The Unit (usually the player) <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [bob] call ace_movement_fnc_handleVirtualMass
|
2016-05-03 16:12:47 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_unit"];
|
|
|
|
|
2016-06-12 07:01:49 +00:00
|
|
|
if (isNull _unit) exitWith {};
|
|
|
|
|
2016-05-03 16:12:47 +00:00
|
|
|
// add sum of virtual loads
|
|
|
|
private _virtualLoad = 0;
|
|
|
|
|
|
|
|
{
|
2021-10-19 18:17:59 +00:00
|
|
|
_virtualLoad = _virtualLoad + (_x getVariable [QGVAR(vLoad), 0]);
|
2016-05-03 16:12:47 +00:00
|
|
|
} forEach [
|
2016-05-10 20:32:40 +00:00
|
|
|
_unit,
|
2016-05-03 16:12:47 +00:00
|
|
|
uniformContainer _unit,
|
|
|
|
vestContainer _unit,
|
|
|
|
backpackContainer _unit
|
|
|
|
];
|
|
|
|
|
2017-03-15 15:12:07 +00:00
|
|
|
_unit setVariable [QGVAR(totalLoad), (loadAbs _unit + _virtualLoad)];
|
|
|
|
|
2016-05-03 16:12:47 +00:00
|
|
|
// get absolute vanilla load
|
2016-06-10 01:30:45 +00:00
|
|
|
private _absLoad = getNumber (configFile >> "CfgInventoryGlobalVariable" >> "maxSoldierLoad");
|
2016-05-03 16:12:47 +00:00
|
|
|
|
|
|
|
// try to preserve other changes to the "LoadCoef" unitTrait
|
|
|
|
private _loadCoef = _unit getVariable QGVAR(loadCoef);
|
|
|
|
|
|
|
|
if (isNil "_loadCoef") then {
|
|
|
|
_loadCoef = _unit getUnitTrait "loadCoef";
|
|
|
|
_unit setVariable [QGVAR(loadCoef), _loadCoef, true];
|
|
|
|
};
|
|
|
|
|
|
|
|
// calc. new "virtual" loadCoef
|
|
|
|
private _virtualLoadCoef = (1 + _virtualLoad / _absLoad) * _loadCoef;
|
|
|
|
|
|
|
|
_unit setUnitTrait ["loadCoef", _virtualLoadCoef];
|