[Mod] Drowning [drowning]

randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

[Mod] Drowning [drowning]

by randomproof » Post

Drowning Damage

Description:

NOW WITH SOUNDS!

I haven't had time to test this just yet. I'm not sure if the function IsPlayerUnderWater() is right. I think that the position you get from the player is at the feet and if you add one node up you get where the head is. If someone knows otherwise let me know. But otherwise you will get DROWNING_DAMAGE every DROWNING_SECONDS seconds (default to 1 damage every 30 seconds under water). On my computer globalstep runs pretty regularly at a little under once a second so popping out of water for at least a second or two should be good to reset the timer. I'm thinking of adding some feedback to the user, such as a countdown with chat messages.

License of code and textures:
WTFPL

Download (old version)

Updated version:
Casimir has continued to work on this mod in Randomproof's absence. See post #55 and surrounding context for details on his updates.

http://minetest.net/forum/viewtopic.php ... 231#p59231
Last edited by VanessaE on Wed Dec 26, 2012 01:09, edited 1 time in total.

Utilisatrice
Member
Posts: 103
Joined: Thu Feb 16, 2012 18:04

by Utilisatrice » Post

Hi randomproof,

Your mod works 100%.

randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

Ok, good. I have to go out shopping with the wife right now, but later I'm going to make a small change so you can set how long you can be underwater before damage starts. So say you want it so that you can be underwater for 60 seconds and then every 10 seconds you get 1 point of damage.

User avatar
kddekadenz
Member
Posts: 323
Joined: Mon Jun 27, 2011 17:21
GitHub: tinyworlds
Location: Germany
Contact:

by kddekadenz » Post

Works!
But I would use a smaller value for the drowning_seconds.

EDIT: You replied faster then me.. Your way would be better, but I would suggest after 30 s and then every 3 seconds.
Last edited by kddekadenz on Sun Mar 25, 2012 17:21, edited 1 time in total.

Utilisatrice
Member
Posts: 103
Joined: Thu Feb 16, 2012 18:04

by Utilisatrice » Post

kddekadenz wrote:Works!
But I would use a smaller value for the drowning_seconds.

EDIT: You replied faster then me.. Your way would be better, but I would suggest after 30 s and then every 3 seconds.
+1 Good Idea.

lord_james
Member
Posts: 51
Joined: Sun Mar 11, 2012 22:06

by lord_james » Post

randomproof wrote:Ok, good. I have to go out shopping with the wife right now, but later I'm going to make a small change so you can set how long you can be underwater before damage starts. So say you want it so that you can be underwater for 60 seconds and then every 10 seconds you get 1 point of damage.
Work on the box. But like falling nodes, I think it's better add the chance to add more drowning nodes:

Code: Select all

--EDIT: Removed code. Suggestion was added.
Also, add a checker for "Enable damage"
Last edited by lord_james on Sun Mar 25, 2012 22:35, edited 1 time in total.

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

you should make it if sand falls on top of you, you begin to drown

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

+1 for this Mod!
I've been waiting for this!
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

sfan5
Moderator
Posts: 4095
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5
Location: Germany

by sfan5 » Post

Topic moved without Request
Hope thats ok ;)
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)

randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

sdzen wrote:you should make it if sand falls on top of you, you begin to drown
Could just check if node is not air? Would have to see if free_move is on though.

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

yes that may work but it should kill you must faster than water

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

lord_james
Member
Posts: 51
Joined: Sun Mar 11, 2012 22:06

by lord_james » Post

sdzen wrote:yes that may work but it should kill you must faster than water
:S Work on the box. Add in my suggestion this:

Code: Select all

default.register_drowning_node("default:sand")
But I think be inside a solid node is a bug.

User avatar
jordan4ibanez
Member
Posts: 1923
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Post

lord_james wrote:
sdzen wrote:yes that may work but it should kill you must faster than water
:S Work on the box. Add in my suggestion this:

Code: Select all

default.register_drowning_node("default:sand")
But I think be inside a solid node is a bug.
no..sand and gravel can fall on you
hello, am program. do language in rust. make computer do. okay i go now.

randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

Code is updated. If you want sand and gravel to drown your players add this to the end of the file:
drowning.register_drowning_node("default:sand")
drowning.register_drowning_node("default:gravel")

Any other mod can depend on this one and add there own as well.

lord_james
Member
Posts: 51
Joined: Sun Mar 11, 2012 22:06

by lord_james » Post

Great job! Now, it's only necessary that API allows a custom HUD (for example, bubbles).
jordan4ibanez wrote:no..sand and gravel can fall on you
Well... I still think a falling solid node must kill you rather drowning haha. But this feature is for another topic:

http://c55.me/minetest/forum/viewtopic.php?id=1303
Last edited by lord_james on Sun Mar 25, 2012 22:52, edited 1 time in total.

User avatar
jordan4ibanez
Member
Posts: 1923
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Post

lord_james wrote:Great job! Now, it's only necessary that API allows a custom HUD (for example, bubbles).
jordan4ibanez wrote:no..sand and gravel can fall on you
Well... I still think a falling solid node must kill you rather drowning haha. But this feature is for another topic:

http://c55.me/minetest/forum/viewtopic.php?id=1303
drown as in suffocate
hello, am program. do language in rust. make computer do. okay i go now.

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

okay then a suffocation mod!

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

