Acquiring a Reference for a specified object of the Players

Post » Tue Jun 19, 2012 1:28 pm

Hope that title makes at least some sense. I'm creating a script that will reference an item in many different ways. Here's exactly what I need to do:

I need to gain a reference for a specific item of the players choice, check for whether it is on the player or not a specific time, and run scripts off of it when it is dropped and picked up.

When using my script, I was able to control everything properly when creating a whole new object. However I want to be able to do all of the above to any lootable item that the player chooses. A helmet, an hourglass, a sword, or even a fork. I'll have to put some restrictions so that consumables can't be used, but that's more for later. The problem is I do not know how I can specifically acquire the reference of the item they choose.

When initially thinking up of how this would work, this was the process I came up with.

I first create a quest alias, that acquires it's reference using "Find Matching Reference From Event: Event Data akRef1". I can fill this reference using "SendStoryEvent(ObjectReference akRef1)"

Player casts a spell at a target. Upon hitting the target, if the target is an object (Not an actor or static object like a wall), it acquires a reference.
This reference is sent to a quest script using something like "QuestName.SendStoryEvent(ObjectReference akRef1Name)".

I now have a referencealias, which I will call RefAlias1, to use within my script. I can detect if the player is holding the item by using Game.GetPlayer().GetItemCount(RefAlias1.GetRef()) == 1. This will check if they are holding any of the objectreference. This is what I need to do. Cool.

Ok so now I need to check when the player drops the reference. Easy, I already have a reference alias that I can attach a script to. I won't go into the code there. Point is, with the reference alias, it's possible.


So, it looks like I can do everything I want to do. However, the biggest problem, is the spell. Spells do not affect objects, only actors.
How can I obtain an objectreference for a specific object?
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Tue Jun 19, 2012 1:14 pm

Some days ago I tried to fill an Alias for an object, looking for the closest reference in the Alias window when the quest was updated, but it didn't work for me. The Alias.GetRef was always None... Not sure if that idea could work since I just checked Aliases that day...

The only other idea that I have right now, is using getclosestref functions with a Form List with all the objects you want. I made a couple of spells that used that way with a Form List of doors to create an open spell...However, "any lootable item" sounds like a lot to add to a Form List.

Also, I do remember that OBSE had a GetCrosshairRef, so maybe it is added to skse too...

Let us know if it works out somehow!
User avatar
Hot
 
Posts: 3433
Joined: Sat Dec 01, 2007 6:22 pm

Post » Tue Jun 19, 2012 2:47 pm

Some days ago I tried to fill an Alias for an object, looking for the closest reference in the Alias window when the quest was updated, but it didn't work for me. The Alias.GetRef was always None... Not sure if that idea could work since I just checked Aliases that day...

The only other idea that I have right now, is using getclosestref functions with a Form List with all the objects you want. I made a couple of spells that used that way with a Form List of doors to create an open spell...However, "any lootable item" sounds like a lot to add to a Form List.

Also, I do remember that OBSE had a GetCrosshairRef, so maybe it is added to skse too...

Let us know if it works out somehow!
Yeah, it's proving to be pretty annoying. It seemed feasible when I was thinking it up, but without spells being able to affect objects...SKSE is still very new and as far as I'm aware all of their functions right now are interface based. I could look into it, but I'm doubtful.

I was sort of thinking about placing the item on a pressure plate or something, and then have the plate's "ontrigger" get a ref for the object that triggered it. I'm not sure if items trigger pressure plates or not though...
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm

Post » Tue Jun 19, 2012 9:28 am

Bump.
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Tue Jun 19, 2012 3:03 pm

What about asking for favors to companions? In there you activate an item and they do something with it. I've looked around and I didn't see anywhere where they pass an object reference, but maybe it's worth understanding how it works.

I'm sorry I don't have a direct solution, but I'm stuck with the same thing myself...
User avatar
JUan Martinez
 
Posts: 3552
Joined: Tue Oct 16, 2007 7:12 am

Post » Tue Jun 19, 2012 5:24 am

What about asking for favors to companions? In there you activate an item and they do something with it. I've looked around and I didn't see anywhere where they pass an object reference, but maybe it's worth understanding how it works.

I'm sorry I don't have a direct solution, but I'm stuck with the same thing myself...
Hmmm, perhaps... But I'm not really sure where the code for that is. :/
User avatar
Sarah MacLeod
 
Posts: 3422
Joined: Tue Nov 07, 2006 1:39 am

Post » Tue Jun 19, 2012 12:07 pm

Hmmm, perhaps... But I'm not really sure where the code for that is. :/

I have not been able to debug companions favors thing to use it, but I have managed to use alias condition functions to get nearest door and pass its reference to a spell that opens it. Maybe you can use that idea setting an spell explosion placed object and checking the distance or the collision with other objects if that's possible. You can find how I did it http://www.gamesas.com/topic/1352976-a-working-open-door-spell/
User avatar
Sylvia Luciani
 
Posts: 3380
Joined: Sun Feb 11, 2007 2:31 am

Post » Tue Jun 19, 2012 3:18 pm



I have not been able to debug companions favors thing to use it, but I have managed to use alias condition functions to get nearest door and pass its reference to a spell that opens it. Maybe you can use that idea setting an spell explosion placed object and checking the distance or the collision with other objects if that's possible. You can find how I did it http://www.gamesas.com/topic/1352976-a-working-open-door-spell/
Interesting. I looked at your script, and I could definitely see this working as long as I specify the location. Thanks for the link.
User avatar
Unstoppable Judge
 
Posts: 3337
Joined: Sat Jul 29, 2006 11:22 pm


Return to V - Skyrim