p_inter.c
/* 
=================== 
= 
= P_GiveAmmo
=
= Num is the number of clip loads, not the individual count (0= 1/2 clip)
= Returns false if the ammo can't be picked up at all
=================== 
*/
P_GiveAmmo
Num is the number of clip loads, not the individual count (0= 1/2 clip)
Returns false if the ammo can't be picked up at all
P_GiveAmmo Num is the number of clip loads not the individual count ( 0 = 1 / 2 clip ) Returns false if the ammo can ' t be picked up at all
boolean P_GiveAmmo (player_t *player, ammotype_t ammo, int num)
{
	int		oldammo;
	if (ammo == am_noammo)
		return false;
	if (ammo > NUMAMMO)
		I_Error ("P_GiveAmmo: bad type %i", ammo);
	if ( player->ammo[ammo] == player->maxammo[ammo]  )
		return false;
	if (num)
		num *= clipammo[ammo];
	else
		num = clipammo[ammo]/2;
	if (gameskill == sk_baby)
		num <<= 1;			
	oldammo = player->ammo[ammo];
	player->ammo[ammo] += num;
	if (player->ammo[ammo] > player->maxammo[ammo])
		player->ammo[ammo] = player->maxammo[ammo];
	if (oldammo)
		return true;		
	switch (ammo)
	{
	case am_clip:
		if (player->readyweapon == wp_fist)
		{
			if (player->weaponowned[wp_chaingun])
				player->pendingweapon = wp_chaingun;
			else
				player->pendingweapon = wp_pistol;
		}
		break;
	case am_shell:
		if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol)
		{
			if (player->weaponowned[wp_shotgun])
				player->pendingweapon = wp_shotgun;
		}
		break;
	case am_cell:
		if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol)
		{
			if (player->weaponowned[wp_plasma])
				player->pendingweapon = wp_plasma;
		}
		break;
	case am_misl:
		if (player->readyweapon == wp_fist)
		{
			if (player->weaponowned[wp_missile])
				player->pendingweapon = wp_missile;
		}
	default:
		break;
	}
	return true;
}
boolean P_GiveAmmo ( player_t * player , ammotype_t ammo , int num ) { int oldammo ; if ( ammo == am_noammo ) return false ; if ( ammo > NUMAMMO ) I_Error ( " " , ammo ) ; if ( player -> ammo [ ammo ] == player -> maxammo [ ammo ] ) return false ; if ( num ) num *= clipammo [ ammo ] ; else num = clipammo [ ammo ] / 2 ; if ( gameskill == sk_baby ) num <<= 1 ; oldammo = player -> ammo [ ammo ] ; player -> ammo [ ammo ] += num ; if ( player -> ammo [ ammo ] > player -> maxammo [ ammo ] ) player -> ammo [ ammo ] = player -> maxammo [ ammo ] ; if ( oldammo ) return true ; switch ( ammo ) { case am_clip : if ( player -> readyweapon == wp_fist ) { if ( player -> weaponowned [ wp_chaingun ] ) player -> pendingweapon = wp_chaingun ; else player -> pendingweapon = wp_pistol ; } break ; case am_shell : if ( player -> readyweapon == wp_fist || player -> readyweapon == wp_pistol ) { if ( player -> weaponowned [ wp_shotgun ] ) player -> pendingweapon = wp_shotgun ; } break ; case am_cell : if ( player -> readyweapon == wp_fist || player -> readyweapon == wp_pistol ) { if ( player -> weaponowned [ wp_plasma ] ) player -> pendingweapon = wp_plasma ; } break ; case am_misl : if ( player -> readyweapon == wp_fist ) { if ( player -> weaponowned [ wp_missile ] ) player -> pendingweapon = wp_missile ; } default : break ; } return true ; }
P_GiveAmmo
Num is the number of clip loads, not the individual count (0= 1/2 clip)
Returns false if the ammo can't be picked up at all
P_GiveAmmo Num is the number of clip loads not the individual count ( 0 = 1 / 2 clip ) Returns false if the ammo can ' t be picked up at all
/* give double ammo in trainer mode */ /* don't change up weapons, player was lower on */ /* purpose */