Cooperative node breaking

Post Reply
User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Cooperative node breaking

by texmex » Post

How do I make a node breakable only by at least two players punching it?

Edit: Full concept.
Last edited by texmex on Mon Jun 19, 2017 13:14, edited 1 time in total.

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Cooperative node breaking

by Byakuren » Post

I don't think there is a way, the server doesn't keep track of whether people are digging a node. Maybe you could approximate the effect like this:
- Make your node undiggable, and have it turn into a different node (with identical appearance) if two different players punch (activate the node's on_punch callback) in close succession. You might also check that the tools they are holding can dig the node, unless it is breakable by hand.
- Have this new node be diggable. Also make it use a node timer to turn it back into the first node if it isn't dug after a little bit.
Every time a mod API is left undocumented, a koala dies.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Cooperative node breaking

by texmex » Post

Byakuren wrote:I don't think there is a way, the server doesn't keep track of whether people are digging a node. Maybe you could approximate the effect like this:
- Make your node undiggable, and have it turn into a different node (with identical appearance) if two different players punch (activate the node's on_punch callback) in close succession. You might also check that the tools they are holding can dig the node, unless it is breakable by hand.
- Have this new node be diggable. Also make it use a node timer to turn it back into the first node if it isn't dug after a little bit.
Thank you for taking the time to reply. That sounds like it can be done. I want to build coop elements into a game, so that bedrock is only breakable if you cooperate, for example.

I know nothing about node timers currently. Can you think of any other mods that could have parts of such implementation to look to for examples? Thanks regardless!

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Cooperative node breaking

by Byakuren » Post

I don't know of any mods that do what you are doing. If you just want an example of nodetimer usage you could look at the furnace code in Minetest Game, but your use case is much simpler so it might just be distracting to have to look through everything specific to furnaces.

Using the node timer would mean having an on_timer that turns the node into the non-activated node. Also when you activate the node (replace it with the second type of node), you need to start the node timer.
Every time a mod API is left undocumented, a koala dies.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Cooperative node breaking

by texmex » Post

Byakuren wrote:I don't know of any mods that do what you are doing. If you just want an example of nodetimer usage you could look at the furnace code in Minetest Game, but your use case is much simpler so it might just be distracting to have to look through everything specific to furnaces.

Using the node timer would mean having an on_timer that turns the node into the non-activated node. Also when you activate the node (replace it with the second type of node), you need to start the node timer.
Thank you again. I'll start reading up on it!

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Cooperative node breaking

by texmex » Post

Concept
1. Player 1 punches the node. The first crack texture shows on the punched node.
2. Player 2 punches the node. The second crack textures show on the punched node.
3. Step 1 and 2 is repeated (and the crack gets bigger) until node is dug. The dug node is either given to the player with the last successful punch or, if an item_drop mod is used, dropped.

Restrictions
- The same player cannot further crack a node two times in a row.
- A timer of 1-3 seconds resets the partly cracked node to its original state if the timer is not restarted by further successful punching.

Implementation
- Use can_dig to check if the node has been punched enough and by enough players and drop it if so.
- Use on_punch to start and restart timer, to count punches and to count players punching. (registering which players specifically could be good for future features).
- Node group definition could be dig_coop. If 0 it's disabled, if 1 it's enabled but optional, if 2 it's enabled and mandatory.
- Drop group definition could be drop_coop, and work exactly as regular drop.

Issues
The way regular crack textures are applied on a node is probably by overlaying a node box, so replicating this will probably be harder than the rest.

As you can see, I can make out the general feature set. Coding it will be a challenge though :D

User avatar
kaadmy
Member
Posts: 706
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: Cooperative node breaking

by kaadmy » Post

I think if you change the node, the digging is stopped client-side, so switching nodes won't work (and is INCREDIBLY ugly)
Also digging is 100% client side right now, the server doesn't have any knowledge of digging until it's finished.
Never paint white stripes on roads near Zebra crossings.

Pixture

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Cooperative node breaking

by texmex » Post

kaadmy wrote:I think if you change the node, the digging is stopped client-side, so switching nodes won't work (and is INCREDIBLY ugly)
Also digging is 100% client side right now, the server doesn't have any knowledge of digging until it's finished.
How about counting punches in on_punch and dig the node from there if requirements are met? (And fake the cracking)

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Cooperative node breaking

by Byakuren » Post

How about in on_dig you check if there are any other players pointing at it with their LMB down (check if the player's view direction is toward the node within some tolerance, or use some raytracing code)?
Every time a mod API is left undocumented, a koala dies.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Cooperative node breaking

by texmex » Post

Byakuren wrote:How about in on_dig you check if there are any other players pointing at it with their LMB down (check if the player's view direction is toward the node within some tolerance, or use some raytracing code)?
It sounds more complex than it possibly have to be. Do you think my idea above is not possible?

Byakuren
Member
Posts: 818
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: Cooperative node breaking

by Byakuren » Post

texmex wrote:
Byakuren wrote:How about in on_dig you check if there are any other players pointing at it with their LMB down (check if the player's view direction is toward the node within some tolerance, or use some raytracing code)?
It sounds more complex than it possibly have to be. Do you think my idea above is not possible?
I thought you wanted something like normal Minetest digging where you hold down the mouse button to dig.
Every time a mod API is left undocumented, a koala dies.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: Cooperative node breaking

by texmex » Post

Byakuren wrote:I thought you wanted something like normal Minetest digging where you hold down the mouse button to dig.
Hmm, yes, you're right. Will try it.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests