Using IsNearPlayer in exterior cells

Post » Tue Jun 19, 2012 2:37 pm

http://www.creationkit.com/IsNearPlayer_-_ObjectReference

I'm looking to use IsNearPlayer to enable/disable objects without the player being around. Does it return true if the player is in the same worldspace?
For instance, my worldspace has no interior cells. If I use this function will it forever be returning false because the player will always be "near" the object?

What if the player is say, 8 cells away and still cannot view the object?
The wiki has this to say
Whether this object is too close to the player to safely unload. Will err on the side of caution -- might return true in cases where you could monkey about with the object without the player seeing it, but will only return false if it is definitely safe to monkey with the object because the player will not see it.

But I take that as the function will still return false if the player is near the object but is blocked from its view by a large static. Is there a certain distance away where the player is not considered "near"?
User avatar
Amy Siebenhaar
 
Posts: 3426
Joined: Fri Aug 10, 2007 1:51 am

Post » Tue Jun 19, 2012 2:31 pm

Just look at the implementation, its a Papyrus function.
User avatar
Erika Ellsworth
 
Posts: 3333
Joined: Sat Jan 06, 2007 5:52 am

Post » Tue Jun 19, 2012 6:14 pm

Just look at the implementation, its a Papyrus function.

Did you read my post?

I know it's a papyrus function, I'm using it in papyrus code.. I'm trying to find out whether or not it will ever return true if both the object and player are in the same exterior worldspace regardless of distance between them
User avatar
joseluis perez
 
Posts: 3507
Joined: Thu Nov 22, 2007 7:51 am

Post » Tue Jun 19, 2012 9:48 am

Then look again at the code, it answers your question. Hell, its even commented.
User avatar
Andrea Pratt
 
Posts: 3396
Joined: Mon Jul 31, 2006 4:49 am

Post » Tue Jun 19, 2012 11:45 am

I'm not sure if you understood my question. I had tested it a few times but I found a logic error in my code and tried it out again. It works if the player is more than 2 cells away. It seems to work as an alias function for IsDistance > X where x is distance of 2 cells.

The reason I asked is because I have no interior cells - I thought that the function would return true if the player was completely and clearly far away - say 20 cells away or in a different worldspace (such as an interior).

Since my worldspace is quite small, I didn't think it would work, but yes it does. I guess I misunderstood the notes I quoted.
User avatar
Rebecca Clare Smith
 
Posts: 3508
Joined: Fri Aug 04, 2006 4:13 pm

Post » Tue Jun 19, 2012 5:02 pm

I think you misunderstood (which could have been obvious to me) what I meant with its a Papyrus function.
I meant its a function declared in Papyrus code instead of being an import of a native function.

Just open ObjectReference.psc and go line 36, that's where IsNearPlayer is declared.
It defines near as 3000 units which might not work in your case.
So, if it doesn't suit your needs, just roll your own function.
User avatar
Jonathan Montero
 
Posts: 3487
Joined: Tue Aug 14, 2007 3:22 am

Post » Tue Jun 19, 2012 5:38 pm

Oh, I have not thought about opening up the ObjectReference.psc, in fact I did not know you could see the code behind the functions. This will definitely be useful in the future, thanks.
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm


Return to V - Skyrim