Jump to content
Sign in to follow this  
colej_uk

Detect if unit if AI or player controlled?

Recommended Posts

Hi,

I'm building a mission which can be played in MP, but also has AI support (so if slots are empty they can be taken up by AI).

I need to detect if units are AI controlled or player controlled, then if they are AI controlled give them waypoints etc (essentially code the ai to play the game mode). While if they are players, I don't want any waypoints etc showing up.

So is there a way to detect if a unit is AI or player?

Share this post


Link to post
Share on other sites

Also... check out...

playableunits (for multiplayer)

switchableunits (for singleplayer)

I've been using something like this that works in both SP and MP.

_controllableAI = [];

_controllableAI = [] call {
_array = [];
if (isMultiplayer) then {
	_array = playableunits;
} else {
	_array = switchableunits;
};
_array
};

//more code here for whatever...
//blah...
//blah...
//blah...

if (_unit in _controllableAI) then {
   hint format ["%1 is playable",_unit];
} else {
   hint format ["%1 is not playable",_unit];
}; 

Share this post


Link to post
Share on other sites

Thanks for your help! I knew it was probably something simple, I was searching for something to do with ai and not thinking of the negate isPlayer.

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  

×