How to show HP points and HP life bar on Monster?
#24


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)



Messages In This Thread
[No subject] - by Andrein95 - 05-14-2021, 07:16 PM
[No subject] - by Scura - 05-15-2021, 11:20 AM
[No subject] - by Desarija - 05-15-2021, 11:30 AM
[No subject] - by Scura - 05-15-2021, 12:23 PM
[No subject] - by Andrein95 - 05-15-2021, 10:51 PM
[No subject] - by Scura - 05-15-2021, 11:33 PM
[No subject] - by Desarija - 05-15-2021, 11:57 PM
[No subject] - by Andrein95 - 05-16-2021, 09:24 AM
[No subject] - by Scura - 05-16-2021, 09:59 AM
[No subject] - by Andrein95 - 05-19-2021, 06:06 PM
[No subject] - by Andrein95 - 05-19-2021, 06:08 PM
[No subject] - by Andrein95 - 05-01-2022, 08:50 PM
[No subject] - by Desarija - 05-02-2022, 07:49 AM
[No subject] - by Andrein95 - 05-02-2022, 08:24 AM
[No subject] - by Desarija - 05-02-2022, 08:26 AM
[No subject] - by Andrein95 - 05-02-2022, 09:18 AM
[No subject] - by Andrein95 - 05-04-2022, 09:39 PM
[No subject] - by Desarija - 05-04-2022, 11:45 PM
[No subject] - by Andrein95 - 05-07-2022, 02:09 PM
[No subject] - by Andrein95 - 05-07-2022, 03:46 PM
[No subject] - by JLT - 08-28-2022, 12:13 AM
[No subject] - by Andrein95 - 08-28-2022, 10:23 AM
[No subject] - by azpirin44 - 03-19-2025, 10:22 PM
[No subject] - by Andrein95 - 03-21-2025, 01:29 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)