GetRandomObjectByTag
From NWN Lexicon
Jump to navigationJump to search
GetRandomObjectByTag(string, float)
Get a random nearby object within the specified distance with the specified tag.
object GetRandomObjectByTag(
string sTag,
float fMaxDistance
);
Parameters
sTag
The tag of the object you want to find.
fMaxDistance
This number is used to figure the nNth object to get.
Description
Get a random nearby object within the specified distance with the specified tag.
Remarks
Returns a valid object on success, OBJECT_INVALID on failure.
This uses DISTANCE_* constants if you want for fMaxDistance.
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.
Requirements
#include " x0_i0_anims "
Version
???
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.
}
}
See Also
| functions: | |
| constants: |
author: Baragg, editor: Mistress