Jump to content

SKSE's SetSlotMask


Recommended Posts

Does anyone know how to use that properly?

 

I have a worn object that uses a particular slot. I want to be able to allow the player to change which slot is used by it so that it does not interfere with other worn objects that they might have.

 

I could do this the old fashioned way and have one NIF, one ArmorAddon & one Armor form per slot I wish to make usable. Tedious, time consuming but doable.

 

However, I saw SetSlotMask and GetSlotMask. I did a small test and I believe I successfully changed the slot, but I do not know how to get the object to be visible with the new slot.

 

My test was to take my object assigned to slot 58 and reassign it to slot 33 (the hands). As expected the hands disappeared, but so did my object. I've tried having two nodes in the NIF, one set at 58 and the other at 33. Didn't display. I tried setting both the armor & armor addon forms to have slot 33 & 58. The game crashed after reassigning the slot.

 

My test script if anyone was curious

 

 

Armor Property TheObject Auto
Actor Property PlayerRef Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	Utility.Wait(5.0)
	If akBaseObject == TheObject
		Int SlotMask = TheObject.GetSlotMask()
		Int NewSlot = 0x00000008 ;33
		If SlotMask != NewSlot
			TheObject.SetSlotMask(NewSlot)
			PlayerRef.QueueNiNodeUpdate()
		EndIf
	EndIf	
EndEvent 

 

 

Link to comment
Share on other sites

 

I tried setting both the armor & armor addon forms to have slot 33 & 58.

So you tried using SetSlotMask() on both the armour and armour addon? In which order?

 

The engine does funny things when moving stuff around in the named nodes, but usually the invisible object stuff is caused by a discrepancy between the biped slots for the armour and its addon(s).

 

Also, I have noticed a lot of unreliability in Queuing NiNode updates for this stuff. You may want to try unequip and equipping the piece of armour to reset it on the player.

 

Lastly, you don't need to use the hexadecimal numbers for these functions, decimal should be fine. Thought I might mention it just in case you didn't know.

Link to comment
Share on other sites

 

 

So you tried using SetSlotMask() on both the armour and armour addon? In which order?

I was referring to settings in the CK. SetSlotMask() is on the armor form so it would only work for armor objects. I don't think it would work for armor addon forms. Then again documentation is so scant that there is no way to know what it does and how to actually use it.

 

 

 

 

Lastly, you don't need to use the hexadecimal numbers for these functions, decimal should be fine. Thought I might mention it just in case you didn't know.

I used the hex because the decimal that makes sense did not work. 33 is the slot for hands but when using 33 it removed the head rather than the hands. Why they couldn't program it to work with already existing and known numbers is beyond me.

 

 

 

 

Also, I have noticed a lot of unreliability in Queuing NiNode updates for this stuff. You may want to try unequip and equipping the piece of armour to reset it on the player.

I did manual equip/unequip and the results were the same.

Link to comment
Share on other sites

 

I was referring to settings in the CK. SetSlotMask() is on the armor form so it would only work for armor objects. I don't think it would work for armor addon forms. Then again documentation is so scant that there is no way to know what it does and how to actually use it.

There are SetSlotMask() functions for both armour and armour addons. They work the exact same, but if you change the amour slot mask, the armour addon's slot mask needs to be changed to match it. This is probably the issue. To get the armour addon use:

ArmorAddon TheObjectAA = TheObject.GetNthArmorAddon(0)

 

I used the hex because the decimal that makes sense did not work. 33 is the slot for hands but when using 33 it removed the head rather than the hands. Why they couldn't program it to work with already existing and known numbers is beyond me.

That's because the decimal version of 0x00000008 is 8, not 33. The node index of the biped slot is not the decimal version, you have to take the hex version and convert it to decimal.

Edited by DragonDude1029
Link to comment
Share on other sites

Here's a revised version of your script:

 

