Jump to content

GetNthDetectedActor - OBSE


Recommended Posts

I'm not quite following how this is supposed to work.

 

For example:

 

Reference.GetNthDetectedActor

 

as stated in the wiki just caused errors when saving scripts. There isn't much more of an explaination anywhere even when googling.

 

Maybe it's the wrong type of function that I need? If there was a way to detect when hostiles are around the way the game does when "You cannot sleep around enemies nearby" thing happens. Maybe there's a flag that is set somewhere and some function can return 1 or 0 if it's set?

 

For now all I can see that will get me a similar result is GetNthDetectedActor, which doesn't seem to work (at least I must be doing something wrong?).

Link to comment
Share on other sites

Umm... Well... I just checked the wiki page, and as I do not have CSE here at the moment, I cannot tell how it would work. I suspect the Nth needs to be defined somewhere, or else it would make little sense to use just 'get some nth actor, please, figure yourself out which one'.

 

It is, however, possible to use a ForEach loop to check all actors and maybe then somehow see if one of them is hostile? GetHighActors returns all high-level AI processing actors and it could probably be used to get the ones in the surroundings. But I am not sure how to get the 'hostile' status for creatures.

Array_var aActors
Array_var aTemp
ref       rTemp
int       iTemp

let aActors := GetHighActors
let aTemp   := ar_Construct Array
let iTemp   := 0

ForEach aTemp <- aActors
    let rTemp := *aTemp
    If ( rTemp.IsActorEvil ) && ( rTemp.IsCreature == 0 )
        let iTemp += 1
    EndIf
Loop

PrintD "SomePrefix: Currently " + $iTemp + " hostile NPCs in high-level AI processing"

let aTemp   := ar_Null
let aActors := ar_Null
That is all I could think of. And I have not tested it. The IsActorHostile does not work on creatures according to the wiki, and I have never used it, so I have no idea what it returns if called on a creature. Maybe 0, but I put the condition there just in case it returns 1.

 

Hopefully that helps a little. You could also use GetDistance to see how far the actors are from player, if you need it. Some have said GetDistance is a performance-heavy function, but others have said it is not. Using it with care should be safe, though, I think. Unless you plan to use it a thousand times every frame... or something like it.

 

What is it you are trying to achieve? Just out of curiosity. I am drowning in my own projects, so I do not have the time to steal yours. :P

Edited by PhilippePetain
Link to comment
Share on other sites

A GetNth... function, usually have a corresponding GetNum... function (in this case, GetNumDetectedActors)

 

They are designed so you, first, get the number of <whatever> and, then, loop thru them using an index o-n.

Link to comment
Share on other sites

All right. Thank you. :) And 'nth' is defined how? The CSE would show arguments for all, but I do not have it here at the moment. The CS wiki misses that part. Is it just put at the end?

<reference>.GetNthDetectedActor <number>
Link to comment
Share on other sites

Thanks for updating that wiki.

 

But is their simpler way of say determining whether it's safe for the player to sleep/wait via scripting?

 

 

 



What is it you are trying to achieve? Just out of curiosity. I am drowning in my own projects, so I do not have the time to steal yours. :tongue:

 

 

Basically, I am trying to detect the status of whether the player can sleep/wait as when the game prevents it due to "enemies nearby".

 

And don't worry about stealing my idea. If anything when/if it can be figured out how to do this it should be documented somewhere online for reference material.

Edited by crippknottick
Link to comment
Share on other sites

  • Recently Browsing   0 members

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