OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: angusjm on 09 Aug 2005, 20:01:27

Title: Is a unit AI?
Post by: angusjm on 09 Aug 2005, 20:01:27
I'm looking for a simple way to tell if a unit is AI or not.

It has to work in multiplayer so:
? _unit == player
is not good enough.

Nor is the deletevehicle test, because I dont want the unit deleted if it is AI.

Is there any simple test?

Thanks,
angusjm
Title: Re:Is a unit AI?
Post by: Artak on 09 Aug 2005, 21:37:59
AI unit is local on server. Thus giving us the option to ask
?local _unit: unit is either playing on server machine, or is AI

To take this further you can add
?local _unit && _unit != player: unit is not player and is on server, so it must be AI

I came to this very quickly. I may be totally off, but it seems logical doesn't it?  :)


Quote
Nor is the deletevehicle test, because I dont want the unit deleted if it is AI.
What on earth is a deletevehicle test?! And do I even dare what will happen if you delete a player unit  :o
Title: Re:Is a unit AI?
Post by: .pablo. on 09 Aug 2005, 22:38:06
Quote
What on earth is a deletevehicle test?! And do I even dare what will happen if you delete a player unit :o
my guess (based on what he said) is that the deletevehicle command doesn't work on players, so if you wanted to "test" whether or not a unit was a player, you could try to delete him and see what happens :o :D ;D
Title: Re:Is a unit AI?
Post by: DBR_ONIX on 10 Aug 2005, 01:35:00
That's like shooting someone to see if their alive, if they should, chances are their alive.. ::)
Anyway
_ai = (player == _this select 0)

_ai will be true if the unit is a real person, false if the unit is an AI (I think at this time I could be wrong :P)
- Ben
Title: Re:Is a unit AI?
Post by: Terox on 10 Aug 2005, 16:28:48
is it one specific unit that you need to check
or is it more than 1

and why do u need to do this, there maybe a better way or a simpler solution

perhaps do the following

lets say the units name is W1

INIT.sqs
Quote
tx_IamAi = true
if(player == W1)then{tx_IamAi = false; Publicvariable "tx_IamAi"}


therefore if you use
?(tx_IamAi): add your code here
the code will only be run if W1 is an ai

hope thats simple enough
Title: Re:Is a unit AI?
Post by: benreeper on 13 Aug 2005, 05:46:41
Aren't AI units in a clients group non-local and non-player?  How would you check for them?
--Ben
Title: Re:Is a unit AI?
Post by: Terox on 13 Aug 2005, 13:51:13
Aren't AI units in a clients group non-local and non-player?  How would you check for them?
--Ben

tx_IamAi = true
if(player == W1)then{tx_IamAi = false; Publicvariable "tx_IamAi"}


will only change the boolean tx_IamAi to false, if the player unit is W1 on any client

if w1 is in the players group but not the actual players unit, it will remain false


on an additional note, a pause (~2) would probably be required to give the clients enough time to transmit/receive the boolean pv before any conditional code is run on the tx_IamAi variable
Title: Re:Is a unit AI?
Post by: ShowID on 13 Aug 2005, 14:36:08
Yes that would work.  I'm going to try it out.  A pause of 2s would be reasonable in the context - if the crew of a helicopter addon are AI then the CAS script will be activated.

Thanks for your contributions.

ShowID