killerwhale 1 Posted March 8, 2013 So I am making a mission where a machine gunner is part of squad and is suppose to hold his position and not move. I am able to achieve that but he just wont fire at the enemy, what could be the cause? Here is the code I am using below Unit1 setpos ( pos t1) Unit1 stop true Unit1 setDir 130 Unit1 setunitpos"down" He can see the enemy but wont fire on them Share this post Link to post Share on other sites
ProfTournesol 956 Posted March 8, 2013 ARe you sure he is in range ? Share this post Link to post Share on other sites
ryanbeckey0 1 Posted March 8, 2013 isnt it dostop unit1/this ? Share this post Link to post Share on other sites
killerwhale 1 Posted March 8, 2013 isnt it dostop unit1/this ? Maybe but i'll try this command as well. Yes he is within range, less than 150 meters Share this post Link to post Share on other sites
ProfTournesol 956 Posted March 8, 2013 What happens if the unit isn't "down" ? Share this post Link to post Share on other sites
ryanbeckey0 1 Posted March 8, 2013 he has Unit1 setunitpos "down" which forces the unit to prone position Share this post Link to post Share on other sites
QuiteFranklyMyMaN 1 Posted March 8, 2013 You need to set his behavior at his last stop, and make sure he is engaging, open fire all. Share this post Link to post Share on other sites
kylania 568 Posted March 8, 2013 If you're using SQF you're going to need trailing ; on all of those lines. If you're missing it your script is erroring out at the first line and never getting to the second. Share this post Link to post Share on other sites
ProfTournesol 956 Posted March 8, 2013 he has Unit1 setunitpos "down"which forces the unit to prone position I know, my bad, my question was "does he refuse to fire even if the unit isn't forced to be lying on the ground" Share this post Link to post Share on other sites
killerwhale 1 Posted March 8, 2013 isnt it dostop unit1/this ? the doStop command works, Thanks big time! Share this post Link to post Share on other sites
ryanbeckey0 1 Posted March 9, 2013 no problem :) glad to help Share this post Link to post Share on other sites
killerwhale 1 Posted August 21, 2013 Hi, is it possible to make unit go to nearestojects, does the below code make sense? _cover = nearestObjects [unit1, [], 50]; unit1 move (getpos _cover) Share this post Link to post Share on other sites
cuel 25 Posted August 21, 2013 Almost, nearestObjects returns an array of the nearest objects unless you specify a className. Hence, you'd have to select an element from the array: _objArray = nearestObjects [unit1, [], 50]; if (count _objArray > 0) then { _cover = _objArray select floor random count _objArray; unit1 move (getpos _cover); }; Note that the objects can be almost anything. Share this post Link to post Share on other sites
killerwhale 1 Posted August 21, 2013 (edited) this works, thanks very much. is it possible to find the classnames for rocks and trees? Edited August 21, 2013 by killerwhale Share this post Link to post Share on other sites
kylania 568 Posted August 21, 2013 Most rocks and plants don't have classnames. Share this post Link to post Share on other sites
killerwhale 1 Posted August 21, 2013 but they seem to have ID number, can we do something with their ID number Share this post Link to post Share on other sites
lappihuan 178 Posted August 21, 2013 (edited) Use nearestObject instead of nearestObjects which allows you to search for ID's Edited August 21, 2013 by Lappihuan Share this post Link to post Share on other sites
killerwhale 1 Posted August 28, 2013 thanks Lappihuan, this command {_x commandMove((nearestBuilding _x)buildingPos random 4)}forEach units W1 causes units to move to nearest building, assigning random positions, but some of the units right away get out after taking positions, what can be done to prevent the getout Share this post Link to post Share on other sites
kylania 568 Posted August 28, 2013 (edited) Not all buildings will have 5 positions to go to. //find array of possible building positions function //_build_positions = _building call fnc_ghst_find_positions; fnc_ghst_find_positions = { private ["_i","_p","_b"]; _i = 0; _b = []; _build_positions = []; _pIsEmpty = false; while { ! _pIsEmpty } do { _p = _this buildingPos _i; if ( str _p != "[0,0,0]" ) then { _b = _b + [_p]; } else { _pIsEmpty = true; }; _i = _i + 1; }; if ((count _b > 0) and !(isNil "_b")) then { _build_positions = _build_positions + _b; }; _build_positions }; Edited August 28, 2013 by kylania Share this post Link to post Share on other sites
killerwhale 1 Posted August 28, 2013 Thanks very much, it works great! Share this post Link to post Share on other sites