Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- *
- * Copyright (c) 1999, Valve LLC. All rights reserved.
- *
- * This product contains software technology licensed from Id
- * Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
- * All Rights Reserved.
- *
- * Use, distribution, and modification of this source code and/or resulting
- * object code is restricted to non-commercial enhancements to products from
- * Valve LLC. All other use, distribution, or modification is prohibited
- * without written permission from Valve LLC.
- *
- ****/
- //
- // hud_overheat.cpp - Source of the CHudOverheat class.
- //
- #include "hud.h"
- #include "cl_util.h"
- #include "parsemsg.h"
- DECLARE_MESSAGE( m_Overheat, Overheat );
- int CHudOverheat::Init( void )
- {
- HOOK_MESSAGE( Overheat );
- m_iHeat = 0;
- m_iFlags |= HUD_ACTIVE;
- gHUD.AddHudElem( this );
- return 1;
- }
- int CHudOverheat::Draw( float flTime )
- {
- // Don't draw this HUD if the health is told to be hidden or we are in spectator mode
- if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
- return 1;
- // Don't draw this HUD if we don't have the HEV suit.
- if ( !(gHUD.m_iWeaponBits & (1 << WEAPON_SUIT)) )
- return 1;
- // Don't draw this HUD if we are using anything else than the MP5
- if ( !gHUD.m_Ammo.GetCurrentWeapon() || gHUD.m_Ammo.GetCurrentWeapon()->iId != 4 ) // 4 = WEAPON_MP5 - Look at "weapons.h" for the proper value
- return 1;
- if ( m_iHeat > 0 )
- {
- int iWidth = XRES( 340 );
- int iHeight = YRES( 10 );
- int iBarWidth = XRES( 1 );
- int iBarHeight = XRES( 1 );
- int iPosX = (ScreenWidth - iWidth) / 2;
- int iPosY = (ScreenHeight - iHeight) / 2 + YRES( 50 );
- int iRed = 0;
- int iGreen = 0;
- int iBlue = 0;
- PercentageToColor( m_iHeat, iRed, iGreen, iBlue );
- FillRGBA( iPosX + iBarWidth * 2, iPosY + iBarHeight * 2, CalculatePercentage( iWidth, iBarWidth ), iHeight - 4 * iBarHeight, iRed, iGreen, iBlue, 255 );
- }
- return 1;
- }
- int CHudOverheat::MsgFunc_Overheat( const char *pszName, int iSize, void *pbuf )
- {
- BEGIN_READ( pbuf, iSize );
- m_iHeat = READ_BYTE();
- return 1;
- }
- int CHudOverheat::CalculatePercentage( const int _iWidth, const int _iBarWidth )
- {
- return (int)((m_iHeat / 100.0f) * (_iWidth - 4 * _iBarWidth));
- }
- void CHudOverheat::PercentageToColor( const int _iPercentage, int &_iRed, int &_iGreen, int &_iBlue )
- {
- _iRed = (255 * _iPercentage) / 100;
- _iGreen = (255 * (100 - _iPercentage)) / 100;
- _iBlue = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement