diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2017-08-23 22:32:10 +0200 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-23 22:32:10 +0200 |
commit | f7d50a80782376d2e1c068e4d0a7ce9632f28bda (patch) | |
tree | 1235977bb6ce8639c24a5315f094364a39e34ee0 /src/content_sao.cpp | |
parent | d01b65abebf3b2e86d076c6b69996fd3a205a960 (diff) | |
download | hax-minetest-server-f7d50a80782376d2e1c068e4d0a7ce9632f28bda.tar.gz hax-minetest-server-f7d50a80782376d2e1c068e4d0a7ce9632f28bda.zip |
Respect object property hp_max field for players (#6287)
* Respect object property hp_max field for players
This allows modders to configure the maximal HP per player
* Statbars: Downscale bar to full 20 HP when exceeding this value
Add default max HP for players and breath constants to builtin
Document the constants
* Rename PLAYER_MAX_HP -> PLAYER_MAX_HP_DEFAULT
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r-- | src/content_sao.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 621a64de0..bc5fb164b 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -782,7 +782,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id { assert(m_peer_id != 0); // pre-condition - m_prop.hp_max = PLAYER_MAX_HP; + m_prop.hp_max = PLAYER_MAX_HP_DEFAULT; m_prop.physical = false; m_prop.weight = 75; m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f); @@ -799,7 +799,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id m_prop.is_visible = true; m_prop.makes_footstep_sound = true; m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS; - m_hp = PLAYER_MAX_HP; + m_hp = m_prop.hp_max; } PlayerSAO::~PlayerSAO() @@ -1235,8 +1235,8 @@ void PlayerSAO::setHP(s16 hp) if (hp < 0) hp = 0; - else if (hp > PLAYER_MAX_HP) - hp = PLAYER_MAX_HP; + else if (hp > m_prop.hp_max) + hp = m_prop.hp_max; if (hp < oldhp && !g_settings->getBool("enable_damage")) { return; |