Armor Property TheObject Auto
Actor Property PlayerRef Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	Utility.Wait(5.0)
	If akBaseObject == TheObject
		Int SlotMask = TheObject.GetSlotMask()
		Int NewSlot = 8 ;33
		If SlotMask != NewSlot
			TheObject.SetSlotMask(NewSlot)
			TheObject.GetNthArmorAddon().SetSlotMask(NewSlot)
			PlayerRef.QueueNiNodeUpdate()
		EndIf
	EndIf	
EndEvent 

 

 

Edited by DragonDude1029
Link to comment
Share on other sites

 

 

That's because the decimal version of 0x00000008 is 8, not 33. The node index of the biped slot is not the decimal version, you have to take the hex version and convert it to decimal.

I understand that. And realized what was going on, hence I used the hex (copy/paste to ensure it was right). Still it would have made logical sense (perhaps not programming sense) to use values that equated to the biped slots, that is after all what is being changed. Biped slot numbers are what I will need to use to communicate with users regarding their choices. Probably end up making a converter function so I can stick with the biped slot values throughout the rest of the script(s).

 

GetNthArmorAddon is not listed on the CK wiki yet. No wonder I never saw it and never thought to try it. I'm not in the habit of looking at the SKSE scripts to see what they changed/added so I never saw it..

Link to comment
Share on other sites

They have to follow a hex chain so you can use bit logic to figure out what slot masks compose the armour mask. Using GetSlotMask() == x isn't enough to figure out if a piece of armour occupies a slot, because GetSlotMask() returns the total of all the slots used (the armour mask). What I means is, if I want to find out if a piece of armour occupies the hand slot I would need to do:

Math.LogicalAnd(TheObject.GetSlotMask(), 0x00000008)

It's a very common thing to do in programming, bit masks that is: http://en.wikipedia.org/wiki/Mask_(computing)

It means the masks must follow the geometric pattern to be derivable. So the first is 1 (binary: 1), the second is 2 (binary: 10), the third is 4 (binary: 100), so on and so forth.

 

Naming the nodes (biped slots) along the geometric pattern is a very disorganized thing to do, especially when mapping them out for placement on a skeleton. It also has to follow the same index convention as the rest of the non-'slot mask' nodes and such.

 

The CKWiki has most of the functions now, not including the alpha stuff. It's been updated a fair bit. http://www.creationkit.com/GetNthArmorAddon_-_Armor

 

Glad I could be of service! If you ever need help with scripting feel free to contact me :D

Link to comment
Share on other sites

That is a lost wiki page. Not on the scripting reference list with the rest of the functions/events.

 

Anyway, I got it finally to not crash.

TheObject.GetNthArmorAddon().SetSlotMask(NewSlot)

This line wouldn't compile without a # in the GetNthArmorAddon. Unlike every other index I've encountered it turns out that this one starts with 1 instead of 0. Stopped crashing once I put 1 in there.

 

Still doesn't perform as I expect. The slot changes, the hands indeed went away but I was expecting my model to still be visible. It was not.

 

I guess I need to go the old fashioned way and make armor forms, armor addon forms and nifs for each biped slot that I want to offer to the user for use. They can use only one but I want them to decide which one works with their specific gear setup.

 

As far as the bitwise, I understand that to an extent. Worked with it some in my Baldur's Gate modding. However, there it was referred to as flags with 1 being on and 0 being off. We dealt with it in an 8 character string of 1's and 0's. The at install time compiler would handle the dirty work of figuring out whatever value it was supposed to be in the file.

Link to comment
Share on other sites

Oh, I never go directly from the script list. I go by heading to the form script pages, like http://www.creationkit.com/Armor_Script or http://www.creationkit.com/ObjectReference_Script. Woops, I forgot to throw a 1 in there, my bad. It's a Nth basis, not a list, so it would be 1 not 0. Same as GetNthForm() and all the other GetNth stuff (I'm pretty sure). I still think you can get it to work by setting the slot, I know I've done it before. I'll dig around and see if I can find my old scripts to do it!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...