zapat 56 Posted July 31, 2011 It may be an obvious thing, but I don't know how I could count the number of vechiles (ground vehicles) a specific group have at a certain time. (eg. a tank platoon or a motorized infantry squadron) Counting units is easy, but afaik that only returns infantry (and crew), and I couldn't find anything straightforward for counting vehicles. ---------- Post added at 09:38 PM ---------- Previous post was at 08:24 PM ---------- I came up with the following: _grp = _this; _vehArray = []; { _veh = vehicle _x; if (_veh != _x) then { if (!(_veh in _vehArray)) then { _vehArray set [count _vehArray, _veh]; }; }; }foreach units _grp; count _vehArray if anyone knows a simplier method, I d thank it Share this post Link to post Share on other sites
cobra4v320 27 Posted July 31, 2011 Varray = []; {If !((Vehicle _x) in Varray) then {Varray = Varray + [Vehicle _x]}} Foreach (units mygroup); vehicleCount = "LandVehicle" countType Varray; hint format ["%1", vehicleCount]; Share this post Link to post Share on other sites
demonized 20 Posted August 1, 2011 @OP there is no problem in doing what you did in first post, and cobra shortened it abit, and piled it all into a single line, instead of spacing it out like you did, so its harder to understand. considering amount of lines like 10+ have zero effect on lag or scripts time. what you must consider is what the lines does, then a single line can easily out lag 2000 other lines. many ways of doing it, yours would be the way i would have done aswell, also just for the hell of it, here is a few other ways, similar and not, with a few less characters used than cobra: :D _vehs = []; { _veh = vehicle _x; if (_veh != _x AND !(_veh in _vehs)) then {_vehs = _vehs + [_veh]}; } foreach units _grp; hint format["vehicle count is %1",(count _vehs)]; _cnt = 0; { _veh = _x; if (({_veh == (assignedVehicle _x)} count (units _grp)) != 0) then {_cnt = _cnt + 1}; } foreach vehicles; hint format["vehicle count is %1",_cnt]; this one checks all vehicles ingame at that point, and checks if its assigned to any member of your group. simple checks go superfast, even when done on may many units like all vehicles, so it doesnt matter. Share this post Link to post Share on other sites
moricky 211 Posted August 1, 2011 (edited) Speaking about simplicity: _vehicleCount = {crew vehicle _x select 0 == _x && vehicle _x != _x} count units _grp; @Demonized Going through all vehicles is quite dangerous, as computing time rapidly increases with total amount present in mission. While group size usually stays quite small (12 for tank platoon, if I'm not mistaken), number of vehicles in mission can grow significantly higher. Edited August 1, 2011 by Moricky Share this post Link to post Share on other sites
zapat 56 Posted August 1, 2011 Thanks Gaia! I knew something similiar is achievable! :) Share this post Link to post Share on other sites