Jump to content

detect how far the player is from map marker


TheBlob2

Recommended Posts

There is the GetDistance function.

 

Syntax: (Distance:float) [Actor, Activator].GetDistance Target:ref

 

Example:

player.GetDistance MapMarkerREF

Please note: If the reference is null (empty), or is not in the current cell, the script will crash.

Source: The GECK Bethsoft Wiki

 

Hint: Player is 128 units tall. 7 units is about equal to 10 cm. (see here)

 

Hope I helped!

Link to comment
Share on other sites

ok, now all i need is a way to detect the nearest map marker to the player

Well, I'm brand new to TESScript (I believe that's the name for the scripting used in GECK, as it's the same used in Oblivion and Skyrim). So I'm not sure exactly what to do for that. I know in FOSE there's the function GetFirstRef, GetNextRef. Which may or may not work in your case, as I said, I'm new to it, plus I haven't even started with scripting in FOSE (but I may need it for my mod eventually) If you want you can find the documentation for the GetFirstRef function here.

Warning: If you use GetFirstRef, creating an infinite loop will result in game crashing. (Sort of like infinite loops in for statements in Python)

 

There's also the GetRefs function in NVSE which returns an array of the refs in the cell it's ran in. See documentation here.

Link to comment
Share on other sites

GetRefs is totally the way to go about doing it. Map markers are part of the Static group of objects, so you can look for type 32

GetRefs 32 3
would get all statics within a 3 cell range, which will encompass all loaded cells. The best part about this function is that you don't have to do a gamemode loop. Once the array is created you can then use the, imo, way better foreach loop to process the array, which among other things avoids the infinite loop issue as well as the logical issues of having to create your own exit conditions.

 

This code uses the Lutana version of the function, but you can place the NVSE version in there and it works the same.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...