Right, Problems problems (i'm sorry about this...)
First off, I can't run your test esp to check it works, as I get a CTD as soon as it kicks in. However I went ahead and attempted to implenent the effects anyway. I've duplicated your other scrupts (prefacing the with uv rather than DW for internal consistency reasons).
Here's the code i'm using:
let file_path := GetModelPath Weapon
let nifIDarchive := NifOpen $file_path 1
let children := NifGetNumChildren nifIDarchive
let R := Call uvgetXRotationMatrix 180
let childIndex := 0
let numChildren := NifGetNumChildren nifIDarchive
while ( childIndex < numChildren )
let locrot := NifGetNthChildLocalRotation childIndex nifIDarchive
let array := Call uvmatMult R locrot ; order matters
let one := array[0][0]
let two := array[0][1]
let three := array[0][2]
let four := array[1][0]
let five := array[1][1]
let six := array[1][2]
let seven := array[2][0]
let eight := array[2][1]
let nine := array[2][2]
PrintC "| %+0.3f %+0.3f %+0.3f |" one two three
PrintC "| %+0.3f %+0.3f %+0.3f |" four five six
PrintC "| %+0.3f %+0.3f %+0.3f |" seven eight nine
NifSetNthChildLocalRotationTEMP one two three four five six seven eight nine childIndex nifIDarchive
let childIndex += 1
loop
SetModelPathEx "%z" file_path newWeapon
It does seem to run, but with no effect on the weapon. Any thoughts? I Imagine i'm just doing something stupid...
Complete script in spoiler tags below (it's probably got some left over variables from an earlier script it was duplicated from.
Spoiler
scn uvRotateGrip
int isPlayer
ref Weapon
ref newWeapon
ref ench
float health
float charges
float weight
float attackdamage
float value
float speed
float reach
int type
int isPlayer
int weaponLoc
int newType
ref temp
string_var path
short nifIDno
short nifIDarchive
short nifIDfolder
short edIndex
short childIndex
short numChildren
array_var array
string_var file_path
string_var name
short children
int counter
array_var array
float one
float two
float three
float four
float five
float six
float seven
float eight
float nine
array_var R
array_var locrot
Begin Function{isPlayer}
printc "rotating weapon"
set Weapon to GetEquippedObject 16
set type to GetWeaponType Weapon
;--first we'll check that the weapon is suitable for switching. Then and only then will we switch it
if(type > 3)
if(isplayer)
Message "Sorry that weapon type is not suitable for rotating"
endif
return
endif
if(Weapon.isQuestItem)
if(isplayer)
Message "Sorry you can't rotate quest items - too many potential issues"
endif
return
endif
;-- get the various values associated with this weapon:
set ench to getenchantment weapon
set health to getequippedcurrenthealth 16
if(ench)
set charges to getequippedcurrentcharge 16
endif
let weaponLoc := player.call uvFindByName Weapon uvVariablesQuest.rotatedWeapons
printc "weaponloc is %.2f" weaponloc
if(weaponLoc == -1)
;-- this weapon has never been rotated
let uvVariablesQuest.rotatedWeapons[ar_size uvVariablesQuest.rotatedWeapons] := Weapon
set newWeapon to CloneForm Weapon
addItemNS newWeapon 1
removeItemNS Weapon 1
setgoldvalue value newweapon
setweight weight newweapon
let file_path := GetModelPath Weapon
let nifIDarchive := NifOpen $file_path 1
let children := NifGetNumChildren nifIDarchive
let R := Call uvgetXRotationMatrix 180
let childIndex := 0
let numChildren := NifGetNumChildren nifIDarchive
while ( childIndex < numChildren )
let locrot := NifGetNthChildLocalRotation childIndex nifIDarchive
let array := Call uvmatMult R locrot ; order matters
let one := array[0][0]
let two := array[0][1]
let three := array[0][2]
let four := array[1][0]
let five := array[1][1]
let six := array[1][2]
let seven := array[2][0]
let eight := array[2][1]
let nine := array[2][2]
PrintC "| %+0.3f %+0.3f %+0.3f |" one two three
PrintC "| %+0.3f %+0.3f %+0.3f |" four five six
PrintC "| %+0.3f %+0.3f %+0.3f |" seven eight nine
NifSetNthChildLocalRotationTEMP one two three four five six seven eight nine childIndex nifIDarchive
let childIndex += 1
loop
SetModelPathEx "%z" file_path newWeapon
;-----------------------------------------------------------------------------
equipItemNS newWeapon
setequippedcurrenthealth health 16
if(ench)
setenchantment ench newWeapon
setequippedcurrentcharge charges 16
endif
appendtoname " Rotated" newWeapon
let uvVariablesQuest.rotatedWeapons[ar_size uvVariablesQuest.rotatedWeapons] := newWeapon
printc "Done rotating new weapon"
else
let temp := uvVariablesQuest.rotatedWeapons[weaponLoc]
let name := getname temp
if (sv_Count "Rotated" name > 0)
;--it's a nifscript mesh so it must be a cloned weapon - that means we're just swapping it back
let newWeapon := uvVariablesQuest.rotatedWeapons[weaponLoc-1]
else
let newWeapon := uvVariablesQuest.rotatedWeapons[weaponLoc]
endif
addItemNS newWeapon 1
removeItemNS Weapon 1
equipItemNS newWeapon
setequippedcurrenthealth health 16
if(ench)
setequippedcurrentcharge charges 16
endif
printc "done rotating back"
endif
if(isPlayer)
enablecontrol 4
endif
End
HeX