Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invincible peds #777

Merged
9 commits merged into from
Apr 20, 2020
21 changes: 11 additions & 10 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,15 @@ void CClientPed::InternalSetHealth(float fHealth)
// Recheck we have a ped, ReCreateModel might destroy it
if (m_pPlayerPed)
{
// update dead state for peds
if (fHealth > 0 && IsDead())
{
m_bDead = false;
}

// Set the new health
m_pPlayerPed->SetHealth(fHealth);
m_pTaskManager->RemoveTask(TASK_SIMPLE_DEAD);
FileEX marked this conversation as resolved.
Show resolved Hide resolved
This conversation was marked as resolved.
Show resolved Hide resolved
}
}
}
Expand Down Expand Up @@ -1880,16 +1887,10 @@ void CClientPed::Kill(eWeaponType weaponType, unsigned char ucBodypart, bool bSt
}
}
}
if (m_bIsLocalPlayer)
{
SetHealth(0.0f);
SetArmor(0.0f);
}
else
{
LockHealth(0.0f);
LockArmor(0.0f);
}

// set health and armor to 0
SetHealth(0.0f);
SetArmor(0.0f);

// Silently remove the ped satchels
DestroySatchelCharges(false, true);
Expand Down
7 changes: 7 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,13 @@ bool CStaticFunctionDefinitions::SetElementHealth(CElement* pElement, float fHea
// This makes sure the health is set to what will get reported
unsigned char ucHealth = static_cast<unsigned char>(fHealth * 1.25f);
fHealth = static_cast<float>(ucHealth) / 1.25f;

// update dead state for peds
if (fHealth > 0 && pPed->IsDead())
{
pPed->SetIsDead(false);
}
// set new health
FileEX marked this conversation as resolved.
Show resolved Hide resolved
pPed->SetHealth(fHealth);
}
else
Expand Down