GetNumActorsInRangeFromRef

From GECK
Jump to: navigation, search


A function added by the ShowOff NVSE Plugin.

Description

Returns the amount of actors that are under or at a certain distance (in game Units) from the calling reference. The type of actor to be counted can be optionally filtered via the flagsBitMask argument (bit values are written under Notes).

This function can be used either in a script, or as a Condition.

Syntax

[help]
(numActors:int) reference.GetNumActorsInRangeFromRef maxDistance:float flagsBitMask:int

Example

int iNumActors
let iNumActors := player.GetNumActorsInRangeFromRef 500

Will return the number of actors that are in 500 units distance from the player. Equivalent to `player.GetNumActorsInRangeFromRef 500 0`.

let iNumActors := player.GetNumActorsInRangeFromRef 500 1

Same as above, except that the amount of actors is further filtered by only counting alive actors.

let iNumActors := player.GetNumActorsInRangeFromRef 500 3

Returns the amount of actors that are alive, not invisible, and in 500 units distance from the player.
Thanks to Inline Expressions, this could be more clearly written as:

let iNumActors := player.GetNumActorsInRangeFromRef 500 (1 << 0 | 1 << 1) 

The above notation makes it clear that bit 0 and 1 (flag 1 and 2) are enabled.

Notes

flagsBitMask works with the following values:

Flags Bit Decimal Value
No dead actors 0 1
No invisible actors 1 2
Only detected actors 2 4
  • Only detected actors was added in version 1.25. With it toggled, only combat actors that actorRefr can detect are counted (further filters still apply).
  • No invisible actors works by checking if either the actor's Invisibility or Chameleon actor values are greater than 0.

See Also