Пример #1
0
//-----------------------------------------------------------------------------
// Purpose: Player has chosen to draw the currently selected weapon
//-----------------------------------------------------------------------------
void CBaseHudWeaponSelection::SelectWeapon( void )
{
	if ( !GetSelectedWeapon() )
	{
		engine->ClientCmd( "cancelselect\n" );
		return;
	}

	C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
	if ( !player )
		return;

	// Don't allow selections of weapons that can't be selected (out of ammo, etc)
	if ( !GetSelectedWeapon()->CanBeSelected() )
	{
		player->EmitSound( "Player.DenyWeaponSelection" );
	}
	else
	{
		SetWeaponSelected();
	
		m_hSelectedWeapon = NULL;
	
		engine->ClientCmd( "cancelselect\n" );

		// Play the "weapon selected" sound
		player->EmitSound( "Player.WeaponSelected" );
	}
}
int	CTFFreezePanel::HudElementKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding )
{
	if ( ShouldDraw() && pszCurrentBinding )
	{
		if ( FStrEq( pszCurrentBinding, "screenshot" ) || FStrEq( pszCurrentBinding, "jpeg" ) )
		{
			// move the target id to the corner
			if ( m_pBasePanel )
			{
				int w, h;
				m_pBasePanel->GetSize( w, h );
				m_pBasePanel->SetPos( ScreenWidth() - w, ScreenHeight() - h );
			}

			// Get the local player.
			C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
			if ( pPlayer )
			{
				//Do effects
				g_flFreezeFlash = gpGlobals->curtime + 0.75f;
				pPlayer->EmitSound( "Camera.SnapShot" );

				//Extend Freezecam by a couple more seconds.
				engine->ClientCmd( "extendfreeze" );
				view->FreezeFrame( 3.0f );

				//Hide the reminder panel
				m_flShowSnapshotReminderAt = 0;
				ShowSnapshotPanel( false );

				m_bHoldingAfterScreenshot = true;

				//Set the screenshot name
				if ( m_iKillerIndex <= MAX_PLAYERS )
				{
					const char *pszKillerName = g_PR->GetPlayerName( m_iKillerIndex );

					if ( pszKillerName )
					{
						ConVarRef cl_screenshotname( "cl_screenshotname" );

						if ( cl_screenshotname.IsValid() )
						{
							char szScreenShotName[512];

							Q_snprintf( szScreenShotName, sizeof( szScreenShotName ), "%s %s", pszKillerName, FREEZECAM_SCREENSHOT_STRING );

							cl_screenshotname.SetValue( szScreenShotName );
						}
					}
				}
			}
		}
	}

	return 0;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_VoteController::FireGameEvent( IGameEvent *event )
{
	CHudVote *pHudVote = GET_HUDELEMENT( CHudVote );
	if ( pHudVote && pHudVote->IsVisible() )
	{
		const char *eventName = event->GetName();
		if ( !eventName )
			return;

		C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
		if ( !pLocalPlayer )
			return;

		int team = event->GetInt( "team", TEAM_UNASSIGNED );
		if ( team > TEAM_UNASSIGNED && team != pLocalPlayer->GetTeamNumber() )
			return;

		if ( FStrEq( eventName, "vote_cast" ) )
		{
			if ( m_bIsYesNoVote )
			{
				int vote_option = event->GetInt( "vote_option", TEAM_UNASSIGNED );
				if( vote_option == VOTE_OPTION2 )
				{
					pLocalPlayer->EmitSound( "Vote.Cast.No" );
				}
				else if( vote_option == VOTE_OPTION1 )
				{
					pLocalPlayer->EmitSound( "Vote.Cast.Yes" );
				}
			}
			else
			{
				pLocalPlayer->EmitSound( "Vote.Cast.Yes" );
			}
		}
	}
}
Пример #4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged(updateType);

	CHandle< C_BaseCombatWeapon > handle = this;

	// If it's being carried by the *local* player, on the first update,
	// find the registered weapon for this ID

	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	C_BaseCombatCharacter *pOwner = GetOwner();

	// check if weapon is carried by local player
	bool bIsLocalPlayer = pPlayer && pPlayer == pOwner;
	if ( bIsLocalPlayer && ShouldDrawLocalPlayerViewModel() )		// TODO: figure out the purpose of the ShouldDrawLocalPlayer() test.
	{
		// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
		if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) )
		{
			// Tell the HUD this weapon's been picked up
			if ( ShouldDrawPickup() )
			{
				CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection();
				if ( pHudSelection )
				{
					pHudSelection->OnWeaponPickup( this );
				}

				pPlayer->EmitSound( "Player.PickupWeapon" );
			}
		}
	}
	else // weapon carried by other player or not at all
	{
		int overrideModelIndex = CalcOverrideModelIndex();
		if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() )
		{
			SetModelIndex( overrideModelIndex );
		}
	}

	if ( updateType == DATA_UPDATE_CREATED )
	{
		UpdateVisibility();
	}

	m_iOldState = m_iState;

	m_bJustRestored = false;
}
Пример #5
0
//-----------------------------------------------------------------------------
// Purpose: Localize, display, and animate the hud element
//-----------------------------------------------------------------------------
void CHudSideHintPanel::LocalizeAndDisplay( const char *pszHudTxtMsg, const char *szRawString )
{
	static wchar_t szBuf[128];
	static wchar_t *pszBuf;

	// init buffers & pointers
	szBuf[0] = 0;
	pszBuf = szBuf;

	// try to localize
	if ( pszHudTxtMsg )
	{
		pszBuf = g_pVGuiLocalize->Find( pszHudTxtMsg );
	}
	else
	{
		pszBuf = g_pVGuiLocalize->Find( szRawString );
	}

	if ( !pszBuf )
	{
		// use plain ASCII string 
		g_pVGuiLocalize->ConvertANSIToUnicode( szRawString, szBuf, sizeof(szBuf) );
		pszBuf = szBuf;
	}

	// make it visible
	if ( SetHintText( pszBuf ) )
	{
		SetVisible( true );
		g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SideHintShow" ); 

		C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
		if ( pLocalPlayer )
		{
			pLocalPlayer->EmitSound( "Hud.Hint" );

			if ( pLocalPlayer->Hints() )
			{
				pLocalPlayer->Hints()->PlayedAHint();
			}
		}
	}
	else
	{
		g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SideHintHide" ); 
	}
}
Пример #6
0
//Overridden because we want the menu to stay up after selection
void CHudMenuStatic::SelectMenuItem(int menu_item)
{
    if (SelectFunc)
        SelectFunc(menu_item);

    m_flSelectionTime = gpGlobals->realtime;
    m_nSelectedItem = menu_item;
    g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuPulse");
    C_BasePlayer *cPlayer = C_BasePlayer::GetLocalPlayer();
    if (cPlayer != NULL)
    {
        cPlayer->EmitSound("Momentum.UIMenuSelection");
    }
    if (menu_item == 0)
        HideMenu();
}
Пример #7
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged(updateType);

	CHandle< C_BaseCombatWeapon > handle = this;

	// If it's being carried by the *local* player, on the first update,
	// find the registered weapon for this ID

	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	C_BaseCombatCharacter *pOwner = GetOwner();

	// check if weapon is carried by local player
	bool bIsLocalPlayer = pPlayer && pPlayer == pOwner;
	if ( bIsLocalPlayer && !ShouldDrawLocalPlayer() )
	{
		// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
		if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) )
		{
			// Tell the HUD this weapon's been picked up
			if ( ShouldDrawPickup() )
			{
				CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection();
				if ( pHudSelection )
				{
					pHudSelection->OnWeaponPickup( this );
				}

				pPlayer->EmitSound( "Player.PickupWeapon" );
			}
		}
	}
	else // weapon carried by other player or not at all
	{
		// BRJ 10/14/02
		// FIXME: Remove when Yahn's client-side prediction is done
		// It's a hacky workaround for the model indices fighting
		// (GetRenderBounds uses the model index, which is for the view model)
		SetModelIndex( GetWorldModelIndex() );
	}

	UpdateVisibility();

	m_iOldState = m_iState;

	m_bJustRestored = false;
}
//-----------------------------------------------------------------------------
// Purpose: Receive messages from the server
// Input  : classID - class to receive the message
//			&msg - message in question
//-----------------------------------------------------------------------------
void C_GrenadeHopwire::ReceiveMessage( int classID, bf_read &msg )
{
	if ( classID != GetClientClass()->m_ClassID )
	{
		// Message is for subclass
		BaseClass::ReceiveMessage( classID, msg );
		return;
	}

	int messageType = msg.ReadByte();
	switch( messageType )
	{
	case HOPWIRE_START_EXPLOSION:
		{
			m_ExplosionEffect.SetActive();
			m_ExplosionEffect.SetOwner( this );

#ifdef C17
			C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

			if (pPlayer)
			{
				//pPlayer->EmitSound( "Weapon_AR3.Geiger" );
				pPlayer->EmitSound("Weapon_AR3.BlackHole");
			}
			else
			{
				//No player?
				//Emit from the blackhole instead.
				//EmitSound( "Weapon_AR3.Geiger" );
				EmitSound("Weapon_AR3.BlackHole");
			}
#endif

			m_ExplosionEffect.StartExplosion();
		}
		break;
	case HOPWIRE_STOP_EXPLOSION:
		{
			m_ExplosionEffect.StopExplosion();
		}
		break;
	default:
		break;
	}
}
Пример #9
0
//====================================================================
// [Evento] Recibimos un método de un objeto
//====================================================================
void CBaseHTML::OnMethodCall( Awesomium::WebView* pCaller, unsigned int pObjectID, const Awesomium::WebString& pMethod, const Awesomium::JSArray& args )
{
	if ( pMethod == WSLit("emitSound") )
	{
		C_BasePlayer *pPlayer	= C_BasePlayer::GetLocalPlayer();
		const char *pSoundName	= ToString(args[0].ToString()).c_str();

		DevMsg("[AWE] Reproduciendo: %s \n", ToString(args[0].ToString()).c_str() );

		// Si el Juego ha iniciado podemos usar el método del Jugador
		if ( pPlayer )
		{
			pPlayer->EmitSound( pSoundName );
		}

		// De otra forma usamos el comando "play"
		// Ojo: Solo acepta rutas hacia archivos, no SoundScripts
		else
		{
			const char *pCommand = UTIL_VarArgs( "play %s", pSoundName );
			engine->ClientCmd_Unrestricted( pCommand );
		}
	}

	// Ejecutar comando
	if ( pMethod == WSLit("runCommand") )
	{
		engine->ClientCmd_Unrestricted( ToString(args[0].ToString()).c_str() );
		DevMsg("[GameUI] Ejecutando comando: %s \n", ToString(args[0].ToString()).c_str() );
	}

	// Recarga la página
	if ( pMethod == WSLit("reload") )
	{
		// Por ahora esta bien esto
		pCaller->ExecuteJavascript( WSLit("document.location.reload();"), WSLit("") );	
	}

	// Log
	if ( pMethod == WSLit("log") )
		Msg("[GameUI] %s \n", ToString(args[0].ToString()).c_str() );
	if ( pMethod == WSLit("warn") )
		Warning("[GameUI] %s \n", ToString(args[0].ToString()).c_str() );

	BaseClass::OnMethodCall( pCaller, pObjectID, pMethod, args );
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged(updateType);

	CHandle< C_BaseCombatWeapon > handle = this;

	// If it's being carried by the *local* player, on the first update,
	// find the registered weapon for this ID

	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	C_BaseCombatCharacter *pOwner = GetOwner();

	// check if weapon is carried by local player
	bool bIsLocalPlayer = pPlayer && pPlayer == pOwner;
	if ( bIsLocalPlayer && !ShouldDrawLocalPlayer() )
	{
		// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
		if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) )
		{
			// Tell the HUD this weapon's been picked up
			if ( ShouldDrawPickup() )
			{
				CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection();
				if ( pHudSelection )
				{
					pHudSelection->OnWeaponPickup( this );
				}

				pPlayer->EmitSound( "Player.PickupWeapon" );
			}
		}
	}
	else // weapon carried by other player or not at all
	{
		// See comment below
		EnsureCorrectRenderingModel();
	}

	UpdateVisibility();

	m_iOldState = m_iState;

	m_bJustRestored = false;
}
Пример #11
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
{
	BaseClass::OnDataChanged( updateType );

	// If it's being carried by the *local* player, on the first update,
	// find the registered weapon for this ID

	C_BaseCombatCharacter *pOwner = GetOwner();
	C_BasePlayer *pPlayer = ToBasePlayer( pOwner );

	// check if weapon is carried by local player
	bool bIsLocalPlayer = C_BasePlayer::IsLocalPlayer( pPlayer );
	if ( bIsLocalPlayer )
	{
		ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) );

		// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
		if ( ( m_iState != WEAPON_NOT_CARRIED ) && 
			 ( m_iOldState == WEAPON_NOT_CARRIED ) )
		{
			// Tell the HUD this weapon's been picked up
			if ( ShouldDrawPickup() )
			{
				CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection();
				if ( pHudSelection )
				{
					pHudSelection->OnWeaponPickup( this );
				}

				pPlayer->EmitSound( "Player.PickupWeapon" );
			}
		}
	}
	
	UpdateVisibility();

	m_iOldState = m_iState;

	m_bJustRestored = false;
}
Пример #12
0
//=========================================================
//=========================================================
void C_GameInstructor::PlaySound( const char *pchSoundName )
{
	// emit alert sound
	C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
 
	if ( pLocalPlayer )
	{
		// Local player exists
		if ( pchSoundName[ 0 ] != '\0' && Q_strcmp( m_szPreviousStartSound, pchSoundName ) != 0 )
		{
			Q_strcpy( m_szPreviousStartSound, pchSoundName );
			m_fNextStartSoundTime = 0.0f;
		}
 
		if ( gpGlobals->curtime >= m_fNextStartSoundTime && pchSoundName[ 0 ] != '\0' )
		{
			// A sound was specified, so play it!
			pLocalPlayer->EmitSound( pchSoundName );
			m_fNextStartSoundTime = gpGlobals->curtime + gameinstructor_start_sound_cooldown.GetFloat();
		}
	}
}
Пример #13
0
//-----------------------------------------------------------------------------
// Purpose: Abort selecting a weapon
//-----------------------------------------------------------------------------
void CBaseHudWeaponSelection::CancelWeaponSelection( void )
{
	C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
	if ( !player )
		return;

	// Fastswitches happen in a single frame, so the Weapon Selection HUD Element isn't visible
	// yet, but it's going to be next frame. We need to ask it if it thinks it's going to draw,
	// instead of checking it's IsActive flag.
	if ( ShouldDraw() )
	{
		HideSelection();

		m_hSelectedWeapon = NULL;

		// Play the "close weapon selection" sound
		player->EmitSound( "Player.WeaponSelectionClose" );
	}
	else
	{
		engine->ClientCmd("escape");
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTeamRoundTimer::SendTimeWarning( int nWarning )
{
	// don't play sounds if the level designer has turned them off or if it's during the WaitingForPlayers time
	if ( !m_bTimerPaused && m_bAutoCountdown && !TeamplayRoundBasedRules()->IsInWaitingForPlayers() )
	{
		C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
		if ( pPlayer )
		{
			if ( ObjectiveResource() )
			{
				bool bShouldPlaySound = false;

				if ( TeamplayRoundBasedRules()->IsInTournamentMode() == true && TeamplayRoundBasedRules()->IsInStopWatch() == true )
				{
					int iActiveTimer = ObjectiveResource()->GetTimerToShowInHUD();
					int iStopWatchTimer = ObjectiveResource()->GetStopWatchTimer();

					if ( IsStopWatchTimer() == true && IsWatchingTimeStamps() == false )
					{
						CTeamRoundTimer *pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( iActiveTimer ) );

						if ( pTimer && pTimer->IsTimerPaused() == false && pTimer->GetTimeRemaining() > GetTimeRemaining() )
						{
							bShouldPlaySound = true;
						}
					}
					else
					{
						CTeamRoundTimer *pStopWatch = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( iStopWatchTimer ) );

						if ( ObjectiveResource()->GetTimerToShowInHUD() == entindex()  )
						{
							if ( pStopWatch )
							{
								if ( pStopWatch->IsTimerPaused() == true )
								{
									bShouldPlaySound = true;
								}

								if ( pStopWatch->GetTimeRemaining() > GetTimeRemaining() && pStopWatch->IsWatchingTimeStamps() == false )
								{
									bShouldPlaySound = true;
								}

								if ( pStopWatch->IsWatchingTimeStamps() == true )
								{
									bShouldPlaySound = true;
								}
							}
							else
							{
								bShouldPlaySound = true;
							}
						}
					}
				}
				else 
				{
					if( ObjectiveResource()->GetTimerToShowInHUD() == entindex())
					{
						bShouldPlaySound = true;
					}
				}

				if ( bShouldPlaySound == true )
				{
					pPlayer->EmitSound( GetTimeWarningSound( nWarning ) );
				}
			}
		}
	}
}