mrcurry 496 Posted July 20, 2013 I'll get right down to it. I have a list of classes retrieved from CfgVehicles and I need to filter out abstract (non-spawnable) classes so I can get to the good stuff. Anyone know of a way of doing this? Technically I could just try spawning the class and check if it returns anything but that just seems stupid and performance unfriendly. What I've got so far is a fairly standard fetching of classes. _cfgVehicles = configFile >> "CfgVehicles"; _lastIndex = count _cfgVehicles - 1; _return = []; for "_i" from 0 to _lastIndex do { _xConf = _cfgVehicles select _i; _xClass = configName _xConf; if(isClass _xConf) then { /*Some checks against other stuff*/ _return set [count _return, _xClass]; }; }; _return I've tried testing against the class' model ( getText (configFile >> "CfgVehicles" >> _x >> "model") ) and checking if it returns "" or "bmp". Weirdly enough it seems most abstract vehicle classes in cfgVehicles has the model "bmp" but not all of them, so this only gets me so far. What I would really want is a "isAbstract" command like so... _config = (configFile >> "CfgVehicles") select 0; if(!isAbstract _config) then { //Do stuff }; ...but any way of doing without resorting to spawning would be sweet. Thanks! Share this post Link to post Share on other sites
Sealife 22 Posted July 20, 2013 probably using the "_config = (configFile >> "CfgVehicles") select 0;" and a comination of getNumber and Scope where > 0 is the value you want Scope 0 = protected Scope 1 = can be spawned scope 2 = public or listed in editor Share this post Link to post Share on other sites
Ed! 13 Posted July 20, 2013 I've worked on this. But it's not 100% done since there aren't planes and some other vehicle types yet. //[class name, description, [weapon class names], [turrets, [weapon classes]], [hitpoint class, hitpoint name]] ED_vehicles_air_heli_attack = []; //Attack helicopters with CAS ED_vehicles_air_heli_transport = []; //Transport helicopters with transport and drop support. ED_vehicles_air_heli_unarmed = []; //Helicopters without any weapons(or flares). ED_vehicles_air_heli_armed = []; //All helicopters with weapons. ED_vehicles_land_car_armed = []; //Cars with mounted weapons. ED_vehicles_land_car_unarmed = []; //Cars without mounted weapons. ED_vehicles_land_armor = []; //Tanks ED_vehicles_sea_ship_armed = []; //Ships with mounted weapons. ED_vehicles_sea_ship_unarmed = []; //Unarmed ships. ED_vehicles_sea_submarine = []; //Submarines ED_vehicles_static = []; //Static weapons. ED_vehicles_backpacks = []; //Backpacks. ED_vehicles_ammo = []; //Ammo Boxes _mentypes = ["", "Army", "SLA", "RACS", "Diver", "Sniper", "Story", "Recon", "Support"]; { call compile format["ED_vehicles_men%1 = [];", _x]; }foreach _mentypes; _cfg = configFile >> "cfgVehicles"; for[{_i = 1}, {_i < count(_cfg)}, {_i=_i+1}] do { _class = configName(_cfg select _i); _genMac = getText((_cfg select _i) >> "_generalMacro"); _type = getText((_cfg select _i) >> "vehicleClass"); _description = ""; if !(_class in ["B_Carryall_mcamo", "B_Carryall_mcamo_AAA", "B_Carryall_mcamo_AAT"]) then { _description = format["%1",getText((_cfg select _i) >> "displayName")]; }; _roles = getArray((_cfg select _i) >> "availableForSupportTypes"); _weapons = getArray((_cfg select _i) >> "weapons"); _magazines = getArray((_cfg select _i) >> "magazines"); _type2 = getText((_cfg select _i) >> "simulation"); _fuelCap = getNumber((_cfg select _i) >> "fuelCapacity"); _model = getText((_cfg select _i) >> "model"); _hasModel = { _result = true; if((toArray(_model) select 0) != (toArray("\") select 0)) then { _result = false; }; _result; }; _turretsCfg = configFile >> "CfgVehicles" >> _class >> "Turrets"; _turrets = []; for[{_j = 0}, {_j < count(_turretsCfg)}, {_j=_j+1}] do { _turCfg = _turretsCfg select _j; _turrets = _turrets + [[configName(_turCfg), getArray(_turCfg >> "weapons")]]; }; _hitpoints = []; _hitpointsCfg = configFile >> "CfgVehicles" >> _class >> "HitPoints"; for[{_j = 0}, {_j < count(_hitpointsCfg)}, {_j=_j+1}] do { _hitPointCFG = _hitpointsCfg select _j; _hitpoints = _hitpoints + [[configName(_hitPointCFG), getText((_hitpointsCfg select _j) >> "name")]]; }; _isBase = { _filter = toArray("BASE"); _result = false; _int = 0; { if((_x == _filter select 0) && (_int == 0)) then { _int = 1; }; if((_x == _filter select 1) && (_int == 1)) then { _int = 2; }; if((_x == _filter select 2) && (_int == 2)) then { _int = 3; }; if((_x == _filter select 3) && (_int == 3)) then { _result = true; }; }foreach (toArray (toUpper(_class))); _result; }; _isUnarmed = { _unarmed = true; { if(count(_x select 1) > 0) then { _unarmed = false }; }foreach _turrets; if(count(_weapons) > 1) then { _unarmed = false; }; _unarmed; }; if(_genMac != "" && _genMac != _type && _type != "" && _type != _class && (_description != _class) && (_description != "") && (_description != _type) && (!("FakeWeapon" in _weapons)) && (!(call(_isBase))) && (call(_hasModel))) then { if(_type == "Air") then { if(_type2 == "helicopterX") then { if("CAS_Heli" in _roles) then { ED_vehicles_air_heli_attack = ED_vehicles_air_heli_attack + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; if("Drop" in _roles || "Transport" in _roles) then { ED_vehicles_air_heli_transport = ED_vehicles_air_heli_transport + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; if(call _isUnarmed) then { ED_vehicles_air_heli_unarmed = ED_vehicles_air_heli_unarmed + [[_class, _description, _weapons, _turrets, _hitpoints]]; } else { ED_vehicles_air_heli_armed = ED_vehicles_air_heli_armed + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; }; }; if(_type == "Car") then { if(call _isUnarmed) then { ED_vehicles_land_car_unarmed = ED_vehicles_land_car_unarmed + [[_class, _description, _weapons, _turrets, _hitpoints]]; } else { ED_vehicles_land_car_armed = ED_vehicles_land_car_armed + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; }; if(_type == "Armor") then { ED_vehicles_land_armor = ED_vehicles_land_armor + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; if(_type == "Ship") then { if(call _isUnarmed) then { ED_vehicles_sea_ship_unarmed = ED_vehicles_sea_ship_unarmed + [[_class, _description, _weapons, _turrets, _hitpoints]]; } else { ED_vehicles_sea_ship_armed = ED_vehicles_sea_ship_armed + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; }; if(_type == "Submarine") then { ED_vehicles_sea_submarine = ED_vehicles_sea_submarine + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; if(_type == "Static" && _genMac == _class) then { ED_vehicles_static = ED_vehicles_static + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; if(_type == "Backpacks") then { ED_vehicles_backpacks = ED_vehicles_backpacks + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; if(_type == "Ammo" && _genMac == "thingX") then { if(count(configfile >> "CfgVehicles" >> _class >> "TransportWeapons") > 0) then { ED_vehicles_ammo = ED_vehicles_ammo + [[_class, _description, _weapons, _turrets, _hitpoints]]; }; }; { call compile format["if(""%7"" == ""Men%1"") then { ED_vehicles_men%1 = ED_vehicles_men%1 + [[""%2"", ""%3"", %4, %5, %6]]; };", _x, _class, _description, _weapons, _turrets, _hitpoints, _type]; }foreach _mentypes; }; }; ---------- Post added at 11:19 ---------- Previous post was at 11:16 ---------- probably using the "_config = (configFile >> "CfgVehicles") select 0;" and a comination of getNumber and Scope where > 0 is the value you want Scope 0 = protected Scope 1 = can be spawned scope 2 = public or listed in editor Seems like an even easier way. Share this post Link to post Share on other sites
Sealife 22 Posted July 20, 2013 if scope is null you will probably have to check inheitance https://community.bistudio.com/wiki/inheritsFrom Share this post Link to post Share on other sites
mrcurry 496 Posted July 23, 2013 (edited) probably using the "_config = (configFile >> "CfgVehicles") select 0;" and a comination of getNumber and Scope where > 0 is the value you want Scope 0 = protected Scope 1 = can be spawned scope 2 = public or listed in editor if scope is null you will probably have to check inheitance https://community.bistudio.com/wiki/inheritsFrom Cheers Sealife, that did the trick. Turns out getNumber returns 0 when the supplied config entry is not valid so the inheritance issue sorts itself out, at least for my purposes. For anyone interested here's the result: //retrieveClasses.sqf by [EVO] Curry private ["_allowed", "_disallowed", "_sides", "_return", "_cfgVehicles", "_lastIndex", "_i", "_xConf", "_xClass", "_isAllowed", "_j", "_isDisallowed", "_sideNums"]; _allowed = _this select 0; _disallowed = _this select 1; _sides = _this select 2; //Define sides _sideNums = []; if(typeName _sides == typeName []) then { { _sideNums set [_forEachIndex, _x call VSS_fnc_sideToNum ]; } forEach _sides; } else { _sideNums = [_sides call VSS_fnc_sideToNum]; }; diag_log text format ["_sideNums = %1", _sideNums]; _return = []; _cfgVehicles = configFile >> "CfgVehicles"; _lastIndex = (count _cfgVehicles)-1; //Fetch appropiate classes for "_i" from 0 to _lastIndex do { _xConf = _cfgVehicles select _i; _xClass = configName _xConf; if(isClass _xConf) then { if(getNumber (_xConf >> "scope") > 0) then { _isAllowed = {_xClass isKindOf _x} count _allowed > 0; _isDisallowed = {_xClass isKindOf _x} count _disallowed > 0; //Check side if( (getNumber (_xConf >> "side")) in _sideNums || (count _sideNums == 1 && -1 in _sideNums)) then { if(_isAllowed && !_isDisallowed) then { _return set [count _return, _xClass]; }; }; }; }; }; _return It makes use of the supporting function VSS_fnc_sideToNum defined in sideToNum.sqf //sideToNum.sqf by [EVO] Curry #define NO_SIDE -1 #define SIDE_EAST 0 #define SIDE_WEST 1 #define SIDE_RESISTANCE 2 #define SIDE_CIVILIAN 3 switch(_this) do { case west: {SIDE_WEST}; case east: {SIDE_EAST}; case resistance: {SIDE_RESISTANCE}; case civilian: {SIDE_CIVILIAN}; default {NO_SIDE}; } Edited July 23, 2013 by mrCurry Darn typos Share this post Link to post Share on other sites