ACE3/addons/dragging/functions/fnc_getWeight.sqf

46 lines
1.5 KiB
Plaintext
Raw Normal View History

2015-03-18 13:14:16 +00:00
/*
2015-08-09 12:53:13 +00:00
* Author: L-H, edited by commy2, rewritten by joko // Jonas
* Returns the weight of a crate.
*
* Arguments:
2015-08-26 08:05:30 +00:00
* 0: Crate to get weight of <OBJECT>
2015-08-09 12:53:13 +00:00
*
* Return Value:
* Total Weight <NUMBER>
*
* Example:
2016-01-28 18:52:53 +00:00
* [Crate1] call ace_dragging_fnc_getweight;
2015-08-09 12:53:13 +00:00
*
* Public: No
2015-03-18 13:14:16 +00:00
*/
#include "script_component.hpp"
2015-08-26 08:05:30 +00:00
params ["_object"];
2016-01-28 18:52:53 +00:00
2015-08-09 12:53:13 +00:00
// Initialize the total weight.
2016-01-28 18:52:53 +00:00
private _totalWeight = 0;
2015-08-09 12:53:13 +00:00
// Cycle through all item types with their assigned config paths.
{
2016-01-28 18:52:53 +00:00
_x params ["_items", "_getConfigCode"];
2015-08-26 07:10:29 +00:00
_items params ["_item", "_count"];
2015-08-09 12:53:13 +00:00
// Cycle through all items and read their mass out of the config.
{
2015-08-09 12:53:13 +00:00
// Multiply mass with amount of items and add the mass to the total weight.
_totalWeight = _totalWeight + (getNumber ((call _getConfigCode) >> "mass") * (_count select _forEachIndex));
} forEach _item;
true
} count [
//IGNORE_PRIVATE_WARNING ["_x"];
2015-08-26 08:05:30 +00:00
[getMagazineCargo _object, {configFile >> "CfgMagazines" >> _x}],
[getBackpackCargo _object, {configFile >> "CfgVehicles" >> _x}],
[getItemCargo _object, {configFile >> "CfgWeapons" >> _x >> "ItemInfo"}],
[getWeaponCargo _object, {configFile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo"}]
2015-08-09 12:53:13 +00:00
];
2015-03-18 13:14:16 +00:00
2015-08-09 12:53:13 +00:00
// add Weight of create to totalWeight
2015-11-30 16:19:57 +00:00
_totalWeight = _totalWeight + (getNumber (configFile >> "CfgVehicles" >> typeOf _object >> "mass"));
2015-03-18 13:14:16 +00:00
2015-08-09 12:53:13 +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).
_totalWeight * 0.5