Jump to content
Sign in to follow this  
Rydygier

How to get cargo capacity and cost/weight of stuff into sqf?

Recommended Posts

Many questions in short time appeared in my head...

Somehow I've never used getNumber command and such till today. Now I have a reason, but haven't sufficient knowledge about syntax. I need to store in ordinary, local script variables, both, capacity of any vehicle with cargo space, and "capacity cost" of any weapon/magazine/item (space for weapon and magazines are separated, or this is same pool? What with other items?) to know, if there is enough space in a trunk for given stuff. What sqf code will do this for me? BIKI's example for getNumber is not quite sufficient for me. I suppose, that needed code will be similar:

_value = getNumber (configFile >> "CfgVehicles" >> "Thing" >> "maxSpeed")

But what should be inputed instead of "Thing"? Variable refering to vehicle object will be sufficient (_vehicle)? What names have relevant entries (what instead of "maxSpeed" to get capacity and cost)? Also what insted of "CfgVehicles" (if not same) for retrieving cost of weapons/magazines/items? And how can I in the future posses such info about paths for other certain entries, if needed?

Share this post


Link to post
Share on other sites

Don't know if it's exactly what you're looking for but anyway:

Kylania has made available a PDF listing the cargo capacities of most, maybe all A2 & CO vehicles, plus a neat little demo for using the BIS config viewer function:

http://www.kylania.com/ex/

To get the number of seats for squaddies, use

getNumber (configFile >> "CfgVehicles" >> _veh >> "transportSoldier")

Share this post


Link to post
Share on other sites

Handy pdf, indeed. But to use it its content must be transformed into huge array with all classes and numbers and then code can look for type of tested vehicle in this array to check bounded with given type number... Possible, but impractical.

Although, I see, one question is answered: _veh is sufficient as "Thing". Thanks. Oh. And this config viewer may be very helpful too.

Edited by Rydygier

Share this post


Link to post
Share on other sites

I cannot find these values in the configs either, surely they must be somewhere?

There is no "getAmmoCargoSpace" or "getWeaponCargoSpace" command in the Command reference...

Share this post


Link to post
Share on other sites

Hi mate

For troops in APCs, search for "transportSoldier"

Under that listing in the config there will usually be a list for class "TransportMagazines".

Here's a default listing for a BMP2 (IIRC this would have been from 1.56 or so)

transportSoldier = 7;
   class TransportMagazines
   {
     class _xx_30Rnd_545x39_AK
     {
       magazine = "30Rnd_545x39_AK";
       count = "30*1";
     };
     class _xx_100Rnd_762x54_PK
     {
       magazine = "100Rnd_762x54_PK";
       count = "5*1";
     };
     class _xx_8Rnd_9x18_Makarov
     {
       magazine = "8Rnd_9x18_Makarov";
       count = "20*1";
     };
     class _xx_HandGrenade
     {
       magazine = "HandGrenade";
       count = "10*1";
     };
     class _xx_10Rnd_762x54_SVD
     {
       magazine = "10Rnd_762x54_SVD";
       count = "10*1";
     };
     class _xx_PG7VR
     {
       magazine = "PG7VR";
       count = "3*1";
     };
     class _xx_1Rnd_HE_GP25
     {
       magazine = "1Rnd_HE_GP25";
       count = "3*1";
     };
   };
   transportAmmo = 0;

