ID8879488948574 Posted June 23, 2020 Share Posted June 23, 2020 Referring to the standard event OnItemEquipped Event OnItemEquipped(Form akBaseObject, ObjectReference akReference) if akReference == None Debug.Trace("Supplied reference was empty") return endIf ; Do stuf otherwise endEvent I want to inspect equipped object, not simply its form. How to do this? The signature contains akReference, but it is ALWAYS empty when I try to access it (i.e. my log will always contain the message that the reference was empty and I never get anything to do in my handler). The manual points "it should be persistent", but what does that mean? Any ideas on how to get the specific object that was just equipped? Link to comment Share on other sites More sharing options...
Pokepunch Posted June 23, 2020 Share Posted June 23, 2020 From my understanding, an object is persistant if it's being used by a quest or script and because of this it stays in memory.What are you trying to achieve? What about the equipped item are wanting to find out about? Link to comment Share on other sites More sharing options...
ID8879488948574 Posted June 23, 2020 Author Share Posted June 23, 2020 (edited) From my understanding, an object is persistant if it's being used by a quest or script and because of this it stays in memory. What are you trying to achieve? What about the equipped item are wanting to find out about?This, specifically. I'm working on the idea where the user-defined name will allow to alter certain behavior of an item / giving special properties and so on (yes, there are ENCH and APPR but those aren't dynamic and there's a whole long story why I want to work with user-defined data - suffice it is to say, it is NECESSARARY for me to get an item ref to make things work). I don't actually care how do I get the reference. Events just seem to be the most obvious and easy (and I guess, proper) way. But seeing as it's so inconsistent, I'm up for whatever way of solving this. Edited June 23, 2020 by Dellecross Link to comment Share on other sites More sharing options...
SKKmods Posted June 23, 2020 Share Posted June 23, 2020 I had exactly the same problem with a weapon degradation mod that I had to abandon as ActorValue condition counters can't be maintained without an ObjectReference to attach them to. The issue is that non unique objects do not have unique references in player or any container inventory so it is not possible to get a discrete ObjectReference for them. Workaround 1 Use a quest to generate the item and fillthe RefAlias with an ObjectRefernce, BUT, the RefAlias will be cleared once the item is added to a container. Workaround 2 Attach the FeaturedItem keyword to the base form before the item is created/spawns which seems to make some items (MISC, BOOKS) unique and persist an ObjectReference in inventory. But it pops the featured item flash every time it is accessed. Workaround 3 If the item has OMOD attach point (weapons, armor) attach an invisible/ghost OMOD to make them unique. Link to comment Share on other sites More sharing options...
ID8879488948574 Posted June 23, 2020 Author Share Posted June 23, 2020 (edited) I had exactly the same problem with a weapon degradation mod that I had to abandon as ActorValue condition counters can't be maintained without an ObjectReference to attach them to. The issue is that non unique objects do not have unique references in player or any container inventory so it is not possible to get a discrete ObjectReference for them. Workaround 1 Use a quest to generate the item and fillthe RefAlias with an ObjectRefernce, BUT, the RefAlias will be cleared once the item is added to a container. Workaround 2 Attach the FeaturedItem keyword to the base form before the item is created/spawns which seems to make some items (MISC, BOOKS) unique and persist an ObjectReference in inventory. But it pops the featured item flash every time it is accessed. Workaround 3 If the item has OMOD attach point (weapons, armor) attach an invisible/ghost OMOD to make them unique. Question then - how does the game store the information about items? If the item is renamed on a workbench, the game somehow knows about that, right? I.e. if I have two 10mm pistols and rename one of them to "My gun" then the game will be able to properly distinguish the two of them and if I equip "My gun" then it will stay equipped no matter how many other items of same FormID do I have in my inventory. To give you a bit of a background of what I'm trying to do is to allow the user to manipulate any arbitrary armor item (derived potentially from any mod that is) to alter its properties within the context of my mod. I tried to work with APPR first, but there is no way to alter than on the fly. Even F4SE doesn't have the functionality (in case you don't know - APPR is the parent slot attach point, the one which allows for OMOD attachment). Which is why the Workaround 3 won't work because if I knew the way of dynamically adding attach points to an item, I would go that route in the first place Workaround 1 can't work because I don't have an item ref to begin with. For all I care the user could spawn it in the console (like a lot of custom armors mods do these days) or created it in the chemistry station. Workaround 2 seems interesting. Could you maybe explain more? Because I know that attaching keywords to a Form (base item) is indeed possible. LL_Fourplay for instance, allows doing it with ease. I won't care if the item is "flashing" because it's a small price for what I try to achieve. What I want to know is: - What does "featured" mean? What's the corresponding keyword?- Does it work on armor items?- What happens when I destroy such an item? Will the ref be successfully deleted as well? And will the next spawned / crafted item of same FormID be featured, and therefore - persistent? EDIT: just tried this out with the keyword "FeaturedItem" (vanilla, Fallout4.esm record 1B3FAC). Observed behavior: - Yes indeed, the item starts to "flash" (I added keyword to a form and thus all created items of this form behave like that)- But no, it doesn't allow the reference to be passed My code part, for the reference: Event Actor.OnItemEquipped(Actor equippingActor, Form equippedItem, ObjectReference equippedReference) if equippingActor != Player ; we don't care return endif if equippedReference == None ; can't do anything if equippedItem.hasKeyword(featuredKeyword) DebugNotification(equippedItem.getName() + " is already featured") else ; this simply does AddKeywordToForm from LL_Fourplay and it works bool result = makeItemPersistent(equippedItem, featuredKeyword, callerId) string text = " " if !result text = " NOT " endif DebugNotification("Featured keyword" + text + "added to " + equippedItem.getName()) endif return endif ; useful stuff here It never gets past the empty check for the reference regardless of the keyword presence. Of course after adding the keyword I tried both existing item and spawning a new one (the fact that I added the keyword attachment to the code is just to quickly check if the workaround 2 will actually work) Edited June 23, 2020 by Dellecross Link to comment Share on other sites More sharing options...
SKKmods Posted June 23, 2020 Share Posted June 23, 2020 I cant provide any more info as I abandoned the concept. Don't be surprised if all objects in containers are unique records (like renamed guns) only there is no SCRIPT INTERFACE to get at that stuff (check F4SE, dunno don't use it). Your going to have to test out the ideas yourself to try and solve the challenge. Link to comment Share on other sites More sharing options...
ID8879488948574 Posted June 23, 2020 Author Share Posted June 23, 2020 (edited) Solved.After assigning the keyword it is sufficient to respawn an item with the persistency flag enabled. Edited June 23, 2020 by Dellecross Link to comment Share on other sites More sharing options...
Recommended Posts