Page 1 of 3
[Mod] Drowning [drowning]

Posted:
Sun Mar 25, 2012 16:43
by randomproof
Drowning DamageDescription: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:WTFPLDownload (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?pid=59231#p59231

Posted:
Sun Mar 25, 2012 17:07
by Utilisatrice
Hi randomproof,
Your mod works 100%.

Posted:
Sun Mar 25, 2012 17:16
by randomproof
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.

Posted:
Sun Mar 25, 2012 17:19
by kddekadenz
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.

Posted:
Sun Mar 25, 2012 17:36
by Utilisatrice
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.

Posted:
Sun Mar 25, 2012 17:39
by lord_james
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
--EDIT: Removed code. Suggestion was added.
Also, add a checker for "Enable damage"

Posted:
Sun Mar 25, 2012 17:41
by sdzen
you should make it if sand falls on top of you, you begin to drown

Posted:
Sun Mar 25, 2012 17:56
by sfan5
+1 for this Mod!
I've been waiting for this!

Posted:
Sun Mar 25, 2012 18:07
by sfan5
Topic moved without Request
Hope thats ok ;)

Posted:
Sun Mar 25, 2012 18:40
by randomproof
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.

Posted:
Sun Mar 25, 2012 18:52
by sdzen
yes that may work but it should kill you must faster than water

Posted:
Sun Mar 25, 2012 19:21
by lord_james
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
default.register_drowning_node("default:sand")
But I think be inside a solid node is a bug.

Posted:
Sun Mar 25, 2012 19:54
by jordan4ibanez
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- 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

Posted:
Sun Mar 25, 2012 21:50
by randomproof
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.

Posted:
Sun Mar 25, 2012 22:51
by lord_james
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

Posted:
Mon Mar 26, 2012 01:27
by jordan4ibanez
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

Posted:
Mon Mar 26, 2012 20:27
by sdzen
okay then a suffocation mod!

Posted:
Tue Mar 27, 2012 11:33
by Calinou
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).

Posted:
Tue Mar 27, 2012 11:56
by jordan4ibanez
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

Posted:
Tue Mar 27, 2012 19:16
by Scott
not working for me, im on latest unstable

Posted:
Tue Mar 27, 2012 19:46
by sdzen
but what if your flying!

Posted:
Tue Mar 27, 2012 20:36
by randomproof
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.

Posted:
Tue Mar 27, 2012 20:42
by sdzen
so suffocation or no freemove i think ill just move fast enough where it cant hurt me :P

Posted:
Tue Mar 27, 2012 21:23
by Death Dealer
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

Posted:
Tue Mar 27, 2012 21:53
by randomproof
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.

Posted:
Tue Mar 27, 2012 22:06
by Scott
why does it depend on growing?

Posted:
Tue Mar 27, 2012 22:23
by Death Dealer
randomproof wrote: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.
thanks^_^ it still crashs when swim in oil tho

Posted:
Tue Mar 27, 2012 23:18
by randomproof
Scott wrote:why does it depend on growing?
It doesn't. It depends on "default" (actually I don't think it does)
Death Dealer wrote:randomproof wrote: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.
thanks^_^ it still crashs when swim in oil tho
Hmmm... I don't use the oil mod so I don't know why. I can't see why if you are using the most recent version from github.
Edit: It looks like you are using a version from March 20th. Sound was added on the 24th.

Posted:
Tue Mar 27, 2012 23:24
by Death Dealer
randomproof wrote:Scott wrote:why does it depend on growing?
It doesn't. It depends on "default" (actually I don't think it does)
Death Dealer wrote:randomproof wrote: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.
thanks^_^ it still crashs when swim in oil tho
Hmmm... I don't use the oil mod so I don't know why. I can't see why if you are using the most recent version from github.
i am using ver 20120320. i think thats the newest.

Posted:
Tue Mar 27, 2012 23:30
by randomproof
Death Dealer wrote:randomproof wrote:Scott wrote:why does it depend on growing?
It doesn't. It depends on "default" (actually I don't think it does)
Death Dealer wrote:thanks^_^ it still crashs when swim in oil tho
Hmmm... I don't use the oil mod so I don't know why. I can't see why if you are using the most recent version from github.
i am using ver 20120320. i think thats the newest.
Edit: It looks like you are using a version from March 20th. Sound was added on the 24th. The version you can pull from github and compile yourself is always the most recent. If you go to
https://github.com/celeron55/minetest you can see the most recent commit and its date.
Until a Windows build is made you can comment out the 'sound_play' functions by placing two minus symbols in from of them.