//----------------------------------------------------------------------------- // Purpose: Called every usercmd by the player PreThink //----------------------------------------------------------------------------- void CBasePlayer::ItemPreFrame() { // Handle use events PlayerUse(); CBaseCombatWeapon *pActive = GetActiveWeapon(); // Allow all the holstered weapons to update for ( int i = 0; i < WeaponCount(); ++i ) { CBaseCombatWeapon *pWeapon = GetWeapon( i ); if ( pWeapon == NULL ) continue; if ( pActive == pWeapon ) continue; pWeapon->ItemHolsterFrame(); } if ( gpGlobals->curtime < m_flNextAttack ) return; if (!pActive) return; #if defined( CLIENT_DLL ) // Not predicting this weapon if ( !pActive->IsPredicted() ) return; #endif pActive->ItemPreFrame(); }
//----------------------------------------------------------------------------- // Purpose: Called every usercmd by the player PreThink //----------------------------------------------------------------------------- void CBasePlayer::ItemPreFrame() { // Handle use events PlayerUse(); //Tony; re-ordered this for efficiency and to make sure that certain things happen in the correct order! if ( gpGlobals->curtime < m_flNextAttack ) { return; } if (!GetActiveWeapon()) return; #if defined( CLIENT_DLL ) // Not predicting this weapon if ( !GetActiveWeapon()->IsPredicted() ) return; #endif GetActiveWeapon()->ItemPreFrame(); CBaseCombatWeapon *pWeapon; CBaseCombatWeapon *pActive = GetActiveWeapon(); // Allow all the holstered weapons to update for ( int i = 0; i < WeaponCount(); ++i ) { pWeapon = GetWeapon( i ); if ( pWeapon == NULL ) continue; if ( pActive == pWeapon ) continue; pWeapon->ItemHolsterFrame(); } }
/* ============ ImpulseCommands ============ */ void CBasePlayer::ImpulseCommands() { TraceResult tr;// UNDONE: kill me! This is temporary for PreAlpha CDs // Handle use events PlayerUse(); int iImpulse = GetImpulse(); switch( iImpulse ) { case 99: { bool bOn; if( !gmsgLogo ) { bOn = true; //TODO: figure out why this is done here. - Solokiller gmsgLogo = REG_USER_MSG( "Logo", 1 ); } else { bOn = false; } ASSERT( gmsgLogo > 0 ); // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgLogo, NULL, this ); WRITE_BYTE( bOn ); MESSAGE_END(); if( !bOn ) gmsgLogo = 0; break; } case 100: // temporary flashlight for level designers if( FlashlightIsOn() ) { FlashlightTurnOff(); } else { FlashlightTurnOn(); } break; case 201:// paint decal if( gpGlobals->time < m_flNextDecalTime ) { // too early! break; } UTIL_MakeVectors( GetViewAngle() ); UTIL_TraceLine( GetAbsOrigin() + GetViewOffset(), GetAbsOrigin() + GetViewOffset() + gpGlobals->v_forward * 128, ignore_monsters, ENT( pev ), &tr ); if( tr.flFraction != 1.0 ) {// line hit something, so paint a decal m_flNextDecalTime = gpGlobals->time + decalfrequency.value; auto pCan = static_cast<CSprayCan*>( UTIL_CreateNamedEntity( "spray_can" ) ); pCan->CreateSprayCan( this ); } break; default: // check all of the cheat impulse commands now CheatImpulseCommands( iImpulse ); break; } SetImpulse( 0 ); }