Detect Nearby Objects?

Post » Wed Jun 20, 2012 8:54 pm

How can I determine if certain objects are nearby? Specifically, I am attempting to find out if certain Activators (critterSpawners, to be specific) are within n distance of the player.

Currently the only way I can think of is to make a formlist of ALL spawners in the game, and then use GetDistance(), but that seems horrifically tedious and ineffecient. I could probably optimize it by splitting it into multiple regions-based lists, but still its a scary thought. Is there any kind of "GetNthItemFromMe()" or "GetNthNearest(BaseClass)" function I'm just not seeing, or perhaps a better approach?

I'm making a fishing mod and simply want to know if the player is fishing near an existing fish spawner or not, basically.
User avatar
Baby K(:
 
Posts: 3395
Joined: Thu Nov 09, 2006 9:07 pm

Post » Wed Jun 20, 2012 10:40 pm

http://www.creationkit.com/FindClosestReferenceOfAnyTypeInListFromRef_-_Game

Just create a formlist of the CritterSpawnPond activators, then use the function to find if the closest spawner to the player.
User avatar
sam
 
Posts: 3386
Joined: Sat Jan 27, 2007 2:44 pm

Post » Thu Jun 21, 2012 3:22 am

Awesome, thanks! Somehow I missed the entire page on Game Scripts... coulda saved me hours of work. Now I feel like a little kid with my fathers gun again! Whoopee!
User avatar
Sxc-Mary
 
Posts: 3536
Joined: Wed Aug 23, 2006 12:53 pm

Post » Thu Jun 21, 2012 7:33 am

OK for teh life of me I can't get any of these functions to work.
eg
ObjectReference closestFish = Game.FindClosestReferenceOfAnyTypeInListFromRef(FishingNetSpawnerTypes, Game.GetPlayer(),500000.0)


Ive tried a list of ACTI and MISC, even going so far as to drop instances of the MISC items near the player when the func is called, with a radius of 50k. Are these the wrong item types?

Always returns "None".... any suggestions?
User avatar
He got the
 
Posts: 3399
Joined: Sat Nov 17, 2007 12:19 pm

Post » Thu Jun 21, 2012 1:17 am

I have no problems getting it to work. Did you set the value to your formlist property in the CK?
User avatar
Isabella X
 
Posts: 3373
Joined: Sat Dec 02, 2006 3:44 am

Post » Thu Jun 21, 2012 4:42 am

OK I found the issue - even though there were 12 items in the CK formlist, it was showing up in Papyrus as "0" using GetCount(). I recall seeing a bug report on FormLists where mixing types in lists could cause the entire list to be rejected, and I had created the original list by duplicating another and simply repopulating it with different-type items. This time I simply made a new blank list, populated it, and now the items therein are being recognized.

I appreciate your help on this, by the way. This mod is a memorial to my fiance, who passed away recently, so she can live on in Skyrim, her favorite game.
User avatar
Shaylee Shaw
 
Posts: 3457
Joined: Wed Feb 21, 2007 8:55 pm


Return to V - Skyrim