Ejemplo n.º 1
0
void CASW_Weapon_Sniper_Rifle::UpdateDynamicLight()
{
	// DLIGHT disabled, since it looks bad
	return;

	C_ASW_Marine *pMarine =GetMarine();
	C_ASW_Player *pPlayer = pMarine ? pMarine->GetCommander() : NULL;
	
	if ( !pMarine || pMarine->GetActiveWeapon() != this || !pPlayer || !pMarine->IsInhabited() || !pPlayer->IsLocalPlayer() )
	{
		if (m_pSniperDynamicLight)
		{			
			m_pSniperDynamicLight->die = gpGlobals->curtime + 0.001;
			m_pSniperDynamicLight = NULL;
		}
		return;
	}

	if ( !m_pSniperDynamicLight || (m_pSniperDynamicLight->key != index) )
	{
		m_pSniperDynamicLight = effects->CL_AllocDlight ( index );
	}

	//m_fAmbientLight = asw_flashlight_marine_ambient.GetFloat();
	//m_fLightingScale = asw_flashlight_marine_lightscale.GetFloat();

	Vector vecForward, vecRight, vecUp;

	if (m_pSniperDynamicLight)
	{
		AngleVectors( GetLocalAngles(), &vecForward, &vecRight, &vecUp );
		m_pSniperDynamicLight->origin = pPlayer->GetCrosshairTracePos() + Vector( 0, 0, 10 );	
		Msg( "crosshair trace pos is %f %f %f\n", VectorExpand( pPlayer->GetCrosshairTracePos() ) );
		debugoverlay->AddTextOverlay( m_pSniperDynamicLight->origin, 0.01f, "Light" );
		m_pSniperDynamicLight->color.r = asw_sniper_dlight_r.GetInt();
		m_pSniperDynamicLight->color.g = asw_sniper_dlight_g.GetInt();
		m_pSniperDynamicLight->color.b = asw_sniper_dlight_b.GetInt();
		m_pSniperDynamicLight->radius = asw_sniper_dlight_radius.GetFloat();
		m_pSniperDynamicLight->color.exponent = asw_sniper_dlight_exponent.GetFloat();
		//m_pSniperDynamicLight->decay = 0;
		m_pSniperDynamicLight->die = gpGlobals->curtime + 30.0f;
	}
}
Ejemplo n.º 2
0
void asw_weapon_switch_f()
{
	C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

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

	C_BaseCombatWeapon *pCurrent = pMarine->GetActiveWeapon();
	C_BaseCombatWeapon *pPrimary = pMarine->GetWeapon( ASW_INVENTORY_SLOT_PRIMARY );
	if ( pCurrent != pPrimary && pPrimary )
	{
		::input->MakeWeaponSelection( pPrimary );
	}
	C_BaseCombatWeapon *pSecondary = pMarine->GetWeapon( ASW_INVENTORY_SLOT_SECONDARY );
	if ( pCurrent != pSecondary && pSecondary )
	{
		::input->MakeWeaponSelection( pSecondary );
	}
}
Ejemplo n.º 3
0
void CASWHudWeapons::Paint()
{
	VPROF_BUDGET( "CASWHudWeapons::Paint", VPROF_BUDGETGROUP_ASW_CLIENT );
	GetSize(m_iFrameWidth,m_iFrameHeight);
	BaseClass::Paint();

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

	C_ASW_Marine *pMarine = pPlayer->GetMarine();
	if (!pMarine)
		return;		
	char cbuffer[64];

	if ( !m_hUseArea.Get() )
	{
		m_hUseArea = ( CASWHudUseArea * )GET_HUDELEMENT( CASWHudUseArea );
	}

	ASWUseAction* pUseAction = NULL;
	if ( m_hUseArea.Get() && m_hUseArea->m_pUseIcon )
	{
		pUseAction = m_hUseArea->m_pUseIcon->GetCurrentUseAction();
	}
	
	int r, g, b;
	
	int tall = m_iFrameHeight * 0.25f * asw_hud_scale.GetFloat();	// how tall to draw the weapon icons
	int spacing_y = tall * 0.7f;
	int nWeaponsToShow = asw_hotbar_self.GetBool() ? ASW_NUM_INVENTORY_SLOTS - 1 : ASW_NUM_INVENTORY_SLOTS;
	bool bPowOnWeapon = false;
	for ( int k = 0; k < nWeaponsToShow; k++ )
	{
		C_ASW_Weapon* pWeapon = pMarine->GetASWWeapon(k);
		// set draw color
		bool bActiveWeapon = (pWeapon && pWeapon == pMarine->GetActiveWeapon());
		if ( bActiveWeapon )
		{
			r = 255;
			g = 255;
			b = 255;
		}
		else
		{
			r = 66;	// light blue
			g = 142;
			b = 192;
		}
		
		if (asw_debug_hud.GetInt()!=0)
		{
			if (pWeapon)
			{
				Q_snprintf(cbuffer, sizeof(cbuffer), "%d:%s %d(%d)", k, pWeapon->GetClassname(),
					pWeapon->GetEffects(), pWeapon->IsEffectActive(EF_NODRAW));
			}
			else
			{
				b = 255;
				Q_snprintf(cbuffer, sizeof(cbuffer), "%d:Empty", k);
			}		
			g_pMatSystemSurface->DrawColoredText(m_hWeaponHUDFont, 0, k*tall, r, g, 
				b, 200, &cbuffer[0]);
		}

		// draw icon
		if (pWeapon && ASWEquipmentList())
		{
			int list_index = pWeapon->GetEquipmentListIndex();
			int iTexture = ASWEquipmentList()->GetEquipIconTexture(!pWeapon->GetWeaponInfo()->m_bExtra, list_index);
			if (iTexture != -1)
			{				
				surface()->DrawSetColor(Color(r,g,b,255));
				surface()->DrawSetTexture(iTexture);

				int icon_x_offset = pWeapon->GetWeaponInfo()->m_iHUDIconOffsetX * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
				int icon_y_offset = pWeapon->GetWeaponInfo()->m_iHUDIconOffsetY * (m_iFrameHeight / 160.0f) * asw_hud_scale.GetFloat();
				int text_x_offset = pWeapon->GetWeaponInfo()->m_iHUDNumberOffsetX * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
				int text_y_offset = pWeapon->GetWeaponInfo()->m_iHUDNumberOffsetY * (m_iFrameHeight / 160.0f) * asw_hud_scale.GetFloat();

				// drop shadow
				/*
				surface()->DrawSetColor(Color(0,0,0,255));
				if (pWeapon->GetWeaponInfo()->m_bExtra)
					surface()->DrawTexturedRect(icon_x_offset + 1, k*spacing_y + 1 + icon_y_offset,
												icon_x_offset + 1 + tall, k*spacing_y + tall + 1 + icon_y_offset);
				else
					surface()->DrawTexturedRect(icon_x_offset + 1, k*spacing_y + 1 + icon_y_offset,
												icon_x_offset + 1 + tall * 2, k*spacing_y + tall + 1 + icon_y_offset);
				*/

				//todo: set glow vars to make the weapon glow when it's currently selected
				/*
				bool foundVar;
				MaterialVar* pTextureVar = pMaterial->FindVar( "$basetexture", &foundVar, false );
				if (foundVar)
				{
					if ( bActiveWeapon )
					{

					}
					else
					{

					}
				}
				*/

				surface()->DrawSetColor(Color(r,g,b,255));
				if ( pWeapon->GetWeaponInfo()->m_bExtra )
				{
					surface()->DrawTexturedRect(icon_x_offset, k*spacing_y + icon_y_offset,
												icon_x_offset + tall, k*spacing_y + tall + icon_y_offset);
				}
				else
				{
					surface()->DrawTexturedRect(icon_x_offset, k*spacing_y + icon_y_offset,
												icon_x_offset + tall * 2, k*spacing_y + tall + icon_y_offset);
				}

				pWeaponPos[ k ]->SetBounds( icon_x_offset, k * spacing_y + icon_y_offset, tall * 2, tall );

				if ( pWeapon->m_bPoweredUp )
				{
					int iPowBuffer = m_iFrameHeight/20;
					m_pPowerups->SetBounds(icon_x_offset + (tall*2) + iPowBuffer, (k * spacing_y + icon_y_offset) + iPowBuffer, (tall*2), tall - (iPowBuffer*2));
					bPowOnWeapon = true;
				}

				// show charges?
				if (pWeapon->GetWeaponInfo()->m_bShowCharges)
				{
					Q_snprintf(cbuffer, sizeof(cbuffer), "%d", pWeapon->GetChargesForHUD() );
					g_pMatSystemSurface->DrawColoredText(m_hWeaponHUDFont, text_x_offset, 
						k*spacing_y + text_y_offset, r, g, 	b, 200, &cbuffer[0]); 
				}
				// show weapon swaps
				if ( asw_hud_swaps.GetBool() && pUseAction && pUseAction->iInventorySlot == k )
				{
					const CASW_WeaponInfo* pWeaponData = NULL;
					const char *szWeaponClass = NULL;
					C_ASW_Pickup_Weapon *pPickup = dynamic_cast<C_ASW_Pickup_Weapon*>( pUseAction->UseTarget.Get());
					if ( pPickup )
					{
						pWeaponData = ASWEquipmentList()->GetWeaponDataFor( pPickup->GetWeaponClass() );
						szWeaponClass = pPickup->GetWeaponClass();
					}
					else
					{
						C_ASW_Weapon *pWeapon = dynamic_cast<C_ASW_Weapon*>( pUseAction->UseTarget.Get() );
						if ( pWeapon )
						{
							pWeaponData = pWeapon->GetWeaponInfo();
							szWeaponClass = pWeapon->GetClassname();
						}
					}
					if ( pWeaponData )
					{
						int iEquipListIndex = pWeaponData->m_bExtra ? ASWEquipmentList()->GetExtraIndex( szWeaponClass )
							: ASWEquipmentList()->GetRegularIndex( szWeaponClass );
						int iSwapWeaponTexture = ASWEquipmentList()->GetEquipIconTexture( !pWeaponData->m_bExtra, iEquipListIndex );
						if ( m_nSwapArrowTexture != -1 && iSwapWeaponTexture != -1 )
						{
							surface()->DrawSetColor( Color( r,g,b,m_hUseArea->m_pUseIcon->m_pUseText->GetAlpha() ) );	// fade in along with the use icon
							icon_x_offset = tall * 2.0f;
							icon_y_offset = 0;
							surface()->DrawSetTexture( m_nSwapArrowTexture );
							surface()->DrawTexturedRect( icon_x_offset, k*spacing_y + icon_y_offset,
								icon_x_offset + tall, k*spacing_y + tall + icon_y_offset );

							icon_x_offset = tall * 3.0f + pWeaponData->m_iHUDIconOffsetX;
							icon_y_offset = pWeaponData->m_iHUDIconOffsetY;
							surface()->DrawSetTexture( iSwapWeaponTexture );
							surface()->DrawTexturedRect( icon_x_offset, k*spacing_y + icon_y_offset,
								icon_x_offset + ( pWeaponData->m_bExtra ? tall : tall * 2.0f ) , k*spacing_y + tall + icon_y_offset );
						}
					}
				}
			}
		}		
	}

	if ( !bPowOnWeapon )
	{
		//int iPowBuffer = m_iFrameHeight/20;
		int xpos = 12 * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
		//int ypos = 2 * (m_iFrameWidth / 160.0f) * asw_hud_scale.GetFloat();
		m_pPowerups->SetBounds(xpos, (spacing_y*nWeaponsToShow) + (spacing_y/3), tall, tall*0.75f );
	}
}