Skip to content
Permalink
Browse files

PlayerSAO::setHP - Don't call on_hpchange callbacks if HP hasn't changed

  • Loading branch information...
ClobberXD authored and sfan5 committed Apr 27, 2019
1 parent ad8d68c commit c4578aefe7dd920668ce77a99387ee3581f47311
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/content_sao.cpp
@@ -1340,11 +1340,13 @@ void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)

hp = rangelim(hp, 0, m_prop.hp_max);

s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp, reason);
if (hp_change == 0)
return;
if (oldhp != hp) {
s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, hp - oldhp, reason);
if (hp_change == 0)
return;

hp = rangelim(oldhp + hp_change, 0, m_prop.hp_max);
hp = rangelim(oldhp + hp_change, 0, m_prop.hp_max);
}

if (hp < oldhp && !g_settings->getBool("enable_damage"))
return;

0 comments on commit c4578ae

Please sign in to comment.
You can’t perform that action at this time.