S
Shariku Onikage
Guest
What's a good way to assign talk tokens for npcs? I have a script so that npc objects are wandering around on paths, and if they get close to each other they'll try to initiate a conversation. At the moment i basically have the following script:
Script: EnemyHasAChat
The problem here is that since both are running the script at the same time they both end up with the same talkingToken value (in this case 1) so they end up saying the same thing ("Pay attention to me!"). I've tried a few variations when it comes to assigning the tokens, using if and other. in various combinations but it all leads to the same both are running the script at the same time issue.
I sort of thought that instances would be running the scripts one after each other at slightly different moments but it's like they're running at the exact same time. What's the better way for me to be doing this?
Thanks in advance.
Script: EnemyHasAChat
Code:
with(other) {
if (distance_to_object(other.id) <=100){
if other.talkingToken==1{ //talkingToken starts at 0
talkingToken=2;
}
talkingToken=1;
path_speed = 0;
other.path_speed = 0; //kind of get the feeling this isn't necessary at the moment
}
//actual speech destined to be a bit more complicated
if (talkingToken ==1){
words = "Pay attention to me!"
}
if (talkingToken==2){
words="Geez. Hi there.";
}
}
I sort of thought that instances would be running the scripts one after each other at slightly different moments but it's like they're running at the exact same time. What's the better way for me to be doing this?
Thanks in advance.