vinc3nt 10 Posted September 24, 2013 I have units called reb1 - reb14 and civ1 - civ20 on the map, but for some reason they do not move to the locations I've pre-set in the init. Does anyone know why it doesn't work? [private "_civs","_rebs","_civ","_reb","_positions","_directions","_position","_direction","_rndPos","_rnd","_i"]; _civs = ["civ1","civ2","civ3","civ4","civ5","civ6","civ7","civ8","civ9","civ10","civ11","civ12","civ13","civ14","civ15","civ16","civ17","civ18","civ19","civ20"]; _rebs = ["reb1","reb2","reb3","reb4","reb5","reb6","reb7","reb8","reb9","reb10","reb11","reb12","reb13","reb14"]; _positions = ["[14299,18860.4,0.262897]","[14298.7,18848.4,0.00144196]","[14295.3,18854.3,0.201878]","[14288,18861.3,0.227978]","[14282.6,18869.1,0.315739]","[14288.8,18868.9,0.410454]","[14292.1,18866.8,0.41642]","[14300.9,18856.4,0.267025]","[14304.5,18853.1,0.164486]","[14304.5,18853.1,0.164486]","[14298.7,18848.4,4.00144196]","[14295.3,18854.3,4.201878]","[14288,18861.3,4.227978]","[14282.6,18869.1,4.315739]","[14288.8,18868.9,4.410454]","[14292.1,18866.8,4.41642]","[14300.9,18856.4,4.267025]","[14304.5,18853.1,4.164486]","[14304.5,18853.1,4.164486]","[14373.8,18878.3,0.00152206]","[14368.2,18873.8,0.00152969]","[14398,18915,0.0141029]","[14390.5,18900.3,0.00144196]","[14398.9,18906,0.258644]","[14403.6,18910.7,0.25465]","[14410,18916.6,0.138344]","[14403.8,18918.3,0.00144196]","[14406.5,18921.8,0.00144196]","[14392.9,18909.5,0.00144196]","[14389.1,18905.9,0.00144196]","[14390.5,18900.3,4.00144196]","[14398.9,18906,4.258644]","[14403.6,18910.7,4.25465]","[14410,18916.6,4.138344]","[14403.8,18918.3,4.00144196]","[14406.5,18921.8,4.00144196]","[14392.9,18909.5,4.00144196]","[14389.1,18905.9,4.00144196]","[14330.4,18941.1,0.00144196]","[14341.7,18992.4,0.00143814]","[14341.7,18992.4,0.00143814]","[14351.9,18988.3,0.00144196]","[14353.3,18989.5,0.00143814]","[14353,18992.1,0.00143814]","[14395.9,18964.8,0.00144196]","[14397.8,18963.3,0.00144196]","[14391.9,18960,0.00144196]","[14340,18917.4,0.00144196]","[14346.9,18920.5,0.00141907]","[14312.3,18923.9,0.00144958]","[14316.5,18925,0.00144577]","[14314.1,18931.6,0.00144958]","[14317.1,18933.1,0.00144958]","[14319.5,18931.2,0.00144958]"]; _directions = ["74","0","298","13","131","322","181","168","260","260","0","298","13","131","322","181","168","260","260","287","17","25","71","268","217","228","83","173","97","186","71","268","217","228","83","173","97","186","130","100","220","320","290","240","240","250","20","130","190","90","160","120","160","240"]; for [{_i=0},{_i<=(count _civs)},{_i=_i+1}] do { _rnd = floor random 1; _rndPos = floor random (count _positions); _position = _positions select _rndPos; _civ = _civs select _i; _civ setpos _position; _civ setunitpos "DOWN"; if (_rnd > 0.7) then { _civ setunitpos "MIDDLE"; }; }; for [{_i=0},{_i<=(count _rebs)},{_i=_i+1}] do { _rnd = floor random 1; _rndPos = floor random (count _positions); _position = _positions select _rndPos; _direction = _directions select _rndPos; _reb = _rebs select _i; _reb setpos _position; _reb setdir _direction; if (_rnd > 0.6) then { _reb setunitpos "MIDDLE"; }; }; Share this post Link to post Share on other sites
na_palm 19 Posted September 24, 2013 (edited) Hi vinc3nt, you defined the position array as strings. Get rid of the " in it! greetings Na_Palm P.S.: for directions the same Edited September 24, 2013 by Na_Palm look at directions Share this post Link to post Share on other sites
kylania 568 Posted September 24, 2013 Why is everyone using for loops these days instead of forEach, which is 3x faster? { _pos = _positions select floor random (count _positions); _x setpos _pos; _x setunitpos "DOWN"; if ((random 1) > 0.7) then { _x setunitpos "MIDDLE"; }; } forEach _civs; Share this post Link to post Share on other sites