Jump to content

Recommended Posts

Gentlemen,

 

I am looking for a way to pull one array each for Uniforms, vests, backpacks, headgear and so on from configfile, similar to below example for weapons.

 

I would like to pull all equipment items, and then pick out all uniforms or vests or.... (whatever group of items that I want to make an array for) by filtering it by the "parent" name. (eg, below example "if "rifle" in _parents)

 

Spoiler

VD_weaponarraycustom = [];
VD_weaponarrayblacklist = [];
VD_weaponArray = [];
_count = count VD_weaponarraycustom;

if (_count >= 1) then {VD_weaponArray append VD_weaponarraycustom;}
else {
_cfgWeapons = "true" configClasses (configFile >> "cfgWeapons");

{
    _weaponString = configName (_x);
    _parents = [_x,true] call BIS_fnc_returnParents;

    if ("Rifle" in _parents) then {
        VD_weaponArray append [_weaponString];
    };
  if ("Pistol" in _parents) then {
        VD_weaponArray append [_weaponString];
    };
  if ("Launcher" in _parents) then {
          VD_weaponArray append [_weaponString];
      };
} forEach _cfgWeapons;};
VD_weaponarray = VD_weaponarray - VD_weaponarrayblacklist;

 

 

Now I tried to find the correct parents in config viewer by placing an uniform in eden editor and then rightclick + show in config  viewer, but i think i get the wrong parents there (maybe just the vehicle for the placed uniform / "groundweaponholder"?)

Anyway none of the parents work and i wonder where i am going the wrong way.

 

For backpacks for example, I selected a backpack from the cfg vehicle list in the config viewer and found the parent "Bag_Base" (or something like that) and it would return an array of backpacks, however, many of the backpacks would contain items. Is there a way to avoid this? In the end I only want each array to contain empty vests/uniforms/backpacks.

 

I think my problem is that I use the wrong method to search for an example classname in config viewer and therefore it provides me with wrong parents. I would appreciate any help or guidance in that respect;)

 

Thanks

VD

  • Like 1

Share this post


Link to post
Share on other sites

You can filter a lot of things down by their simulation type and then further via the type property.

// >> "type"
#define WeaponNoSlot            0       // dummy weapons
#define WeaponSlotPrimary       1       // primary weapons
#define WeaponSlotSecondary     4       // secondary weapons
#define WeaponSlotHandGun       2       // HandGun
#define WeaponSlotHandGunItem   16      // HandGun magazines
#define WeaponSlotItem          256     // items
#define WeaponSlotBinocular     4096    // binocular
#define WeaponHardMounted       65536   //vehicle weapons
#define WeaponSlotInventory     131072  // inventory items

// >> "itemInfo" >> "type"
#define DEFAULT_SLOT        0
#define MUZZLE_SLOT         101
#define OPTICS_SLOT         201
#define FLASHLIGHT_SLOT     301
#define BIPOD_SLOT          302
#define FIRSTAIDKIT_SLOT    401
#define FINS_SLOT           501
#define BREATHINGBOMB_SLOT  601
#define NVG_SLOT            602
#define GOGGLE_SLOT         603
#define SCUBA_SLOT          604
#define HEADGEAR_SLOT       605
#define FACTOR_SLOT         607
#define RADIO_SLOT          611
#define HMD_SLOT            616
#define BINOCULAR_SLOT      617
#define MEDIKIT_SLOT        619
#define TOOLKIT_SLOT        620
#define VEST_SLOT           701
#define UNIFORM_SLOT        801
#define BACKPACK_SLOT       901

Then also for weapons you can filter them by cursor or cursorAim.

//Stolen from BIS_fnc_itemType

case "arifle": {"AssaultRifle"};
case "bomb": {"BombLauncher"};
case "cannon": {"Cannon"};
case "gl": {"GrenadeLauncher"};
case "laserdesignator": {"LaserDesignator"};
case "mg": {"MachineGun"};
case "missile": {"MissileLauncher"};
case "mortar": {"Mortar"};
case "rocket": {"RocketLauncher"};
case "sgun": {"Shotgun"};
case "throw": {"Throw"};
case "smg": {"SubmachineGun"};
case "srifle": {"SniperRifle"};

As well as BIS_fnc_itemType another good place to look at is BIS_fnc_loadInventory for some ideas on filtering.

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

thanks for your input;) i will have a closer look and let you know/postvmy solutions here!

