Jump to content

Weapon references


Genamine

Recommended Posts

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 instead

Namely 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 object

But 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

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

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 soon

I 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 charm

But hey, thanks for the quick reply either way :smile:

Link to comment
Share on other sites

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 etc

The CK compiles it but I`m not sure that it would work . But glad you`ve solved your problem :smile:

Edited by kitcat81
Link to comment
Share on other sites

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 etc

The 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 object

Its just that I wouldnt know how to find their reference

Link to comment
Share on other sites

 

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 etc

The 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 object

Its 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 by kitcat81
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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