Difference between revisions of "GetWornItem - Actor"

1,606 bytes added ,  12:46, 2 September 2019
added notes
imported>Qazaaq
(added required f4se version)
imported>Qazaaq
(added notes)
 
Line 25: Line 25:
Debug.Trace("Texture: " + wornItem.Texture)
Debug.Trace("Texture: " + wornItem.Texture)
</source>
</source>


<source lang="papyrus">
<source lang="papyrus">
Line 38: Line 37:
     index += 1
     index += 1
EndWhile
EndWhile
</source>
== Armor Slot Precedence ==
There is a precedence to [[Armor]] slot ordering which is from head-to-toe.
An [[Armor]] form only properly exists on the highest slot it covers, lower slots will return none.
Armors will superfically flag the cover slots it covers as occupied.
For example a helmet with goggles that covers the '''HEAD''' + '''EYE''' slots will have to be accessed via the '''HEAD''' slot.
On the other hand, a gas mask that covers the '''EYE''' + '''MOUTH''' slots will need to be accessed via the '''EYE''' slot.
If for some reason there is a mask that covers the '''HEAD''' + '''EYES''' + '''MOUTH''' then it will need to be accessed via the '''HEAD''' slot because its the highest one.
<source lang="papyrus">
Scriptname WornExample extends Quest
Actor Player
int BipedEyes = 17 const
bool ThirdPerson = false const
Event OnQuestInit()
Player = Game.GetPlayer()
Actor:WornItem worn = GetWorn()
Debug.TraceSelf(self, "OnQuestInit", "Worn:"+worn)
EndEvent
Actor:WornItem Function GetWorn()
{Scans down the highest slot of an eye slot armor.}
int slot = 0
While (slot <= BipedEyes)
Actor:WornItem worn = Player.GetWornItem(slot, ThirdPerson)
If (ItemFilter(worn.Item))
return worn
EndIf
slot += 1
EndWhile
Debug.TraceSelf(self, "GetWorn", "No biped slot has a valid eyes armor.")
return none
EndFunction
bool Function ItemFilter(Form item)
Armor armo = item as Armor
return armo && HasSlotMask(armo, kSlotMask47)
EndFunction
bool Function HasSlotMask(Armor armo, int value) Global
return Math.LogicalAnd(armo.GetSlotMask(), value) == value
EndFunction
</source>
</source>


Line 50: Line 96:




[[Category:F4SE]]
[[Category:Scripting]]
[[Category:Scripting]]
[[Category:Papyrus]]
[[Category:Papyrus]]
[[Category:F4SE]]
Anonymous user