p_enemy.c
/*
================
=
= P_LookForPlayers
=
= If allaround is false, only look 180 degrees in front
= returns true if a player is targeted
================
*/
P_LookForPlayers
If allaround is false, only look 180 degrees in front
returns true if a player is targeted
P_LookForPlayers If allaround is false only look 180 degrees in front returns true if a player is targeted
boolean P_LookForPlayers (mobj_t *actor, boolean allaround)
{
	angle_t		an;
	fixed_t		dist;
	mobj_t		*mo;
	if (! (actor->flags & MF_SEETARGET) )
	{	
newtarget:
		if (playeringame[1] && actor->target == players[0].mo)
			actor->target = players[1].mo;
		else
			actor->target = players[0].mo;
		return false;
	}
	mo = actor->target;
	if (!mo || mo->health <= 0)
		goto newtarget;
	if (actor->subsector->sector->soundtarget == actor->target)
		allaround = true;		
	if (!allaround)
	{
		an = R_PointToAngle2 (actor->x, actor->y, 
		mo->x, mo->y) - actor->angle;
		if (an > ANG90 && an < ANG270)
		{
			dist = P_AproxDistance (mo->x - actor->x,
				mo->y - actor->y);
			if (dist > MELEERANGE)
				return false;		
		}
	}
	actor->threshold = 60;
	return true;
}
boolean P_LookForPlayers ( mobj_t * actor , boolean allaround ) { angle_t an ; fixed_t dist ; mobj_t * mo ; if ( ! ( actor -> flags & MF_SEETARGET ) ) { newtarget : if ( playeringame [ 1 ] && actor -> target == players [ 0 ] . mo ) actor -> target = players [ 1 ] . mo ; else actor -> target = players [ 0 ] . mo ; return false ; } mo = actor -> target ; if ( ! mo || mo -> health <= 0 ) goto newtarget ; if ( actor -> subsector -> sector -> soundtarget == actor -> target ) allaround = true ; if ( ! allaround ) { an = R_PointToAngle2 ( actor -> x , actor -> y , mo -> x , mo -> y ) - actor -> angle ; if ( an > ANG90 && an < ANG270 ) { dist = P_AproxDistance ( mo -> x - actor -> x , mo -> y - actor -> y ) ; if ( dist > MELEERANGE ) return false ; } } actor -> threshold = 60 ; return true ; }
P_LookForPlayers
If allaround is false, only look 180 degrees in front
returns true if a player is targeted
P_LookForPlayers If allaround is false only look 180 degrees in front returns true if a player is targeted
/* pick another player as target if possible */ /* ambush guys will turn around on a shot */ /* if real close, react anyway */ /* behind back */