Jump to content

How to get height above ground via a script


PJMail

Recommended Posts

Not a double post - I started this in the wrong forum so moving it here.

 

How do I get my (rough) height above ground via Papyrus script? The "getnearest..." functions don't work with most ground mesh objects (and the formlist would be huge anyway), so my only though so far is dropping something. The problem I see there is physics (bouncing/sliding) and impact effects (NPC agro?).

Anybody have a working solution (doesn't have to be nice)?

My Vertibird mod allows 'reduce atltitude' but the bird is happy to go underground. I want to stop that.

 

Thanks in advance.

Edited by PJMail
Link to comment
Share on other sites

Random spawning at arbitrary points anywhere on the map that has navmesh indpendent of anything and everything you say ?

 

Tough but dooable.

 

I do this by creating an object, say an xmarker at a known height that is above the highest Z value (fizztop/decayedreactor/trinity) but in game bounds then drop it with the unreliable MoveToNearestNavmeshLocation() function which has no success/fail return or error handling.

 

There are massive areas of map with no good navmesh including Sanctuary and Abernathy which either generate a debug log (no navmesh found) but no script return, or slew the object XY for sveral thousand units creating a slant range issue assuming the player is not moving fast anyway. All need to be handled in code.

Float fPlayerHeight = -1 ; error condition 

SpawnMarker.SetPosition(pPlayerREF.GetPositionX(), pPlayerREF.GetPositionY(), 15000) ;fix known Z datum

SpawnMarker.MoveToNearestNavmeshLocation() ;if this fails the marker will stay at 15000Z

If (SpawnMarker.GetPositionZ() != 15000)    ;there are massive areas on the map with no good navmesh so check it actually dropped 
  Float fSlewX = Math.ABS(SpawnMarker.GetPositionX() - pPlayerREF.GetPositionX())
  Float fSlewY = Math.ABS(SpawnMarker.GetPositionY() - pPlayerREF.GetPositionY())
  If (fSlewX < 1000) && fSlewY < 1000) ;or whatever accuracy you need
     fPlayerHeight = (pPlayerREF.GetPositionZ() - SpawnMarker.GetPositionZ())
  EndIf
EndIf


For compulsive accuracy you could drop a second marker at the player XYZ and then nett off any actual XY distance travelled (vertibird 800-1000 units /second) to detect slew or slant. Also frame rate which can govern script execution can be a factor downtown.

Link to comment
Share on other sites

Thank you SKK50 - I had hoped you would respond!

I have read a lot of your posts (and investigated your mods) as you are clearly the number one 'script wrangler' in these forums (that stops to help at least).

 

So, the reason I avoided Movetonearestnavmeshlocation as a solution is it never returned anything whenever I attempted to use it in my mod.

I wanted to send passengers to safe place on the correct side of the Vertibird for Boarding - it never returned anything. Ever. And I took off from many places.

So I thought something using brute force collision physics would work as you can shoot at the ground and that works everywhere (ballistic radar!)

 

To make it simple, I will be hovering, so no induced slew. And my start Z for probe is my current Z - 500 (as I know I will be above any landmark).

 

I will try your nearestnavmesh idea as a first approximation though. Thanks!

Edited by PJMail
Link to comment
Share on other sites

The reason to not create the marker at the player height is becuase the player can already be underground. Creating at height means the condition can be detected and recovered rather than just blowing up a savegame.

 

Had that problem whilst trying to subvert VertibirdFastTravel.

Link to comment
Share on other sites

Interesting idea - make the action 'Move to ground hover', rather than 'drop to ground', so it works up as well as down.

 

P.S. - your nearestnavmesh idea is working out so far - better than I had hoped. Haven't tested at Santuary Hills yet though.

Link to comment
Share on other sites

I may not be understanding what you're trying to do 100%, but if you look into how Cait's lockpicking quest/script is handled, there's papyrus logic for how high or low the lock is in comparison to her, and this decides which lock picking anim will play (the high one, or the low one where she has to crouch down).

 

Hopefully that's helpful!

Link to comment
Share on other sites

Locks are a simple Z value difference between two known references with standing actor (Z + 64) being hand height.

 

The challenge is when one of the points is "arbitrary" which means undefined, could be anywhere on the map or down a "no navmesh" hole.

 

TL;DR: get the Z height of any XY coordinate anywhere ever (not interior cells tho).

 

It took me a LOT of hours testing various combinations of papyrus functions on every 10x10 XY coordinate of the Commonweth map to solve that problem to arrive at the code. Thats 400 million map samples already tested.

 

Hope it passes validation :wink:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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