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:
|
|
|
|
* Nothing
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
{
|
|
|
|
_virtualLoad = _virtualLoad + (_x getVariable [QGVAR(vLoad), 0]);
|
|
|
|
} forEach [
|
2016-05-10 20:32:40 +00:00
|
|
|
_unit,
|
2016-05-03 16:12:47 +00:00
|
|
|
uniformContainer _unit,
|
|
|
|
vestContainer _unit,
|
|
|
|
backpackContainer _unit
|
|
|
|
];
|
|
|
|
|
|
|
|
// 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];
|