invalid form list passed in to FindClosestReferenceOfType

Post » Wed Jun 20, 2012 6:30 am

Trying to teleport the player to closest inn on bleedout. I created an activator for each inn, and linked each in the script properties to pre-existing xmarkers at each inn . Then created a formlist of all the activators. Calling the formlist results in log error: "None or invalid form list passed in to FindClosestReferenceOfType".

It does work if I substitute a single activator location for the formlist in Moveto().
This refalias script is linked to Player on an always running Quest script. All the properties for the activators and formlist are filled.
... extends ReferenceAliasFormList Property _01_InnTeleportList AutoObjectReference Property _01_innTeleportDawnstar Autoetc.Event OnEnterBleedout()     ObjectReference closestInn = FindClosestReferenceOfAnyTypeInListFromRef(_01_InnTeleportList,	 Game.GetPlayer(),  1000.0)   Debug.Trace("closest inn" + closestInn)  Game.GetPlayer().Moveto(closestInn)endEvent
User avatar
Curveballs On Phoenix
 
Posts: 3365
Joined: Sun Jul 01, 2007 4:43 am

Post » Wed Jun 20, 2012 10:38 am

1000 units isn't actually that far. I think the default activation distance (eg how close you have to be to a door to open it) is something like 150 units.
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Wed Jun 20, 2012 7:04 am

The syntax looks fine--I use code that looks very similar to find the closest bed--but are what are in your formlist really forms? That is, if I understand the game's systems correctly, FindClosestReferenceOfAnyTypeInListFromRef is in essence saying "find me the closest in-game instance of any of these general types of base object." It sounds like you're trying to find the closest one of several possible unique, in-game objects, which is different.
User avatar
Josh Dagreat
 
Posts: 3438
Joined: Fri Oct 19, 2007 3:07 am

Post » Wed Jun 20, 2012 1:37 am

ok that makes sense, so I did this:
made a single new activator Xmarker, which i placed in each Inn and put in a formlist.
Still not working, It always returns "none" for finding the reference.

... extends ReferenceAliasFormList Property _01_InnTeleportList AutoActivator Property _01_innTeleportMarker AutoEvent OnEnterBleedout()     ObjectReference closestInn = FindClosestReferenceOfAnyTypeInListFromRef(_01_InnTeleportList,  Game.GetPlayer(),  10000000.0)   Debug.Trace("closest inn" + closestInn)  Game.GetPlayer().Moveto(closestInn)endEvent
User avatar
Smokey
 
Posts: 3378
Joined: Mon May 07, 2007 11:35 pm

Post » Wed Jun 20, 2012 9:25 am

Did you put your activators actually inside the inn?

I believe the find closest ref functions only search through the current cell/worldspace. All interiors are considered their own worldspace.
User avatar
Evaa
 
Posts: 3502
Joined: Mon Dec 18, 2006 9:11 am

Post » Wed Jun 20, 2012 9:30 am

Thanks, unfortunately you're correct. I tested it and is only for the current cell.
How else could this be accomplished?
User avatar
des lynam
 
Posts: 3444
Joined: Thu Jul 19, 2007 4:07 pm

Post » Wed Jun 20, 2012 3:32 am

I don't know have any good ideas...

There doesn't seem to be a papyrus event like "OnCellChanged" or anything, but there is a Story Manage event node for "Change Location Event". You can use that to keep track of when you change cells/locations/worldspaces. You can have an alias or quest property pointing to the inn you want to teleport to.

If you're in one of the town worldspaces, then change the alias/property to the inn that's in the town. If you're in Tamriel worldspace, use your coordinates to determine which inn you're closest to, and change the alias/property to that inn. If you're not in Tamriel worldspace or one of the town worldspaces, then you've most likely entered a dungeon. Do nothing and leave the alias/property as what it already is.
User avatar
Rachel Briere
 
Posts: 3438
Joined: Thu Dec 28, 2006 9:09 am

Post » Wed Jun 20, 2012 10:18 am

Yeah, if something is in another cell, it won't show up for the FindClosest functions.
User avatar
des lynam
 
Posts: 3444
Joined: Thu Jul 19, 2007 4:07 pm

Post » Tue Jun 19, 2012 11:55 pm

make an array of ObjectReferences in a questvariable, and assign the elements of the array to your Xmarkers...then make a second array of Floats, and have it store the distances on the OnLocationChanged event to the corresponding index, so you can find the "closest" one.Basically you're making your own map.
User avatar
Kat Stewart
 
Posts: 3355
Joined: Sun Feb 04, 2007 12:30 am

Post » Wed Jun 20, 2012 7:10 am

That is what i wanted to do in the first place so I could use existing markers and just calc the distance to, - but, how do I get the current player coordinates? - onLocationChange returns formid for akOldloc and akNewloc



Event OnLocationChange(Location akOldLoc, Location akNewLoc)

User avatar
Kayleigh Mcneil
 
Posts: 3352
Joined: Thu Jun 29, 2006 7:32 am

Post » Wed Jun 20, 2012 4:45 am

Event OnLocationChange(Location Old, Location New)    int N = 0    int Closest = -1    float ShortestDistance = 999999999.9    float Distance    while N <= Gvar.MyGlobalMarkerArray.Length        Distance = (Game.GetPlayer().GetDistance(Gvar.MyGlobalMarkerArray[N])        Gvar.MyGlobalDistanceArray[N] = Distance        if Distance < ShortestDistance            Closest = N            ShortestDistance = Distance        endif        N += 1    endWhile    if Closest != -1 ; If we were able to map the closest one        Gvar.MyClosestMarker = MyGlobalMarkerArray[Closest]    EndifEndEventEvent OnBleedout()    Game.GetPlayer().MoveTo(Gvar.MyClosestMarker)EndEventGlobalQuestScript Property Gvar Auto ; Assign this to the script in your global quest.
User avatar
le GraiN
 
Posts: 3436
Joined: Thu Mar 22, 2007 6:48 pm

Post » Tue Jun 19, 2012 11:39 pm

Thanks very much. :biggrin: i overlooked getdistance / getposition functions because searching for 'distance' or 'postion' does not show those functions as a search result.
User avatar
Add Meeh
 
Posts: 3326
Joined: Sat Jan 06, 2007 8:09 am

Post » Wed Jun 20, 2012 9:58 am

You actually don't have to store the distances...I just did so so you could use the values for something else if you want.

You will also probably need to put the markers OUTSIDE the inns for correct distance calculation. You can have two markers of course, one outside to compute distance, and one inside for the actual move, with matching indexes in two arrays.
User avatar
Trista Jim
 
Posts: 3308
Joined: Sat Aug 25, 2007 10:39 pm


Return to V - Skyrim