GetRandomObjectByTag

From NWN Lexicon

Contents

[edit] GetRandomObjectByTag(string, float)

Get a random nearby object within the specified distance with the specified tag.

object GetRandomObjectByTag(
    string sTag,
    float fMaxDistance
);

[edit] Parameters

sTag

The tag of the object you want to find.

fMaxDistance

This number is used to figure the nNth object to get.


[edit] Description

Get a random nearby object within the specified distance with the specified tag.



[edit] Remarks

Returns a valid object on success, OBJECT_INVALID on failure.

This uses DISTANCE_* constants if you want for fMaxDistance.

[edit] Known Bugs

There are some quirks in how fMaxDistance is used to find the requested object. If fMaxDistance is set to DISTANCE_SHORT (3.0), then d6 being sent.

Meaning, if you send in a distance of DISTANCE_TINY (1.0) you could actually end up with an object that is 6.0 distance away.

[edit] Requirements

#include " x0_i0_anims "


[edit] Version

???

[edit] Example

// Find the nearest object with the tag "CLN_BARAGG".
#include "x0_i0_anims"
 
void main()
{
   // Looking for an object with the tag "CLN_BARAGG" at 50.0 meters away.
   object oThing = GetRandomObjectByTag("CLN_BARAGG", 50.0);
 
   if(TRUE == GetIsObjectValid(oThing))
   {
      // Object found!  Do what you want with it in here.
   }
}

[edit] See Also

functions: 

GetRandomObjectByType

constants: 

DISTANCE_*



author: Baragg, editor: Mistress

Personal tools
Categories