pcc 14 Posted April 10, 2017 Default warfare only spawns 1 AI gunner for all vehicles regardless of number turrets. I tried adding while loop, but still only get 1 AI gunner. if (_vehicle EmptyPositions "gunner" > 0) then { g = 0; while { g <= (_vehicle EmptyPositions "gunner") } do { _gunner = _team CreateUnit [_soldierName,_factoryPosition,[],0.2,"FORM"]; [_gunner] AllowGetIn true; [_gunner] Join _team; _gunner MoveInGunner _vehicle; [_gunner,_side] Call BIS_WF_InitUnit; g = g + 1; }; }; Share this post Link to post Share on other sites
sarogahtyp 1105 Posted April 10, 2017 in arma 2 it is not such easy. Every vehicle has one gunner only. all other men with a vehicle gun are sitting in a turret. So you have to use getInTurret moveInTurret The problem is that arma 2 has only a very limited command set for using and detecting vehicle turrets to detect the turrets of a vehicle I think you need to check the config file of that vehicle But Im not sure. 1 Share this post Link to post Share on other sites
opusfmspol 273 Posted April 11, 2017 KK's function is posted here: https://community.bistudio.com/wiki/moveInTurret This is what I've been using in my SOM-Warfare mission, hope it helps: Spoiler if (_vehicle EmptyPositions "gunner" > 0) then { // Many thanks to Killzone Kid for posting this very helpful function in the A2 Scripting Commands. Private ["_turrets","_turretsArray"]; _turrets = configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "Turrets"; _turretsArray = []; Private ["_i","_j"]; for "_i" from 0 to (count _turrets - 1) do { _turretsArray set [count _turretsArray, [_i]]; for "_j" from 0 to count (_turrets >> configName (_turrets select _i) >> "Turrets") - 1 do { _turretsArray set [count _turretsArray, [_i, _j]]; }; }; _gunner = _team CreateUnit [_soldierName,GetPos _vehicle,[],0.2,"FORM"]; [_gunner] AllowGetIn true; _gunner MoveInGunner _vehicle; [_gunner,sideJoined] Call BIS_WF_InitUnit; // Fill any remaining empty turrets. { _turretUnit = _vehicle turretUnit _x; if (isNull _turretUnit) then { _gunner = _team CreateUnit [_soldierName,_factoryPosition,[],0.2,"FORM"]; [_gunner] AllowGetIn true; _gunner moveInTurret [_vehicle, _x]; [_gunner,sideJoined] Call BIS_WF_InitUnit; }; } forEach _turretsArray; }; 1 Share this post Link to post Share on other sites
sarogahtyp 1105 Posted April 11, 2017 (edited) This uses KKs function as well and might fit ur needs: KK_fnc_commonTurrets = { private ["_arr","_trts"]; _arr = []; _trts = configFile / "CfgVehicles" / typeOf _this / "Turrets"; for "_i" from 0 to count _trts - 1 do { _arr set [count _arr, [_i]]; for "_j" from 0 to count ( _trts / configName (_trts select _i) / "Turrets" ) - 1 do { _arr set [count _arr, [_i, _j]]; }; }; _arr }; _turret_array = _vehicle call KK_fnc_commonTurrets; _crew = crew _vehicle; if(count _crew > 0) then { _team = group (_crew select 0);} else { _team = createGroup side _vehicle; }; _team addVehicle _vehicle; { if (isNull _vehicle turretUnit _x) then { _gunner = _team createUnit [_soldierName,_factoryPosition,[],0.2,"FORM"]; [_gunner] AllowGetIn true; _gunner moveInTurret [_vehicle, _x] }; } forEach _turret_array; Edited April 12, 2017 by sarogahtyp corrected syntax 1 Share this post Link to post Share on other sites