[Source]Healthbar ESP

Selasa, 11 September 2012

[Source]Healthbar ESP


Membutuhkan :
  • Gamestruct
  • W2S ( World to Screen)
  • Value Health
Drawing function:
void DrawRect(IDirect3DDevice9* pD3Ddev, int baseX, int baseY, int baseW, int baseH, D3DCOLOR Cor)
{
    D3DRECT BarRect = { baseX, baseY, baseX + baseW, baseY + baseH }; 
    pD3Ddev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Cor, 0,  0); 
}



void DrawHealthbars (IDirect3DDevice9* pD3Ddev, int PosX, int PosY, int Value)
{
    int HealthR = 0, HealthG = 0, HealthB = 0; // Lets make some integers so we can use them for the healthbar. What we will be using this for is to change the color of the healthbar according to the damage done to the enemy.

    if ( Value > 0 ) // If Value (Health) is greater then 0 draw the healthbar.
    {
        DrawRect(pD3Ddev, PosX - 1, PosY - 1, 42, 8, D3DCOLOR_RGBA(0, 0, 0, 255)); // Lets make a black border for it. I just use it to make it look good.
        DrawRect(pD3Ddev, PosX, PosY, Value / 2, 6, D3DCOLOR_RGBA(HealthR, HealthG, HealthB, 255)); // Ok here is where the action behins. We are taking Value and dividing it in half this does not mean we will only half the health this is for the Length of the health bar. So its not 100 pixels wide.
    }

    if ( Value > 90 ) // I use this "feature" makes it so the enemy health changes color according to dmg inflicted.  So in english it would be "if health is greater then 90 % draw the healthcolor has green
    {
        HealthR = 0;
        HealthG = 250;
        HealthB = 0;
    }
    else if ( Value > 75 && Value < 90 ) // if Value is greater then 75 and not greater then 90 draw the health has a darker shade of green.
    {
        HealthR = 0;
        HealthG = 235;
        HealthB = 0;
    }
    else if ( Value > 60 && Value < 70 ) // Same thing applys.
    {
        HealthR = 0;
        HealthG = 220;
        HealthB = 0;
    }
    else if ( Value > 50 && Value < 60 )
    {
        HealthR = 0;
        HealthG = 150;
        HealthB = 150;
    }
    else if ( Value > 40 && Value < 50 )
    {
        HealthR = 120;
        HealthG = 120;
        HealthB = 0;
    }
    else if ( Value > 30 && Value < 40 )
    {
        HealthR = 100;
        HealthG = 0;
        HealthB = 0;
    }
    else if ( Value > 20 && Value < 30 )
    {
        HealthR = 80;
        HealthG = 0;
        HealthB = 0;
    }
    else if ( Value > 10 && Value < 20 )
    {
        HealthR = 50;
        HealthG = 0;
        HealthB = 0;
    }
    else if ( Value > 5 && Value < 10 )
    {
        HealthR = 30;
        HealthG = 0;
        HealthB = 0;
    }
    
}
"Jangan segan untuk bertanya, bila agan kesulitan silahkan tinggalkan komentar di bawah, maka akan saya bantu semaksimal mungkin "

5 komentar:

  1. Balasan
    1. Nggak.. soalnya cs pake direct8 sedangkan code ini menggunakan direct9

      Hapus
  2. gan masangnya dimana nih... maklum ane baru belajar mohon pencerahan

    BalasHapus
    Balasan
    1. Ini cuma drawing function nya aja gan, jd pasang di global aja :)
      Thanks kunjungan nya.

      Hapus


free counters