From edbc533414b0ba991a82f8003d90924e1dc60d95 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Fri, 15 Sep 2017 12:18:47 +0200 Subject: Customizeable max breath for players (#6411) * Customizeable maximal breath for players --- src/content_sao.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/content_sao.cpp') diff --git a/src/content_sao.cpp b/src/content_sao.cpp index ece921472..2a2384b3d 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -797,6 +797,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id assert(m_peer_id != 0); // pre-condition m_prop.hp_max = PLAYER_MAX_HP_DEFAULT; + m_prop.breath_max = PLAYER_MAX_BREATH_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); @@ -817,6 +818,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS; m_prop.can_zoom = true; m_hp = m_prop.hp_max; + m_breath = m_prop.breath_max; } PlayerSAO::~PlayerSAO() @@ -943,7 +945,7 @@ void PlayerSAO::step(float dtime, bool send_recommended) MapNode n = m_env->getMap().getNodeNoEx(p); const ContentFeatures &c = m_env->getGameDef()->ndef()->get(n); // If player is alive & no drowning, breath - if (m_hp > 0 && m_breath < PLAYER_MAX_BREATH && c.drowning == 0) + if (m_hp > 0 && m_breath < m_prop.breath_max && c.drowning == 0) setBreath(m_breath + 1); } @@ -1274,7 +1276,7 @@ void PlayerSAO::setBreath(const u16 breath, bool send) if (m_player && breath != m_breath) m_player->setDirty(true); - m_breath = MYMIN(breath, PLAYER_MAX_BREATH); + m_breath = MYMIN(breath, m_prop.breath_max); if (send) m_env->getGameDef()->SendPlayerBreath(this); -- cgit v1.2.3