johnskyrim Posted August 13, 2021 Share Posted August 13, 2021 Hi everyone. I've been trying to get the base down for a script and running into a bit of an issue getting it to work. I've spoken to a few people about it but I'm still no closer with a solution. What I currently have is a quest alias running on the PlayerRef and the idea is to have a script running that when OnHit is triggered, it checks for the keyword ArmorShield and then applies an EffectShader to the currently equipped shield. I want this to work globally so that it is compatible with every shield in the game, as well as any modded shield. Applying the script manually to every shield is not an option. So I guess really, the big question is; how can I get the object reference of the currently equipped shield? ThanksJohn Link to comment Share on other sites More sharing options...
SeraphimKensai Posted August 14, 2021 Share Posted August 14, 2021 You could use the GetWornForm(0x00000200) to get your currently equipped shield and save it to a float in a script. Doing so would make your mod dependent upon SKSE, but 95% of anyone using mods for Skyrim has SKSE installed. There's an entry for it on Creation kit.com to give you more details. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted August 14, 2021 Share Posted August 14, 2021 How is GetWornForm any different than GetEquippedShield? Neither returns a usable ObjectReference for the purposes of applying an EffectShader (see Play). GetWornForm returns a form record and GetEquippedShield returns an armor record. Even if one casts into ObjectReference because the object is in the player inventory it may not have an ObjectReference ID unless persistent. This is why DropObject is typically used, it will return the newly created ObjectReference ID and by storing it in a property variable or assigning it to an alias the object becomes at least temporarily persistent and able to be used in things such as this. However, in the OP's case dropping the shield in the middle of combat is not a good idea. A workaround might be to use OnObjectEquipped on a player alias script. Use that to determine if the equipped object is a shield and if it already is persistent with a valid object reference ID. If not, drop it, get the object reference ID, move it back to the player inventory and re-equip. Only thing then to be concerned about is if it is a shield that the player enchanted themselves. Equipping via script may not apply those added enchantments properly. But the player could re-equip themselves, once an item is stored in the property variable it will be persistent and thus bypass being dropped again. ObjectReference Property MyEquippedShield Auto Hidden Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference) Actor PlayerRef = Game.GetPlayer() if akBaseObject as Shield ; equipped a shield If akReference != None; has a valid objectreference id already If akReference != MyEquippedShield ; object ref id does not match stored id MyEquippedShield = akReference ;assign it to our variable Else ;do nothing EndIf Else MyEquippedShield = PlayerRef.DropObject(PlayerRef.GetEquippedShield(), 1) ;drop the shield and assign to our variable PlayerRef.AddItem(MyEquippedShield,1,true) ;add back to inventory without notification PlayerRef.EquipItem(MyEquippedShield) ;re-equip the shield endIf endEvent You'll still need whatever OnHit code you are using to apply the EffectShader. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted August 14, 2021 Share Posted August 14, 2021 Honestly forgot about GetEquipedShield, I've used the GetWornForm to store various an assortment of equipped items for a couple scripts over the years. That said, your knowledge of Papyrus greatly exceeds my own, as I just take my best guess at things and use trial and error until it works, and sometimes takes a long time between iterations where I scratch my head and drink a copious amount of scotch. Link to comment Share on other sites More sharing options...
Recommended Posts