Get Owner of Object as Referance

Post » Sun Jun 24, 2012 1:16 pm

What I would like to do is figure out the owner of the object being activated and assign it to a refferance, so I then can use this script to give and take away stuff from the owner.

For example: The player activates a blacksmith owned by an NPC, I want to be able to give the owner of that NPC 10 Gold.
User avatar
dell
 
Posts: 3452
Joined: Sat Mar 24, 2007 2:58 am

Post » Sun Jun 24, 2012 8:09 am

http://www.creationkit.com/GetActorOwner_-_ObjectReference?
User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Post » Sun Jun 24, 2012 2:55 am

http://www.creationkit.com/GetActorOwner_-_ObjectReference?

Tried that but the compiler was freaking out at me when I tired to add the 10 gold to the reference. Thank you for trying though, it is very much appreciated, do you have any other ideas, or maybe an chance, you could explain to me the proper way to get the owner as a reference and then add 10 gold to them? Because what ever I was doing the compiler did not like.
User avatar
Laura Wilson
 
Posts: 3445
Joined: Thu Oct 05, 2006 3:57 pm

Post » Sun Jun 24, 2012 9:52 am

The problem is that, despite the function name, GetActorOwner returns an ActorBase, not an Actor. That's annoying. Is the owner NPC nearby? If so, I think you could probably use http://www.creationkit.com/FindClosestReferenceOfTypeFromRef_-_Game to get the closest NPC with that ActorBase from the player.
User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am

Post » Sun Jun 24, 2012 6:01 pm

The problem is that, despite the function name, GetActorOwner returns an ActorBase, not an Actor. That's annoying. Is the owner NPC nearby? If so, I think you could probably use http://www.creationkit.com/FindClosestReferenceOfTypeFromRef_-_Game to get the closest NPC with that ActorBase from the player.

Not always, because sometimes the people walk out side of their shops or into their shops and the forge or something like that is no longer in the same cell as them... This appears to be alot harder then I first imagined it would be.

Maybe I could use this any way. I mean, why should you have to pay the owner if they cant see you? Though I feel like they would hear you if you were making an aromor right outside there house, but hey, not everything can be 100% immersion.
User avatar
Ice Fire
 
Posts: 3394
Joined: Fri Nov 16, 2007 3:27 am

Post » Sun Jun 24, 2012 5:37 pm

Not always, because sometimes the people walk out side of their shops or into their shops and the forge or something like that is no longer in the same cell as them... This appears to be alot harder then I first imagined it would be.

Maybe I could use this any way. I mean, why should you have to pay the owner if they cant see you? Though I feel like they would hear you if you were making an aromor right outside there house, but hey, not everything can be 100% immersion.

Can you set up a condition to be true if a reference is an instance of a base actor? If so you can probably find him by triggering a quest from the story manager
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Sun Jun 24, 2012 10:21 am

Can you set up a condition to be true if a reference is an instance of a base actor? If so you can probably find him by triggering a quest from the story manager

Ill have to try http://www.creationkit.com/FindClosestReferenceOfTypeFromRef_-_Game when I get home. I think I kinda like the idea that if the reference isn't within a certain radius it wont charge the user to use the forge. This adds a lot of immersion in my opinion. The only thing that it doesn't do is charge you if the person is in there house, which is more the likely right next to the forge in the first place.

Now if I could get the reference of the person, I could tell the person to come to the forge, but Ill need the person as a reference first... Dilemma. haha
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Sun Jun 24, 2012 2:08 pm

Perhaps:
FormList Property EmptyFLST AutoEvent OnActivate(ObjectReference akActivator)	If GetActorOwner()		EmptyFLST.AddForm(GetActorOwner())		Actor rACHR = Game.FindClosestReferenceOfAnyTypeInListFromRef(EmptyFLST, Game.GetPlayer(), 4096.0) As Actor		If !rACHR		ElseIf !rACHR.IsDead()			rACHR.AddItem(Game.GetForm(0x0000000F), 10)		EndIf		EmptyFLST.Revert()		rACHR = None	EndIfEndEvent

Is this to be a ReferenceAlias script?
User avatar
Ally Chimienti
 
Posts: 3409
Joined: Fri Jan 19, 2007 6:53 am

Post » Sun Jun 24, 2012 2:54 pm

The FindClosestReference... function might work through an interior door into a nearby house, if you set the radius high enough. You'd need to experiment.

Yeah, more immersion generally requires more work, from what I've experienced so far. It's always a matter of finding a balance you can live with.
User avatar
Penny Courture
 
Posts: 3438
Joined: Sat Dec 23, 2006 11:59 pm

Post » Sun Jun 24, 2012 9:33 am

Perhaps:
ScriptName SomeScript extends ObjectReferenceFormList Property EmptyFLST AutoEvent OnActivate(ObjectReference akActivator)	EmptyFLST.AddForm(GetActorOwner())	ObjectReference rACHR = Game.FindClosestReferenceOfAnyTypeInListFromRef(EmptyFLST, Game.GetPlayer(), 4096.0)	If rACHR		rACHR.AddItem(Game.GetForm(0x0000000F), 10)	EndIf	EmptyFLST.Revert()EndEvent

This actually looks like what I am trying to do. You are a amazing, Thank you. Now Ill have to test and tweak it probably, but should do what I am trying to accomplish.



The FindClosestReference... function might work through an interior door into a nearby house, if you set the radius high enough. You'd need to experiment.

Yeah, more immersion generally requires more work, from what I've experienced so far. It's always a matter of finding a balance you can live with.

I have never user this function before. But I am still getting use to scripting for Skyrim. I hope it will work, but don't want to get my hopes up to high. I mean, if it doesn't work because the person isn't in the range because they are inside or outside of the cell the forge is, that is only a small lose in my opinion.
User avatar
Rozlyn Robinson
 
Posts: 3528
Joined: Wed Jun 21, 2006 1:25 am


Return to V - Skyrim