diff --git a/builtin/item.lua b/builtin/item.lua index 9105d8c0..6a01f37f 100644 --- a/builtin/item.lua +++ b/builtin/item.lua @@ -490,6 +490,7 @@ minetest.nodedef_default = { liquid_alternative_flowing = "", liquid_alternative_source = "", liquid_viscosity = 0, + drowning = 0, light_source = 0, damage_per_second = 0, selection_box = {type="regular"}, diff --git a/doc/lua_api.txt b/doc/lua_api.txt index d3458878..5247b248 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1991,7 +1991,7 @@ Node definition (register_node) freezemelt = "", -- water for snow/ice, ice/snow for water leveled = 0, -- Block contain level in param2. value - default level, used for snow. Dont forget use "leveled" type nodebox liquid_range = 8, -- number of flowing nodes arround source (max. 8) - drowning = true, -- Player will drown in these + drowning = 0, -- Player will take this amount of damage if no bubbles are left two or more sources nearly? light_source = 0, -- Amount of light emitted by node damage_per_second = 0, -- If player is inside node, this damage is caused diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua index 9f9db5ac..afde19b5 100644 --- a/games/minimal/mods/default/init.lua +++ b/games/minimal/mods/default/init.lua @@ -1001,6 +1001,7 @@ minetest.register_node("default:water_flowing", { pointable = false, diggable = false, buildable_to = true, + drowning = 1, liquidtype = "flowing", liquid_alternative_flowing = "default:water_flowing", liquid_alternative_source = "default:water_source", @@ -1024,6 +1025,7 @@ minetest.register_node("default:water_source", { pointable = false, diggable = false, buildable_to = true, + drowning = 1, liquidtype = "source", liquid_alternative_flowing = "default:water_flowing", liquid_alternative_source = "default:water_source", @@ -1055,6 +1057,7 @@ minetest.register_node("default:lava_flowing", { pointable = false, diggable = false, buildable_to = true, + drowning = 1, liquidtype = "flowing", liquid_alternative_flowing = "default:lava_flowing", liquid_alternative_source = "default:lava_source", @@ -1082,6 +1085,7 @@ minetest.register_node("default:lava_source", { pointable = false, diggable = false, buildable_to = true, + drowning = 1, liquidtype = "source", liquid_alternative_flowing = "default:lava_flowing", liquid_alternative_source = "default:lava_source", diff --git a/src/environment.cpp b/src/environment.cpp index 40dba9a6..76a8aab5 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 53e4d63f..41956ca2 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 714e1ba2..c0322d91 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 ef054440..f9765b65 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);