void CWeaponEgon::WeaponIdle( void ) { if ( !HasWeaponIdleTimeElapsed() ) return; if ( m_fireState != FIRE_OFF ) EndAttack(); int iAnim; float flRand = random->RandomFloat( 0,1 ); float flIdleTime; if ( flRand <= 0.5 ) { iAnim = ACT_VM_IDLE; flIdleTime = gpGlobals->curtime + random->RandomFloat( 10, 15 ); } else { iAnim = ACT_VM_FIDGET; flIdleTime = gpGlobals->curtime + 3.0; } SendWeaponAnim( iAnim ); SetWeaponIdleTime( flIdleTime ); }
void CEgon::WeaponIdle( void ) { ResetEmptySound( ); if ( m_flTimeWeaponIdle > gpGlobals->time ) return; if ( m_fireState != FIRE_OFF ) EndAttack(); int iAnim; float flRand = RANDOM_FLOAT(0,1); if ( flRand <= 0.5 ) { iAnim = EGON_IDLE1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else { iAnim = EGON_FIDGET1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; } SendWeaponAnim( iAnim ); m_deployed = TRUE; }
void CEgon::Holster( int skiplocal ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; SendWeaponAnim( EGON_HOLSTER ); EndAttack(); }
void CEgon::WeaponIdle( void ) { ResetEmptySound( ); if ( m_flTimeWeaponIdle > gpGlobals->time ) return; if ( m_fireState != FIRE_OFF ) EndAttack(); int iAnim; float flRand = RANDOM_FLOAT(0,1); if ( flRand <= 0.5 ) { iAnim = EGON_IDLE1; m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT(10,15); } else { iAnim = EGON_FIDGET1; m_flTimeWeaponIdle = gpGlobals->time + 3; } SendWeaponAnim( iAnim ); m_deployed = TRUE; }
void CEgon::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; // m_flTimeWeaponIdle = gpGlobals->time + UTIL_RandomFloat ( 10, 15 ); SendWeaponAnim( EGON_HOLSTER ); if ( m_fireState != FIRE_OFF ) EndAttack(); }
bool CASW_Weapon_Chainsaw::Holster( CBaseCombatWeapon *pSwitchingTo ) { if (m_fireState != FIRE_OFF) { EndAttack(); } StopChainsawSound( true ); StopAttackOffSound(); StopSound( "ASW_Chainsaw.Start" ); EmitSound( "ASW_Chainsaw.Stop" ); return BaseClass::Holster( pSwitchingTo ); }
void CASW_Weapon_Chainsaw::Drop( const Vector &vecVelocity ) { if (m_fireState != FIRE_OFF) { EndAttack(); } StopChainsawSound( true ); StopAttackOffSound(); StopSound( "ASW_Chainsaw.Start" ); EmitSound( "ASW_Chainsaw.Stop" ); BaseClass::Drop( vecVelocity ); }
CASW_Weapon_Chainsaw::~CASW_Weapon_Chainsaw() { if (m_fireState != FIRE_OFF) { EndAttack(); } else { if (m_bPlayedIdleSound) { StopSound( "ASW_Chainsaw.Start" ); if ( CBaseEntity::IsAbsQueriesValid() ) EmitSound( "ASW_Chainsaw.Stop" ); } } StopChainsawSound(); StopAttackOffSound(); }
void CASW_Weapon_Chainsaw::WeaponIdle( void ) { if ( !HasWeaponIdleTimeElapsed() ) return; //Msg("%f CASW_Weapon_Chainsaw::WeaponIdle\n", gpGlobals->curtime); float flIdleTime; if ( m_fireState != FIRE_OFF ) { //Msg(" ending attack\n", gpGlobals->curtime); EndAttack(); flIdleTime = gpGlobals->curtime + 1.4f; } else { //Msg(" idle looping\n", gpGlobals->curtime); //EmitSound( "ASW_Chainsaw.IdleLoop" ); flIdleTime = gpGlobals->curtime + 1.7f; } //int iAnim; //float flRand = random->RandomFloat( 0,1 ); //if ( flRand <= 0.5 ) //{ //iAnim = ACT_VM_IDLE; //flIdleTime = gpGlobals->curtime + 1.4f; //} //else //{ //iAnim = ACT_VM_FIDGET; //flIdleTime = gpGlobals->curtime + 3.0; //} //SendWeaponAnim( iAnim ); SetWeaponIdleTime( flIdleTime ); }
void CEgon::Attack( void ) { // don't fire underwater if ( m_pPlayer->pev->waterlevel == 3 ) { if ( m_fireState != FIRE_OFF || m_pBeam ) { EndAttack(); } else { PlayEmptySound( ); } return; } UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = m_pPlayer->GetGunPosition( ); int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif switch( m_fireState ) { case FIRE_OFF: { if ( !HasAmmo() ) { m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25; PlayEmptySound( ); return; } m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 1, 0 ); m_shakeTime = 0; m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; pev->fuser1 = UTIL_WeaponTimeBase() + 2; pev->dmgtime = gpGlobals->time + GetPulseInterval(); m_fireState = FIRE_CHARGE; } break; case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; if ( pev->fuser1 <= UTIL_WeaponTimeBase() ) { PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 0, 0 ); pev->fuser1 = 1000; } if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; } } break; } }
void CEgon::Attack( void ) { // don't fire underwater /**if ( m_pPlayer->pev->waterlevel == 3 ) { if ( m_fireState != FIRE_OFF || m_pBeam ) { EndAttack(); } else { PlayEmptySound( ); } return; }*/ // rather than not working, we're gonna explode in water. makes sense for a prototype supergun. if ( m_pPlayer->pev->waterlevel > 1 ) { // get the remaining ammo to calculate how much damage the explosion will do, and then "use up" the ammo. int remainingAmmo = m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = 0; // do damage! #ifndef CLIENT_DLL ::RadiusDamage( m_pPlayer->pev->origin, m_pPlayer->pev, m_pPlayer->pev, 35 * remainingAmmo, ( 35 * remainingAmmo ) + 40, CLASS_NONE, DMG_ENERGYBEAM | DMG_BLAST | DMG_ALWAYSGIB ); #endif } UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = m_pPlayer->GetGunPosition( ); int flags; #if defined( CLIENT_WEAPONS ) flags = FEV_NOTHOST; #else flags = 0; #endif switch( m_fireState ) { case FIRE_OFF: { if ( !HasAmmo() ) { m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.25; PlayEmptySound( ); return; } m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 1, 0 ); m_shakeTime = 0; m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; pev->fuser1 = UTIL_WeaponTimeBase() + 2; pev->dmgtime = gpGlobals->time + GetPulseInterval(); m_fireState = FIRE_CHARGE; } break; case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; if ( pev->fuser1 <= UTIL_WeaponTimeBase() ) { PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usEgonFire, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, m_fireState, m_fireMode, 0, 0 ); pev->fuser1 = 1000; } if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; } } break; } }
void CEgon::Attack( void ) { // don't fire underwater if (m_pPlayer->pev->waterlevel == 3) { if ( m_pBeam ) { EndAttack(); } else { PlayEmptySound( ); } return; } UTIL_MakeVectors( m_pPlayer->pev->viewangles + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = m_pPlayer->GetGunPosition( ); switch( m_fireState ) { case FIRE_OFF: { if ( !HasAmmo() ) { m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.25; PlayEmptySound( ); return; } m_flAmmoUseTime = gpGlobals->time;// start using ammo ASAP. SendWeaponAnim( g_fireAnims1[ RANDOM_LONG(0,ARRAYSIZE(g_fireAnims1)-1) ] ); m_shakeTime = 0; m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; m_flTimeWeaponIdle = gpGlobals->time + 0.1; m_shootTime = gpGlobals->time + 2; if ( m_fireMode == FIRE_WIDE ) { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, EGON_SOUND_STARTUP, 0.98, ATTN_NORM, 0, 125 ); } else { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, EGON_SOUND_STARTUP, 0.9, ATTN_NORM, 0, 100 ); } pev->dmgtime = gpGlobals->time + GetPulseInterval(); m_fireState = FIRE_CHARGE; } break; case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); m_pPlayer->m_iWeaponVolume = EGON_PRIMARY_VOLUME; if ( m_shootTime != 0 && gpGlobals->time > m_shootTime ) { if ( m_fireMode == FIRE_WIDE ) { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 ); } else { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_STATIC, EGON_SOUND_RUN, 0.9, ATTN_NORM, 0, 100 ); } m_shootTime = 0; } if ( !HasAmmo() ) { EndAttack(); m_fireState = FIRE_OFF; m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 1.0; } } break; } }
bool CWeaponEgon::Holster( CBaseCombatWeapon *pSwitchingTo ) { EndAttack(); return BaseClass::Holster( pSwitchingTo ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponEgon::PrimaryAttack( void ) { CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) { return; } // don't fire underwater if ( pPlayer->GetWaterLevel() == 3 ) { if ( m_fireState != FIRE_OFF || m_hBeam ) { EndAttack(); } else { WeaponSound( EMPTY ); } m_flNextPrimaryAttack = gpGlobals->curtime + 0.5; m_flNextSecondaryAttack = gpGlobals->curtime + 0.5; return; } Vector vecAiming = pPlayer->GetAutoaimVector( 0 ); Vector vecSrc = pPlayer->Weapon_ShootPosition( ); switch( m_fireState ) { case FIRE_OFF: { if ( !HasAmmo() ) { m_flNextPrimaryAttack = gpGlobals->curtime + 0.25; m_flNextSecondaryAttack = gpGlobals->curtime + 0.25; WeaponSound( EMPTY ); return; } m_flAmmoUseTime = gpGlobals->curtime;// start using ammo ASAP. EmitSound( "Weapon_Gluon.Start" ); SendWeaponAnim( ACT_VM_PRIMARYATTACK ); m_flShakeTime = 0; m_flStartFireTime = gpGlobals->curtime; SetWeaponIdleTime( gpGlobals->curtime + 0.1 ); m_flDmgTime = gpGlobals->curtime + EGON_PULSE_INTERVAL; m_fireState = FIRE_STARTUP; } break; case FIRE_STARTUP: { Fire( vecSrc, vecAiming ); if ( gpGlobals->curtime >= ( m_flStartFireTime + 2.0 ) ) { EmitSound( "Weapon_Gluon.Run" ); m_fireState = FIRE_CHARGE; } if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; } } case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; } } break; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CASW_Weapon_Chainsaw::PrimaryAttack( void ) { // If my clip is empty (and I use clips) start reload //if ( UsesClipsForAmmo1() && !m_iClip1 ) //{ //Reload(); //return; //} CASW_Player *pPlayer = GetCommander(); CASW_Marine *pMarine = GetMarine(); if ( !pMarine || !pMarine->IsAlive()) { EndAttack(); return; } // don't fire underwater if ( pMarine->GetWaterLevel() == 3 ) { if ( m_fireState != FIRE_OFF || m_hBeam ) { EndAttack(); } else { WeaponSound( EMPTY ); } m_flNextPrimaryAttack = gpGlobals->curtime + GetWeaponInfo()->m_flFireRate; m_flNextSecondaryAttack = gpGlobals->curtime + GetWeaponInfo()->m_flFireRate; return; } #ifdef GAME_DLL // check for turning on lag compensation if (pPlayer && pMarine->IsInhabited()) { CASW_Lag_Compensation::RequestLagCompensation( pPlayer, pPlayer->GetCurrentUserCommand() ); } #endif Vector vecSrc = pMarine->Weapon_ShootPosition( ); Vector vecAiming = vec3_origin; if ( pPlayer && pMarine->IsInhabited() ) { vecAiming = pPlayer->GetAutoaimVectorForMarine(pMarine, GetAutoAimAmount(), GetVerticalAdjustOnlyAutoAimAmount()); // 45 degrees = 0.707106781187 } else { #ifndef CLIENT_DLL vecAiming = pMarine->GetActualShootTrajectory( vecSrc ); #endif } // make vecaiming go down at 45 degrees vecAiming.z = 0; VectorNormalize(vecAiming); vecAiming.z = -1.0f; VectorNormalize(vecAiming); switch( m_fireState ) { case FIRE_OFF: { //if ( !HasAmmo() ) //{ //m_flNextPrimaryAttack = gpGlobals->curtime + 0.25; //m_flNextSecondaryAttack = gpGlobals->curtime + 0.25; //WeaponSound( EMPTY ); //return; //} m_flAmmoUseTime = gpGlobals->curtime;// start using ammo ASAP. SendWeaponAnim( ACT_VM_PRIMARYATTACK ); m_flShakeTime = 0; m_flStartFireTime = gpGlobals->curtime; SetWeaponIdleTime( gpGlobals->curtime + 0.1 ); m_flDmgTime = gpGlobals->curtime + ASW_CHAINSAW_PULSE_INTERVAL; SetFiringState(FIRE_STARTUP); } break; case FIRE_STARTUP: { Fire( vecSrc, vecAiming ); #ifndef CLIENT_DLL pMarine->OnWeaponFired( this, 1 ); #endif if ( gpGlobals->curtime >= ( m_flStartFireTime + ASW_CHAINSAW_CHARGE_UP_TIME ) ) { //EmitSound( "ASW_Chainsaw.AttackLoop" ); SetFiringState(FIRE_CHARGE); } if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; } } break; case FIRE_CHARGE: { Fire( vecSrc, vecAiming ); #ifndef CLIENT_DLL pMarine->OnWeaponFired( this, 1 ); #endif if ( !HasAmmo() ) { EndAttack(); m_flNextPrimaryAttack = gpGlobals->curtime + 1.0; m_flNextSecondaryAttack = gpGlobals->curtime + 1.0; } } break; } }