LCKB
How to show HP points and HP life bar on Monster? - Printable Version

+- LCKB (https://lckb.dev/forum)
+-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109)
+--- Forum: Guides & Help Section (https://lckb.dev/forum/forumdisplay.php?fid=193)
+---- Forum: Help & Support (https://lckb.dev/forum/forumdisplay.php?fid=157)
+----- Forum: Ep4 Support (https://lckb.dev/forum/forumdisplay.php?fid=128)
+----- Thread: How to show HP points and HP life bar on Monster? (/showthread.php?tid=4740)

Pages: 1 2 3


- JLT - 08-28-2022



On 5/7/2022 at 6:46 PM, Andrein95 said:




/index.php?/profile/18894-desarija/&do=hovercard" data-mentionid="18894" href="/index.php?/profile/18894-desarija/" rel="">@Desarija /index.php?/profile/21749-dimaflash/&do=hovercard" data-mentionid="21749" href="/index.php?/profile/21749-dimaflash/" rel="">@Dimaflash



In the end everything works, the only thing that I can't make it works is to update current target while regenerating HP (example sit down), the HP regenerated of other characters does not trigger UpdateHPInfo().



Do you have any hint?




Was able to solve the problem?




- Andrein95 - 08-28-2022



10 hours ago, JLT said:




Was able to solve the problem?




Not yet




- azpirin44 - 03-19-2025

void CTargetInfoUI::UpdateHPInfo()
{

if (m_pImg[eIMG_HP] == NULL)
return;

if (m_bShowHpBar == FALSE)
{
m_pImg[eIMG_HP]->Hide(TRUE);
return;
}

//add 19/03/2025
CTString strHp;
float fHealth, fHealthMax = 0;
//fin add 19/03/2025
// HP
FLOAT fHPRatio = 0;
ObjInfo* pInfo = ObjInfo::getSingleton();

if ( pInfo->GetTargetEntity(eTARGET) != NULL &&
pInfo->GetTargetServerIdx(eTARGET) == _pNetwork->MyCharacterInfo.index)
{
fHPRatio = (float)_pNetwork->MyCharacterInfo.hp / (float)_pNetwork->MyCharacterInfo.maxHP;
}
else
{
fHPRatio = pInfo->GetTargetCurHP(eTARGET) / pInfo->GetTargetMaxHP(eTARGET);

//add 19/03/2025
fHealth = pInfo->GetTargetCurHP(eTARGET);
fHealthMax = pInfo->GetTargetMaxHP(eTARGET);
//fin add 19/03/2025
}

if (fHPRatio > 1.0f)
fHPRatio = 1.0f;
else if (fHPRatio < 0.0f)
fHPRatio = 0.0f;

//hp texto para los monstruos
//add 19/03/2025
strHp.PrintF("%d/%d", (int)fHealth, (int)fHealthMax);

m_pText[eTEXT_HP]->SetText(strHp);
//add 19/03/2025
m_pImg[eIMG_HP]->SetWidth( (m_nAddWidthGap + m_nHpBarWidth) * fHPRatio);
m_pImg[eIMG_HP]->Hide(FALSE);
}

 




- Andrein95 - 03-21-2025



On 3/19/2025 at 11:22 PM, azpirin44 said:



void CTargetInfoUI::UpdateHPInfo()
{

if (m_pImg[eIMG_HP] == NULL)
return;

if (m_bShowHpBar == FALSE)
{
m_pImg[eIMG_HP]->Hide(TRUE);
return;
}

//add 19/03/2025
CTString strHp;
float fHealth, fHealthMax = 0;
//fin add 19/03/2025
// HP
FLOAT fHPRatio = 0;
ObjInfo* pInfo = ObjInfo::getSingleton();

if ( pInfo->GetTargetEntity(eTARGET) != NULL &&
pInfo->GetTargetServerIdx(eTARGET) == _pNetwork->MyCharacterInfo.index)
{
fHPRatio = (float)_pNetwork->MyCharacterInfo.hp / (float)_pNetwork->MyCharacterInfo.maxHP;
}
else
{
fHPRatio = pInfo->GetTargetCurHP(eTARGET) / pInfo->GetTargetMaxHP(eTARGET);

//add 19/03/2025
fHealth = pInfo->GetTargetCurHP(eTARGET);
fHealthMax = pInfo->GetTargetMaxHP(eTARGET);
//fin add 19/03/2025
}

if (fHPRatio > 1.0f)
fHPRatio = 1.0f;
else if (fHPRatio < 0.0f)
fHPRatio = 0.0f;

//hp texto para los monstruos
//add 19/03/2025
strHp.PrintF("%d/%d", (int)fHealth, (int)fHealthMax);

m_pText[eTEXT_HP]->SetText(strHp);
//add 19/03/2025
m_pImg[eIMG_HP]->SetWidth( (m_nAddWidthGap + m_nHpBarWidth) * fHPRatio);
m_pImg[eIMG_HP]->Hide(FALSE);
}


 




I tried a similar approach, but this one does not update while sitting as I said.

For sitting or other stuff, to update current value of health and mex health a message exchange is required... (maybe)