Genamine Posted January 10, 2017 Share Posted January 10, 2017 In papyrus, you can call functions to retrieve the weapon currently equipped by the player (Actor.GetEquippedWeapon())This however returns only the base object, not the weapon reference If you alternatively call event OnItemEquipped(Form akBaseObject, ObjectReference akReference), then akBaseObject will return the base object of the weapon, but akReference returns null (I think weapons apparently do not have a world reference?)Now, the issue here is that Im particularly interested in the weapon reference insteadNamely I would like to check the weapon reference for a keyword added by an object mod, a keyword that is not present in the base objectBut since akReference returns null, I dont have any reference to search for said keyword Does anyone know of any way to get the weapon reference?Or should no such reference exist, is there an alternative way to check the equipped weapon for the keyword added by an object mod?Or should that also not be possible, is there any way to check the equipped weapon for currently attached weapon mods? Already solved Link to comment Share on other sites More sharing options...
kitcat81 Posted January 10, 2017 Share Posted January 10, 2017 I can tell you an easy way to get the reference of any item that you can grab. Throw your weapon on the ground, grab it (don`t take, grab so you can see it hangs in the air in front of you and type in console getplayergrabbedref). There is some similar script function that allows to command some grabbed reference. But maybe there are better ways to get weapon reference...I just can`t think anything else now. Link to comment Share on other sites More sharing options...
Genamine Posted January 10, 2017 Author Share Posted January 10, 2017 I can tell you an easy way to get the reference of any item that you can grab. Throw your weapon on the ground, grab it (don`t take, grab so you can see it hangs in the air in front of you and type in console getplayergrabbedref). There is some similar script function that allows to command some grabbed reference. But maybe there are better ways to get weapon reference...I just can`t think anything else now. Well, I actually may have started this topic a little too soonI already found a way to circumvent the issue Instead of trying to find a keyword on a non-existent reference that has existent object mods attached to it (a.k.a. trying to find the non-existent), why not just apply actor value X to each object mod (through enchantment), where the value of this AV relates to the keyword of the object mod (e.g. object mod with keyword A -> AV value of 1; object mod with keyword B -> AV value of 2, and so on) At that point you have a tangible value for your keywords that you can look for in your script, just call Actor.GetValue(ActorValueX), compare this to whatever value corresponds to the keyword you want to match with, and mission accomplished Already tested it ingame, works like a charmBut hey, thanks for the quick reply either way :smile: Link to comment Share on other sites More sharing options...
kitcat81 Posted January 10, 2017 Share Posted January 10, 2017 (edited) No problem..Not sure what did you mean by non existent reference. Almost everything that has form has a reference in the game.To command the epipped weapon I`d try this : Form myweapon = Actor.GetEquippedWeapon() as Form (myweapon as objectreference).Disable() ;or check for keywords etcThe CK compiles it but I`m not sure that it would work . But glad you`ve solved your problem :smile: Edited January 10, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
Genamine Posted January 10, 2017 Author Share Posted January 10, 2017 No problem..Not sure what did you mean by non existent reference. Almost everything that has form has a reference in the game.To command the epipped weapon I`d try this : Form myweapon = Actor.GetEquippedWeapon() as Form (myweapon as objectreference).Disable() ;or check for keywords etcThe CK compiles it but I`m not sure that it would work . But glad you`ve solved your problem :smile: Well, if you for instance call ShowInventory on an actor ingame, it will return your weapon(s) as base object(s), not as an object reference (even if you have several differently modded weapons, it will return them as a multiple of their base object, e.g. if you have 3 pistols with 3 different receivers, it will just state that you have 3x the base object of said pistol, with no further information as to them having different receivers) Now, I do find it hard to believe that there is no reference for a weapon at all, after all how could you have 3 different pistols with 3 different receivers without having some kind of reference that states they deviate from the base objectIts just that I wouldnt know how to find their reference Link to comment Share on other sites More sharing options...
kitcat81 Posted January 10, 2017 Share Posted January 10, 2017 (edited) No problem..Not sure what did you mean by non existent reference. Almost everything that has form has a reference in the game.To command the epipped weapon I`d try this : Form myweapon = Actor.GetEquippedWeapon() as Form (myweapon as objectreference).Disable() ;or check for keywords etcThe CK compiles it but I`m not sure that it would work . But glad you`ve solved your problem :smile: Well, if you for instance call ShowInventory on an actor ingame, it will return your weapon(s) as base object(s), not as an object reference (even if you have several differently modded weapons, it will return them as a multiple of their base object, e.g. if you have 3 pistols with 3 different receivers, it will just state that you have 3x the base object of said pistol, with no further information as to them having different receivers) Now, I do find it hard to believe that there is no reference for a weapon at all, after all how could you have 3 different pistols with 3 different receivers without having some kind of reference that states they deviate from the base objectIts just that I wouldnt know how to find their reference It`s because some commands return base objects and another commands return references . They have reference 100% :D Just checked a few grenades by grabbing them...they all have their own reference. You can check them in the CK wiki, it usually tells what they return. Might be that there is no command to return equipped weapon reference at all. Edited January 10, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
spacefiddle Posted January 10, 2017 Share Posted January 10, 2017 Well, I was looking for the solution to something else, and this ain't it. But just to clarify: an item in your inventory has no reference. The player is a container. You can see in Papyrus logging that the thing becomes "Item 3 in container 00000014" (which is the player). An equipped weapon is an extension of the player, and getequippedweapon() will not return an ObjectReference. Long story short, it's a giant pain in the ass. Fortunately, a number of things can be done by grabbing the base form, and you can indirectly refer to something by "what i just picked up" or "what i just equipped" or whatnot. Link to comment Share on other sites More sharing options...
Recommended Posts