//========================================================= // StartFire- since all of this code has to run and then // call Fire(), it was easier at this point to rip it out // of weaponidle() and make its own function then to try to // merge this into Fire(), which has some identical variable names //========================================================= void CGauss::StartFire( void ) { float flDamage; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = m_pPlayer->GetGunPosition( ); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8; if ( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) { flDamage = 200; } else { flDamage = 200 * (( gpGlobals->time - m_pPlayer->m_flStartCharge) / GetFullChargeTime() ); } if ( m_fPrimaryFire ) { // fixed damage on primary attack #ifdef CLIENT_DLL flDamage = 20; #else flDamage = gSkillData.plrDmgGauss; #endif } if (m_fInAttack != 3) { //ALERT ( at_console, "Time:%f Damage:%f\n", gpGlobals->time - m_pPlayer->m_flStartCharge, flDamage ); #ifndef CLIENT_DLL float flZVel = m_pPlayer->pev->velocity.z; if ( !m_fPrimaryFire ) { m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5; } if ( !g_pGameRules->IsMultiplayer() ) { // in deathmatch, gauss can pop you up into the air. Not in single play. m_pPlayer->pev->velocity.z = flZVel; } #endif // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } // time until aftershock 'static discharge' sound m_pPlayer->m_flPlayAftershock = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.3, 0.8 ); Fire( vecSrc, vecAiming, flDamage ); }
void CGauss::StartFire( void ) { float flDamage; if ( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) flDamage = dmg_gauss_secondary.value * (mp_wpn_power.value/100); else flDamage = (dmg_gauss_secondary.value * (mp_wpn_power.value/100)) * (( gpGlobals->time - m_pPlayer->m_flStartCharge) / GetFullChargeTime() ); if (m_fPrimaryFire) flDamage = dmg_gauss.value * (mp_wpn_power.value/100); UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); if(!m_fPrimaryFire) { m_pPlayer->FireBeam(m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 12 + gpGlobals->v_right * 2.5 + gpGlobals->v_up * -2, gpGlobals->v_forward, BEAM_GAUSSCHARGED, flDamage, m_pPlayer->pev); FX_FireGun(m_pPlayer->pev->v_angle, m_pPlayer->entindex(), (m_pPlayer->m_fHeavyArmor)?GAUSS_FIRE_SEC_SOLID:GAUSS_FIRE_SEC, 1, FIREGUN_GAUSS ); if (!m_pPlayer->m_fHeavyArmor) { m_pPlayer->pev->punchangle.x -= 9; if (m_fInAttack != 3) { UTIL_MakeVectors (m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle); m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * flDamage * 5; } } } else { m_pPlayer->FireBeam(m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 10 + gpGlobals->v_right * 2.5 + gpGlobals->v_up * -2, gpGlobals->v_forward, BEAM_GAUSS, flDamage, m_pPlayer->pev); FX_FireGun(m_pPlayer->pev->v_angle, m_pPlayer->entindex(), (m_pPlayer->m_fHeavyArmor)?GAUSS_FIRE_SOLID:GAUSS_FIRE, 0, FIREGUN_GAUSS ); if (!m_pPlayer->m_fHeavyArmor) m_pPlayer->pev->punchangle.x -= 2.5; } }
void CGauss::SecondaryAttack() { entvars_t *pevOwner = VARS( pev->owner ); if ( m_pPlayer->pev->waterlevel == 3 ) { if ( m_fInAttack != 0 ) { ::WaterRadiusDamage( pev->origin, pev, pevOwner, (dmg_gauss_secondary.value*2) * (mp_wpn_power.value/100), (dmg_gauss_secondary.value*4) * (mp_wpn_power.value/100), CLASS_NONE, DMG_SHOCK | DMG_NEVERGIB); EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/electro4.wav", 0.55, ATTN_NORM); m_iClip = 0; SendWeaponAnim( GAUSS_IDLE ); m_fInAttack = 0; } else { PlayEmptySound(3); } m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; return; } if ( m_fInAttack == 0 ) { if ( m_iClip <= 0 ) { PlayEmptySound(3); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } m_fPrimaryFire = FALSE; m_iClip-=2; m_iFiredAmmo++; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); SendWeaponAnim( GAUSS_SPINUP ); m_fInAttack = 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flStartCharge = gpGlobals->time; m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/gauss_charge.wav",1.0 , ATTN_NORM, 0, 110 ); m_iSoundState = SND_CHANGE_PITCH; if ( m_iClip <= 0 ) { StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; m_iClip = 0; return; } } else if (m_fInAttack == 1) { if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) { SendWeaponAnim( GAUSS_SPIN ); m_fInAttack = 2; } } else { // during the charging process, eat one bit of ammo every once in a while if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { m_iClip-=2; m_iFiredAmmo++; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.7; } if ( m_iClip <= 0 ) { // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; m_iClip = 0; return; } if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; } int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; if ( pitch > 250 ) pitch = 250; if ( m_iSoundState == 0 ) EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/gauss_charge.wav", 1.0, ATTN_NORM, m_iSoundState, pitch); m_iSoundState = SND_CHANGE_PITCH; if ( m_pPlayer->m_flStartCharge < gpGlobals->time - 20 ) { // Player charged up too long. Zap him. EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0,0x3f)); STOP_SOUND( ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/gauss_charge.wav" ); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->TakeDamage( VARS(eoNullEntity), VARS(eoNullEntity), 105, DMG_SHOCK | DMG_NEVERGIB ); UTIL_ScreenFade( m_pPlayer, Vector(255,128,0), 2, 0.5, 128, FFADE_IN ); SendWeaponAnim( GAUSS_IDLE ); return; } } }
void CGauss::SecondaryAttack() { // don't fire underwater if ( m_pPlayer->pev->waterlevel == 3 ) { if ( m_fInAttack != 0 ) { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); SendWeaponAnim( GAUSS_IDLE ); m_fInAttack = 0; } else { PlayEmptySound( ); } m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay(0.5); return; } if ( m_fInAttack == 0 ) { if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } m_fPrimaryFire = FALSE; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); // spin up m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; SendWeaponAnim( GAUSS_SPINUP ); m_fInAttack = 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flStartCharge = gpGlobals->time; m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; } else if (m_fInAttack == 1) { if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) { SendWeaponAnim( GAUSS_SPIN ); m_fInAttack = 2; } } else { // during the charging process, eat one bit of ammo every once in a while if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { #ifdef CLIENT_DLL if ( bIsMultiplayer() ) #else if ( g_pGameRules->IsMultiplayer() ) #endif { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; } else { m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; } } if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) { // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; } if ( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; } int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; if ( pitch > 250 ) pitch = 250; // ALERT( at_console, "%d %d %d\n", m_fInAttack, m_iSoundState, pitch ); if ( m_iSoundState == 0 ) ALERT( at_console, "sound state %d\n", m_iSoundState ); PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; if ( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) { // Player charged up too long. Zap him. EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG(0,0x3f)); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0,0x3f)); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; #ifndef CLIENT_DLL m_pPlayer->TakeDamage( VARS(eoNullEntity), VARS(eoNullEntity), 50, DMG_SHOCK ); UTIL_ScreenFade( m_pPlayer, Vector(255,128,0), 2, 0.5, 128, FFADE_IN ); #endif SendWeaponAnim( GAUSS_IDLE ); // Player may have been killed and this weapon dropped, don't execute any more code after this! return; } } }