Jump to content

[SE] [Papyrus] Any way to find player-enchanted item?


Recommended Posts

I'm currently working on a mod that awards extra XP when enchanting items. As a part of this, I need some way to identify what item a player has enchanted, but so far I've had no luck: powerofthree's Papyrus Extender is able to detect when an item is enchanted with its onItemCrafted event, but it contains the *enchantment*, rather than the item.

I only need the base item, not an ObjectReference.

Any help would be appreciated.

Link to comment
Share on other sites

From Papyrus Extender

Event OnItemCrafted(ObjectReference akBench, Location akLocation, Form akCreatedItem)
EndEvent

What is the returned result found within akCreatedItem?  Is it the object with the enchantment attached?  If it is, try running GetBaseObject to see if you can obtain the non-enchanted base.

Link to comment
Share on other sites

7 hours ago, IsharaMeradin said:

From Papyrus Extender

Event OnItemCrafted(ObjectReference akBench, Location akLocation, Form akCreatedItem)
EndEvent

What is the returned result found within akCreatedItem?  Is it the object with the enchantment attached?  If it is, try running GetBaseObject to see if you can obtain the non-enchanted base.

The Enchantment applied. It's a Form anyways, not an ObjectReference, so GetBaseObject wouldn't work.

Link to comment
Share on other sites

Did you try casting to ObjectReference and then use GetBaseObject?  i.e.

(akCreatedItem as ObjectReference).GetBaseObject()

It may or may not work as the item is in the player's inventory but one would never know without trying.  And if that doesn't work, the following may be something to try out: https://forums.nexusmods.com/topic/2789614-creating-an-object-reference-for-an-item-in-a-container/

Link to comment
Share on other sites

You can use my mod Dylbills Papyrus Functions which includes DbSkseEvents. https://www.nexusmods.com/skyrimspecialedition/mods/65410

Example, assuming your script is attached to a form. 

Event OnInit()
    DbSkseEvents.RegisterFormForGlobalEvent("OnItemCraftedGlobal", self)
EndEvent
 
;must re register on load game
Event OnLoadGameGlobal()
    DbSkseEvents.RegisterFormForGlobalEvent("OnItemCraftedGlobal", self)
EndEvent  
 
Event OnItemCraftedGlobal(Form itemCrafted, ObjectReference benchRef, int count, int workBenchType, string benchSkill)
    if benchSkill == "enchanting"
        Debug.MessageBox(itemCrafted.GetName() + " enchanted")
    Endif
EndEvent
  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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