• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Mod or sourcecode ManaBar under healthBar in displayUI

Selfish

Member
Joined
Aug 22, 2011
Messages
22
Reaction score
6
How can I create a mana bar under the player's health bar? Would it be in source or do some mod?
 
Source.
"creature.cpp"
in this function:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
 
Thanks, I did it before I had made a mod for it, but it was not good because the size of the screen always changes, now I did it in C ++ and it's really cool!
 
I can share later, yes! Is that it involves the server and client, so you have to prepare a well explained topic

33emvlz.jpg
 
please someone can share the lines or the edit that i must do in the otclient sources and maybe in my server?
regards
 
Everything is easy after you know...
Are you sure need server side modifications to create a mana bar downstairs of health bar?
Why this mana bar isnt use only client side?
 
Because you need to send the data from the server to the client in the case of mana and maxMana and have to do the updates every time you use mana, in this case using a function to send the information inside the functions that use mana, as for example ChangeMana function, if you do not do this, the mana bar will not do anything, it will be static
 
I read this topic and I made the code to draw manabar under healthbar.
C++:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
{
    if(m_healthPercent < 1) // creature is dead
        return;

    Color fillColor = Color(96, 96, 96);

    if(!useGray)
        fillColor = m_informationColor;

    // calculate main rects
    Rect backgroundRect = Rect(point.x-(13.5), point.y, 27, 4); //27 , 4
    backgroundRect.bind(parentRect);

    Size nameSize = m_nameCache.getTextSize();
    Rect textRect = Rect(point.x - nameSize.width() / 2.0, point.y -12, nameSize);
    textRect.bind(parentRect);

    // recalculate rects to draw manabar
    LocalPlayerPtr localPlayer;
    Rect manaBackgroundRect;
    if (isLocalPlayer()){
        backgroundRect.move(backgroundRect.x(), backgroundRect.y() - 4);
        textRect.move(textRect.x(), backgroundRect.y() - 12);
        manaBackgroundRect = Rect(backgroundRect.x(), backgroundRect.bottom()+ (1.7), 27, 4);
        localPlayer = g_game.getLocalPlayer();
    }

    // distance them
    if(textRect.top() == parentRect.top())
        backgroundRect.moveTop(textRect.top() + 12);
    if(backgroundRect.bottom() == parentRect.bottom())
        textRect.moveTop(backgroundRect.top() - 12);

    // health rect is based on background rect, so no worries
    Rect healthRect = backgroundRect.expanded(-1);
    healthRect.setWidth((m_healthPercent / 100.0) * 25);

    //create mana rect
    Rect manaRect;
    if (isLocalPlayer()){
        manaRect = manaBackgroundRect.expanded(-1);
        double manaPercent = ((localPlayer->getMana() * 100) / localPlayer->getMaxMana());
        manaRect.setWidth((manaPercent/ 100.0) * 25);
    }

    // draw
    if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
        fillColor = Color(0x66, 0xcc, 0xff);

    if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) {
        g_painter->setColor(Color::black);
        g_painter->drawFilledRect(backgroundRect);

        g_painter->setColor(fillColor);
        g_painter->drawFilledRect(healthRect);

        //draw mana bar
        if(isLocalPlayer()){
            g_painter->setColor(Color::black);
            g_painter->drawFilledRect(manaBackgroundRect);

            g_painter->setColor(Color::blue);
            g_painter->drawFilledRect(manaRect);
        }
    }

    if(drawFlags & Otc::DrawNames) {
        if(g_painter->getColor() != fillColor)
            g_painter->setColor(fillColor);
        m_nameCache.draw(textRect);
    }

    if(m_skull != Otc::SkullNone && m_skullTexture) {
        g_painter->setColor(Color::white);
        Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
        g_painter->drawTexturedRect(skullRect, m_skullTexture);
    }
    if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture) {
        g_painter->setColor(Color::white);
        Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
        g_painter->drawTexturedRect(shieldRect, m_shieldTexture);
    }
    if(m_emblem != Otc::EmblemNone && m_emblemTexture) {
        g_painter->setColor(Color::white);
        Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
        g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
    }
    if(m_icon != Otc::NpcIconNone && m_iconTexture) {
        g_painter->setColor(Color::white);
        Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
        g_painter->drawTexturedRect(iconRect, m_iconTexture);
    }
}
 
