Monster Health Bar Gold Name

Started by MOMU, Apr 09, 2025, 06:56 AM

MOMU


Some Share from  MOMU Emulator Soruce Hope its will be usefull


HealthBar.cpp

Quote#include "stdafx.h"
#include "CustomRankUser.h"
#include "Defines.h"
#include "HealthBar.h"
#include "Interface.h"
#include "User.h"
#include "Util.h"
#include "Object.h"
#include "Protect.h"
#include "Import.h"
#include "Common.h"
#include "DamageRender.h"

NEW_HEALTH_BAR gNewHealthBar[MAX_MAIN_VIEWPORT];

void ClearNewHealthBar()
{
    for (int n = 0; n < MAX_MAIN_VIEWPORT; n++)
    {
        gNewHealthBar[n].index = 0xFFFF;
        gNewHealthBar[n].type = 0;
        gNewHealthBar[n].rate = 0;
        gNewHealthBar[n].rate2 = 0;
        gNewHealthBar[n].level = 0;
    }
}

void InsertNewHealthBar(WORD index, BYTE type, BYTE rate, BYTE rate2, short level)
{
    for (int n = 0; n < MAX_MAIN_VIEWPORT; n++)
    {
        if (gNewHealthBar[n].index == 0xFFFF)
        {
            gNewHealthBar[n].index = index;
            gNewHealthBar[n].type = type;
            gNewHealthBar[n].rate = rate;
            gNewHealthBar[n].rate2 = rate2;
            gNewHealthBar[n].level = level;
            return;
        }
    }
}

NEW_HEALTH_BAR* GetNewHealthBar(WORD index, BYTE type)
{
    for (int n = 0; n < MAX_MAIN_VIEWPORT; n++)
    {
        if (gNewHealthBar[n].index != 0xFFFF)
        {
            if (gNewHealthBar[n].index == index && gNewHealthBar[n].type == type)
            {
                return &gNewHealthBar[n];
            }
        }
    }

    return 0;
}

void DrawNewHealthBar()
{
    int PosX, PosY, LifeProgress, ShieldProgress;
    VAngle Angle;

    if (gProtect.m_MainInfo.DisablePartyHpBar == 1)
    {
        if (pPartyMemberCount > 0)
        {
            for (int j = 0; j < pPartyMemberCount; j++)
            {
                signed int PartyNummber = *((DWORD*)&pPartyListStruct + 8 * j + 7);
                DWORD ViewportAddress = ((DWORD(__thiscall*)(void*, DWORD))0x0096A4C0)(((void* (*)())0x00402BC0)(), PartyNummber);

                if (ViewportAddress)
                {
                    Angle.X = *(float*)(ViewportAddress + 0x404);
                    Angle.Y = *(float*)(ViewportAddress + 0x408);
                    Angle.Z = *(float*)(ViewportAddress + 0x40C) + *(float*)(ViewportAddress + 0x3E8) + 100.0f;
                    pGetPosFromAngle(&Angle, &PosX, &PosY);
                }
            }
        }
    }
    else if (gProtect.m_MainInfo.DisablePartyHpBar == 2)
    {
    }
    else
    {
        ((void(*)())0x005BA770)();
    }

    for (int n = 0; n < MAX_MAIN_VIEWPORT; n++)
    {
        DWORD ViewportAddress = ((DWORD(__thiscall*)(void*, DWORD))0x0096A4C0)(((void* (*)())0x00402BC0)(), n);

        gObjUser.m_Logo[n].Active = 0;

        if (!ViewportAddress)
            continue;

        if (*(BYTE*)(ViewportAddress + 0x30C) == 0)
            continue;

        Angle.X = *(float*)(ViewportAddress + 0x404);
        Angle.Y = *(float*)(ViewportAddress + 0x408);
        Angle.Z = *(float*)(ViewportAddress + 0x40C) + *(float*)(ViewportAddress + 0x3E8) + 100.0f;

        pGetPosFromAngle(&Angle, &PosX, &PosY);

        if (*(BYTE*)(ViewportAddress + 0x320) == 1)
        {
            gObjUser.m_Logo[n].Active = 1;
            gObjUser.m_Logo[n].X = PosX;
            gObjUser.m_Logo[n].Y = PosY;
        }

        NEW_HEALTH_BAR* lpNewHealthBar = GetNewHealthBar(*(WORD*)(ViewportAddress + 0x7E), *(BYTE*)(ViewportAddress + 0x320));
        char* name = (char*)(ViewportAddress + 0x38);

        if (lpNewHealthBar == 0)
            continue;

        float LifeBarWidth = (((40 - 1) / 100.0f) * lpNewHealthBar->rate) - 1;
        int LifePercent = lpNewHealthBar->rate / 10;
        int ShieldPercent = lpNewHealthBar->rate2 / 10;
        float LifeBarWidth1 = 38.0;

        PosX -= (int)floor(LifeBarWidth1 / 2.0);
        PosY -= 17;

        pSetBlend(true);

        char LifeDisplay[25];

        if (*(BYTE*)(ViewportAddress + 0x320) == 1)
        {
            if ((pCursorX >= PosX - LifeBarWidth1) && ((float)pCursorX <= (float)PosX + LifeBarWidth1) && (pCursorY >= PosY - 20) && (pCursorY < PosY + 20))
            {
                if (ShieldPercent > 0)
                {
                    wsprintf(LifeDisplay, "HP : %d0%% | SD : %d0%%", LifePercent, ShieldPercent);
                    pSetTextColor(pTextThis(), 0xFF, 0xE6, 0xD2, 0xFF);
                    pDrawText(pTextThis(), PosX - 2.5, PosY - 25, LifeDisplay, 0, 0, (LPINT)1, 0);
                }
                else
                {
                    wsprintf(LifeDisplay, "HP : %d0%%", LifePercent);
                    pSetTextColor(pTextThis(), 0xFF, 0xE6, 0xD2, 0xFF);
                    pDrawText(pTextThis(), PosX, PosY - 10, LifeDisplay, 0, 0, (LPINT)1, 0);
                }
            }

            int custy = 0;
            if (*(WORD*)(ViewportAddress + 0x218) != 65535 && *(BYTE*)(ViewportAddress + 0xE) == 0)
            {
                custy = -10;
            }
            if (*(WORD*)(ViewportAddress + 0x23C) == 7947 && *(BYTE*)(ViewportAddress + 0xE) == 0 && *(WORD*)(ViewportAddress + 0x218) != 65535)
            {
                custy += -13;
            }
            else if (*(WORD*)(ViewportAddress + 0x23C) == 7947 && *(BYTE*)(ViewportAddress + 0xE) == 0)
            {
                custy += -23;
            }
            else if (*(WORD*)(ViewportAddress + 0x23C) == 7914 && *(BYTE*)(ViewportAddress + 0xE) == 0)
            {
                custy += -35;
            }

            float Tamanho = (ShieldPercent > 0) ? 10.0f : 5.0f;

            glColor4f(0.0, 0.0, 0.0, 0.5);
            pDrawBarForm((float)(PosX - 0.5), (float)(PosY - 6.0 + custy), LifeBarWidth1 + 4.0f, Tamanho, 0.0f, 0);
            pGLSwitchBlend();

            glColor3f(0.0f, 0.0f, 0.0f);
            pDrawBarForm((float)PosX, (float)PosY - 4 + custy, LifeBarWidth1, 2.0f, 0.0, 0);

            if (ShieldPercent > 0)
            {
                glColor3f(0.0f, 0.0f, 0.0f);
                pDrawBarForm((float)PosX, (float)PosY + custy, LifeBarWidth1, 2.0f, 0.0, 0);
            }

            LifeProgress = (LifePercent > 10) ? 10 : LifePercent;
            ShieldProgress = (ShieldPercent > 10) ? 10 : ShieldPercent;

            glColor4f(1.0f, 0.0f, 0.0f, 0.0f);

            for (int i = 0; i < LifeProgress; i++)
            {
                pDrawBarForm((float)(i * 4 + PosX + 0), (float)(PosY - 4 + custy), 4.0, 2.0, 0.0, 0);
            }

            if (ShieldPercent > 0)
            {
                glColor4f(1.0f, 0.5f, 0.0f, 0.0f);

                for (int i = 0; i < ShieldProgress; i++)
                {
                    pDrawBarForm((float)(i * 4 + PosX + 0), (float)(PosY + custy), 4.0, 2.0, 0.0, 0);
                }
            }
        }
        else
        {
            if (HpMonsterBar == 1)
            {
                glColor4f(0.1f, 0.1f, 0.1f, 0.5f);
                pDrawBarForm((float)(PosX)-35, (float)(PosY)-25, 140.0f, 30.0f, 0.0f, 0);

                float BarBackgroundWidth = 80.0f;

                glColor4f(RGBTOGLFLOAT(0), RGBTOGLFLOAT(0), RGBTOGLFLOAT(0), 0.6);
                pDrawBarForm((float)(PosX + 0.5), (float)(PosY - 1.5), BarBackgroundWidth, 5, 0.0, 0);

                float LifeBarWidth = (((BarBackgroundWidth - 1) / 100.0f) * lpNewHealthBar->rate) - 1;

                glColor4f(RGBTOGLFLOAT(255),
                    RGBTOGLFLOAT(ABS(((255.0f / 100.0f) * lpNewHealthBar->rate) - 255.0f)),
                    RGBTOGLFLOAT(0), 0.8);
                pDrawBarForm((float)(PosX + 1.5), (float)(PosY), LifeBarWidth, 3, 0.0, 0);

                char Text[100];
                sprintf(Text, "LV: %d, HP:%2d.0%%", lpNewHealthBar->level, lpNewHealthBar->rate);

                DrawInterfaceText(name, (float)(PosX)-30, (float)(PosY)-25, 100, 1, eGold, 1, 3);
                DrawInterfaceText(Text, (float)(PosX)-30, (float)(PosY)-15, 100, 1, eWhite, 1, 3);
            }
        }

        pGLSwitch();
    }

    gCustomRankUser.DrawInfo();

#if(DAMAGE_RENDER_ENABLE)
    g_DamageRender.DrawRender();
#endif

    pGLSwitch();
    glColor3f(1.0, 1.0, 1.0);
}


HealthBar.h
Quote#pragma once

#define MAX_MAIN_VIEWPORT 400
#define RGBTOGLFLOAT(x) ((float)x/255.0f)
#define FLOATTORGB(x)    ((float)x*255)
#define ABS(x) (((x) < 0) ? (-(x)) : (x))

struct NEW_HEALTH_BAR
{
    WORD index;
    BYTE type;
    BYTE rate;
    BYTE rate2;
    short level;
};

/*
struct VAngle
{
    float X;
    float Y;
    float Z;
};
*/

void ClearNewHealthBar();
//void InsertNewHealthBar(WORD index,BYTE type,BYTE rate,BYTE rate2);
void InsertNewHealthBar(WORD index,BYTE type,BYTE rate,BYTE rate2, short level);
NEW_HEALTH_BAR* GetNewHealthBar(WORD index,BYTE type);
void DrawNewHealthBar();


Powered by SMFPacks Ads Manager Mod