Jump to content
Sign in to follow this  
rejenorst

Checking an array for alive units.

Recommended Posts

Im making a very basic mine generation script.

All i need at the moment is how to get an array with units that are alive in sqs.

So far I have the following:

_deadmen = nearestObjects [(getmarkerpos "mine"), ["land"], 150];

this provides me with an array of units closest to the markerpos BUT also includes all dead units.

if i do the following it gives me a count of units alive in the array but not in array form.

_alivemen= {alive _x} count _deadmen

I need to enter an alive condition into the following:

_deadmen = nearestObjects [(getmarkerpos "mine"), ["land"], 150];

OR translate the following into an array:

_alivemen= {alive _x} count _deadmen

can anyone help me? thanks

Share this post


Link to post
Share on other sites

_alivemen = [];

{ if (alive _x) then { _alivemen = _alivemen+[_x] }; } forEach _deadmen;

Then again that's sqf... Leave sqs, stop dressing up a dead horse and make it dance by attaching strings to it, blargh!

Share this post


Link to post
Share on other sites

Lol would take me ages to learn sqf now... took me two bloody years almost to get to grips with sqs lol.

Anyway I got a translation into sqs:

{if ("land" counttype [_x] > 0) then {_victims = _victims + [_x]}} forEach (list _trig)

so with what you've posted there and the above I am pretty sure I can do what I intended now. Thanks man :)

Edit: Having said that are there any great tuts for sqf?

Edited by Rejenorst

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  

×