User avatar
Calinou
Moderator
Posts: 3169
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

by Calinou » Post

Could be easy: all nodes deal 2 HP damage per second (= 1 heart). However, you would "suffocate" if only your feet were inside solid blocks and would not suffocate if only your head was (like lava).

User avatar
jordan4ibanez
Member
Posts: 1923
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Post

Calinou wrote:Could be easy: all nodes deal 2 HP damage per second (= 1 heart). However, you would "suffocate" if only your feet were inside solid blocks and would not suffocate if only your head was (like lava).
then use "if above" or whatever it is to get the node above it
hello, am program. do language in rust. make computer do. okay i go now.

Scott
Member
Posts: 100
Joined: Sun Nov 13, 2011 06:35

by Scott » Post

not working for me, im on latest unstable
ubuntu would be #1, without unity

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

but what if your flying!

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

sdzen wrote:but what if your flying!
I can't test to see if you have free_move on so you can drown if flying.

User avatar
sdzen
Member
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Post

so suffocation or no freemove i think ill just move fast enough where it cant hurt me :P

Zen S.D.

The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno

User avatar
Death Dealer
Member
Posts: 1379
Joined: Wed Feb 15, 2012 18:46
Location: Limbo
Contact:

by Death Dealer » Post

ya ive tryed this several times on differrent recent versions here is the error text i get after the program crashs when trying to call the field "sound play"

14:13:27: INFO[main]: Client packetcounter (20s):
14:13:27: INFO[main]: cmd 16 count 0
14:13:27: INFO[main]: cmd 32 count 14
14:13:27: INFO[main]: cmd 39 count 0
14:13:27: INFO[main]: cmd 41 count 0
14:13:27: INFO[main]: cmd 49 count 0
14:13:27: INFO[main]: cmd 50 count 93
14:13:27: INFO[main]: cmd 51 count 0
14:13:27: INFO[main]: cmd 52 count 0
14:13:27: INFO[main]: cmd 54 count 0
14:13:27: INFO[main]: cmd 56 count 0
14:13:27: INFO[main]: cmd 58 count 0
14:13:27: INFO[main]: cmd 60 count 0
14:13:27: INFO[main]: cmd 61 count 0
14:13:28: INFO[main]: Client: avg_rtt=0
14:13:28: INFO[ServerThread]: ServerMap: Unloaded 42 blocks from memory, of which 19 were written, 163 blocks in memory.
14:13:28: INFO[ServerThread]: ServerMap: Blocks modified by:
14:13:28: INFO[ServerThread]: setTimestamp: - - - - - - - - - - - - - - 19
14:13:31: INFO[ServerThread]: ServerMap: Unloaded 38 blocks from memory, of which 0 were written, 125 blocks in memory.
14:13:37: VERBOSE[main]: Client: time_of_day=11623 time_speed=96 dr=1000
14:13:38: INFO[main]: Client: avg_rtt=0
14:13:47: INFO[main]: Client packetcounter (20s):
14:13:47: INFO[main]: cmd 16 count 0
14:13:47: INFO[main]: cmd 32 count 0
14:13:47: INFO[main]: cmd 39 count 0
14:13:47: INFO[main]: cmd 41 count 1
14:13:47: INFO[main]: cmd 49 count 0
14:13:47: INFO[main]: cmd 50 count 94
14:13:47: INFO[main]: cmd 51 count 0
14:13:47: INFO[main]: cmd 52 count 0
14:13:47: INFO[main]: cmd 54 count 0
14:13:47: INFO[main]: cmd 56 count 0
14:13:47: INFO[main]: cmd 58 count 0
14:13:47: INFO[main]: cmd 60 count 0
14:13:47: INFO[main]: cmd 61 count 0
14:13:47: INFO[ServerThread]: Players:
14:13:47: INFO[ServerThread]: * singleplayer RemoteClient 2: m_blocks_sent.size()=63, m_blocks_sending.size()=0, m_nearest_unsent_d=0, m_excess_gotblocks=0
14:13:48: INFO[main]: Client: avg_rtt=0
14:13:53: ERROR[ServerThread]: ERROR: An unhandled exception occurred: LuaError: error: ...0120320-win32\bin\..\mods\mesetint\drowning\init.lua:39: attempt to call field 'sound_play' (a nil value)
14:13:53: ERROR[ServerThread]: stack traceback:

In thread 700:
C:\tmp\minetest\src\server.cpp:118: ServerThread::Thread: Assertion '0' failed.
Debug stacks:
DEBUG STACK FOR THREAD 444:
#0 main
#1 ClientMap::renderMap
(Leftover data: #2 ClientEnvironment::step)
(Leftover data: #3 Client::Receive)
(Leftover data: #4 Client::ProcessData)
(Leftover data: #5 MeshUpdateQueue::addBlock)
DEBUG STACK FOR THREAD 700:
#0 ServerThread::Thread
(Leftover data: #1 Server::AsyncRunStep)
(Leftover data: #2 ServerEnvironment::step)
(Leftover data: #3 RemoteClient::GetNextBlocks)
(Leftover data: #4 BlockEmergeQueue::addBlock)
DEBUG STACK FOR THREAD ff4:
#0 MeshUpdateThread::Thread
Keep calm and code python^_^

randomproof
Member
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Post

I think it might be because I forgot the depends.txt file. I've updated the download, but you could add the depends.txt file with "default" in it.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests