Note: If using the Devious Framework mod it will attempt to perform this registration automatically. The slave control file focuses on identifying slaves and masters while the slave action file is more related to animations and applying restraints and devices. Note: From what I understand there are two main ZaZ Animation Pack files for working with the player as a slave, zbfSlaveControl.psc, and zbfSlaveActions.psc. Whether there are more or not, I am not sure. There are three that I have learned about and I will describe them in this section with sample code.
The ZaZ Animation Pack has a number of features that help co-ordinate mods keeping track of player slavery. If (0 iMutex) || (_iMutexNext = iTimeoutMs) AddXxxToArray() can unlock the thread allowing this function to run again. Lock the mutex protecting the mutex list to protect creating two at once. Int Function iMutexCreate(String szName, Int iTimeoutMs=1000) Create an initial mutex for protecting the mutex list. A reference to the Devious Framework Util quest script.
If adding to an already started game you will need to initialize global variables in the script's upgrade section. You can add these functions to a private function section of your own script and use them. In general thread execution should be unlocked as infrequently as possible. I will not add mutex code to DFW utility script as it does not make sense to unlock thread execution in order to lock thread execution. If you have a need for a section of code to run to completion without other code interrupting it use mutexes. Note that even functions such as Debug.Trace() will potentially unlock thread execution. While code cannot run concurrently a function may begin to execute and then perform a remote function call, allowing other code in the script to run before the function returns to what is was doing. However, there is still a need for mutexes. No functions or events can run and no properties can be accessed concurrently. Script instances are generally thread safe. More information can be found on the Papyrus Threading Notes web page. the DFW utility script) behaves more or less like a remote function call, releasing the lock execution of the current thread. I planned to add a set of mutex functions to the Devious Framework (DFW) utility script however, I have since learned accessing external scripts (i.e. The "Apply Script" => "Report Masters" feature of TESVEdit to identify if they are used. If you have the real Dawnguard and Dragonborn master (.esm) files, instead of step 2 you can use