SKYRIM
Proper Spell Cast Direction by Staff of Flames
Skyrim » Animation
Added: 16/08/2015 - 05:26AM
Updated: 30/08/2017 - 11:56AM

726 Endorsements

0.0.5 Latest version

9,496 Unique D/Ls

19,835 Total D/Ls

64,994 Total Views

Uploaded by fxxkoff

Description

Last updated at 11:56, 30 Aug 2017 Uploaded at 5:26, 16 Aug 2015

A person bends his spine backwards when he is aiming towards something flying in the sky(a dragon, for example). This natural posture happens to all NPCs in Skyrim and to the player when he is using a bow, but not when the player is using magic. This is not only a aesthetic problem, because the position where spell's projectile emerges depends on the position of caster's hands/staves which in turn depends on the caster's posture. As a result, if you are standing on a deep slope and cast a spell towards something uphill, the projectile will often be blocked by the slope. This mod fixes this problem by adding a hkbTwistModifier to the casting modifier list in magicbehavior.hkx, thus forcing the player to pose correctly when casting a spell. Only IsWeaponMagicOut==true states are affected, in order not to conflict with PC Head Tracking and Voice Type. Make sure your headtracking mod automatically turns off itself during combat, otherwise the spine will be overbent.



Update: The latest version selectively bends spine, arms and neck according to player's animation state. For example, spine and neck are bent in all cases but arms are bend only when you are casting aimed concentration spells such as Frostbite, or aiming with a bow, or raising a shield. This makes the pose look more natural.




If you can't replace your magicbehavior.hkx with my file, you can modify it by following the steps below:
1. Use hkxcmd to convert magicbehavior.hkx to a xml file
2. Open the xml file with a text editor
3. Note that the file consists of objects which begin with something like <hkobject name="#0077"...., where #0077 is the object's name, a unique identifier.
4. You need to add two named objects, so you need to find two unused names which can be allocated to them. This is easy since there is no allocation table sort of things you have to concern about. Just scroll down to the bottom of the xml file to find the largest name number, say #1347. So the new objects can be named as #1348 and #1349
5.Copy the following texts to the xml file, place them among those <hkobject name="xxx"> ... </hkobject>. You can place them anywhere you want, just don't go outside <hksection>...</hksection>

<hkobject name="#1348" class="hkbVariableBindingSet" signature="0x338ad4ff">
<hkparam name="bindings" numelements="1">
<hkobject>
<hkparam name="memberPath">twistAngle</hkparam>
<hkparam name="variableIndex">77</hkparam>
<hkparam name="bitIndex">-1</hkparam>
<hkparam name="bindingType">BINDING_TYPE_VARIABLE</hkparam>
</hkobject>
</hkparam>
<hkparam name="indexOfBindingToEnable">1</hkparam>
</hkobject>
<hkobject name="#1349" class="hkbTwistModifier" signature="0xb6b76b32">
<hkparam name="variableBindingSet">#1348</hkparam>
<hkparam name="userData">1</hkparam>
<hkparam name="name">MagicSpineTwistModifier</hkparam>
<hkparam name="enable">true</hkparam>
<hkparam name="axisOfRotation">(1.000000 0.000000 0.000000 0.000000)</hkparam>
<hkparam name="twistAngle">0.000000</hkparam>
<hkparam name="startBoneIndex">24</hkparam>
<hkparam name="endBoneIndex">26</hkparam>
<hkparam name="setAngleMethod">LINEAR</hkparam>
<hkparam name="rotationAxisCoordinates">ROTATION_AXIS_IN_MODEL_COORDINATES</hkparam>
<hkparam name="isAdditive">true</hkparam>
</hkobject>
You should set the parameter variableBindingSet in the second object to the name of the hkbVariableBindingSet object in case you naming is different from mine.
6. Now go back to the beginning of the xml file and locate the animation variable list, which begins with <hkparam name="variableNames"...>. Find the line number of the variable Pitch(whose meaning should be clear to you), then minus the line number of the first variable of the list to get the index of the variable Pitch. The result is 77 in my case so the variableIndex parameter is set to 77 in the first new object.
8. Search for Casting_ML in the xml file, you should find something like this:
<hkobject name="#1019" class="hkbModifierList" signature="0xa4180ca1">
<hkparam name="variableBindingSet">null</hkparam>
<hkparam name="userData">1</hkparam>
<hkparam name="name">Casting_ML</hkparam>
<hkparam name="enable">true</hkparam>
<hkparam name="modifiers" numelements="4">
#1018 #1016 #1014 #1012
</hkparam>
</hkobject>
Now add the name of the new hkbTwistModifier object to this Casting Modifier List by changing its modifiers parameter to
<hkparam name="modifiers" numelements="5">
#1018 #1016 #1014 #1012 #1349
</hkparam>
9. Save file. Use hkxcmd to convert it into Data\meshes\actors\character\behaviors\magicbehavior.hkx and you are done.


