Results 1 to 3 of 3
  1. #1
    gflames12's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Location
    Rochester, Ny
    Posts
    21
    Reputation
    10
    Thanks
    6

    Crappy Horizontal HealthBar

    Thought id release this since i have seen many people complaining of health bars on other forums, draws horizontal health bars about enemys head on screen. I have been using this same health bar since i made my first cod 4 d3d hack, using fleeps tutorials.
    Credits: Mainly to fleep for code
    drawing functions
    Code:
    void Drawing::DrawBorderBox( int x, int y, int w, int h, int thickness, D3DCOLOR Colour, IDirect3DDevice9 *pDevice)
    {
    	//t
    	DrawFilledRect( x, y, w, thickness,  Colour, pDevice );
    	//l
    	DrawFilledRect( x, y, thickness, h, Colour, pDevice );
    	//r
    	DrawFilledRect( (x + w), y, thickness, h, Colour, pDevice );
    	//b
    	DrawFilledRect( x, y + h, w+thickness, thickness, Colour, pDevice );
    }
    
    
    
    void Drawing::DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
    {
    	
    	D3DRECT BarRect = { x, y, x + w, y + h }; 
    	
    	dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
    }
    next we have our actual function
    Code:
    void ESP::DrawEnemyHealth(int x, int y, int w, int h, int health)
    {
    	Drawing::DrawBorderBox(x, y, w/*w*/, h/*h*/, 4, D3DCOLOR_ARGB(255, 0, 0, 255), D3dDevice );
    
    	
    	float healthPercentage = ((float)health/(float)MAXHEALTH) * 100.0f;
    	
    	
    	float barPercentage = ((float)w*(float)(healthPercentage/100));
    
    	RECT healthRect = 
    	{
    		x, //L 
    		y-20,//T
    		x + w,//R
    		y + h//B
    	};
    
    	
    	M_font->DrawText(NULL, I_O::IntToString(health).c_str() , -1, &healthRect, DT_NOCLIP, D3DCOLOR_ARGB(255, 255, 0, 0));
    
    	Drawing::DrawFilledRect( x, y, (int)barPercentage, h, GetHealthColor(health), D3dDevice );
    }
    to change colour of bar as health is lowered
    Code:
    D3DCOLOR ESP::GetHealthColor(int currentHealth)
    {
    	
    	if(currentHealth > 89 && currentHealth <= 100)
    		return D3DCOLOR_ARGB(255, 0, 255, 0);
    	else if(currentHealth > 79 && currentHealth < 90)
    		return D3DCOLOR_ARGB(255, 0, 255, 155);
    	else if(currentHealth > 69 && currentHealth < 80)
    		return D3DCOLOR_ARGB(255, 255, 255, 0);
    	else if(currentHealth > 59 && currentHealth < 70)
    		return D3DCOLOR_ARGB(255, 255, 205, 0);
    	else if(currentHealth > 49 && currentHealth < 60)
    		return D3DCOLOR_ARGB(255, 255, 170, 0);
    	else if(currentHealth > 39 && currentHealth < 50)
    		return D3DCOLOR_ARGB(255, 255, 128, 0);
    	else if(currentHealth > 29 && currentHealth < 40)
    		return D3DCOLOR_ARGB(255, 255, 97, 0);
    	else if(currentHealth > 19 && currentHealth < 30)
    		return D3DCOLOR_ARGB(255, 255, 58, 0);
    	else if(currentHealth > 9 && currentHealth < 20)
    		return D3DCOLOR_ARGB(255, 255, 0, 66);
    	else if(currentHealth > 1 && currentHealth < 9)
    		return D3DCOLOR_ARGB(255, 255, 0, 0);
    }
    to draw health bar (example call):
    Code:
    DrawEnemyHealth(
    						(int)(ScreenX - (drawx/2)),
    						(int)(ScreenY - (drawy*2)),
    						drawx, drawy/4, enemiesVec[i].health);

  2. The Following User Says Thank You to gflames12 For This Useful Post:

    Skaterforeva1 (07-12-2013)

  3. #2
    flameswor10's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Posts
    12,528
    Reputation
    981
    Thanks
    10,404
    My Mood
    In Love
    Code:
    DWORD GetHealthColour(int health)
    {
    	if( health > 100 ) return D3DCOLOR_ARGB(255, 0, 255, 0);
    	float Red = 255-(health*2.55f);
    	float Green =    health*2.55f;
    
    	return D3DCOLOR_ARGB(255, (INT)Red, (INT)Green, 0);
    }
    I'd say my function is a tad more neat instead of ~10 different if statements.
    Last edited by flameswor10; 07-13-2013 at 06:02 AM.
    No I do not make game hacks anymore, please stop asking.


    Been MPGH Minion: 6 July 2011 - 1 August 2012

  4. The Following 2 Users Say Thank You to flameswor10 For This Useful Post:

    [MPGH]Flengo (07-12-2013),Skaterforeva1 (07-12-2013)

  5. #3
    Departure's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    818
    Reputation
    125
    Thanks
    1,785
    My Mood
    Doh
    Nice logical function Flameswor10...
    DJector.Lite
    Get the advantages of new injection technology, with 1 click easy to use injector, work for all platforms x86/x64

    Download

    D-Jector
    Get the most advanced and full featured injector around, works for any game and any platform x86/x64, nothing comes even close.
    Download

Similar Threads

  1. My relly crappy sig
    By NeedHacksBad in forum Art & Graphic Design
    Replies: 19
    Last Post: 09-24-2007, 01:54 PM
  2. My (Albeit Crappy) Gallery - Jackal
    By Jackal in forum Art & Graphic Design
    Replies: 8
    Last Post: 07-09-2006, 09:25 PM
  3. Lol check out my crappy sig
    By Severed in forum Art & Graphic Design
    Replies: 1
    Last Post: 02-21-2006, 12:05 PM
  4. Crappy sig
    By OMGH4X in forum Art & Graphic Design
    Replies: 4
    Last Post: 01-17-2006, 08:14 PM
  5. Crappy Test
    By Kyojiro in forum Art & Graphic Design
    Replies: 8
    Last Post: 01-02-2006, 09:16 PM