//----------------------------------------------------------------------------- // Purpose: Draw the weapon's crosshair //----------------------------------------------------------------------------- void C_ObjectBaseMannedGun::DrawCrosshair() { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( !player ) return; CHudCrosshair *crosshair = (CHudCrosshair *)GET_HUDELEMENT( CHudCrosshair ); if ( !crosshair ) return; if ( iconCrosshair ) { crosshair->SetCrosshair( iconCrosshair, gHUD.m_clrNormal ); } else { static wrect_t nullrc; crosshair->SetCrosshair( 0, Color( 255, 255, 255, 255 ) ); } }
//----------------------------------------------------------------------------- // Purpose: Set a crosshair when in a vehicle and we don't have a proper // crosshair sprite (ie. a commando laser rifle). //----------------------------------------------------------------------------- void CBaseTFVehicle::SetupCrosshair( void ) { if ( !m_pIconDefaultCrosshair ) { // Init the default crosshair the first time. CHudTexture newTexture; Q_strncpy( newTexture.szTextureFile, "sprites/crosshairs", sizeof( newTexture.szTextureFile ) ); newTexture.rc.left = 0; newTexture.rc.top = 48; newTexture.rc.right = newTexture.rc.left + 24; newTexture.rc.bottom = newTexture.rc.top + 24; m_pIconDefaultCrosshair = gHUD.AddUnsearchableHudIconToList( newTexture ); } CHudCrosshair *crosshair = GET_HUDELEMENT( CHudCrosshair ); if ( crosshair ) { if ( !crosshair->HasCrosshair() && m_pIconDefaultCrosshair ) { crosshair->SetCrosshair( m_pIconDefaultCrosshair, gHUD.m_clrNormal ); } } }
//----------------------------------------------------------------------------- // Purpose: Draw the weapon's crosshair //----------------------------------------------------------------------------- void C_BaseCombatWeapon::DrawCrosshair() { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( !player ) return; Color clr = gHUD.m_clrNormal; /* // TEST: if the thing under your crosshair is on a different team, light the crosshair with a different color. Vector vShootPos, vShootAngles; GetShootPosition( vShootPos, vShootAngles ); Vector vForward; AngleVectors( vShootAngles, &vForward ); // Change the color depending on if we're looking at a friend or an enemy. CPartitionFilterListMask filter( PARTITION_ALL_CLIENT_EDICTS ); trace_t tr; traceline->TraceLine( vShootPos, vShootPos + vForward * 10000, COLLISION_GROUP_NONE, MASK_SHOT, &tr, true, ~0, &filter ); if ( tr.index != 0 && tr.index != INVALID_CLIENTENTITY_HANDLE ) { C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( tr.index ); if ( pEnt ) { if ( pEnt->GetTeamNumber() != player->GetTeamNumber() ) { g = b = 0; } } } */ CHudCrosshair *crosshair = GET_HUDELEMENT( CHudCrosshair ); if ( !crosshair ) return; // Find out if this weapon's auto-aimed onto a target bool bOnTarget = ( m_iState == WEAPON_IS_ONTARGET ); if ( player->GetFOV() >= 90 ) { // normal crosshairs if ( bOnTarget && GetWpnData().iconAutoaim ) { clr[3] = 255; crosshair->SetCrosshair( GetWpnData().iconAutoaim, clr ); } else if ( GetWpnData().iconCrosshair ) { clr[3] = 255; crosshair->SetCrosshair( GetWpnData().iconCrosshair, clr ); } else { crosshair->ResetCrosshair(); } } else { Color white( 255, 255, 255, 255 ); // zoomed crosshairs if (bOnTarget && GetWpnData().iconZoomedAutoaim) crosshair->SetCrosshair(GetWpnData().iconZoomedAutoaim, white); else if ( GetWpnData().iconZoomedCrosshair ) crosshair->SetCrosshair( GetWpnData().iconZoomedCrosshair, white ); else crosshair->ResetCrosshair(); } }