GetFirstInPersistentObject(object, int, int)

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

object GetFirstInPersistentObject(
    object oPersistentObject = OBJECT_SELF,
    int nResidentObjectType = OBJECT_TYPE_CREATURE,
    int nPersistentZone = PERSISTENT_ZONE_ACTIVE
);

Parameters

oPersistentObject

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

nResidentObjectType

OBJECT_TYPE_* (Default: OBJECT_TYPE_CREATURE)

nPersistentZone

PERSISTENT_ZONE_ACTIVE. [This could also take the value PERSISTENT_ZONE_FOLLOW, but this is no longer used.] (Default: 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 normall 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 are persistent objects, so you can cycle through objects in triggers using this command. See the code example below.


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
categories: Miscellaneous Functions
constants: OBJECT_TYPE_* Constants | PERSISTENT_ZONE_* Constants


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