Difference between revisions of "GetFirstInPersistentObject"

From NWN Lexicon
Jump to: navigation, search
 
Line 29: Line 29:
 
====Description====
 
====Description====
  
Returns the first object within oPersistentObject of the specified type in order and OBJECT_INVALID if no object is found. <br /><br /> PERSISTANT_ZONE_FOLLOW probably will no longer work, due to Bioware's own comments, and is never used. It was probably once used for mobile AOE's that are on aura's. <br /><br /> The order for things got during this is not based on range or anything, but normall works clockwise from west (0.0), but this rarely matters.
+
Returns the first object within oPersistentObject of the specified type in order and OBJECT_INVALID if no object is found.
  
<br /><br />
+
PERSISTANT_ZONE_FOLLOW probably will no longer work, due to Bioware's own comments, and is never used. It was probably once used for mobile AOE's that are on aura's.
 +
 
 +
The order for things got during this is not based on range or anything, but normal works clockwise from west (0.0), but this rarely matters.
  
 
====Remarks====
 
====Remarks====
  
Used to cycle through all of contained objects via GetNextInPersistentObject(). <br /><br /> Bioware uses this function in scripts to implement area of effect spells. <br /><br /> Also note that triggers are persistent objects, so you can cycle through objects in triggers using this command. See the code example below.
+
Used to cycle through all of contained objects via [[GetNextInPersistentObject]]().
 +
 
 +
Bioware uses this function in scripts to implement area of effect spells.
 +
 
 +
Also note that triggers (and therefore encounters too) are persistent objects, so you can cycle through objects in triggers/encounters using this command. See the code example below.
 +
 
 +
The area equivalent of this is [[GetFirstObjectInArea]].
  
<br />
+
Like similar functions this won't work on DMs.
  
 
====Version====
 
====Version====

Latest revision as of 21:58, 28 July 2020

GetFirstInPersistentObject(object, int, int)

Determines the first object of a specific type that is inside a persistent object.

object GetFirstInPersistentObject(
    object oPersistentObject = OBJECT_SELF,
    OBJECT_TYPE_CREATURE,
    PERSISTENT_ZONE_ACTIVE
);

Parameters

oPersistentObject

The object that contains the object. (Default: OBJECT_SELF)

nResidentObjectType

OBJECT_TYPE_CREATURE )

nPersistentZone

PERSISTENT_ZONE_ACTIVE. PERSISTENT_ZONE_ACTIVE )


Description

Returns the first object within oPersistentObject of the specified type in order and OBJECT_INVALID if no object is found.

PERSISTANT_ZONE_FOLLOW probably will no longer work, due to Bioware's own comments, and is never used. It was probably once used for mobile AOE's that are on aura's.

The order for things got during this is not based on range or anything, but normal works clockwise from west (0.0), but this rarely matters.

Remarks

Used to cycle through all of contained objects via GetNextInPersistentObject().

Bioware uses this function in scripts to implement area of effect spells.

Also note that triggers (and therefore encounters too) are persistent objects, so you can cycle through objects in triggers/encounters using this command. See the code example below.

The area equivalent of this is GetFirstObjectInArea.

Like similar functions this won't work on DMs.

Version

1.32

Example

void main()
{
//The trigger to look in
object oTrigger=GetObjectByTag("killer_trigger");
 
//First object in that trigger. We can use bitwise |
//Because of the values of the OBJECT_TYPE_* constants
object oInTrigger=GetFirstInPersistentObject(oTrigger, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE |OBJECT_TYPE_ITEM);
 
while (GetIsObjectValid(oInTrigger))
   {
   DestroyObject(oInTrigger);
 
   oInTrigger=GetNextInPersistentObject(oTrigger, OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE |OBJECT_TYPE_ITEM);
   }
}

See Also

functions: 

GetNextInPersistentObject

constants: 

PERSISTENT_ZONE_* Constants



 author: Tom Cassiotis, editor: Jasperre, additional contributor(s): Lilac Soul