p_enemy.c
/*
==============
=
= A_Chase
=
= Actor has a melee attack, so it tries to close as fast as possible
=
==============
*/
A_Chase
Actor has a melee attack, so it tries to close as fast as possible
A_Chase Actor has a melee attack so it tries to close as fast as possible
void A_Chase (mobj_t *actor)
{
	int		delta;
	const mobjinfo_t* ainfo = &mobjinfo[actor->type];
	if (actor->reactiontime)
		actor->reactiontime--;
	if  (actor->threshold)
		actor->threshold--;
	if (actor->movedir < 8)
	{
		actor->angle &= (7<<29);
		delta = actor->angle - (actor->movedir << 29);
		if (delta > 0)
			actor->angle -= ANG90/2;
		else if (delta < 0)
			actor->angle += ANG90/2;
	}
	if (!actor->target || !(actor->target->flags&MF_SHOOTABLE))
	{	
		if (P_LookForPlayers(actor,true))
			return;		
		P_SetMobjState (actor, ainfo->spawnstate);
		return;
	}
	if (actor->flags & MF_JUSTATTACKED)
	{
		actor->flags &= ~MF_JUSTATTACKED;
		P_NewChaseDir (actor);
		return;
	}
	if (ainfo->meleestate && P_CheckMeleeRange (actor))
	{
		if (ainfo->attacksound)
			S_StartSound (actor, ainfo->attacksound);
		P_SetMobjState (actor, ainfo->meleestate);
		return;
	}
	if ( (gameskill == sk_nightmare || !actor->movecount) && ainfo->missilestate
	&& P_CheckMissileRange (actor))
	{
		P_SetMobjState (actor, ainfo->missilestate);
		if (gameskill != sk_nightmare)
			actor->flags |= MF_JUSTATTACKED;
		return;
	}
	if (--actor->movecount<0 || !P_Move (actor))
		P_NewChaseDir (actor);
	if (ainfo->activesound && P_Random () < 3)
		S_StartSound (actor, ainfo->activesound);
}
void A_Chase ( mobj_t * actor ) { int delta ; const mobjinfo_t * ainfo = & mobjinfo [ actor -> type ] ; if ( actor -> reactiontime ) actor -> reactiontime -- ; if ( actor -> threshold ) actor -> threshold -- ; if ( actor -> movedir < 8 ) { actor -> angle &= ( 7 << 29 ) ; delta = actor -> angle - ( actor -> movedir << 29 ) ; if ( delta > 0 ) actor -> angle -= ANG90 / 2 ; else if ( delta < 0 ) actor -> angle += ANG90 / 2 ; } if ( ! actor -> target || ! ( actor -> target -> flags & MF_SHOOTABLE ) ) { if ( P_LookForPlayers ( actor , true ) ) return ; P_SetMobjState ( actor , ainfo -> spawnstate ) ; return ; } if ( actor -> flags & MF_JUSTATTACKED ) { actor -> flags &= ~ MF_JUSTATTACKED ; P_NewChaseDir ( actor ) ; return ; } if ( ainfo -> meleestate && P_CheckMeleeRange ( actor ) ) { if ( ainfo -> attacksound ) S_StartSound ( actor , ainfo -> attacksound ) ; P_SetMobjState ( actor , ainfo -> meleestate ) ; return ; } if ( ( gameskill == sk_nightmare || ! actor -> movecount ) && ainfo -> missilestate && P_CheckMissileRange ( actor ) ) { P_SetMobjState ( actor , ainfo -> missilestate ) ; if ( gameskill != sk_nightmare ) actor -> flags |= MF_JUSTATTACKED ; return ; } if ( -- actor -> movecount < 0 || ! P_Move ( actor ) ) P_NewChaseDir ( actor ) ; if ( ainfo -> activesound && P_Random ( ) < 3 ) S_StartSound ( actor , ainfo -> activesound ) ; }
A_Chase
Actor has a melee attack, so it tries to close as fast as possible
A_Chase Actor has a melee attack so it tries to close as fast as possible
/* */ /* modify target threshold */ /* */ /* */ /* turn towards movement direction if not there yet */ /* */ /* look for a new target */ /* got a new target */ /* */ /* don't attack twice in a row */ /* */ /* */ /* check for melee attack */ /*	 */ /* */ /* check for missile attack */ /* */ /* */ /* chase towards player */ /* */ /* */ /* make active sound */ /* */