mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue