void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
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?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); } }
sorry @margoh my bad there was a few lines in my creature.cpp that were making conflicts but solved@CipsoftStinks Show your creature.cpp