What the 1.08 code does:
A. If Tom met Bill, Tom would assess his chances for greeting. 30% chance of success. If this failed, Tom wouldn’t try again with Bill for another 20 seconds. If Bill was gone at that point, no greeting would occur.
B. Once Tom got past the “chance” check, the GreetingBarkTask() would see if 3 minutes had gone by since the last time Tom greeted Bill. If so, the greeting was allowed. If not, the greeting was denied.
C. If a greeting occurs, Tom greets Bill, then sends him a message so he knows to return the greeting. Bill then acts like he’s the initiator, barking his reply and sending Tom a return message. Tom gets this message and tries to bark a reply to Bill, but the code prevents this from happening.
D. For Tom to greet Bill, Tom and Bill each need the other’s eye position to be w/in their FOV. This means only AI who are facing each other are allowed to exchange a greeting.
Problems with these rules:
1. If Tom and Bill are placed sitting at a table at spawn time, and don’t have any reason to get up, they will greet each other on average every 4 minutes, ad nauseum. This sounds silly after the first exchange.
2. If Tom meets Bill and at least one is moving, they probably only get one shot to exchange greetings. 70% of the time, this will fail. So the effect is two AI who might not have seen each other before, or who haven’t seen each other for a long time, don’t say anything to each other. An observer might expect them to greet each other.
3. In 2.0, if the player is friendly with or neutral to Tom, and encounters Tom, Tom is allowed to greet him. Following the rules A & B, if the player stands near a table full of Toms, the odds are high that he will be continuously greeted.
4. For Rule C, there’s no reason Bill has to act like he’s an initiator. He should just bark his reply and end the exchange. The return message back to Tom and having Tom discover he shouldn’t process it is a waste of cpu time.
5. If Tom comes up from behind Bill, then continues past him, no exchange will occur, because of rule D. In real life, Tom might very well say something to Bill as he approaches.
Fixes in 2.0:
1. Don’t let seated AI greet each other.
2. Eliminate the “30% chance” check. Replace it and the 3 minute waiting period with a random waiting period between 8 and 12 minutes. This reduces the frequency of exchanges between the same AI, or an AI and the player, and guarantees that when an exchange can happen, it happens, and isn’t subject to chance.
3. Mark the greeting and the response differently, so GreetingBarkTask() doesn’t get run excessively.
4. Tom can greet Bill if Bill is in Tom’s FOV, regardless of whether Tom is in Bill’s FOV. Bill responds even though he can’t see Tom. Since the AI look at who’s talking to them, this has the effect of Bill looking over his shoulder at Tom as Bill responds.
Ok, this code is now in SVN to choose the response sound for greetings:
First, the "rank" spawnarg is checked (is integer valued). A "rank" of "0" means "no rank". The smallest rank is 1.
If both AI have a rank > 0, then "snd_response_positive_superior" is chosen if otherRank > myRank.
If no rank information is available, this fallback logic comes into play:
If the AI itself is a superior (Noble, Elite, Priest) the ordinary "snd_response_positive" is chosen.
If the AI itself is not a superior, the other person is checked. If the other person is considered superior (Noble, Priest, Elite), the "superior" sound is chosen, otherwise the ordinary sound is used.