From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.

BlockLinesIterator is a type of iterator used to search for lines in the Blockmap. Contrary to the name, this does not grab only blocking lines but all lines. Instead it gets any line that exists in a blockmap square within the given radius. You can use this to get nearby lines instead of having to iterate through all of them. If you wish to get only blocking lines you'll have to manually check the flags on each line found in the iterator.

While iterating, you should take care not to call any function that refers to the validcount variable, such as other iterators or actor spawning functions. Doing so would interfere with the operation of the iterator, causing lines to be skipped or counted several times. Cf. this forum link.


Type Variables Use
Line CurLine The line the iterator is currently checking.
Vector3 position The xy map position for the origin of the check relative to the line. The z value is the radius that was given.
int portalflags Used to signify what Portal-related flags were used when getting the line.


Return Type Function Arguments (first to last) Use/Arguments
BlockLinesIterator Create
  1. Actor origin,
  2. double checkradius = -1

Initializes the iterator upon a pointer. Either this or CreateFromPos can be used.

  • origin - A pointer to an Actor to perform the search upon. To perform it on the calling actor, self can be used.
  • checkradius - The radius to search. Default is -1, interpreted as "use the pointer's radius".

Note: this function is static and should be called off the class name, i.e. BlockLinesIterator.Create(...).

BlockLinesIterator CreateFromPos
  1. Vector3 pos,
  2. double checkh,
  3. double checkradius,
  4. Sector sec = null

Initializes the iterator upon a vector. Either this or Create can be used.

  • pos - The map coordinates to set the origin of the search to.
  • checkh - The height to use for the origin point. Important for getting correct portal information.
  • checkradius - The radius to search.
  • sec - The starting sector to do the search from. If null, this will get the sector at the provided xy position.

Note: this function is static and should be called off the class name, i.e. BlockLinesIterator.CreateFromPos(...).

bool Next None Iterates through the list of found lines. Returns false when at the end of the list.


This function returns how many blocking lines there are within approximately rad distance.

int CountBlockingLines(double rad)
   // Create the iterator
   BlockLinesIterator it = BlockLinesIterator.Create(self, rad);
   Line ln;
   int blocking;

   while (it.Next())
       ln = it.CurLine; // Get the line it's currently on
       if (!(ln.flags & Line.ML_BLOCKING))


   return blocking;

See Also