Share this post


Link to post
Share on other sites

@Larrow Hi again, 

 

So I finally got around to try this and its working great for most bits, thanks again! =)

 

I am successfully pulling weapon arrays with the following code:

 

Spoiler

VD_WeaponArrayRifles = ("getnumber (_x >> 'type') isEqualTo 1 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};

 

 

And thanks to your input it works adapted for equipment as following.

However, Backpacks and Goggles wont work, meaning no items get added to the array, do you have any idea what i would need to change in the last 2 code lines for Backpacks and Goggles?

 

Spoiler

VD_EquipmentUniforms = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 801 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentVests = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 701 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentHeadgears = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 605 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};

//This one for goggles does not add goggles to the array yet
VD_EquipmentGoggles = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 603 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};

//This one for Backpacks does not add Backpacks to the array yet
VD_EquipmentBackpacks = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 901 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};

 

 

EDIT: 

OK I got the Backpacks sorted:

Spoiler

VD_EquipmentBackpacks = ("getnumber (_x >> 'isbackpack') isEqualTo 1 && getNumber (_x>> 'scope') >1 && getNumber (_x>> 'maximumLoad') != 0" configClasses (configfile >> "CfgVehicles")) apply {configName _x};

 

 

 

thank you in advance and BR

VD

Edited by Vandeanson
Backpack solution found
  • Like 1

Share this post


Link to post
Share on other sites

Alright everyone,

 

To sort of complete this post and provide some help for others, below a copy paste code to fetch available weapons, equipment and weapon attachments from config files (including active mods) into respective arrays that can be accessed otherwise.

 

Spoiler

VD_WeaponArrayRifles = [];
VD_WeaponArrayPistols = [];
VD_WeaponArrayPistolsPL = [];
VD_WeaponArrayLaunchers = [];
VD_WeaponArrayAll = [];

//melee weapon mod that rocks! Maxjoiner's Max Melee Weapons mod is available on steam or armaholic: http://www.armaholic.com/page.php?id=33693
VD_MAX_weaponArrayMelee = ("getnumber (_x >> 'type') isEqualTo 2 && getText (_x >> 'Author') == 'Maxjoiner' && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};

//weapon arrays
VD_WeaponArrayRifles = ("getnumber (_x >> 'type') isEqualTo 1 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_WeaponArrayPistols = ("getnumber (_x >> 'type') isEqualTo 2 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_WeaponArrayLaunchers = ("getnumber (_x >> 'type') isEqualTo 4 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_WeaponArrayAll append VD_WeaponArrayRifles;
VD_WeaponArrayAll append VD_WeaponArrayPistols;
VD_WeaponArrayAll append VD_WeaponArrayLaunchers;
VD_WeaponArrayPistolsPL append VD_WeaponArrayPistols; //this line combines pistols and max joiners melee weapons into one array - i use this for zombie survival mission player loadouts

//equipment
VD_EquipmentUniforms = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 801 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentVests = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 701 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentHeadgears = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 605 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentBackpacks = ("getnumber (_x >> 'isbackpack') isEqualTo 1 && getNumber (_x>> 'scope') >1 && getNumber (_x>> 'maximumLoad') != 0" configClasses (configfile >> "CfgVehicles")) apply {configName _x};

//weapon attachments
VD_EquipmentMuzzles = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 101 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentOptics = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 201 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentFlashlights = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 301 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};
VD_EquipmentBipods = ("getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 302 && getNumber (_x>> 'scope') >1" configClasses (configfile >> "CfgWeapons")) apply {configName _x};

 

 

It works fine for me but let me know if you spot any issues.

Also I dont know yet how to get a goggles array, appreciate any input=)

 

below a simple player loadout generator example i use

 

Spoiler

// create an .sqf file and name it e.g. playerequipper.sqf
// can be called from init.sqf or for example onplayerrespawn.sqf via execVM "playerequipper.sqf";

removeUniform player;
  player forceAddUniform selectRandom VD_EquipmentUniforms;
_goggles =  selectRandom VD_EquipmentGoggles;
  player additem _goggles;
  player assignItem _goggles;
  player addVest selectRandom VD_EquipmentVests;
  player addBackpack selectRandom VD_EquipmentBackpacks;
  player addHeadgear selectRandom VD_EquipmentHeadgears;
  _rifle =  selectRandom VD_WeaponArrayRifles;
  _pistol = selectRandom VD_WeaponArrayPistolsPL;

  [player, _rifle, 1 +(random 3), 0] call BIS_fnc_addWeapon;
  [player, _pistol, 1 +(random 3), 0] call BIS_fnc_addWeapon;
  
//the below bit comes from George FlorosGR
  _MuzzleSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
  _Muzzle = selectRandom _MuzzleSlot;

  _CowsSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
  _Optic = selectRandom _CowsSlot;

  _PointerSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems");
  _Pointer = selectRandom _PointerSlot;

  _UnderBarrelSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems");
  _UnderBarrel = selectRandom _UnderBarrelSlot;

  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _Muzzle;};
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _Optic;};
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _Pointer;};
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _UnderBarrel;};

 

 

