p_mobj.c
/*
================
=
= P_SpawnPlayerMissile
=
= Tries to aim at a nearby monster
================
*/
P_SpawnPlayerMissile
Tries to aim at a nearby monster
P_SpawnPlayerMissile Tries to aim at a nearby monster
void P_SpawnPlayerMissile (mobj_t *source, mobjtype_t type)
{
	mobj_t			*th;
	angle_t			an;
	fixed_t			x,y,z, slope;
	int				speed;
	const mobjinfo_t* thinfo = &mobjinfo[type];
	an = source->angle;
	slope = P_AimLineAttack (source, an, 16*64*FRACUNIT);
	if (!linetarget)
	{
		an += 1<<26;
		slope = P_AimLineAttack (source, an, 16*64*FRACUNIT);
		if (!linetarget)
		{
			an -= 2<<26;
			slope = P_AimLineAttack (source, an, 16*64*FRACUNIT);
		}
		if (!linetarget)
		{
			an = source->angle;
			slope = 0;
		}
	}
	x = source->x;
	y = source->y;
	z = source->z + 4*8*FRACUNIT;
	th = P_SpawnMobj (x,y,z, type);
	if (thinfo->seesound)
		S_StartSound (source, thinfo->seesound);
	th->target = source;
	th->angle = an;
	speed = th->speed >> 16;
	th->momx = speed * finecosine(an>>ANGLETOFINESHIFT);
	th->momy = speed * finesine(an>>ANGLETOFINESHIFT);
	th->momz = speed * slope;
	P_CheckMissileSpawn (th);
}
void P_SpawnPlayerMissile ( mobj_t * source , mobjtype_t type ) { mobj_t * th ; angle_t an ; fixed_t x , y , z , slope ; int speed ; const mobjinfo_t * thinfo = & mobjinfo [ type ] ; an = source -> angle ; slope = P_AimLineAttack ( source , an , 16 * 64 * FRACUNIT ) ; if ( ! linetarget ) { an += 1 << 26 ; slope = P_AimLineAttack ( source , an , 16 * 64 * FRACUNIT ) ; if ( ! linetarget ) { an -= 2 << 26 ; slope = P_AimLineAttack ( source , an , 16 * 64 * FRACUNIT ) ; } if ( ! linetarget ) { an = source -> angle ; slope = 0 ; } } x = source -> x ; y = source -> y ; z = source -> z + 4 * 8 * FRACUNIT ; th = P_SpawnMobj ( x , y , z , type ) ; if ( thinfo -> seesound ) S_StartSound ( source , thinfo -> seesound ) ; th -> target = source ; th -> angle = an ; speed = th -> speed >> 16 ; th -> momx = speed * finecosine ( an >> ANGLETOFINESHIFT ) ; th -> momy = speed * finesine ( an >> ANGLETOFINESHIFT ) ; th -> momz = speed * slope ; P_CheckMissileSpawn ( th ) ; }
P_SpawnPlayerMissile
Tries to aim at a nearby monster
P_SpawnPlayerMissile Tries to aim at a nearby monster
/* */ /* see which target is to be aimed at */ /* */