CheckFOV

From ZDoom Wiki
Jump to navigation Jump to search

bool CheckFOV(Actor target, double fov)

Usage

Checks if target is within the horizontal FOV of the caller.

Parameters

  • target: The other actor to check.
  • fov: The FOV to check if target is within.

Return value

Returns true if the target actor is within the FOV of the caller.

Example

This Imp simply stays in place, and looks at the player whenever he is within 180 degrees of his FOV.

class PeepingImp : DoomImp Replaces DoomImp
{
	States
	{
		See:
			TROO AB 10
			{
				A_Chase (Null,Null,CHF_DONTMOVE|CHF_DONTTURN);
				If (Target && CheckFOV (Target,90))
					A_FaceTarget (20);
			}
			Loop;
		Pain:
			TROO H 2;
			TROO H 2 A_Pain();
			Goto See;
	}
}