Пример #1
0
int CHudHealth::Draw(float flTime)
{
	int r, g, b;
	int a = 0, x, y;
	int HealthWidth;

	if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
		return 1;

	if ( !m_HSPRITE )
		m_HSPRITE = LoadSprite(PAIN_NAME);
	
	// Has health changed? Flash the health #
	if (m_fFade)
	{
		m_fFade -= (gHUD.m_flTimeDelta * 20);
		if (m_fFade <= 0)
		{
			a = MIN_ALPHA;
			m_fFade = 0;
		}

		// Fade the health number back to dim

		a = MIN_ALPHA +  (m_fFade/FADE_TIME) * 128;

	}
	else
		a = MIN_ALPHA;

	// If health is getting low, make it bright red
	if (m_iHealth <= 15)
		a = 255;
		
	GetPainColor( r, g, b );
	ScaleColors(r, g, b, a );

	// Only draw health if we have the suit.
	if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
	{
		HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
		int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;

		y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
		x = CrossWidth /2;

		SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
		SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));

		x = CrossWidth + HealthWidth / 2;

		//x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
		gHUD.DrawHudNumber2( x, y, false, 3, m_iHealth, r, g, b);
	}

	DrawDamage(flTime);
	return DrawPain(flTime);
}
Пример #2
0
int CHudHealth::Draw(float flTime)
{
	int r = 0, g = 0, b = 0;
	int x = 0, y = 0;
	int iDraw = 0;

	if ( gHUD.m_iHideHUDDisplay & (HIDEHUD_ALL) )
		return 1;

	if(g_iTeamNumber == UNDEFINED || g_iTeamNumber == SPECS )
	{
		gHUD.m_iHideHUDDisplay |= HIDEHUD_HEALTH;
		return 1;
	}

	if(g_iUser1 != 0)
		return 1;

	m_flHealth = g_flHealth;

	if ( !m_hSprite )
		m_hSprite = LoadSprite(PAIN_NAME);

	//hocked on here as this is a good palce as they are related.
	if(IEngineStudio.IsHardware())
		iDraw = gBackground.Draw(flTime);

	if(iDraw == 0)
	{
		gHUD.m_iHideHUDDisplay |= HIDEHUD_HEALTH;
		return 1;
	}
	else
	{
		gHUD.m_iHideHUDDisplay &= ~HIDEHUD_HEALTH;
	}

	gStamina.Draw(flTime);

	if(ScreenWidth >= 640)
		gMiddle.Draw(flTime);
	gHintBox.Draw(flTime);

	UnpackRGB(r, g, b, RGB_WHITEISH);

	HSPRITE m_hSprite = gHUD.GetSprite( m_HUD_health );
	wrect_t *m_SpriteArea = &gHUD.GetSpriteRect( m_HUD_health );

	int x_length, y_length;      // positions of the spots

	y_length = gHUD.GetSpriteRect(m_HUD_health).bottom - gHUD.GetSpriteRect(m_HUD_health).top;
	x_length = gHUD.GetSpriteRect(m_HUD_health).right - gHUD.GetSpriteRect(m_HUD_health).left;

	if(ScreenWidth >= 640)
		x = 5;
	else
		x = 2;	

	y = (YRES(480) - (y_length + ((ScreenWidth >= 640) ? 5 : 3)));

	if(!IEngineStudio.IsHardware())
	{
		UnpackRGB(r, g, b, RGB_WHITEISH);
		gStamina.Draw(flTime);
			
		if(ScreenWidth >= 640)
			x = 5;
		else
			x = 2;	

		y = (YRES(480) - (20 + ((ScreenWidth >= 640) ? 5 : 3)));		

		gHUD.DrawHudNumber(x, y, DHN_2DIGITS | DHN_DRAWZERO, m_flHealth, r, g, b);
		return 1;
	}

	SPR_Set(m_hSprite, r, g, b);

	int iClipLevel = (y_length - ((m_flHealth * y_length) / MAX_HEALTH));
	//clipper starts at the clipping level. its height is the full amount of health take away the mamount clipped
	SPR_EnableScissor(x, y+iClipLevel, 24 , y_length-iClipLevel);
	SPR_DrawHoles(0, x, y, m_SpriteArea);
	SPR_DisableScissor();

	DrawDamage(flTime);
	return DrawPain(flTime);
}
Пример #3
0
int CHudHealth::Draw(float flTime)
{
	int r, g, b;
	int a = 0, x, y;
	int HealthWidth;

//	if (m_iHealth <= 0)
//		return 1;

	if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
		return 1;

	if ( !m_hSprite )
		m_hSprite = LoadSprite(PAIN_NAME);
	
	// Has health changed? Flash the health #
	if (m_fFade)
	{
		m_fFade -= (gHUD.m_flTimeDelta * 20);
		if (m_fFade <= 0)
		{
			a = MIN_ALPHA;
			m_fFade = 0;
		}

		// Fade the health number back to dim

		a = MIN_ALPHA +  (m_fFade/FADE_TIME) * 128;

	}
	else
		a = MIN_ALPHA;

	// If health is getting low, make it bright red
	if (m_iHealth <= 15)
		a = 255;
		
	GetPainColor( r, g, b );
	ScaleColors(r, g, b, a );

	// Only draw health if we have the suit.
	{
		HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
		int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;

		y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
		x = CrossWidth /2;

		SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
		SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));

		x = CrossWidth + HealthWidth / 2;

		x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);

		x += HealthWidth/2;

		int iHeight = gHUD.m_iFontHeight;
		int iWidth = HealthWidth/10;
		FillRGBA(x, y, iWidth, iHeight, 255, 160, 0, a);
	}

	DrawDamage(flTime);
	return DrawPain(flTime);
}