Skip to content

Commit b4f26f5

Browse files
Synchronize changes from 1.6 master branch [ci skip]
612f9a6 Fixed element health issues (#3633)
2 parents 45b2d18 + 612f9a6 commit b4f26f5

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,13 +1465,8 @@ bool CStaticFunctionDefinitions::SetElementHealth(CClientEntity& Entity, float f
14651465
// Grab the model
14661466
CClientPed& Ped = static_cast<CClientPed&>(Entity);
14671467

1468-
// Limit to max health
1469-
float fMaxHealth = Ped.GetMaxHealth();
1470-
if (fHealth > fMaxHealth)
1471-
fHealth = fMaxHealth;
1472-
14731468
// Set the new health
1474-
Ped.SetHealth(fHealth);
1469+
Ped.SetHealth(Clamp(0.0f, fHealth, Ped.GetMaxHealth()));
14751470
return true;
14761471
break;
14771472
}

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,27 +1654,15 @@ bool CStaticFunctionDefinitions::SetElementHealth(CElement* pElement, float fHea
16541654
case CElement::PLAYER:
16551655
{
16561656
CPed* pPed = static_cast<CPed*>(pElement);
1657-
if (pPed->IsSpawned())
1658-
{
1659-
// Limit their max health to what the stat says
1660-
float fMaxHealth = pPed->GetMaxHealth();
1661-
if (fHealth > fMaxHealth)
1662-
fHealth = fMaxHealth;
1657+
if (!pPed->IsSpawned())
1658+
return false;
16631659

1664-
// Do not set the health below zero
1665-
if (fHealth < 0.0f)
1666-
fHealth = 0.0f;
1660+
fHealth = Clamp(0.0f, fHealth, pPed->GetMaxHealth());
1661+
pPed->SetHealth(fHealth);
16671662

1668-
// This makes sure the health is set to what will get reported
1669-
unsigned char ucHealth = static_cast<unsigned char>(fHealth * 1.25f);
1670-
fHealth = static_cast<float>(ucHealth) / 1.25f;
1671-
pPed->SetHealth(fHealth);
1663+
if (pPed->IsDead() && fHealth > 0.0f)
1664+
pPed->SetIsDead(false);
16721665

1673-
if (pPed->IsDead() && fHealth > 0.0f)
1674-
pPed->SetIsDead(false);
1675-
}
1676-
else
1677-
return false;
16781666
break;
16791667
}
16801668
case CElement::VEHICLE:

0 commit comments

Comments
 (0)