Friday 27 September 2013

Creating Custom Gearboxes

Sorry for the long delay in any posts, didn't expect anyone to actually read them! Thanks for any readers so far, I will try to get at least one post a week from this point on (including any larger projects I may have in the works).

So onto gearboxes. Sometimes you will want to kit your character out at a particular point in a mission, While you could set trigger areas to do this, it doesn't feel as real or smooth as using gearboxes. However, first we will need to find ourselves a way of stashing our glorious ArmA loot.

Open up the editor and place down a single unit. This should create a player unit(to check, look if the unit has a red ring around it). Once this is placed, a new option will appear for placing single units called "Empty". In here there are a mass of different objects that can be placed, from tents to car wrecks. We will be focusing on the "Ammo" class. [Shown below]



Once we decide on an ammo box, it can be placed near our character as a normal object would. Now to get to the script, open the item's INIT line:
 Depending on what box is chosen, it will contain some related items by default, we don't want this. By entering the clearMagazineCargo, clearWeaponCargo and clearItemCargo, we can remove all items from withing the box, thus providing a blank slate.
clearMagazineCargo this;

clearItemCargo this;

clearWeaponCargo this;

Now for the fun stuff. We can begin to add and customise our Gearbox as desired. The entire code for a personal Bluefor loadout can be found at the bottom of this post. We will be using four main commands to fill our Gearbox with goodies. These are:

this addItemCargo ["Classname",Quantity];

this addMagazineCargo [Classname,Quantity];

this addBackpackCargo [Classname,Quantity];

this addWeaponCargo [Classname,Quantity] ;

Let's break this down; "this" refers to the current object of the INIT line (the gearbox), when referencing the gearbox for other purposes, a name must be assigned and this replaced with the object name. for example, gearboxBlue1.
     addItemCargo, or it's variations, refer to the actual type of item we are adding. Magazines. backpacks and weapons are exactly what they say. However, addItemCargo covers more than just medkits and NVG;s. Uniforms, attachments, vests, headgear, explosives and items, are all covered by this command.
     Classname refers to the actually config name of the item, such as, "H_Milcap_blk" for a black military cap. [How to find these classnames will be shown in a later blog using 2 different methods]
     Quantity refers to, well, how many of the item you want to be stored, if you have a 3-man squad, make sure you have plenty of ammo and supplies!

Now we can start to place real items, an example for each command are below:

this addWeaponCargo ["arifle_MX_F",3];

this addItemCargo ["optic_Aco",3];

this addMagazineCargo ["16Rnd_9x21_Mag",15];

this addBackpackCargo ["B_Bergen_Base",1];

Here we can see that 3 base MX rifles have been added, along with three red ACO scopes, 15 9mm handgun mags and a single Bergen backpack. Remeber to use square brackets "[ ]" to denote the items and quantity within the command as shown.

So here is what the gearbox will look like when opened:

So here is all the coding for this post.
___________________________________________________________________________________

Emptying the box:

Remove magazines
clearMagazineCargo this;
Remove items and equipment
clearItemCargo this; 

 Remove weapons
clearWeaponCargo this;

Adding gear templates

Adding items and equipment
this addItemCargo ["Classname",Quantity];

Adding magazines
this addMagazineCargo [Classname,Quantity];

Adding backpacks
this addBackpackCargo [Classname,Quantity];

Adding weapons
this addWeaponCargo [Classname,Quantity] ;

Some gear examples

Adding 3 base MX rifles
this addWeaponCargo ["arifle_MX_F",3];

Adding 3 red ACO scopes
this addItemCargo ["optic_Aco",3];

Adding 15 9mm handgun mags
this addMagazineCargo ["16Rnd_9x21_Mag",15];

Adding a single Bergen backpack
this addBackpackCargo ["B_Bergen_Base",1];


A full, custom gearbox script!

//Clearing the box
clearMagazineCargo this;
clearItemCargo this;
clearWeaponCargo this;

//Adding all the required items
this addItemCargo ["FirstAidKit",3];
this addItemCargo ["nvgoggles",3];
this addItemCargo ["MediKit",3];
this addItemCargo ["ItemGPS",3];
this addItemCargo ["ItemCompass",3];
this addItemCargo ["ItemMap",3];
this addItemCargo ["ItemRadio",3];
this addItemCargo ["ItemWatch",3];

//Adding the weapons
this addWeaponCargo ["arifle_MX_F",3];
this addWeaponCargo ["hgun_P07_F",3];

//Adding the ammunition
this addMagazineCargo ["16Rnd_9x21_Mag",15];
this addMagazineCargo ["30Rnd_65x39_caseless_mag",21];

//Adding all the attachment options
this addItemCargo ["optic_Aco",3];
this addItemCargo ["optic_Hamr",3];
this addItemCargo ["optic_Holosight",3];
this addItemCargo ["acc_flashlight",3];
this addItemCargo ["acc_pointer_IR",3];
this addItemCargo ["muzzle_snds_H",3];
this addItemCargo ["muzzle_snds_L",3];

//Adding the three different uniforms
this addItemCargo ["U_B_CombatUniform_mcam_vest",1];
this addItemCargo ["U_B_CombatUniform_mcam_tshirt",1];
this addItemCargo ["U_B_CombatUniform_mcam",1];

//Adding the headgear options and glasses
this addItemCargo ["H_HelmetB",1];
this addItemCargo ["H_Cap_brn_SERO",1];
this addItemCargo ["H_Cap_Headphones",1];
this addItemCargo ["G_Tactical_Clear",3];

//Adding the vests
this addItemCargo ["V_PlateCarrier1_rgr",1];
this addItemCargo ["V_PlateCarrier2_rgr",1];
this addItemCargo ["V_BandollierB_rgr",1];

//Adding the backpacks
this addBackpackCargo ["B_Bergen_Base",1];
this addBackpackCargo ["B_Carryall_Base",1];
this addBackpackCargo ["B_Kitbag_sgg",1]; 

_________________________________________________________________________________

That's all the tools needed to start creating custom gearboxes for tactical re-arming or secret weapon stashes. Next time, we will be looking at how SQF can be used to allow for all players to be instantly "geared-up" with an animation.