Thanks to @Larrow and @GEORGE FLOROS GR for input regarding the above code!

cheers

vd

  • Thanks 1

Share this post


Link to post
Share on other sites
8 minutes ago, Vandeanson said:

code

 

Thanks Vandeanson !

 

This is also for the handguns :

//________________	add _Side_Weapon's compatible attachments	________________

_Side_Weapon_MuzzleSlot = getArray (configFile / "CfgWeapons" >> _Side_Weapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
_Side_Weapon_Muzzle = selectRandom _Side_Weapon_MuzzleSlot; 

_Side_Weapon_CowsSlot = getArray (configFile / "CfgWeapons" >> _Side_Weapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
_Side_Weapon_Optic = selectRandom _Side_Weapon_CowsSlot; 

_Side_Weapon_PointerSlot = getArray (configFile / "CfgWeapons" >> _Side_Weapon >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems");
_Side_Weapon_Pointer = selectRandom _Side_Weapon_PointerSlot; 

if (floor (random 10) < 4) then {_this addHandgunItem _Side_Weapon_Muzzle;};
if (floor (random 10) < 4) then {_this addHandgunItem _Side_Weapon_Optic;};
if (floor (random 10) < 4) then {_this addHandgunItem _Side_Weapon_Pointer;};

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Spoiler

_MuzzleSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
  if (count _MuzzleSlot >= 1) then {  _Muzzle = selectRandom _MuzzleSlot;
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _Muzzle;};
  };

  _CowsSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
  if (count _CowsSlot >= 1) then {_Optic = selectRandom _CowsSlot;
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _Optic;};
  };

  _PointerSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems");
  if (count _pointerslot >= 1) then {_Pointer = selectRandom _PointerSlot;
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _Pointer;};
  };

  _UnderBarrelSlot = getArray (configFile / "CfgWeapons" >> _rifle >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems");
  if (count _UnderBarrelSlot >= 1) then {  _UnderBarrel = selectRandom _UnderBarrelSlot;
  if (floor (random 10) < 2) then {player addPrimaryWeaponItem _UnderBarrel;};
   };


  _Side_Weapon_MuzzleSlot = getArray (configFile / "CfgWeapons" >> _pistol >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
  if (count _Side_Weapon_MuzzleSlot >= 1) then { _Side_Weapon_Muzzle = selectRandom _Side_Weapon_MuzzleSlot;
  if (floor (random 10) < 2) then {player addHandgunItem _Side_Weapon_Muzzle;};
  };
  _Side_Weapon_CowsSlot = getArray (configFile / "CfgWeapons" >> _pistol >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
  if (count _Side_Weapon_CowsSlot >= 1) then {_Side_Weapon_Optic = selectRandom _Side_Weapon_CowsSlot;
  if (floor (random 10) < 2) then {player addHandgunItem _Side_Weapon_Optic;};
  };
  _Side_Weapon_PointerSlot = getArray (configFile / "CfgWeapons" >> _pistol >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems");
    if (count _Side_Weapon_PointerSlot >= 1) then {_Side_Weapon_Pointer = selectRandom _Side_Weapon_PointerSlot;
  if (floor (random 10) < 2) then {player addHandgunItem _Side_Weapon_Pointer;};
  };

 

Thanks! I noticed some issues with WW2 weapons that are in my array, I have added an if condition to not attempt to add attachments in case there are no available attachements for such weapons

 

cheers

vd

  • Like 1

Share this post


Link to post
Share on other sites

Goggles/glasses are in CfgGlasses

  • Like 1
  • Thanks 1

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

×