Difference between revisions of "Slot Masks - Armor"
Jump to navigation
Jump to search
added an example
imported>Egocarib m |
imported>Egocarib (added an example) |
||
Line 40: | Line 40: | ||
For example, if an item takes up the slots for body (kSlotMask32), hands (kSlotMask33), and forearms (kSlotMask34), then you add its values together (0x00000004 + 0x00000008 + 0x00000010 = 4 + 8 + 16) to get the value of its slot mask (28). | For example, if an item takes up the slots for body (kSlotMask32), hands (kSlotMask33), and forearms (kSlotMask34), then you add its values together (0x00000004 + 0x00000008 + 0x00000010 = 4 + 8 + 16) to get the value of its slot mask (28). | ||
==Example== | |||
Iterate through all of an actor's currently equipped armor and identify the name of any enchanted items (the WornObject functions used in this example require SKSE 1.7.0 or higher): | |||
<source lang=papyrus> | |||
String[] Function GetWornEnchantedFormNames(Actor target) | |||
String[] wornEnchantedForms = new String[30] | |||
int index | |||
int slotsChecked | |||
slotsChecked += 0x00100000 | |||
slotsChecked += 0x00200000 ;ignore reserved slots | |||
slotsChecked += 0x80000000 | |||
int thisSlot = 0x01 | |||
while (thisSlot < 0x80000000) | |||
if (Math.LogicalAnd(slotsChecked, thisSlot) != thisSlot) ;only check slots we haven't found anything equipped on already | |||
Armor thisArmor = target.GetWornForm(thisSlot) as Armor | |||
if (thisArmor) | |||
if (thisArmor.GetEnchantment()) ;check for basic enchantments | |||
wornEnchantedForms[index] = thisArmor.getName() | |||
index += 1 | |||
elseif (WornObject.GetEnchantment(target, 0, thisSlot)) ;check for player-added enchantments | |||
wornEnchantedForms[index] = WornObject.GetDisplayName(target, 0, thisSlot) | |||
if (!wornEnchantedForms[index]) ;if it wasn't given a custom name, take the item's original name: | |||
wornEnchantedForms[index] = thisArmor.getName() | |||
endif | |||
index += 1 | |||
endif | |||
slotsChecked += thisArmor.GetSlotMask() ;add all slots this item covers to our slotsChecked variable | |||
else ;no armor was found on this slot | |||
slotsChecked += thisSlot | |||
endif | |||
endif | |||
thisSlot *= 2 ;double the number to move on to the next slot | |||
endWhile | |||
return wornEnchantedForms | |||
EndFunction | |||
</source> | |||
==See Also== | ==See Also== | ||
[[Biped_Object|Suggested Slot Mask Usage]] | [[Biped_Object|Suggested Slot Mask Usage]] |