Forum Jump :

Author Message


Posts: 38
Rank:


Level: Member

Country: tz
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-05-02 05:32        
     
I had help finishing this idea so I decided to share. Gets the units current carrying mass and also the total carrying capacity based on the units gear.

//To use
a_CapacityArray=[] call GetUnitCarry;


//function
GetUnitCarry=
{
_PlayerInv=player call 
{
_unit=_this;

_playerList1=uniformitems _unit; 
_playerList2=vestitems _unit; 
_playerList3=backpackitems _unit;

_PlayerItemList=[];
_PlayerCountList=[];
{
	{
		if !(_x in _PlayerItemList) then 
			{
				_PlayerItemList pushback _x;
				_PlayerCountList pushback 1;
			} else 
				{
					_PlayerCountList set [(_PlayerItemList find _x),(_PlayerCountList select (_PlayerItemList find _x)) + 1];
				};
	}foreach _x;

}foreach [_playerList1,_playerList2,_playerList3];


[_PlayerItemList,_PlayerCountList];
};


	_Items=_PlayerInv select 0;
	_Counts=_PlayerInv select 1;
	
private ["_value"];
	
_Weights=0;
{
	_CFG=_x call 
{
_item=_this;
_CFG="";
if ( isClass (configFile >> "CFGweapons" >> _item)) then {
	_CFG="CfgWeapons";
}else{
    if ( isClass (configFile >> "CFGMagazines" >> _item)) then {
		_CFG="CfgMagazines";
    }else{
		_CFG="CfgVehicles";
    };
}; 
_CFG;
};


if ( 
		(_x isKindOf ["Pistol", configFile >> "CfgWeapons"]) ||
		(_x iskindof ["Binocular",configFile >> "CfgWeapons"])
	) then {_CFG="WeaponSlot"};

switch (_CFG) do {

	case "CfgWeapons": {_value=getnumber (configfile >> _CFG >> _x >> "ItemInfo" >> "mass") };
	case "CfgMagazines": {_value=getnumber (configfile >> _CFG >> _x >> "mass") };
	case "WeaponSlot": {_value=getnumber (configfile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo" >> "mass")};
	

};

	_Weights=_Weights + (_value * (_Counts select _foreachindex));

}foreach _Items;



_capacity=0;
{

	_container=gettext (configfile >> "CfgWeapons" >> _x >> "ItemInfo" >> "containerClass");
	_carry=getnumber (configfile >> "CfgVehicles" >> _container >> "maximumLoad");
	
_capacity=_capacity + _carry;
	
}foreach [uniform player, vest player];
_backCarry=getnumber (configfile >> "CfgVehicles" >> (backpack player) >> "maximumLoad"); 

_capacity=_capacity + _backCarry;

[_weights, _capacity];
};
EDITED to properly calculate binocular and pistols

This post was edited by alphapan (2016-05-05 23:33, 584 days ago)


Author Message


Posts: 612
Rank:


Level: Member

Country: au
Location: Perth
Occupation: Arma Addict
Age: 20
In-game name: BroBeans

 
#2 Posted at 2016-05-02 07:24        
     
This would be worth posting in the Script Library Section :-)


Advertisement


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#3 Posted at 2016-05-02 09:58        
     
Some hints reporting to mass:
BI issued two different commands:
- getmass , but this command returns 0 for a non-physX object. See my note.
- load which is more a "percentage" referring to 1 at full loaded unit, rather than what B.I. calls "a sum of mass", even if mass are added.

This "Load" command is interesting because you can see a load bar in inventory changing from 0 to 1 as you equip the unit with uniform, vest, magazines...
load your_unit == 1 when you have plenty of ammos in backpack, but some of them, particularly from add-ons, can contain plenty of charges, missiles,tools,etc.
That's probably the reason why BI decided to set fatigue to max (1) for an overloaded unit. But it's weird!
A unit with load at 0.999 (ammo bearer +) will see his fatigue from 0 to 1, depending on his speed, terrain, wounds...
A unit with load at 1.001 (say you add a chemlight) will see his fatigue ALWAYS at 1. It's a non-sense.

That's the reason why I decided to bypass this behavior in MGI Tactical Pack. Each load > 1 will have the same behavior than a 0.99 load. Then Fatigue will be the same as a max load but gradually, from 0 to 1!

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS