A_FindTracer

From DoomWiki.org

A_FindTracer(fov, rangeblocks) is a generic missile function that is part of the MBF21 specification. It searches for a target and, if found, updates the tracer field of the calling actor accordingly. The function has two parameters, using the values in the Args1 and Args2 fields as arguments.

The first argument determines the field of view, relative to the calling actor, used to search for a target. The angle has to be passed to the function in fixed point, meaning the intended value has to be multiplied by 65536 (FRACUNIT). If zero, a target will be searched for in all directions. The second argument sets the range in which to search for a target. The range is measured in blocks of 128 map units. If not set, the parameter defaults to a value of 10 blocks (1280 map units).

The function will abort if the calling actor already has a target. (To forcibly reacquire a new target, A_ClearTracer must be called first.)

The function will also ignore any actor that is friendly to the shooter, e.g., players will not target friendly monsters and enemy monsters will not target each other unless they are infighting.

Example[edit]

The following is an example of how to set the A_FindTracer code pointer in a DeHackEd file using BEX syntax:

Frame 1234
Next frame = 1235
Duration = 2
Args1 = 2949120
Args2 = 20

Frame 1235
Next frame = 1234
Duration = 2
Args1 = 983040
Args2 = 983040

[CODEPTR]
FRAME 1234 = FindTracer
FRAME 1235 = SeekTracer

Or using DECOHack syntax:

state 1234
{
TNT A 2 A_FindTracer(45, 20)
goto 1235
}

state 1235
{
TNT A 2 A_SeekTracer(15, 15)
goto 1234
}

The example above uses A_FindTracer in combination with A_SeekTracer to make a projectile search for a target and home in on it, with the ability to acquire a new target and change course if the current target is killed off while the projectile is still in flight. (This example mirrors the behavior of the triple missile shot fired by the homing launcher from Crusader.)

External links[edit]