Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
// Purpose: Hide all the ASW hud in certain cases
//-----------------------------------------------------------------------------
bool CASW_HudElement::ShouldDraw( void )
{
	if (!CHudElement::ShouldDraw())
		return false;

	if (engine->IsLevelMainMenuBackground())
		return false;

	if (ASWGameRules())
	{
		if (ASWGameRules()->IsIntroMap() || ASWGameRules()->IsOutroMap())
			return false;
	}

	C_ASW_Player *pASWPlayer = C_ASW_Player::GetLocalASWPlayer();
	C_ASW_Marine *pMarine = pASWPlayer ? pASWPlayer->GetViewMarine() : NULL;
	// hide things due to turret control
	if ( ( m_iHiddenBits & HIDEHUD_REMOTE_TURRET ) && pMarine && pMarine->IsControllingTurret() )
		return false;
	if ( ( m_iHiddenBits & HIDEHUD_PLAYERDEAD ) && ( !pMarine || pMarine->GetHealth() <= 0 ) )
		return false;

	if ( !asw_draw_hud.GetBool() )
		return false;

	return true;
}
Ejemplo n.º 2
0
bool C_GameInstructor::Mod_HiddenByOtherElements( void )
{
	C_ASW_Marine *pLocalMarine = C_ASW_Marine::GetLocalMarine();
	if ( pLocalMarine && pLocalMarine->IsControllingTurret() )
	{
		return true;
	}

	return false;
}
Ejemplo n.º 3
0
void CASWHudCrosshair::GetCurrentPos( int &x, int &y )
{
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	C_ASW_Marine *pMarine = pPlayer->GetViewMarine();
	bool bControllingTurret = (pMarine && pMarine->IsControllingTurret());

	m_pTurretTextTopLeft->SetVisible( bControllingTurret );
	m_pTurretTextTopRight->SetVisible( bControllingTurret );
	m_pTurretTextTopLeftGlow->SetVisible( bControllingTurret );
	m_pTurretTextTopRightGlow->SetVisible( bControllingTurret );

	if ( !bControllingTurret )
	{
		ASWInput()->GetSimulatedFullscreenMousePos( &x, &y );
	}
	else
	{
		x = ScreenWidth() / 2;
		y = ScreenHeight() / 2;
	}
}
Ejemplo n.º 4
0
void CASWHudCrosshair::OnThink()
{
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( !pPlayer )
		return;

	PaintReloadProgressBar();

	C_ASW_Marine *pMarine = pPlayer->GetViewMarine();
	bool bControllingTurret = (pMarine && pMarine->IsControllingTurret());
	if (!bControllingTurret)
		return;

	C_ASW_Remote_Turret *pTurret = pMarine->GetRemoteTurret();
	if (!pTurret)
		return;

	Vector vecWeaponPos = pTurret->GetAbsOrigin();
	QAngle angWeapon = pTurret->EyeAngles();
	Vector vecWeaponDir;
	AngleVectors(angWeapon, &vecWeaponDir);

	// increase lock time of all targets and discard out of range/facing ones
	for (int k=0;k<ASW_MAX_TURRET_TARGETS;k++)
	{
		C_BaseEntity *pEnt = m_TurretTarget[k].Get();
		if (pEnt)
		{
			// validate the target
			bool bValid = true;
			Vector diff = pEnt->GetAbsOrigin() - vecWeaponPos;
			if (diff.Length() > ASW_TURRET_TARGET_RANGE || !pEnt->ShouldDraw())				
			{
				bValid = false;
			}
			else
			{
				diff.NormalizeInPlace();
				float flDot = diff.Dot(vecWeaponDir);
				if (flDot < asw_turret_dot.GetFloat())
					bValid = false;
					
			}
			// fade it in or out appropriately
			if (bValid)
			{
				if (m_fTurretTargetLock[k] < 1.0f)
				{
					m_fTurretTargetLock[k] += gpGlobals->frametime * 2;
					if (m_fTurretTargetLock[k] > 1.0f)
						m_fTurretTargetLock[k] = 1.0f;
				}
			}
			else
			{
				if (m_fTurretTargetLock[k] <= 0)
				{
					m_TurretTarget[k] = NULL;
				}
				else
				{
					m_fTurretTargetLock[k] -= gpGlobals->frametime * 2;
					if (m_fTurretTargetLock[k] < 0.0f)
						m_fTurretTargetLock[k] = 0.0f;
				}
			}
		}
	}

	// check for adding new targets to the array
	for ( int i = 0; i < IASW_Client_Aim_Target::AutoList().Count(); i++ )
	{
		IASW_Client_Aim_Target *pAimTarget = static_cast< IASW_Client_Aim_Target* >( IASW_Client_Aim_Target::AutoList()[ i ] );
		C_BaseEntity *pEnt = pAimTarget->GetEntity();
		if (!pEnt || !pAimTarget->IsAimTarget() || !pEnt->ShouldDraw())
			continue;
		
		// check he's in range
		Vector vecAlienPos = pEnt->WorldSpaceCenter();
		float flAlienDist = vecAlienPos.DistTo(vecWeaponPos);		
		if (flAlienDist > ASW_TURRET_TARGET_RANGE)
			continue;

		// check it's in front of us
		Vector dir = vecAlienPos - vecWeaponPos;
		dir.NormalizeInPlace();
		if (dir.Dot(vecWeaponDir) <= asw_turret_dot.GetFloat())
			continue;

		// we've got a possible target, add him to the list if he's not in there already
		bool bAlreadyInArray = false;
		int iSpace = -1;
		for (int k=0;k<ASW_MAX_TURRET_TARGETS;k++)
		{
			if (m_TurretTarget[k].Get() == pEnt)
			{
				bAlreadyInArray = true;
				break;
			}
			if (iSpace == -1 && m_TurretTarget[k].Get() == NULL)
				iSpace = k;
		}

		if (bAlreadyInArray)
			continue;

		if (iSpace != -1)
		{
			m_TurretTarget[iSpace] = pEnt;
			m_fTurretTargetLock[iSpace] = 0;
		}
	}
}
Ejemplo n.º 5
0
void CASWHudCrosshair::PaintTurretTextures()
{
	// draw border in centre of screen
	//int h = ScreenHeight();
	//int w = h * 1.333333f;
	//int x = (ScreenWidth() * 0.5f) - (w * 0.5f);
	//int y = 0;

	surface()->DrawSetColor(Color(255,255,255,255));

	/*
	int tx = YRES( 5 );
	int ty = YRES( 5 );
	vgui::surface()->DrawSetTextFont( m_hTurretFont );
	vgui::surface()->DrawSetTextColor( 255, 255, 255, 200 );
	vgui::surface()->DrawSetTextPos( tx, ty );

	int nFontTall = vgui::surface()->GetFontTall( m_hTurretFont );

	wchar_t szconverted[ 1024 ];
	g_pVGuiLocalize->ConvertANSIToUnicode( "#asw_turret_text_top_left", szconverted, sizeof( szconverted )  );
	vgui::surface()->DrawPrintText( szconverted, wcslen( szconverted ) );

	ty = ScreenHeight() - nFontTall * 8 - YRES( 100 );
	vgui::surface()->DrawSetTextPos( tx, ty );
	g_pVGuiLocalize->ConvertANSIToUnicode( "#asw_turret_text_lower_left", szconverted, sizeof( szconverted )  );
	vgui::surface()->DrawPrintText( szconverted, wcslen( szconverted ) );
	*/

	// draw black boxes either side
	//if (m_nBlackBarTexture != -1)
	//{
		//surface()->DrawSetTexture(m_nBlackBarTexture);
		//surface()->DrawTexturedRect(0, y, x, y + h);
		//surface()->DrawTexturedRect(x + w, y, x, y + h);
	//}

	// draw fancy brackets over all turret targets
	float fScale = (ScreenHeight() / 768.0f);
	int iBSize = fScale * 32.0f;
	for (int i=0;i<ASW_MAX_TURRET_TARGETS;i++)
	{
		C_BaseEntity *pEnt = m_TurretTarget[i];
		if (!pEnt)
			continue;

		// distance of each bracket part from the ent
		float fDist = fScale * 200.0f * (1.0f - m_fTurretTargetLock[i]);
		
		Vector pos = (pEnt->WorldSpaceCenter() - pEnt->GetAbsOrigin()) + pEnt->GetRenderOrigin();
		Vector screenPos;
		debugoverlay->ScreenPosition( pos, screenPos );
		surface()->DrawSetColor(Color(255,255,255,255.0f * m_fTurretTargetLock[i] ));

		surface()->DrawSetTexture(m_nLeftBracketTexture);
		int bx = screenPos[0] - fDist;
		int by = screenPos[1] - fDist;
		surface()->DrawTexturedRect(bx - iBSize, by - iBSize, bx + iBSize, by + iBSize);

		surface()->DrawSetTexture(m_nRightBracketTexture);
		bx = screenPos[0] + fDist;
		by = screenPos[1] - fDist;
		surface()->DrawTexturedRect(bx - iBSize, by - iBSize, bx + iBSize, by + iBSize);

		surface()->DrawSetTexture(m_nLowerBracketTexture);
		bx = screenPos[0];
		by = screenPos[1] + fDist;
		surface()->DrawTexturedRect(bx - iBSize, by - iBSize, bx + iBSize, by + iBSize);
	}

	// draw crosshair
	C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
	if ( pPlayer )
	{
		C_ASW_Marine *pMarine = pPlayer->GetViewMarine();
		bool bControllingTurret = (pMarine && pMarine->IsControllingTurret());
		if (bControllingTurret)
		{
			C_ASW_Remote_Turret *pTurret = pMarine->GetRemoteTurret();
			if (pTurret)
			{
				Vector vecWeaponSrc = pTurret->GetTurretMuzzlePosition();
				QAngle angFacing = pTurret->EyeAngles();
				Vector vecWeaponDir;
				AngleVectors(angFacing, &vecWeaponDir);

				// trace along until we hit something
				trace_t tr;
				UTIL_TraceLine(vecWeaponSrc, vecWeaponSrc + vecWeaponDir * 1200,	// fog range of the turret
					MASK_SHOT, pTurret, COLLISION_GROUP_NONE, &tr);
				//Msg("Tracing from %s ", VecToString(vecWeaponSrc));
				//Msg("at angle %s\n", VecToString(angFacing));
				
				Vector pos = tr.DidHit() ? tr.endpos : vecWeaponSrc + vecWeaponDir * 1200;
				Vector screenPos;
				debugoverlay->ScreenPosition( pos, screenPos );

				// paint a crosshair at that spot
				surface()->DrawSetColor(Color(255,255,255,255));
				surface()->DrawSetTexture(m_nTurretCrosshair);
				surface()->DrawTexturedRect(screenPos[0] - iBSize, screenPos[1] - iBSize,	// shift it up a bit to match where the gun actually fires (not sure why it's not matched already!)
											screenPos[0] + iBSize, screenPos[1] + iBSize);
			}
		}
	}

	// draw interlace/noise overlay
	if (m_nTurretTexture!=-1)
	{
		surface()->DrawSetColor(Color(255,255,255,255));
		surface()->DrawSetTexture(m_nTurretTexture);
		surface()->DrawTexturedRect(0, 0, ScreenWidth(), ScreenHeight());
	}
}
Ejemplo n.º 6
0
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);
	}
}