This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tutorial:adding-havok-variables [2025/02/24 21:03] – created admin | tutorial:adding-havok-variables [2025/02/27 00:49] (current) – admin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | <hidden>Hidden | + | ====== Adding Havok Variables ====== |
| + | Authors: Vawser | ||
| + | |||
| + | This tutorial is for Dark Souls III. | ||
| + | |||
| + | The same concepts can be applied with Elden Ring and Sekiro behavior files, however HKXPack does not currently support these two games. | ||
| + | |||
| + | For Elden Ring, you can use [[https:// | ||
| + | |||
| + | ===== Tools ===== | ||
| + | To complete this tutorial, the following tools are needed: | ||
| + | * HKXPack | ||
| + | * WitchyBND | ||
| + | * Notepad++ or any other text editor. | ||
| + | |||
| + | ===== Glossary ===== | ||
| + | HKS: means Havok Script, these files are denoted by the .hks file extension. | ||
| + | HavokParam: a section with a decompiled behavior file within | ||
| + | HavokObject: | ||
| + | |||
| + | ===== Adding a Havok Variable ===== | ||
| + | A havok variable functions similarly to a variable as in any other programming language. However, it's usefulness is that it permits the transfer of information for a HavokScript (such as c0000.hks) into a Behavior file (such as the one contains in c0000.behbnd.dcx). | ||
| + | |||
| + | This allows any of the attributes used within the various Havok classes (such as HavokParam, HavokObject, | ||
| + | |||
| + | For example, allowing the ' | ||
| + | |||
| + | ==== Preparation ==== | ||
| + | First, you will need to unpack the behavior file. During this tutorial, we will be editing the player behavior file, which is c0000.behbnd.dcx. However, this tutorial can be applied to any character behavior file. | ||
| + | |||
| + | - Unpack the c0000.behbnd.dcx (folder: /Game/chr/) with WitchyBND. | ||
| + | - Navigate to the c0000.hkx file that contains the behaviors within the unpacked c0000.behbnd.dcx (folder: Behviors/ | ||
| + | - Decompile the c0000.hkx file with HKXPack. | ||
| + | - Open the resulting c0000.xml file with a text editor. | ||
| + | |||
| + | ==== Adding a Variable ==== | ||
| + | To define a havok variable, you will need to extend four HavokParam lists within the behavior file. These are: | ||
| + | - variableInfos | ||
| + | - variableBounds | ||
| + | - wordVariableValues | ||
| + | - variableNames | ||
| + | |||
| + | To do this, simply search for the word within the file. This will bring you to the list within the HavokObject. To extend each list, duplicate the last entry at the bottom of the list, and increment the numelements value by 1. Repeat as necessary if implementing more than one variable. | ||
| + | |||
| + | Additionally, | ||
| + | |||
| + | Remeber to increment the Num value at the top of the file. | ||
| + | |||
| + | === Variable Info === | ||
| + | Each variable info entry is represented by the following (or a variant of): | ||
| + | |||
| + | <code XML> | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The function of the role attributes (" | ||
| + | |||
| + | The function of the typing attribute (type) is to define the data type of the variable. The following data types are used: | ||
| + | <code XML> | ||
| + | VARIABLE_TYPE_REAL | ||
| + | VARIABLE_TYPE_INT8 | ||
| + | VARIABLE_TYPE_INT16 | ||
| + | VARIABLE_TYPE_INT32 | ||
| + | VARIABLE_TYPE_BOOL | ||
| + | VARIABLE_TYPE_POINTER | ||
| + | VARIABLE_TYPE_VECTOR4 | ||
| + | VARIABLE_TYPE_QUATERNION | ||
| + | </ | ||
| + | |||
| + | In most cases you will either want VARIABLE_TYPE_REAL for a decimal/ | ||
| + | |||
| + | === Variable Bounds === | ||
| + | Each variable bounds entry is represented by the following (or a variant of): | ||
| + | |||
| + | <code XML> | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | <hkparam name=" | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The function of the " | ||
| + | |||
| + | === Word Variable Values === | ||
| + | Each word variable value entry is represented by the following (or a variant of): | ||
| + | |||
| + | <code XML> | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | The function of the " | ||
| + | |||
| + | === Variable Names === | ||
| + | Each variable name entry is represented by the following (or a variant of): | ||
| + | |||
| + | <code XML> | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | This is the string that is used within HavokScript with the SetHavokVariable command. | ||
| + | |||
| + | ===== Using a Variable ===== | ||
| + | Having setup a Havok Variable, you now need to make use of it. To do this, you will need to create a HavokVariableBindingSet (hkbVariableBindingSet). | ||
| + | |||
| + | A variable binding set entry should look similar to the following, substituting the #ID, #MEMBERNAME and #VARINDEX text with the appropriate values. | ||
| + | |||
| + | <code XML> | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | **#ID** is the ID that every havok class object requires. Make sure it is unique. | ||
| + | |||
| + | **# | ||
| + | |||
| + | For example, the first entry has an index of 0, the next 1, etc. This means the last entry will be (numelements - 1). | ||
| + | |||
| + | **# | ||
| + | |||
| + | In some circumstances, | ||
| + | |||
| + | Having defined a hkbVariableBindingSet, | ||
| + | |||
| + | === Example of Usage === | ||
| + | Here is an example of using where a Havok Variable within the name of " | ||
| + | |||
| + | Added hkbVariableBindingSet: | ||
| + | <code XML> | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Usage in hkbClipGenerator: | ||
| + | |||
| + | <code XML> | ||
| + | < | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | <hkparam name=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== Finishing ==== | ||
| + | You should now: | ||
| + | - Recompile the c0000.xml with HKXPack to produce a new c0000.hkx | ||
| + | - Replace the c0000.hkx in the decompiled c0000.behbnd.dcx folder with the new c0000.hkx. | ||
| + | - Repack the c0000.behbnd.dcx. | ||
| + | |||
| + | ===== Usage in Script ===== | ||
| + | Having done the following, the Havok Variable is now in place for usage within the c0000.hks file. | ||
| + | |||
| + | For exaple, you can now add the following code to set the animation speed of all hkbClipGenerators that make use of the hkbVariableBindingSet that targets playbackSpeed and uses the WeaponAnimSpeed variable. | ||
| + | |||
| + | <code Lua> | ||
| + | SetVariable(" | ||
| + | </ | ||
| + | |||
| + | This will multiple the playbackSpeed of all the hkbClipGenerators that use the hkbVariableBindingSet we setup by 0.5, causing them to play at 50% speed. | ||
| + | |||
| + | You can then combine this with conditions to create new in-game effects, here for example a ring could provide +10% weapon swing speed: | ||
| + | |||
| + | <code Lua> | ||
| + | --- 111121 is the SpEffect given by the ring | ||
| + | if env(GetSpEffectID, | ||
| + | | ||
| + | end | ||
| + | </code> | ||