diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/environment.cpp | 9 | ||||
-rw-r--r-- | src/nodedef.cpp | 2 | ||||
-rw-r--r-- | src/nodedef.h | 2 | ||||
-rw-r--r-- | src/script/common/c_content.cpp | 3 |
4 files changed, 9 insertions, 7 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 40dba9a6c..76a8aab51 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -2243,7 +2243,8 @@ void ClientEnvironment::step(float dtime) v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS); MapNode n = m_map->getNodeNoEx(p); ContentFeatures c = m_gamedef->ndef()->get(n); - if(c.isLiquid() && c.drowning && lplayer->hp > 0){ + u8 drowning_damage = c.drowning; + if(drowning_damage > 0 && lplayer->hp > 0){ u16 breath = lplayer->getBreath(); if(breath > 10){ breath = 11; @@ -2255,8 +2256,8 @@ void ClientEnvironment::step(float dtime) updateLocalPlayerBreath(breath); } - if(lplayer->getBreath() == 0){ - damageLocalPlayer(1, true); + if(lplayer->getBreath() == 0 && drowning_damage > 0){ + damageLocalPlayer(drowning_damage, true); } } if(m_breathing_interval.step(dtime, 0.5)) @@ -2270,7 +2271,7 @@ void ClientEnvironment::step(float dtime) if (!lplayer->hp){ lplayer->setBreath(11); } - else if(!c.isLiquid() || !c.drowning){ + else if(c.drowning == 0){ u16 breath = lplayer->getBreath(); if(breath <= 10){ breath += 1; diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 53e4d63f5..41956ca2e 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -220,7 +220,7 @@ void ContentFeatures::reset() liquid_renewable = true; freezemelt = ""; liquid_range = LIQUID_LEVEL_MAX+1; - drowning = true; + drowning = 0; light_source = 0; damage_per_second = 0; node_box = NodeBox(); diff --git a/src/nodedef.h b/src/nodedef.h index 714e1ba2c..c0322d919 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -228,7 +228,7 @@ struct ContentFeatures std::string freezemelt; // Number of flowing liquids surrounding source u8 liquid_range; - bool drowning; + u8 drowning; // Amount of light the node emits u8 light_source; u32 damage_per_second; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index ef0544400..f9765b655 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -400,7 +400,8 @@ ContentFeatures read_content_features(lua_State *L, int index) getboolfield(L, index, "liquid_renewable", f.liquid_renewable); getstringfield(L, index, "freezemelt", f.freezemelt); - getboolfield(L, index, "drowning", f.drowning); + f.drowning = getintfield_default(L, index, + "drowning", f.drowning); // Amount of light the node emits f.light_source = getintfield_default(L, index, "light_source", f.light_source); |