You can get formatted config listings from Dev Heaven - you need to register but that is painless and saves a lot of time wading through the stock PBOs with a config viewer (though that would still be useful for new units - e.g., ACR - or mod units.

Share this post


Link to post
Share on other sites

i'm working on this atm so thought i'd update this post - see this

http://forums.bistudio.com/showthread.php?104700-retrieve-vehicle-s-cargo-capacity

its maxmags and maxweps you need

e.g.

_veh = TypeOf (vehicle player); //for example

_maxpeople = getNumber (configFile >> "CfgVehicles" >> _veh >> "transportSoldier");

_maxguns = getNumber (configFile >> "CfgVehicles" >> _veh >> "transportMaxWeapons");

_maxmags = getNumber (configFile >> "CfgVehicles" >> _veh >> "transportMaxMagazines");

_maxpacks = getNumber (configFile >> "CfgVehicles" >> _veh >> "transportMaxBackpacks");

lookup chart here

http://forums.bistudio.com/showthread.php?107661-Vehicle-Cargo-Capacity-Chart

and here's a little script that adds items to all vehicles at start of game

/*
Eggbeast script to add statics, weapons and ammo to vehicles
called globally from Sinit.sqf on ALL spawning vehicles including aircraft using the line
_events = [] execVM "data\scripts\static_cargo.sqf";//wherever you put it

uses sensors in mission.sqm as follows:
class Item6
	{
		position[]={5135.4976,22.860474,4726.9219};
		a=6500;
		b=6500;
		rectangular=1;
		activationBy="ANY";
		timeoutMin=3;
		timeoutMid=3;
		timeoutMax=3;
		age="UNKNOWN";
		name="BIS_EVO_ALL";
		class Effects
		{
		};
	};
	class Item23
	{
		position[]={4498.6797,0.50941157,-112.93164};
		timeoutMin=1;
		timeoutMid=1;
		timeoutMax=1;
		interruptable=1;
		age="UNKNOWN";
		text="sinit";
		name="sinit";
		expCond="isServer";
		expActiv="plays = [] execVM ""data\scripts\sinit.sqf"";";
		class Effects
		{
		};
	};

uses init.sqf entriesfor standard arrays as follows:
//adding bag types for static_Cargo
EGG_EVO_bagtypes_west = ["TOW_TriPod_US_Bag_EP1","M252_US_Bag_EP1","Mk19_Tripod_US_Bag_EP1","M2HD_mini_TriPod_US_Bag_EP1","M2staticMG_US_bag_EP1","BAF_L2A1_ACOG_tripod_bag","BAF_L2A1_ACOG_minitripod_bag","BAF_GPMG_Minitripod_D_bag","BAF_GMG_ACOG_minitripod_bag","RBS70_Bag_ACR"];

EGG_EVO_bagtypes_east = ["DSHkM_Mini_TriPod_TK_INS_Bag_EP1","DSHKM_TK_INS_Bag_EP1","KORD_TK_Bag_EP1","KORD_high_TK_Bag_EP1","SPG9_TK_INS_Bag_EP1","Metis_TK_Bag_EP1","2b14_82mm_TK_Bag_EP1","AGS_TK_Bag_EP1"];

EGG_EVO_cargoweapons_east = ["AK_47_S","AK_74","RPK_74","RPG7V","Sa61_EP1"];

EGG_EVO_cargomags_east0 = ["30Rnd_762x39_AK47","30Rnd_545x39_AK","75Rnd_545x39_RPK","PG7V","20Rnd_B_765x17_Ball","HandGrenade_East","PMC_ied_v1","OG7","100Rnd_762x54_PK","10Rnd_762x54_SVD","20Rnd_762x51_FNFAL"];

EGG_EVO_cargomags_east1 = ["Laserbatteries","PMC_ied_v2","PMC_ied_v3","PMC_ied_v4","pipebomb","mineE","PG7VR","PG7VL","Strela","Igla","AT13"];

EGG_EVO_cargoweapons_west = ["M4A1","M1014","MP5A5","M136","UZI_EP1"];

EGG_EVO_cargomags_west0 = ["30rnd_556x45_Stanag","8Rnd_B_Beneli_Pellets","30Rnd_9x19_MP5","M136","30Rnd_9x19_UZI","Laserbatteries","HandGrenade_West","pipebomb","100Rnd_762x51_M240","100Rnd_556x45_M249","20Rnd_762x51_DMR"];

EGG_EVO_cargomags_west1 = ["PMC_ied_v1","PMC_ied_v2","PMC_ied_v3","PMC_ied_v4","mine","SMAW_HEAA","SMAW_HEDP","Stinger","JAVELIN","Dragon_EP1","MAAWS_HEAT","MAAWS_HEDP","NLAW","30Rnd_556x45_G36SD","100Rnd_556x45_BetaCMag","20Rnd_762x51_B_SCAR","200Rnd_762x51_M240","200Rnd_556x45_M249","5Rnd_762x51_M24","10Rnd_127x99_m107"];

EGG_EVO_factionsW = ["USMC","BIS_US","BIS_CZ","BIS_GER","BIS_UN","BIS_BAF","PMC_BAF"];

EGG_EVO_factionsE = ["CDF","RU","INS","GUE","CIV","CIV_RU","BIS_TK","BIS_TK_INS","BIS_TK_GUE","BIS_TK_CIV","BIS_CIV_special"];

//for reference these are some of the backpack weapons available

Tripod_Bag
TOW_TriPod_US_Bag_EP1
M252_US_Bag_EP1
Mk19_Tripod_US_Bag_EP1
M2HD_mini_TriPod_US_Bag_EP1
M2staticMG_US_bag_EP1

BAF_L2A1_ACOG_tripod_bag
BAF_L2A1_ACOG_minitripod_bag
BAF_GPMG_Minitripod_D_bag
BAF_GMG_ACOG_minitripod_bag
RBS70_Bag_ACR

SPG9_TK_GUE_Bag_EP1
2b14_82mm_TK_GUE_Bag_EP1
AGS_TK_GUE_Bag_EP1
DSHkM_Mini_TriPod_TK_GUE_Bag_EP1
DSHKM_TK_GUE_Bag_EP1
AGS_UN_Bag_EP1
KORD_UN_Bag_EP1
KORD_high_UN_Bag_EP1

DSHkM_Mini_TriPod_TK_INS_Bag_EP1
DSHKM_TK_INS_Bag_EP1
KORD_TK_Bag_EP1
KORD_high_TK_Bag_EP1
SPG9_TK_INS_Bag_EP1
Metis_TK_Bag_EP1
2b14_82mm_TK_Bag_EP1
AGS_TK_Bag_EP1

*/

//script \static_cargo.sqf starts

_side = "USMC";
_vtype = "HMMWV_M2";
_magtypes0 = [];
_magtypes1 = [];
_mag = "15rnd_9x19_m9";
_extramags = 1;
_guntypes = [];
_gun = "M9";
_extraguns = 1;
_bagtypes = [];
_bag = "M2staticMG_US_bag_EP1";
_extrabags = 1;
_maxA = 1;
_maxB = 1;
_maxC = 1;
_maxguns = 0;
_maxmags = 0;
_maxmags2 = 0;
_maxpacks = 0;

sleep 2.0;
{
_side = faction _x;
_vtype = TypeOf vehicle _x;
clearMagazineCargoGlobal _x;
clearWeaponCargoGlobal _x;

//	hintsilent format["vec is : %1",_vtype];
sleep 0.1;

//types = 0 heli, 1 plane, 2 boat, 3 static, 4 car, 5 truck, 6 tank, 7 motorbike

sleep 0.2;

_type=3; 
if (_vtype isKindOf "Helicopter") then {_type=0};
if (_vtype isKindOf "Plane") then {_type=1};
if (_vtype isKindOf "Ship") then {_type=2};
if (_vtype isKindOf "StaticWeapon") then {_type=3};
if (_vtype isKindOf "Car") then {_type=4};
if (_vtype isKindOf "Truck") then {_type=5};
if (_vtype isKindOf "Tank") then {_type=6};
if (_vtype isKindOf "Motorcycle") then {_type=7};

/*
if (_vec isKindOf "Helicopter") then {_type=0};
if (_vec isKindOf "Plane") then {_type=1};
if (_vec isKindOf "Ship") then {_type=2};
if (_vec isKindOf "StaticWeapon") then {_type=3};
if (_vec isKindOf "Car") then {_type=4};
if (_vec isKindOf "Truck") then {_type=5};
if (_vec isKindOf "Tank") then {_type=6};
if (_vec isKindOf "Motorcycle") then {_type=7};
*/

//	hint format["ktype is: %1",_type];
sleep 0.1;

//get the cargo count for each vehicle
//_maxpeople = getNumber (configFile >> "CfgVehicles" >> _vtype >> "transportSoldier");
_maxguns = getNumber (configFile >> "CfgVehicles" >> _vtype >> "transportMaxWeapons");
_maxmags = getNumber (configFile >> "CfgVehicles" >> _vtype >> "transportMaxMagazines");
_maxmags2 = round (_maxmags/3);
_maxpacks = getNumber (configFile >> "CfgVehicles" >> _vtype >> "transportMaxBackpacks");

//	hintsilent format["type: %1 guns: %2 mags: %3 bags: %4",_type,_maxguns,_maxmags,_maxpacks];

switch (_type) do
{
	case 0://heli
	{
		_extrabags = 3;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 4;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (5 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
	case 1://plane
	{
		_extrabags = 1;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 1;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (2 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
	case 2://ship
	{
		_extrabags = 2;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 2;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (4 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
	case 3: //static weapon
	{
	};
	case 4://car
	{
		_extrabags = 2;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 2;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (4 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
	case 5://truck
	{
		_extrabags = 5;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 5;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (12 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
	case 6://tank
	{
		_extrabags = 4;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 4;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (8 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
	case 7://motorbike
	{
		_extrabags = 2;
		if (_extrabags > _maxpacks) then {_extrabags = _maxpacks};
		[_x,_side,_extrabags] spawn EGG_EVO_getbags;
		_extraguns = 1;
		if (_extraguns > _maxguns) then {_extraguns = _maxguns};
		[_x,_side,_extraguns] spawn EGG_EVO_getguns;
		_extramags = (2 - _extraguns);
		if (_extramags > _maxmags2) then {_extramags = _maxmags2};
		[_x,_side,_extramags] spawn EGG_EVO_getmags;
	};
};
EGG_EVO_getguns =
{
	_x = _this select 0;
	_side = _this select 1;
	_extraguns = _this select 2;
	sleep 0.1;
	_guntypes = [];
	_magtypes0 = [];
	sleep 0.1;
	if (_side in EGG_EVO_factionsE) then 
	{
		_guntypes = EGG_EVO_cargoweapons_east;
		_magtypes0 = EGG_EVO_cargomags_east0
	} else {
		_guntypes = EGG_EVO_cargoweapons_west;
		_magtypes0 = EGG_EVO_cargomags_west0
	};
	_maxA = (count _guntypes)-1;
	_i = 0;
	while {_i < _extraguns} do 
	{
		_r = (round random _maxA);
		_gun = _guntypes select _r;
		_mag = _magtypes0 select _r;
		_x AddWeaponCargoGlobal [_gun,1];
		_x AddMagazineCargoGlobal [_mag,3];
		_i = _i + 1;
		sleep 0.02;
	};
};
EGG_EVO_getmags =
{
	_x = _this select 0;
	_side = _this select 1;
	_extramags = _this select 2;
	sleep 0.1;
	_magtypes1 = [];
	sleep 0.1;
	if (_side in EGG_EVO_factionsE) then 
	{
		_magtypes1 = EGG_EVO_cargomags_east1
	} else {
		_magtypes1 = EGG_EVO_cargomags_west1
	};
	_maxB = (count _magtypes1)-1;
	_j = 0;
	while {_j < _extramags} do 
	{
		_r = (round random _maxB);
		_mag = _magtypes1 select _r;
		_x AddMagazineCargoGlobal [_mag,3];
		_j = _j + 1;
		sleep 0.02;
	};
};
EGG_EVO_getbags =
{
	_x = _this select 0;
	_side = _this select 1;
	_extrabags = _this select 2;
	_bagtypes = [];
	sleep 0.1;
	if (_side in EGG_EVO_factionsE) then 
	{
		_bagtypes = EGG_EVO_bagtypes_east
	} else {
		_bagtypes = EGG_EVO_bagtypes_west
	};
	_maxC = (count _bagtypes)-1;
	_k = 0;
	while {_k < _extrabags} do 
	{
		_bag = _bagtypes select (round random _maxC);
		if (_k == 2) then {_bag ="Tripod_Bag"};
		_x addBackpackCargoGlobal [_bag,1];
		_k = _k + 1;
		sleep 0.2;
	};
};
} forEach list BIS_EVO_ALL;
deletevehicle BIS_EVO_ALL;

Edited by eggbeast

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×