GetFirstInPersistentObject

From NWN Lexicon

Contents

[edit] 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
);

[edit] Parameters

oPersistentObject

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

nResidentObjectType

OBJECT_TYPE_CREATURE )

nPersistentZone

PERSISTENT_ZONE_ACTIVE. PERSISTENT_ZONE_ACTIVE )


[edit] 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 normall works clockwise from west (0.0), but this rarely matters.



[edit] 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 are persistent objects, so you can cycle through objects in triggers using this command. See the code example below.


[edit] Version

1.32

[edit] 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);
   }
}

[edit] See Also

functions: 

GetNextInPersistentObject

constants: 

PERSISTENT_ZONE_* Constants



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

Personal tools
Categories