2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-18 13:14:16 +00:00
|
|
|
/*
|
2019-12-11 17:53:34 +00:00
|
|
|
* Author: L-H, edited by commy2, rewritten by joko // Jonas, re-rewritten by mharis001
|
|
|
|
* Returns the weight of the given object.
|
2023-07-22 03:30:40 +00:00
|
|
|
* Weight is calculated from the object's mass, its current inventory, and PhysX mass if applicable.
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2019-12-11 17:53:34 +00:00
|
|
|
* 0: Object <OBJECT>
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2019-12-11 17:53:34 +00:00
|
|
|
* Weight <NUMBER>
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-07-19 17:13:44 +00:00
|
|
|
* cursorTarget call ace_dragging_fnc_getWeight
|
2015-08-09 12:53:13 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2019-12-11 17:53:34 +00:00
|
|
|
*/
|
2015-03-18 13:14:16 +00:00
|
|
|
|
2015-08-26 08:05:30 +00:00
|
|
|
params ["_object"];
|
2016-01-28 18:52:53 +00:00
|
|
|
|
2023-10-24 04:57:05 +00:00
|
|
|
// Skip weight checking if it will be 0
|
|
|
|
if (GVAR(weightCoefficient) == 0) exitWith {0};
|
|
|
|
|
2023-06-22 07:04:19 +00:00
|
|
|
private _weight = loadAbs _object;
|
2019-12-11 17:53:34 +00:00
|
|
|
|
2024-07-19 17:13:44 +00:00
|
|
|
if (!GVAR(skipContainerWeight)) then {
|
2023-07-22 03:30:40 +00:00
|
|
|
// Add the mass of the object itself
|
|
|
|
// getMass handles PhysX mass, this should be 0 for SupplyX containers and WeaponHolders
|
|
|
|
// Use originalMass in case we're checking weight for a carried object
|
2024-07-19 17:13:44 +00:00
|
|
|
_weight = _weight + (_object getVariable [QGVAR(originalMass), getMass _object]);
|
2023-07-22 03:30:40 +00:00
|
|
|
};
|
2019-12-11 17:53:34 +00:00
|
|
|
|
2024-07-19 17:13:44 +00:00
|
|
|
// Fixed in https://feedback.bistudio.com/T167469 on 2.16 profiling branch and for 2.18 stable
|
|
|
|
if ((productVersion select 3) < 152017) then {
|
|
|
|
{
|
|
|
|
_x params ["", "_container"];
|
|
|
|
_weight = _weight - (loadAbs _container);
|
|
|
|
} forEach (everyContainer _object);
|
|
|
|
};
|
2019-12-11 17:53:34 +00:00
|
|
|
|
2023-06-22 07:04:19 +00:00
|
|
|
// Mass in Arma isn't an exact amount but rather a volume/weight value
|
|
|
|
// This attempts to work around that by making it a usable value (sort of)
|
2023-10-24 04:57:05 +00:00
|
|
|
GVAR(weightCoefficient) * _weight * 0.5 // return
|