Get distance to closest sleep marker or bed furniture?

Post » Wed Jun 20, 2012 5:04 am

I want to find the distance from the player to the closest sleepable furniture--bed or bedroll. Is there a way to do this that doesn't involve making a formlist containing every single bed and bedroll (and thus not taking into account any mod-added new furniture) and then using FindClosestReferenceOfAnyTypeInListFromRef? Is there a way that I can find the closest sleep marker, wherever the player happens to be?
User avatar
Chantel Hopkin
 
Posts: 3533
Joined: Sun Dec 03, 2006 9:41 am

Post » Tue Jun 19, 2012 9:30 pm

In my case I wanted to find the closest door. To do that I created a quest with a reference alias that finds the closest matching reference. You can see it http://www.gamesas.com/topic/1352976-a-working-open-door-spell/

The thing is that beds and bedrolls are Furniture types, so I cannot think right now anyway you could check on that, but take a look at Condition Functions, maybe using GetObjectType = Furniture and something else could give you an idea.

Another thing I can think of is using a sleep package on a npc. They look like they can search for nearest bed...
User avatar
remi lasisi
 
Posts: 3307
Joined: Sun Jul 02, 2006 2:26 pm

Post » Tue Jun 19, 2012 2:16 pm

Thanks for the reply, Yeah, I was looking at that "closest match" system, but I couldn't see a way to narrow down the focus enough to get just beds or bedrolls.

In fact what I'm trying to do is make a dialogue choice that will initiate a sleep package for a follower, but have it display conditionally based on whether or not there is an available bed nearby. I don't want to have the dialogue option available all the time, if there is no bed available.

I wonder if I could store the objectlist generated by a Find procedure in a variable that my quest script can access...hmmm.
User avatar
Louise Lowe
 
Posts: 3262
Joined: Fri Jul 28, 2006 9:08 am

Post » Tue Jun 19, 2012 9:39 pm

Use Aliases and FormList:

Create a FormList of bedrolls to check against.
As per this thread: http://www.gamesas.com/topic/1349649-dynamically-attaching-scripts-to-actors-near-the-player
Create a Quest containing e.g. 5 Aliases that looks for nearest objects and has a condition "InList" and use the FormList you created to check against.
Create another Quest that stops/starts the Quest that contains the Aliases.

I know this works because I use this already in my unreleased Gold Adjustment mod to look for Coin Purse objects and attach Scripts to them.

I hope that helps.
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Tue Jun 19, 2012 10:58 pm

Do you think using aliases is better than using Game.FindClosestReferenceOfAnyTypeInListFromRef()? I ended up using that--I was worried that it would take too long to find the closest of the 100+ bed objects in my FormList, but it seems to process in less than a second. And in this case, unlike your mod, I only need the single closest bed.
User avatar
Chase McAbee
 
Posts: 3315
Joined: Sat Sep 08, 2007 5:59 am

Post » Tue Jun 19, 2012 10:54 pm

FindClosestReferenceOfAnyTypeInListFromRef () would be better I think - it's cleaner. Not sure of which is faster.
User avatar
Jade Payton
 
Posts: 3417
Joined: Mon Sep 11, 2006 1:01 pm


Return to V - Skyrim