HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Communication between the AI and map

04-18-2003, 05:41 PM#1
Polistes
I've been experimenting with trying to send the AI commands from a trigger in the map. I know the trigger is AI send AI Commant (#,#) or something to that effect.
My question is, how do you get the AI to assign that info to variables.


Basically in the AI I have a variable say, i
I start off with i=0
later there is a loop
I have the command exitwhen i= 1
in the loop

I have been having trouble changing i from 0 to 1

in the game I send the AI 1's for both the command and data

I've tried looking at the campaign maps and mimicing those but
it doesn't seem to work.


Any help would be appriciated. Thanks
04-18-2003, 10:36 PM#2
AIAndy
There are 4 natives you need to call to receive these commands.

When you send a command from trigger to an AI that command is put on a stack. CommandsWaiting returns how many commands are currently waiting on this stack. GetLastCommand returns the command value of the topmost element of the stack (the last sent). GetLastData returns the data value of that element. You can remove the topmost element with PopLastCommand.

So a normal command receiving loop would look like that (cmd and data are supposed to be local or global variables in your script):

loop
exitwhen CommandsWaiting() != 0
call Sleep(2)
endloop
set cmd = GetLastCommand()
set data = GetLastData()
call PopLastCommand()
04-19-2003, 06:49 PM#3
Polistes
Thanks

I think I was missing the commandswaiting function.
I'll give it a shot