How can I make an AI wait for a variable?
Posted: Tue Feb 17, 2004 5:37 pm
After hours doing searches I decided to post this...
I have 2 AI targetnames "cit1" and "cit2". These 2 guys have a routine (go here, go there, wait, etc) and, at a certain point, they go towards a cardtable and start playing cards (btw, I'm not using the cardgame.scr).
When cit1 reaches the cardtable, I set a variable like this:
level.playcards[cit1] = 1
cit2 takes a random time to reach the destination, but always more time than cit1. When he reaches, I set:
level.playcards[cit2] = 1
Ok, I'd like to make cit1 sit and wait for cit2 for 30 sec. If cit2 arrives while cit1 is waiting, cit1 starts to play that animations etc, and go on w/ the thread...If not he leaves and go on with the thread...
This is what I have now for cit1 (Iwant him to react to the presence of cit2):
I know why is not working! I just dunno how to make it work...
I've try "while" "if" etc...But the truth is that I'm not good w/ scripts...(took me an hour to understand the difference between "=" and "==")
Can somebody clarify this cloudy brain?
Thanks
I have 2 AI targetnames "cit1" and "cit2". These 2 guys have a routine (go here, go there, wait, etc) and, at a certain point, they go towards a cardtable and start playing cards (btw, I'm not using the cardgame.scr).
When cit1 reaches the cardtable, I set a variable like this:
level.playcards[cit1] = 1
cit2 takes a random time to reach the destination, but always more time than cit1. When he reaches, I set:
level.playcards[cit2] = 1
Ok, I'd like to make cit1 sit and wait for cit2 for 30 sec. If cit2 arrives while cit1 is waiting, cit1 starts to play that animations etc, and go on w/ the thread...If not he leaves and go on with the thread...
This is what I have now for cit1 (Iwant him to react to the presence of cit2):
Code: Select all
routine_1:
level.playcards[cit1] = 0
wait 1
//MOVE AND SIT
self walkto $cardchair_1
self waittill movedone
self turnto $cardtable
wait 1
self anim chair_sit
self waittill animdone
iprintln "Citizen 1 is in the cardtable!"
level.playcards[cit10] = 1
//THIS IS THE CRAPPY PART, DON'T LAUGH!!! :lol:
self anim chair_actor1_idleloop //WAITING
self waittill animdone //AT THIS POINT HE LEAVES
if(level.playcards[cit2] == 1)
{
iprintln "cit 1 detected cit 2"
self anim chair_actor2_idleloop //MAIN LOOP
self waittill animdone
self anim chair_actor1_fish
self waittill animdone
self anim chair_actor2_drawcard //GRAB A CARD
self waittill animdone
self anim chair_actor1_queen //GIVE ME THE QUEEN
self waittill animdone
}
self anim chair_curious_stand //BOTH SITUATIONS SHOULD LEAD TO HERE
self waittill animdone
goto routine_10
end
Can somebody clarify this cloudy brain?
Thanks