Jump to content

Trying to get HasDirectLOS() to work


Greslin

Recommended Posts

Hey, all.

I've been beating my head against this for the better part of a week now, and I'm about to give up. What I'm trying to do in my own script is replicate what's happening here in the base Inst307Fight_BeaconQuestRespawn01 script:


ObjectReference function GetRespawnMarker()
	if (myBeaconMarkerRef == None || myOffsetMarkerRef == None)
		myBeaconMarkerRef = myBeaconMarker.GetRef()
		myOffsetMarkerRef = myOffsetMarker.GetRef()
	EndIf
	int tries = 0
	;Offset the spawn point from the beacon.
	While (tries < 5)
		myOffsetMarkerRef.MoveTo(myBeaconMarkerRef, Utility.RandomInt(-32, 32), Utility.RandomInt(-32, 32), 0, True)
		myOffsetMarkerRef.MoveToNearestNavmeshLocation()
		;Check for DirectLoS between the two markers to make sure we haven't offset through a wall or something.
		if (myOffsetMarkerRef.HasDirectLoS(myBeaconMarkerRef))
			return myOffsetMarkerRef
		endif
		tries = tries + 1
	EndWhile
	return myBeaconMarkerRef	
EndFunction

Both of those markers are FlagPurple heading markers. I'm specifically focused on the HasDirectLOS() step, determining whether the LOS between two statics is blocked.

 

Best I can tell, almost every other place in the base code that uses HasDirectLOS() checks between the player and the object, or else it's using HasDetectionLOS() instead. Unfortunately HasDetectionLOS() is useless for me here, because what I'm trying to do is programmatically determine whether there is something blocking the LOS of two static objects.

 

That code above would imply to me that this indeed should work. However, every time I've attempted it in my own script, the HasDirectLOS() function call returns a false - even if it's a clear path. I've verified that they're on roughly the same Z plane, that the coordinates aren't screwy, and all that.

 

My concern is that, looking at the Bethesda script up there, it wouldn't break exactly if HasDirectLOS() simply didn't work. It would just default to returning myBeaconMarkerRef. So I'm starting to wonder if HasDirectLOS() doesn't work at all.

 

Does anyone else have experience with this that could spare me more days of frustration, or prevent me from just giving up on this effort completely? Any help is appreciated. Thanks.

 

Link to comment
Share on other sites

Yes I have had similar issues with HasDirectLOS() in both my combat spawning mods for datum xmarker to spawn xmarker.

 

My initial inelegant workaround has been to spawn (or move from holding which is faster) temp npcs at/to the markers, use HasDetectionLOS() then clear them.

 

Also tried to re-design everything to speed up and use the PlayerREF as datum for HasDetectionLOS(), but that has problems when the player is moving fast with rapid angle changes.

 

So, I have no solution but maybe you can elaborate on the above.

Link to comment
Share on other sites

Yes I have had similar issues with HasDirectLOS() in both my combat spawning mods for datum xmarker to spawn xmarker.

 

My initial inelegant workaround has been to spawn (or move from holding which is faster) temp npcs at/to the markers, use HasDetectionLOS() then clear them.

 

Also tried to re-design everything to speed up and use the PlayerREF as datum for HasDetectionLOS(), but that has problems when the player is moving fast with rapid angle changes.

 

So, I have no solution but maybe you can elaborate on the above.

 

Mostly I just wanted to confirm that someone else has seen the same issue. Thanks. I found an alternate method to get the results I need.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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