minetest icon indicating copy to clipboard operation
minetest copied to clipboard

Prevent damage avoidance in damage_per_second nodes

Open Wuzzy2 opened this issue 4 years ago • 13 comments

Problem

Often, you can manage to avoid damage from nodes with damage_per_second even if you are inside. You just have to be inside those blocks at the right moment and for less for a second. That way, you could pass a couple of such nodes with 0 damage.

This is bad if you want to create a barrier that guarantees damage when passing it. It screws up game design if players can just luck out and walk through without any damage.

Analysis

It seems that damage is dealt on fixed time points that are the same for all players. So the nodes only hurt when the player is inside a specific time. Any other times are completely safe. So you can easily luck out.

Solutions

I propose a solution that guarantees damage when entering a node:

  1. Create internal “damage timers” for every player, initialize them with 0
  2. When a player is touching any damage_per_second node anywhere, immediately apply the node damage
  3. Start the player's damage timer
  4. Every time the timer has advanced by 1 second and the player is still touching any damage_per_second node(s), deal node damage again
  5. When the player is “safe” (outside of all damage_per_second nodes, stop the timer and reset it to 0

Alternatives

In case the current damage method is still desired for some reason:

Add a new field to the node definition. If set to true, apply the new method of instant damage. If set to false (=default), use the current damage method.

Wuzzy2 avatar Feb 07 '20 16:02 Wuzzy2

This won't allow hacked clients to completely bypass damage?

LoneWolfHT avatar Feb 07 '20 17:02 LoneWolfHT

Hacked clients are a separate problem. This issue does not care about hacked clients. It is concerned about basic gameplay functionionality of damage_per_second. You do not need a hacked client to exploit the current behavior of damage_per_second, you just need to be lucky.

Wuzzy2 avatar Feb 07 '20 17:02 Wuzzy2

Hacked clients are a separate problem. This issue does not care about hacked clients. It is concerned about basic gameplay functionality of damage_per_second. You do not need a hacked client to exploit the current behaviour of damage_per_second, you just need to be lucky.

But you can't get around the current behaviour of damage_per_second with a hacked client.

Maybe do this by having the player send a 'entered DPS node' packet that resets the server's check-&-damage-if-in-dps-node timer (for them only, other players might enter at a different time). It should have about the same result, and that way if the player's client doesn't send the packet the server will still deal damage as usual. This will also preserve backwards-compatibility too AFAIK

LoneWolfHT avatar Feb 07 '20 17:02 LoneWolfHT

I cannot see how the suggested solution allows hacked clients to avoid damage, presumably the suggested solution is also serverside?

I think the solution needs to be fairly simple, as this is a minor issue. For many damaging nodes, running quickly through without being damaged makes sense, for example fire.

paramat avatar Feb 07 '20 22:02 paramat

I cannot see how the suggested solution allows hacked clients to avoid damage, presumably the suggested solution is also serverside?

Heh, might be. I was assuming Create internal “damage timers” for every player meant a timer for each client

I think the solution needs to be fairly simple, as this is a minor issue. For many damaging nodes, running quickly through without being damaged makes sense, for example fire.

I'd lower the DPS on my fire node, not force all DPS nodes to have behaviour like that. I don't think you can not burn when running through a fire half your size anyway

LoneWolfHT avatar Feb 07 '20 22:02 LoneWolfHT

Realistically it is possible to run through a 1m fire without harm.

paramat avatar Feb 09 '20 03:02 paramat

Just realized the MTG player can't run :thinking:

LoneWolfHT avatar Feb 09 '20 17:02 LoneWolfHT

I guess instead of immediately triggering damage support could be added for delaying how soon after entry you will take damage

LoneWolfHT avatar Feb 10 '20 06:02 LoneWolfHT

Realistically it is possible to run through a 1m fire without harm.

True, but it's not realistic to be able to run through 1m of lava without harm. Yet I can do that very easily in Minetest :)

sorcerykid avatar Feb 24 '20 03:02 sorcerykid

Good point, there may be nodes that cause extreme damage where running through should never avoid damage.

paramat avatar Feb 25 '20 01:02 paramat

This should be optional to not break current expected behavior of no damage if the player is in the node for less than a second.

appgurueu avatar Apr 27 '20 13:04 appgurueu

Has this been fixed?

farooqkz avatar Jul 24 '22 11:07 farooqkz

Has this been fixed?

No, otherwise there would be a linked PR or commit and this issue would have been closed.

appgurueu avatar Jul 24 '22 12:07 appgurueu