I need to write a script that checks for nearby NPCs in a formlist who are looking at, or at least facing, the player.
Can I use formlists with the GetDistance() and GetHeadingAngle() functions? Or would I have to use an SKSE GetNthForm() loop?
I need to write a script that checks for nearby NPCs in a formlist who are looking at, or at least facing, the player.
Can I use formlists with the GetDistance() and GetHeadingAngle() functions? Or would I have to use an SKSE GetNthForm() loop?
Actor Player = Game.GetPlayer()FormList Property NPCs AutoInt Count = NPCs.GetLength()Actor CurrentNPCFloat DistanceFloat HeadingAngleWhile Count > 0 Count -= 1 CurrentNPC = NPCs.GetAt(Count) as Actor Distance = CurrentNPC.GetDistance(Player) HeadingAngle = CurrentNPC.GetHeadingAngle(Player) If Distance < 200 && HeadingAngle < 15 ; lotsa code EndIfEndWhileThe amount of local variables I defined is not specifically due to the while loop, but as an optimization, so I don't have to write atrocities like this:
If (NPCs.GetAt(Count) as Actor).GetDistance(Game.GetPlayer()) < 200 && (NPCs.GetAt(Count) as Actor).GetHeadingAngle(Game.GetPlayer()) < 15