package to find nearest alias

Post » Wed Dec 04, 2013 7:58 pm

Hey Guys,

How can I find an actor from among 10 Aliases that is closest to the player? Note that this actor will likely not be in "loaded areas" and may well be in an interior cell in a city, town or dungeon.

I tried using Packages (with its Object List and Selected Target options) and Quest Aliases (with its Find Matching options). But I can't seem to get it to work. And because Papyrus' GetDistance () function can return an unusable value when used between actors in different Worldspaces and "non-connected" cells, I can't use it.

Can we find the nearest Object Reference from among 10 when the Object References can be anywhere (in different WorldSpaces, Locations, Interior Cells, etc.)?
User avatar
naomi
 
Posts: 3400
Joined: Tue Jul 11, 2006 2:58 pm

Post » Wed Dec 04, 2013 9:21 am

That's a tricky one, and I know my aliases. What you could do is make a script attached to the quest that puts all the aliases in a formlist, then use http://www.creationkit.com/FindClosestReferenceOfAnyTypeInListFromRef_-_Game to search through your formlist filled with aliases. I think this might be your best shot.

User avatar
Elizabeth Davis
 
Posts: 3406
Joined: Sat Aug 18, 2007 10:30 am

Post » Wed Dec 04, 2013 5:21 pm

Cool! thanks B1gBad! I'll try that out. I've not used that function before.
User avatar
Breautiful
 
Posts: 3539
Joined: Tue Jan 16, 2007 6:51 am

Post » Wed Dec 04, 2013 5:33 pm

put a keyword on that aliases you want to search for then.

make a helper quest (high priority, run once unchecked) that has nothing but one alias, find matching reference, closest,

add a condition hasKeyword your keyword on that alias (and any other conditions that might apply)

when you need to find that ref, start that quest, it fills the alias with the ref you want, get it, stop the quest until next use (or you can also have a script on that helper alias do all that).

that's how i find stolen horses (GetPlayersLastRiddenHorse won't get these), works 100% reliable and in no time.

User avatar
Tracey Duncan
 
Posts: 3299
Joined: Wed Apr 18, 2007 9:32 am

Post » Wed Dec 04, 2013 6:10 pm

Won't work. "Closest" only works in the loaded areas - e.g. if you and the actor you are looking for are in the Skyrim Worldspace.

But if one of the those 10 actors is in a cave and another in the palace in Solitude and another in Markarth's Hall of the dead they won't be found.

Haven't tried BigBadDaddy's suggestion.
User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm

Post » Wed Dec 04, 2013 3:15 pm

Yeh that makes sense, in a weird way. Even if an interior is set as part of a Location, in reality its infinity away :P

Are the ref's you are looking for placed by yourself, or are they placed by the game somehow?

If they're placed by you, then perhaps have an array of them, then have a script select the right one depending where the player is OnLocationChange(). It will be a lot more work for you because you'll have to program the whole thing rather then just a function doing it automatically for you.

I cannot think of any other way off the top of my head at the moment :shrug:

- Hypno
User avatar
Vicki Gunn
 
Posts: 3397
Joined: Thu Nov 23, 2006 9:59 am

Post » Wed Dec 04, 2013 11:18 am

The refs could be anyone. I'm allowing the user to select which actors are among the 10. When the user sets an actor as one of them, that actor is placed into one of the aliases.

And refs between load doors are practically infinitely distant from each other in Papyrus' GetDiatance (). It's a number like 3 ^ 50 or something. Even if one is in Breezehome and the other just outside in the street, GetDistance () returns this weird number.

But I'm sure the game engine can find nearest actor better. Or I hope so. :/
User avatar
Roanne Bardsley
 
Posts: 3414
Joined: Wed Nov 08, 2006 9:57 am

Post » Wed Dec 04, 2013 9:48 pm

ah, i thought you wanted always the ref closest to _player_.

tried forcing the actors this runs on in essential aliases or a scene or stg?

maybe that makes them, uhm, persistent enough to perform their thing...

or another idea, with limited potential target count though, so not 100% reliable insofar it could also detect 2nd...closest if actor count > alias count -

anyway: since the problem here is apparently the "closer", you could:

make x aliases conditioned to your actor type (like keyword as above or whatever).

1st one fills with the first best condition matching actor it finds

and then you condition every one of rest of the aliases to the prev one with distance conditions.

like: (run on center actor) IsCloserToAthanB current alias / prev alias

and when it's done you get the last filled alias, that should be your closest actor.

edit: guess with some effort, you could also make that limitless count, like an endless cycle through always the same 2 aliases as long as they fill

User avatar
Gwen
 
Posts: 3367
Joined: Sun Apr 01, 2007 3:34 am


Return to V - Skyrim