void CASWInput::SetMouseOverEntity( C_BaseEntity* pEnt ) { // highlight the next entity m_hMouseOverEntity = pEnt; //m_MouseOverGlowObject.SetEntity( pEnt ); if ( !pEnt ) return; C_ASW_Marine *pOtherMarine = C_ASW_Marine::AsMarine( pEnt ); if ( pOtherMarine ) return; C_ASW_Player *pPlayer = C_ASW_Player::GetLocalASWPlayer(); C_ASW_Marine *pMarine = pPlayer ? pPlayer->GetMarine() : NULL; if ( !pMarine ) return; IASW_Client_Aim_Target* pAimEnt = dynamic_cast<IASW_Client_Aim_Target*>( pEnt ); if ( pAimEnt ) { // check we have LOS to the target CTraceFilterLOS traceFilter( pMarine, COLLISION_GROUP_NONE ); trace_t tr2; Vector vecWeaponPos = pMarine->GetRenderOrigin() + Vector( 0,0, ASW_MARINE_GUN_OFFSET_Z ); UTIL_TraceLine( vecWeaponPos, pAimEnt->GetAimTargetRadiusPos( vecWeaponPos ), MASK_OPAQUE, &traceFilter, &tr2 ); //C_BaseEntity *pEnt = pAimEnt->GetEntity(); //bool bHasLOS = (!tr2.startsolid && (tr2.fraction >= 1.0 || tr2.m_pEnt == pEnt)); // we can't shoot it, so skip it // if ( bHasLOS ) // { // m_MouseOverGlowObject.SetRenderFlags( true, true ); // m_MouseOverGlowObject.SetColor( Vector( 0.65f, 0.45f, 0.15f ) ); // m_MouseOverGlowObject.SetAlpha( 0.875f ); // } // else // { // m_MouseOverGlowObject.SetRenderFlags( true, true ); // m_MouseOverGlowObject.SetColor( Vector( 0.4f, 0.35f, 0.3f ) ); // m_MouseOverGlowObject.SetAlpha( 0.8f ); // } } }
void CASWHudCrosshair::DrawDirectionalCrosshair( int x, int y, int iSize ) { C_ASW_Player *local = C_ASW_Player::GetLocalASWPlayer(); if (!local) return; C_ASW_Marine *pMarine = local->GetMarine(); if (!pMarine) return; Vector MarinePos = pMarine->GetRenderOrigin(); Vector screenPos; debugoverlay->ScreenPosition( MarinePos + Vector( 0, 0, 45 ), screenPos ); int cx, cy, dx, dy; ASWInput()->ASW_GetWindowCenter(cx, cy); dx = x - cx; dy = y - cy; float flDistance = FastSqrt( dx * dx + dy * dy ); //CASWScriptCreatedItem *pItem = static_cast<CASWScriptCreatedItem*>( pMarine->GetActiveASWWeapon()->GetAttributeContainer()->GetItem() ); //if ( !m_bIsCastingSuitAbility )//pItem && pItem->IsMeleeWeapon() && //{ // here is where we do the crosshair scaling int iMax = YRES(54); int iMin = YRES(16); // clamp the min and max distance the cursor is from the marine on screen float flSizeDist = clamp( flDistance, iMin, iMax ); // this is the full percentage to scale by float flTemp = (flSizeDist - iMin) / ( iMax - iMin ); float flMinTexScale = 0.8; float flMaxTexScale = 1.0; // this is the final percentage to scale by based on the clamping we want for the min and max texture scaling float flAdjust = flTemp * (flMaxTexScale - flMinTexScale) + flMinTexScale; iSize *= flAdjust; m_pAmmoProgress->SetScale( flAdjust ); //} iSize *= 2; int iXHairHalfSize = iSize / 2; // draw a red pointing, potentially blinking, arrow //Vector vecFacing(screenPos.x - (ScreenWidth() * 0.5f), screenPos.y - (ScreenHeight() * 0.5f), 0); //float fFacingYaw = -UTIL_VecToYaw(vecFacing); Vector2D vXHairCenter( x , y ); Vector vecCornerTL(-iXHairHalfSize, -iXHairHalfSize, 0); Vector vecCornerTR(iXHairHalfSize, -iXHairHalfSize, 0); Vector vecCornerBR(iXHairHalfSize, iXHairHalfSize, 0); Vector vecCornerBL(-iXHairHalfSize, iXHairHalfSize, 0); Vector vecCornerTL_rotated, vecCornerTR_rotated, vecCornerBL_rotated, vecCornerBR_rotated; int current_posx = 0; int current_posy = 0; ASWInput()->GetSimulatedFullscreenMousePos( ¤t_posx, ¤t_posy ); Vector vecFacing( 0, 0, 0 ); vecFacing.x = screenPos.x - current_posx; vecFacing.y = screenPos.y - current_posy; float fFacingYaw = -UTIL_VecToYaw( vecFacing ); /* if ( ASWInput()->ControllerModeActive() ) { int current_posx = 0; int current_posy = 0; ASWInput()->GetSimulatedFullscreenMousePos( ¤t_posx, ¤t_posy ); vecFacing.x = screenPos.x - current_posx; vecFacing.y = screenPos.y - current_posy; fFacingYaw = -UTIL_VecToYaw( vecFacing ); } */ // rotate it by our facing yaw QAngle angFacing(0, -fFacingYaw + 90.0, 0); VectorRotate(vecCornerTL, angFacing, vecCornerTL_rotated); VectorRotate(vecCornerTR, angFacing, vecCornerTR_rotated); VectorRotate(vecCornerBR, angFacing, vecCornerBR_rotated); VectorRotate(vecCornerBL, angFacing, vecCornerBL_rotated); // float flAlpha = 245; // fade the crosshair out when it is very close to the marine float flAdjust2 = flDistance / YRES(28); flAdjust2 = clamp( flAdjust2, 0.1f, 1.0f ); bool bShotWarn = false; Color colorCross = Color(255,255,255,flAlpha*flAdjust2); C_ASW_Weapon* pWeapon = pMarine->GetActiveASWWeapon(); if ( pWeapon && pWeapon->IsOffensiveWeapon() ) { C_BaseEntity *pEnt = pWeapon->GetLaserTargetEntity(); if ( pEnt && pEnt->Classify() == CLASS_ASW_MARINE ) { bShotWarn = true; colorCross = Color(255,0,0,flAlpha*flAdjust2); } } surface()->DrawSetColor( colorCross ); if ( !asw_crosshair_use_perspective.GetBool() ) { surface()->DrawSetTexture( m_nDirectCrosshairTexture2 ); } else { if ( bShotWarn ) surface()->DrawSetTexture( m_nDirectCrosshairTextureX ); else surface()->DrawSetTexture( m_nDirectCrosshairTexture ); } Vertex_t points[4] = { Vertex_t( Vector2D(vXHairCenter.x + vecCornerTL_rotated.x, vXHairCenter.y + vecCornerTL_rotated.y), Vector2D(0,0) ), Vertex_t( Vector2D(vXHairCenter.x + vecCornerTR_rotated.x, vXHairCenter.y + vecCornerTR_rotated.y), Vector2D(1,0) ), Vertex_t( Vector2D(vXHairCenter.x + vecCornerBR_rotated.x, vXHairCenter.y + vecCornerBR_rotated.y), Vector2D(1,1) ), Vertex_t( Vector2D(vXHairCenter.x + vecCornerBL_rotated.x, vXHairCenter.y + vecCornerBL_rotated.y), Vector2D(0,1) ) }; surface()->DrawTexturedPolygon( 4, points ); // draw the center if ( !asw_crosshair_use_perspective.GetBool() ) { surface()->DrawSetColor( colorCross ); surface()->DrawSetTexture( m_nCrosshairTexture ); surface()->DrawTexturedRect(vXHairCenter.x - iXHairHalfSize, vXHairCenter.y - iXHairHalfSize, vXHairCenter.x + iXHairHalfSize, vXHairCenter.y + iXHairHalfSize); } }