Beispiel #1
0
void C_ASW_Alien::ClientThink()
{
	BaseClass::ClientThink();

	// asw temp fix demo playback 
	//ASWUpdateClientSideAnimation();

	m_vecLastRenderedPos = WorldSpaceCenter();
	m_vecAutoTargetRadiusPos = GetLocalAutoTargetRadiusPos();

	if ( GetHealth() > 0 && m_bElectroStunned && m_fNextElectroStunEffect <= gpGlobals->curtime)
	{
		// apply electro stun effect
		HACK_GETLOCALPLAYER_GUARD( "C_ASW_Alien::ClientThink FX_ElectroStun" );
		FX_ElectroStun(this);
		m_fNextElectroStunEffect = gpGlobals->curtime + RandomFloat( 0.3, 1.0 );
		//Msg( "%f - ElectroStunEffect\n", gpGlobals->curtime );
	}

	UpdateFireEmitters();

	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pPlayer && pPlayer->IsSniperScopeActive() )
	{
		m_GlowObject.SetRenderFlags( true, true );
	}
	else
	{
		m_GlowObject.SetRenderFlags( false, false );
	}
}
void CASWNightVisionSelfIllumProxy::OnBind( void *pC_BaseEntity )
{
	Assert( m_pResult );
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer || !pC_BaseEntity )
	{
		SetFloatResult( 0.0f );
		return;
	}

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if ( !pMarine )
	{
		SetFloatResult( 0.0f );
		return;
	}

	if ( C_JaS_Alien_Controller::AutoList().Count() )
	{
		C_JaS_Alien_Controller *pAlienController = dynamic_cast<C_JaS_Alien_Controller *>( C_JaS_Alien_Controller::AutoList().Head()->GetEntity() );
		if ( pAlienController->m_hBuzzerOverride )
		{
			SetFloatResult( 255.0f );
			return;
		}
	}

	C_BaseCombatWeapon*	pExtraItem = pMarine->GetWeapon( 2 );
	if ( pExtraItem && pExtraItem->Classify() == CLASS_ASW_NIGHT_VISION )
	{
		C_ASW_Weapon_Night_Vision *pVision = assert_cast<CASW_Weapon_Night_Vision*>( pExtraItem );
		float flVisionAlpha = pVision->m_flVisionAlpha;
		if ( flVisionAlpha != 0.0f )
		{
			SetFloatResult( flVisionAlpha / 255.0f * asw_night_vision_self_illum_multiplier.GetFloat() );
			return;
		}
	}

	if ( pPlayer->IsSniperScopeActive() && g_bRenderingGlows )
	{
		SetFloatResult( asw_sniper_scope_self_illum_multiplier.GetFloat() );
		return;
	}

	SetFloatResult( 0.0f );
}
void C_ASW_Buzzer::ClientThink()
{
	BaseClass::ClientThink();

	if (m_bElectroStunned && m_fNextElectroStunEffect <= gpGlobals->curtime)
	{
		// apply electro stun effect
		FX_ElectroStun(this);
		m_fNextElectroStunEffect = gpGlobals->curtime + RandomFloat( 0.2, 0.7 );
	}

	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pPlayer && pPlayer->IsSniperScopeActive() )
	{
		m_GlowObject.SetRenderFlags( true, true );
	}
	else
	{
		m_GlowObject.SetRenderFlags( false, false );
	}
}
void CASWHudCrosshair::PaintReloadProgressBar( void )
{
	if ( !engine->IsActiveApp() )
	{
		m_pAmmoProgress->SetVisible( false );
		m_pFastReloadBar->SetVisible( false );
		return;
	}

	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine* pMarine = pPlayer->GetMarine();
	if ( !pMarine )
		return;

	C_ASW_Weapon* pWeapon = pMarine->GetActiveASWWeapon();
	if ( !pWeapon || !asw_crosshair_use_perspective.GetBool() )
	{
		m_pAmmoProgress->SetVisible( false );
		m_pFastReloadBar->SetVisible( false );
		return;
	}

	int x, y;
	GetCurrentPos( x, y );
	int nCrosshair = GetCurrentCrosshair( x, y );

	if ( pWeapon && pWeapon->IsReloading() )
	{	
		m_bIsReloading = true;

		float flProgress = 0.0;

		float fStart = pWeapon->m_fReloadStart;
		float fNext = pWeapon->m_flNextPrimaryAttack;
		float fTotalTime = fNext - fStart;
		if (fTotalTime <= 0)
			fTotalTime = 0.1f;

		// if we're in single player, the progress code in the weapon doesn't run on the client because we aren't predicting
		if ( !cl_predict->GetInt() )
			flProgress = RescaleProgessForArt( (gpGlobals->curtime - fStart) / fTotalTime );
		else
			flProgress = RescaleProgessForArt( pWeapon->m_fReloadProgress );

		if ((int(gpGlobals->curtime*10) % 2) == 0)
			m_pAmmoProgress->SetFgColor( Color( 215, 205, 80, 255) );
		else
			m_pAmmoProgress->SetFgColor( Color( 175, 80, 80, 255) );

		if ( asw_fast_reload_enabled.GetBool() )
		{
			m_pFastReloadBar->SetFgColor( Color( 235, 235, 235, 100) );
			m_pFastReloadBar->SetBgColor( Color( 0, 0, 0, 0 ) );
			// fractions of ammo wide for fast reload start/end
			float fFastStart = RescaleProgessForArt( (pWeapon->m_fFastReloadStart - fStart) / fTotalTime );
			float fFastEnd = RescaleProgessForArt( (pWeapon->m_fFastReloadEnd - fStart) / fTotalTime );
			m_pFastReloadBar->SetStartProgress( fFastStart );
			m_pFastReloadBar->SetProgress( fFastEnd );
			m_pFastReloadBar->SetVisible( true );
		}

		m_pAmmoProgress->SetProgress( flProgress );
		m_pAmmoProgress->SetAlpha( 255 );
		m_pAmmoProgress->SetBgColor( Color( 100, 100, 100, 160*m_pAmmoProgress->GetScale() ) );
		m_pAmmoProgress->SetVisible( true );
	}
	/*else if ( m_bIsReloading )
	{
		m_bIsReloading = false;
		m_pAmmoProgress->SetFgColor( Color( 200, 200, 200, 255 ) );
		m_pAmmoProgress->SetProgress( 1.0 );
		vgui::GetAnimationController()->RunAnimationCommand( m_pAmmoProgress, "alpha",	0,		0, 0.5f, vgui::AnimationController::INTERPOLATOR_ACCEL );
	}
	*/
	else
	{
		float flScale = m_pAmmoProgress->GetScale();
		m_bIsReloading = false;
		m_pAmmoProgress->SetFgColor( Color( 220, 220, 220, 140*flScale ) );
		m_pFastReloadBar->SetVisible( false );

		int	nClip1 = pWeapon->Clip1();
		if ( nClip1 < 0 )
		{
			m_pAmmoProgress->SetVisible( false );
			return;
		}

		float flProgress = RescaleProgessForArt( float(nClip1) / float(pWeapon->GetMaxClip1()) ); 

		m_pAmmoProgress->SetProgress( flProgress );
		if ( flProgress < 0.25 && (int(gpGlobals->curtime*10) % 2) == 0 )
		{
			m_pAmmoProgress->SetBgColor( Color( 130, 90, 50, 160*flScale ) );
		}
		else
		{
			m_pAmmoProgress->SetBgColor( Color( 80, 80, 80, 130*flScale ) );
		}

		m_pAmmoProgress->SetVisible( !pPlayer->IsSniperScopeActive() && nCrosshair == m_nCrosshairTexture );
	}
};
void CASWHudCrosshair::Paint( void )
{
	VPROF_BUDGET( "CASWHudCrosshair::Paint", VPROF_BUDGETGROUP_ASW_CLIENT );
	if ( !crosshair.GetBool() )
		return;

	if ( engine->IsDrawingLoadingImage() || engine->IsPaused() || !engine->IsActiveApp() )
		return;
	
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	if ( pPlayer->GetFlags() & FL_FROZEN )
		return;

	if ( pPlayer->entindex() != render->GetViewEntity() )
		return;

	m_curViewAngles = CurrentViewAngles();
	m_curViewOrigin = CurrentViewOrigin();

	C_ASW_Marine *pMarine = pPlayer->GetViewMarine();
	bool bControllingTurret = (pMarine && pMarine->IsControllingTurret());
	if ( bControllingTurret )
	{
		PaintTurretTextures();
		return;	// don't draw the normal cross hair in addition
	}

	int x, y;
	GetCurrentPos( x, y );

	int nCrosshair = GetCurrentCrosshair( x, y );

	if ( nCrosshair == m_nCrosshairTexture )
	{
		if ( pPlayer->IsSniperScopeActive() )
		{
			DrawSniperScope( x, y );
		}
		else
		{
			if ( pPlayer->GetASWControls() != 1 )
				return;
			DrawDirectionalCrosshair( x, y, YRES( asw_crosshair_progress_size.GetInt() ) );
		}
	}
	else if ( nCrosshair != -1 )
	{
		const float fCrosshairScale = 1.0f;
		int w = YRES( 20 ) * fCrosshairScale;
		int h = YRES( 20 ) * fCrosshairScale;
		surface()->DrawSetColor( m_clrCrosshair );
		surface()->DrawSetTexture( nCrosshair );
		surface()->DrawTexturedRect( x - w, y - h, x + w, y + h );
	}

	// icons attached to the cursor
	x += 32; y += 16;	// move them down and to the right a bit
	if ( m_bShowGiveAmmo )
	{
		// todo: this text should in the ammo report tooltip?
		const wchar_t *ammoName = g_pVGuiLocalize->Find(GetAmmoName(m_iShowGiveAmmoType));
		DrawAttachedIcon(m_nGiveAmmoTexture, x, y, ammoName);
	}
	else if (m_bShowGiveHealth)
	{
		DrawAttachedIcon(m_nGiveHealthTexture, x, y);
	}
}