mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Add support for different drowning damage and allow drowning in other nodetypes
This commit is contained in:
parent
ba65e2ae6c
commit
7b13d119ed
7 changed files with 15 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue