This may be of interest to anyone scripting emotions, especially if you're trying to keep tight control over the associated animations. There's nothing terribly revolutionary here, but it might be useful.
Emotional state vs animation typeI sat down tonight to try to decipher the links (if any) between the four emotion variables in the brain (Compliment, Hate, Insults and Swear), and the associated animations played on the Hap heads. To be honest I wasn't expecting much success - what if there are random chances involved? What happens in a complicated emotional situation, such as all four variables having a value (e.g. Compliment = 4, Hate = 2, Insult = 1 and Swear = 1, all at the same time)?
My observations have shown that it's actually very simple, and therefore fairly easy to control by script.
Simply subtract the negative emotions from the positive one, i.e.:
Compliment - Hate - Insult - Swear = X
Then look up X on the table below:
6 and higher: happy
4 or 5: surprised
1 through 3: happy
0: normal
-1: angry
-2 or -3: sad
-4 through -6: angry
-7 and lower: sad
So the "complicated" example above is just 4 - 2 - 1 - 1 = 0, and the poor emotionally distraught Hal would appear "normal".
Animation type vs hap animationThe descriptions above ("happy," "normal," "angry" etc) are looked up in Default.psn (in the Characters directory), and the associated hap animations played. Note that there are two or three options for each type (e.g. "Happy1" and "Happy2").
Random options from the current animation type are played at random times. If the User isn't doing anything, then after a minute the "Snooze" animation is played and repeated until the User gets talking to Hal again.
Playing hap animations through HalCommandsPlaying a hap animation using the HalCommands variable is strictly temporary. The chosen animation is played just once, and then Hal will revert back to the animation type specified by his four emotion variables. For reference, hap files are played using something like this:
HalCommands = HalCommands & "<HAPFILE>psycho.hap</HAPFILE>"
ConclusionAnyone scripting Hal's emotions should be aware of the animation rules above. They can be used in two main ways:
a) Use the four variables in your scripting, taking into account their effect on the animation; or
b) Create your own emotion variables, keep three of the in-built variables zero, and set the fourth to certain values to set Hal's animation state. e.g. Set Compliment to 4 for "surprised" animations.
How I figured this outStarting with a fresh brain, I commented out all lines that alter the four emotion variables (except the lines that initialise these variables at the start of a session with Hal). I programmed key words that would increment, decrement or reset the variables, while reading back their values. I played with them while watching the Haptek Console list the playing animation files.
Hopefully this is of use to somebody else [
]