Jump to content
Sign in to follow this  
killerwhale

this stop true

Recommended Posts

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
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

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
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

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

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

this works, thanks very much. is it possible to find the classnames for rocks and trees?

Edited by killerwhale

Share this post


Link to post
Share on other sites

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

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 by kylania

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×