I read this topic and I made the code to draw manabar under healthbar.
C++:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
{
    if(m_healthPercent < 1) // creature is dead
        return;

    Color fillColor = Color(96, 96, 96);

    if(!useGray)
        fillColor = m_informationColor;

    // calculate main rects
    Rect backgroundRect = Rect(point.x-(13.5), point.y, 27, 4); //27 , 4
    backgroundRect.bind(parentRect);

    Size nameSize = m_nameCache.getTextSize();
    Rect textRect = Rect(point.x - nameSize.width() / 2.0, point.y -12, nameSize);
    textRect.bind(parentRect);

    // recalculate rects to draw manabar
    LocalPlayerPtr localPlayer;
    Rect manaBackgroundRect;
    if (isLocalPlayer()){
        backgroundRect.move(backgroundRect.x(), backgroundRect.y() - 4);
        textRect.move(textRect.x(), backgroundRect.y() - 12);
        manaBackgroundRect = Rect(backgroundRect.x(), backgroundRect.bottom()+ (1.7), 27, 4);
        localPlayer = g_game.getLocalPlayer();
    }

    // distance them
    if(textRect.top() == parentRect.top())
        backgroundRect.moveTop(textRect.top() + 12);
    if(backgroundRect.bottom() == parentRect.bottom())
        textRect.moveTop(backgroundRect.top() - 12);

    // health rect is based on background rect, so no worries
    Rect healthRect = backgroundRect.expanded(-1);
    healthRect.setWidth((m_healthPercent / 100.0) * 25);

    //create mana rect
    Rect manaRect;
    if (isLocalPlayer()){
        manaRect = manaBackgroundRect.expanded(-1);
        double manaPercent = ((localPlayer->getMana() * 100) / localPlayer->getMaxMana());
        manaRect.setWidth((manaPercent/ 100.0) * 25);
    }

    // draw
    if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
        fillColor = Color(0x66, 0xcc, 0xff);

    if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) {
        g_painter->setColor(Color::black);
        g_painter->drawFilledRect(backgroundRect);

        g_painter->setColor(fillColor);
        g_painter->drawFilledRect(healthRect);

        //draw mana bar
        if(isLocalPlayer()){
            g_painter->setColor(Color::black);
            g_painter->drawFilledRect(manaBackgroundRect);

            g_painter->setColor(Color::blue);
            g_painter->drawFilledRect(manaRect);
        }
    }

    if(drawFlags & Otc::DrawNames) {
        if(g_painter->getColor() != fillColor)
            g_painter->setColor(fillColor);
        m_nameCache.draw(textRect);
    }

    if(m_skull != Otc::SkullNone && m_skullTexture) {
        g_painter->setColor(Color::white);
        Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
        g_painter->drawTexturedRect(skullRect, m_skullTexture);
    }
    if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture) {
        g_painter->setColor(Color::white);
        Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
        g_painter->drawTexturedRect(shieldRect, m_shieldTexture);
    }
    if(m_emblem != Otc::EmblemNone && m_emblemTexture) {
        g_painter->setColor(Color::white);
        Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
        g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
    }
    if(m_icon != Otc::NpcIconNone && m_iconTexture) {
        g_painter->setColor(Color::white);
        Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
        g_painter->drawTexturedRect(iconRect, m_iconTexture);
    }
}
where i must put that?
 
1>------ Rebuild All started: Project: otclient, Configuration: Release Win32 ------
1> animatedtext.cpp
1> animator.cpp
1> client.cpp
1> container.cpp
1> creature.cpp
1> creatures.cpp
1> effect.cpp
1> game.cpp
1>..\src\client\creature.cpp(48): error C2065: 'm_manaPercent': undeclared identifier
1>..\src\client\creature.cpp(322): error C2084: function 'void Creature::drawInformation(const Point &,bool,const Rect &,int)' already has a body
1> ..\src\client\creature.cpp(105): note: see previous definition of 'drawInformation'
1>..\src\client\creature.cpp(358): error C2065: 'm_manaPercent': undeclared identifier
1>..\src\client\creature.cpp(375): error C2065: 'm_manaColor': undeclared identifier
1>..\src\client\creature.cpp(375): error C2143: syntax error: missing ';' before ':'
1>..\src\client\creature.cpp(375): error C2059: syntax error: ':'
1>..\src\client\creature.cpp(408): error C2039: 'setManaPercent': is not a member of 'Creature'
1> c:\users\raquel\desktop\otclient7.72 dark theme best - copia\src\client\creature.h(37): note: see declaration of 'Creature'
1>..\src\client\creature.cpp(410): error C2065: 'm_manaColor': undeclared identifier
1>..\src\client\creature.cpp(412): error C2065: 'm_manaPercent': undeclared identifier
1>..\src\client\creature.cpp(413): error C2065: 'm_manaPercent': undeclared identifier
1>..\src\client\creature.cpp(413): error C3861: 'callLuaField': identifier not found
1> houses.cpp
1> item.cpp
1> itemtype.cpp
1> lightview.cpp
1> localplayer.cpp
1> luafunctions.cpp
1> luavaluecasts.cpp
1> map.cpp
1> mapio.cpp
1> mapview.cpp
1> minimap.cpp
1> missile.cpp
1> outfit.cpp
1> player.cpp
1> protocolcodes.cpp
1> protocolgame.cpp
1> protocolgameparse.cpp
1> protocolgamesend.cpp
1> shadermanager.cpp
1> spritemanager.cpp
1> statictext.cpp
1> thing.cpp
1> thingtype.cpp
1> thingtypemanager.cpp
1> tile.cpp
1> towns.cpp
1> uicreature.cpp
1> uiitem.cpp
1> uimap.cpp
1> uimapanchorlayout.cpp
1> uiminimap.cpp
1> uiprogressrect.cpp
1> uisprite.cpp
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========



i get this error when i try to rebuild otclient
what i need to change?
@margoh @gugu15
 
Back
Top