FindObject (deprecated)

Category: Objects / Search
Since engine version: 4.6.5.0 CP (extended in 4.9.1.0 GWE)

Description

Returns the first object matching the search criteria. If iWdt and iHgt are both -1, the closest object will be found. If both are 0, only the point iX/iY will be searched. If iX, iY, iWdt and iHgt are 0, the whole landscape will be searched (even if called from an object). All criteria which are specified and not 0 have to be fulfilled.

Syntax

object FindObject (id idDef, int iX, int iY, int iWdt, int iHgt, int dwOCF, string szAction, object pActionTarget, any pContainer, object pFindNext);

Parameters

idDef:
[opt] Object type
iX:
[opt] Search position or left boundary of the search rectangle respectively. Relative to the calling object if applicable.
iY:
[opt] Search position or upper boundary of the search rectangle, respectively. Relative to the calling object, if applicable.
iWdt:
[opt] Width of the search rectangle. See remark below.
iHgt:
[opt] Height of the search rectangle. See remark below.
dwOCF:
[opt] Bit mask of object character flags. All objects which have at least one of the given flags are found. 0 for all objects.
szAction:
[opt] Activity of the object to be found.
pActionTarget:
[opt] Activity target of the object to be found. See also SetAction, GetActionTarget
pContainer:
[opt] Container of the object to be found. If given, only this container will be searched. Also possible is NoContainer for objects outside and AnyContainer for all contained objects.
pFindNext:
[opt] Object after which the search will begin. With this parameter and a loop all objects matching the criteria can be found.

Remarks

If called from an object, the calling object will not be found.
If a full search rectangle is provided (i.e. width and height larger than zero), objects match if their center point lies within this rectangle. If all four values of the search rectangle (iX, iY, iWdt, iHgt) are zero or not provided, the complete landscape area is searched. If both width and height (iWdt, iHgt) of the search rectangle are zero, the position (iX, iY) is interpreted as a search point and objects match if their shape overlaps that point. If both width and height of the search rectangle are -1, the object nearest to the search point is found.
This function is deprecated. It is recommended that FindObject2 or FindObjects is used instead, because those functions support assitional search criterions, and they are often faster.

Examples

var obj;
if (FindObject(0, LandscapeWidth()-100, 0, 100,LandscapeHeight(), OCF_CrewMember()))
  Message (Format ("<%s>|Hier gehts nicht weiter.", obj, GetName (obj)");"
The clonk realizes the landscape is finite at the right border.
Incinerate(FindObject(CLNK, 0,0, -1,-1));
Inflames the closest clonk.
Explode(100, FindObject(0, 100, 100, 0, 0, OCF_Living(), "Jump"));
If a clonk is at position 100/100 and jumping (or falling), he explodes.
var obj;
while (obj=FindObject(WIPF, 0,0,0,0, 0, 0,0, NoContainer(), obj)) Incinerate(obj);
Inflames all Wipfs outside.
See also: AnyContainer, FindObject2, FindObjectOwner, FindObjects, NoContainer
Sven2, November 2001
matthes, Juni 2004