Exemplo n.º 1
0
/*
============
W_Attack

An attack impulse can be triggered now
============
*/
void W_Attack()
{
	float           r;

	if ( !W_CheckNoAmmo() )
		return;

	makevectors( self->s.v.v_angle );	// calculate forward angle for velocity
	self->show_hostile = g_globalvars.time + 1;	// wake monsters up

	switch ( ( int ) self->s.v.weapon )
	{
	case IT_AXE:
		self->attack_finished = g_globalvars.time + 0.5;
		sound( self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM );
		r = g_random();
		if ( r < 0.25 )
			player_axe1();
		else if ( r < 0.5 )
			player_axeb1();
		else if ( r < 0.75 )
			player_axec1();
		else
			player_axed1();
		break;

	case IT_SHOTGUN:
		player_shot1();
		self->attack_finished = g_globalvars.time + 0.5;
		W_FireShotgun();
		break;

	case IT_SUPER_SHOTGUN:
		player_shot1();
		self->attack_finished = g_globalvars.time + 0.7;
		W_FireSuperShotgun();
		break;

	case IT_NAILGUN:
		player_nail1();
		break;

	case IT_SUPER_NAILGUN:
		player_nail1();
		break;

	case IT_GRENADE_LAUNCHER:
		player_rocket1();
		self->attack_finished = g_globalvars.time + 0.6;
		W_FireGrenade();
		break;

	case IT_ROCKET_LAUNCHER:
		player_rocket1();
		self->attack_finished = g_globalvars.time + 0.8;
		W_FireRocket();
		break;

	case IT_LIGHTNING:
		self->attack_finished = g_globalvars.time + 0.1;
		sound( self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM );
		player_light1();
		break;
	}
}
Exemplo n.º 2
0
//===============================================================================
// PLAYER WEAPON USE
//===============================================================================
void CBasePlayer::W_Attack(int iQuadSound)
{
	// Out of ammo?
	if(!W_CheckNoAmmo())
		return;

	if(m_iQuakeWeapon != IT_LIGHTNING)
		((CBasePlayerWeapon *)m_pActiveItem)->SendWeaponAnim(1, 1);

	if(m_iQuakeWeapon == IT_AXE)
	{
#ifdef THREEWAVE
		if(m_iRuneStatus == ITEM_RUNE3_FLAG)
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.3;
		else
#endif
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;

		PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usAxeSwing, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iQuadSound, 0, 0, 0);

		// Delay attack for 0.3
		m_flAxeFire = gpGlobals->time + 0.3;

		PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usAxe, 0.3, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iQuadSound, 0, 0, 0);
	}
	else if(m_iQuakeWeapon == IT_SHOTGUN)
	{
#ifdef THREEWAVE
		if(m_iRuneStatus == ITEM_RUNE3_FLAG)
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.3;
		else
#endif
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;

		W_FireShotgun(iQuadSound);
	}
	else if(m_iQuakeWeapon == IT_SUPER_SHOTGUN)
	{
#ifdef THREEWAVE
		if(m_iRuneStatus == ITEM_RUNE3_FLAG)
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.4;
		else
#endif
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.7;

		W_FireSuperShotgun(iQuadSound);
	}
	else if(m_iQuakeWeapon == IT_NAILGUN)
	{
		m_flNextAttack = UTIL_WeaponTimeBase() + 0.1;

		W_FireSpikes(iQuadSound);
	}
	else if(m_iQuakeWeapon == IT_SUPER_NAILGUN)
	{
		m_flNextAttack = UTIL_WeaponTimeBase() + 0.1;
		W_FireSpikes(iQuadSound);
	}
	else if(m_iQuakeWeapon == IT_GRENADE_LAUNCHER)
	{
#ifdef THREEWAVE
		if(m_iRuneStatus == ITEM_RUNE3_FLAG)
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.3;
		else
#endif
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;

		W_FireGrenade(iQuadSound);
	}
	else if(m_iQuakeWeapon == IT_ROCKET_LAUNCHER)
	{
#ifdef THREEWAVE
		if(m_iRuneStatus == ITEM_RUNE3_FLAG)
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.4;
		else
#endif
			m_flNextAttack = UTIL_WeaponTimeBase() + 0.8;

		W_FireRocket(iQuadSound);
	}
	else if(m_iQuakeWeapon == IT_LIGHTNING)
	{
		m_flNextAttack = UTIL_WeaponTimeBase() + 0.1;

		// Play the lightning start sound if gun just started firing
		if(m_afButtonPressed & IN_ATTACK)
			EMIT_SOUND(ENT(pev), CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);

		W_FireLightning(iQuadSound);
	}

#ifdef THREEWAVE
	else if(m_iQuakeWeapon == IT_EXTRA_WEAPON)
	{
		if(!m_bHook_Out)
			W_FireHook();

		m_flNextAttack = UTIL_WeaponTimeBase() + 0.1;
	}
#endif

	// Make player attack
	if(pev->health >= 0)
		SetAnimation(PLAYER_ATTACK1);
}