mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-26 21:26:38 +01:00
fix: poison kill player
i fixed before this behaviour but somehow it is broken. now i am clamping if 1 or 2 hp player is left with 1 hp.
This commit is contained in:
1 parent
ed63aaf8c4
commit
e1383cc6a3
1 file changed
+6
-2
@@ -137,9 +137,13 @@ void MobEffect::applyEffectTick(shared_ptr<LivingEntity> mob, int amplification)
|
||||
}
|
||||
else if (id == poison->id)
|
||||
{
|
||||
if (mob->getHealth() > 1.0f)
|
||||
// poison must never reduce health below 1 hp
|
||||
// if the current health is between 1 and 2 hp the player is left at exactly 1 HP rather than dying.
|
||||
float currentHealth = mob->getHealth();
|
||||
if (currentHealth > 1.0f)
|
||||
{
|
||||
mob->hurt(DamageSource::magic, 1.0f);
|
||||
float poisonDmg = min(1.0f, currentHealth - 1.0f);
|
||||
mob->hurt(DamageSource::magic, poisonDmg);
|
||||
}
|
||||
}
|
||||
else if (id == wither->id)
|
||||
|
||||
Reference in new issue
Block a user