How to edit 0_master.hkx for Lightning Storm
Step 1-6 is similar to above. Let's suppose the first two object added are
<hkobject name="#2712" class="hkbVariableBindingSet" signature="0x338ad4ff">
<hkparam name="bindings" numelements="1">
<hkobject>
<hkparam name="memberPath">twistAngle</hkparam>
<hkparam name="variableIndex">16</hkparam>
<hkparam name="bitIndex">-1</hkparam>
<hkparam name="bindingType">BINDING_TYPE_VARIABLE</hkparam>
</hkobject>
</hkparam>
<hkparam name="indexOfBindingToEnable">1</hkparam>
</hkobject>
<hkobject name="#2713" class="hkbTwistModifier" signature="0xb6b76b32">
<hkparam name="variableBindingSet">#2712</hkparam>
<hkparam name="userData">1</hkparam>
<hkparam name="name">RitualSpellSpineTwistModifier</hkparam>
<hkparam name="enable">true</hkparam>
<hkparam name="axisOfRotation">(1.000000 0.000000 0.000000 0.000000)</hkparam>
<hkparam name="twistAngle">0.000000</hkparam>
<hkparam name="startBoneIndex">24</hkparam>
<hkparam name="endBoneIndex">26</hkparam>
<hkparam name="setAngleMethod">LINEAR</hkparam>
<hkparam name="rotationAxisCoordinates">ROTATION_AXIS_IN_MODEL_COORDINATES</hkparam>
<hkparam name="isAdditive">true</hkparam>
</hkobject>
7. Search for RitualSpell_AimedConcentrationLoop, you should find something like
<hkobject name="#2524" class="hkbStateMachineStateInfo" signature="0xed7f9d0">
<hkparam name="variableBindingSet">null</hkparam>
<hkparam name="listeners" numelements="0"></hkparam>
<hkparam name="enterNotifyEvents">null</hkparam>
<hkparam name="exitNotifyEvents">null</hkparam>
<hkparam name="transitions">null</hkparam>
<hkparam name="generator">#2525</hkparam>
<hkparam name="name">RitualSpell_AimedConcentrationLoop</hkparam>
<hkparam name="stateId">7</hkparam>
<hkparam name="probability">1.000000</hkparam>
<hkparam name="enable">true</hkparam>
</hkobject>
8. We should apply the hkbTwistModifier to #2525. To do this, add another object
<hkobject name="#2714" class="hkbModifierGenerator" signature="0x1f81fae6">
<hkparam name="variableBindingSet">null</hkparam>
<hkparam name="userData">1</hkparam>
<hkparam name="name">RitualSpell_AimedConLoop_MG</hkparam>
<hkparam name="modifier">#2713</hkparam>
<hkparam name="generator">#2525</hkparam>
</hkobject>
then change <hkparam name="generator">#2525</hkparam> in #2524 in to <hkparam name="generator">#2714</hkparam>
9. Save and convert back to hkx