mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Add support for different drowning damage and allow drowning in other nodetypes
This commit is contained in:
parent
ba65e2ae6c
commit
7b13d119ed
@ -490,6 +490,7 @@ minetest.nodedef_default = {
|
|||||||
liquid_alternative_flowing = "",
|
liquid_alternative_flowing = "",
|
||||||
liquid_alternative_source = "",
|
liquid_alternative_source = "",
|
||||||
liquid_viscosity = 0,
|
liquid_viscosity = 0,
|
||||||
|
drowning = 0,
|
||||||
light_source = 0,
|
light_source = 0,
|
||||||
damage_per_second = 0,
|
damage_per_second = 0,
|
||||||
selection_box = {type="regular"},
|
selection_box = {type="regular"},
|
||||||
|
@ -1991,7 +1991,7 @@ Node definition (register_node)
|
|||||||
freezemelt = "", -- water for snow/ice, ice/snow for water
|
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
|
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)
|
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?
|
two or more sources nearly?
|
||||||
light_source = 0, -- Amount of light emitted by node
|
light_source = 0, -- Amount of light emitted by node
|
||||||
damage_per_second = 0, -- If player is inside node, this damage is caused
|
damage_per_second = 0, -- If player is inside node, this damage is caused
|
||||||
|
@ -1001,6 +1001,7 @@ minetest.register_node("default:water_flowing", {
|
|||||||
pointable = false,
|
pointable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
|
drowning = 1,
|
||||||
liquidtype = "flowing",
|
liquidtype = "flowing",
|
||||||
liquid_alternative_flowing = "default:water_flowing",
|
liquid_alternative_flowing = "default:water_flowing",
|
||||||
liquid_alternative_source = "default:water_source",
|
liquid_alternative_source = "default:water_source",
|
||||||
@ -1024,6 +1025,7 @@ minetest.register_node("default:water_source", {
|
|||||||
pointable = false,
|
pointable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
|
drowning = 1,
|
||||||
liquidtype = "source",
|
liquidtype = "source",
|
||||||
liquid_alternative_flowing = "default:water_flowing",
|
liquid_alternative_flowing = "default:water_flowing",
|
||||||
liquid_alternative_source = "default:water_source",
|
liquid_alternative_source = "default:water_source",
|
||||||
@ -1055,6 +1057,7 @@ minetest.register_node("default:lava_flowing", {
|
|||||||
pointable = false,
|
pointable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
|
drowning = 1,
|
||||||
liquidtype = "flowing",
|
liquidtype = "flowing",
|
||||||
liquid_alternative_flowing = "default:lava_flowing",
|
liquid_alternative_flowing = "default:lava_flowing",
|
||||||
liquid_alternative_source = "default:lava_source",
|
liquid_alternative_source = "default:lava_source",
|
||||||
@ -1082,6 +1085,7 @@ minetest.register_node("default:lava_source", {
|
|||||||
pointable = false,
|
pointable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
buildable_to = true,
|
buildable_to = true,
|
||||||
|
drowning = 1,
|
||||||
liquidtype = "source",
|
liquidtype = "source",
|
||||||
liquid_alternative_flowing = "default:lava_flowing",
|
liquid_alternative_flowing = "default:lava_flowing",
|
||||||
liquid_alternative_source = "default:lava_source",
|
liquid_alternative_source = "default:lava_source",
|
||||||
|
@ -2243,7 +2243,8 @@ void ClientEnvironment::step(float dtime)
|
|||||||
v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS);
|
v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS);
|
||||||
MapNode n = m_map->getNodeNoEx(p);
|
MapNode n = m_map->getNodeNoEx(p);
|
||||||
ContentFeatures c = m_gamedef->ndef()->get(n);
|
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();
|
u16 breath = lplayer->getBreath();
|
||||||
if(breath > 10){
|
if(breath > 10){
|
||||||
breath = 11;
|
breath = 11;
|
||||||
@ -2255,8 +2256,8 @@ void ClientEnvironment::step(float dtime)
|
|||||||
updateLocalPlayerBreath(breath);
|
updateLocalPlayerBreath(breath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lplayer->getBreath() == 0){
|
if(lplayer->getBreath() == 0 && drowning_damage > 0){
|
||||||
damageLocalPlayer(1, true);
|
damageLocalPlayer(drowning_damage, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m_breathing_interval.step(dtime, 0.5))
|
if(m_breathing_interval.step(dtime, 0.5))
|
||||||
@ -2270,7 +2271,7 @@ void ClientEnvironment::step(float dtime)
|
|||||||
if (!lplayer->hp){
|
if (!lplayer->hp){
|
||||||
lplayer->setBreath(11);
|
lplayer->setBreath(11);
|
||||||
}
|
}
|
||||||
else if(!c.isLiquid() || !c.drowning){
|
else if(c.drowning == 0){
|
||||||
u16 breath = lplayer->getBreath();
|
u16 breath = lplayer->getBreath();
|
||||||
if(breath <= 10){
|
if(breath <= 10){
|
||||||
breath += 1;
|
breath += 1;
|
||||||
|
@ -220,7 +220,7 @@ void ContentFeatures::reset()
|
|||||||
liquid_renewable = true;
|
liquid_renewable = true;
|
||||||
freezemelt = "";
|
freezemelt = "";
|
||||||
liquid_range = LIQUID_LEVEL_MAX+1;
|
liquid_range = LIQUID_LEVEL_MAX+1;
|
||||||
drowning = true;
|
drowning = 0;
|
||||||
light_source = 0;
|
light_source = 0;
|
||||||
damage_per_second = 0;
|
damage_per_second = 0;
|
||||||
node_box = NodeBox();
|
node_box = NodeBox();
|
||||||
|
@ -228,7 +228,7 @@ struct ContentFeatures
|
|||||||
std::string freezemelt;
|
std::string freezemelt;
|
||||||
// Number of flowing liquids surrounding source
|
// Number of flowing liquids surrounding source
|
||||||
u8 liquid_range;
|
u8 liquid_range;
|
||||||
bool drowning;
|
u8 drowning;
|
||||||
// Amount of light the node emits
|
// Amount of light the node emits
|
||||||
u8 light_source;
|
u8 light_source;
|
||||||
u32 damage_per_second;
|
u32 damage_per_second;
|
||||||
|
@ -400,7 +400,8 @@ ContentFeatures read_content_features(lua_State *L, int index)
|
|||||||
|
|
||||||
getboolfield(L, index, "liquid_renewable", f.liquid_renewable);
|
getboolfield(L, index, "liquid_renewable", f.liquid_renewable);
|
||||||
getstringfield(L, index, "freezemelt", f.freezemelt);
|
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
|
// Amount of light the node emits
|
||||||
f.light_source = getintfield_default(L, index,
|
f.light_source = getintfield_default(L, index,
|
||||||
"light_source", f.light_source);
|
"light_source", f.light_source);
|
||||||
|
Loading…
Reference in New Issue
Block a user