Item reference of picked up item

Post » Fri Nov 16, 2012 1:45 pm

In the quest triggered by player add item, how do I refer to the item picked up?
User avatar
Taylah Illies
 
Posts: 3369
Joined: Fri Feb 09, 2007 7:13 am

Post » Fri Nov 16, 2012 12:55 pm

Generally (I can't vow, that no special other cases exist), only items that exist as objects in the world have reference ID's. Once you pick it up, it becomes a quantity number (of the base item in question) in your inventory. Once you drop it into the world, it is given a fresh new reference ID.

So, with generic items, you probably have to play with inventory quantity numbers. If the item in question is unique, perhaps you could have a specific script attached to it, doing whatever you think is appropriate. You might also be able to use a quest item flag to your benefit, but I am not really sure how that would work in practice.
User avatar
Emily Shackleton
 
Posts: 3535
Joined: Sun Feb 11, 2007 12:36 am

Post » Fri Nov 16, 2012 8:01 am

In the quest triggered by player add item, how do I refer to the item picked up?
As an ObjectReference. It'll have to be persistent and/or filling a ReferenceAlias if there is to be only one and it's to retain its FormID.

Bool bPlayerHasYourItem = Game.GetPlayer().GetItemCount(YourPersistentREF)
...or...
Bool bPlayerHasYourItem = Game.GetPlayer().GetItemCount(YourReferenceAlias.GetReference())
User avatar
Oyuki Manson Lavey
 
Posts: 3438
Joined: Mon Aug 28, 2006 2:47 am

Post » Fri Nov 16, 2012 7:22 am

OK cool, can the reference ID of the base item that was picked up be used? I want the item picked up that starts the quest to be copied into a container. My plan was to use additem with the reference.
User avatar
Tamara Dost
 
Posts: 3445
Joined: Mon Mar 12, 2007 12:20 pm

Post » Fri Nov 16, 2012 4:51 pm

it would actually be better to use the SM Event Data than ObjectReference.

a declared object reference will remain persistent forever in memory.

here's a list of event data associated to the Player Add Item story manager event:
http://www.creationkit.com/Player_Add_Item

you could use ObjectForm to return the value of the picked up item from your quest.

if you need to use this object in a papyrus script, you can use a reference alias that fills with the event data specified, and in your script refer to it as the alias.getref() (this solution will make your object persistent only for the length of time your quest takes place, much better than permanent persistence).

yourcontainer.AddItem(YourRefAlias.GetRef())

if the quest object never had a world reference to begin with (or it never occupied world space at any time) you may need to add GetBaseObject() after GetRef(), otherwise it may return "None"
User avatar
Joanne
 
Posts: 3357
Joined: Fri Oct 27, 2006 1:25 pm

Post » Fri Nov 16, 2012 11:49 am

Or just fill an "Optional" alias with the item.
YourReferenceAlias.ForceRefTo(PlayerREF.PlaceAtMe(YourItem))PlayerREF.AddItem(YourReferenceAlias.GetReference());YourReferenceAlias.Clear() ; Fairly certain the REFR will not remain persistent at this point.
...or use a created reference in or at the player. In either case, nothing should stay persistent in your plugin/quest's absence unless the ReferenceAlias is of the "Specific Reference" type, is filled with a REFR from Skyrim.ESM and is a Skyrim.ESM form. Otherwise, all should get wiped in the plugin's absence then the form ceases to exist. Doesn't really matter unless you're making something persistent in Skyrim.ESM that is not already.
User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am

Post » Fri Nov 16, 2012 6:31 pm

I like the idea of using object form to get the base object. I have tried to do this without success as alias.getref() causes the function not recognised error.

I created a reference alias and selected 'From Event', but which event data should I choose from the drop down menu out of the three choices none, original container, and ownerref?

I added a property for the alias and in the start up quest stage's papyrus fragment window put alias.getref(), which causes the error.

What did I do wrong here?
User avatar
Mistress trades Melissa
 
Posts: 3464
Joined: Mon Jun 19, 2006 9:28 pm


Return to V - Skyrim