Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow player entities to be switched to server-side authority #8567

Closed
tenplus1 opened this issue May 28, 2019 · 18 comments
Closed

Allow player entities to be switched to server-side authority #8567

tenplus1 opened this issue May 28, 2019 · 18 comments
Labels
@ Client / Controls / Input Feature request Issues that request the addition or enhancement of a feature @ Server / Client / Env.

Comments

@tenplus1
Copy link
Contributor

tenplus1 commented May 28, 2019

Would it be possible to add a new flag to player overrides that allows mods to switch player control on/off, and when off the set_velocity and set_acceleration functions work with player model ?

e.g.

player:set_physics_override({control=false}) -- turn off player control/movement
player:set_acceleration({x=0,y=20,z=0})
player:set_physics_override({control=true}) -- turn on player control

Note: This would also be a handy jail function for naughty players :) and player knockback.

2nd Note: Being able to move player without locking movement would be much better :)

@tenplus1
Copy link
Contributor Author

Forum page added for feature discussion: https://forum.minetest.net/viewtopic.php?f=5&t=22633&p=347975

@IhrFussel
Copy link

IhrFussel commented May 28, 2019

Yes, give server owners and game designers finally a way to directly manipulate player controls.

The hacky way via entities is bad and tedious. It also leaves a lot of room for errors when trying to implement it (for example forgetting to delete the entity and therefore filling the map with garbage data).

I also don't understand the viewpoint of some that servers should never have full control over players.

Maybe they don't see what kind of control server staff already got.

We can:

  • Mute
  • Kick
  • Ban
  • Read PMs
  • Disable any movement simply by attaching a player to an entity

...and more

But when it comes to controlling player velocity and acceleration on a server directly people don't want to allow it? Sorry but I don't follow that logic.

@Desour
Copy link
Member

Desour commented May 28, 2019

Related: #3208

The hacky way via entities is bad and tedious. It also leaves a lot of room for errors when trying to implement it (for example forgetting to delete the entity and therefore filling the map with garbage data).

The example shouldn't be a problem with static_save = false.

We can[…] Disable any movement simply by attaching a player to an entity

So in what way would physics overrides be better than player attachment?

This would also be a handy jail function for naughty players

This wouldn't be better than setting speed in set_physics_override to 0, would it?

Also note that doing thing like knockback with this would be horrible.

@tenplus1
Copy link
Contributor Author

@DS-Minetest - What is 'static_save = false' referring to ? also the jailed players is an example and why would using this flag be bad for knockback ? please explain ?

@Desour
Copy link
Member

Desour commented May 28, 2019

What is 'static_save = false' referring to ?

In object properties:

minetest/doc/lua_api.txt

Lines 5709 to 5713 in a1459a9

static_save = true,
-- If false, never save this object statically. It will simply be
-- deleted when the block gets unloaded.
-- The get_staticdata() callback is never called then.
-- Defaults to 'true'.

The object isn't there anymore when it's unloaded and won't come back which means that forgetting to delete it won't fill the map with garbage data.

why would using this flag be bad for knockback ?

Using this flag for knockback would mean that the player can't move for a certain period of time. And this period is depends on the connection latency to the server. This means that it is possible that a player hits another one and 5 seconds later the punched player can't control and has a certain velocity and this state of awkwardness can take many seconds.
All in all this isn't even better as if you would just add a certain velocity on punch without stopping control. This would mean that one player punches another one and some seconds later the punched player gets a velocity in a direction added to him. But the player could still move around with this added velocity which would be unnoticeable after some seconds of friction and moving against the velocity.

@tenplus1
Copy link
Contributor Author

@DS-Minetest - Thanks for the 'static_save' information. Knockback for example would only affect the player for 0.5 seconds before returning control, this would be enough time to push the player in a certain direction and regain control. player set_velocity and set_acceleration is an important funciton that we currently lack.

@TS440S
Copy link

TS440S commented May 28, 2019

I would also like to add that using entities to attach players and move them is really laggy, even on a server with no mods. During a lag spike the player that's attached will keep moving in the direction before the lag, and not stop. A good example is minecarts. Sometimes while going around a turn the player and cart keeps moving off the rails and in the wrong direction. Also, many vehicle mods or airship mods all have the lag problem. And I do not think that player control should be disabled while being "knocked" back. If this lag were to happen during pvp, it would really ruin it. I think minetest's knockback should be as similar as possible to minecraft's knockback. Only lasting fractions of a second, non laggy, and the player can move during it. Imagine all the great things you could do with KB, sumo, pvp battles and tnt blasts would all be fun things!

@LoneWolfHT
Copy link
Contributor

minetest.raycast() and move_to() might also be workarounds for the lack of set_velocity(), ect.
I did a quick (Probably poorly done due to my limited vector knowledge) knockback mod with them. Seems to work fine in PvP.
https://github.com/LoneWolfHT/knockback

@TS440S
Copy link

TS440S commented May 28, 2019

minetest.raycast() and move_to() might also be workarounds for the lack of set_velocity(), ect.
I did a quick (Probably poorly done due to my limited vector knowledge) knockback mod with them. Seems to work fine in PvP.
https://github.com/LoneWolfHT/knockback

Woah, a working, simple, usable knockback mod? I don't care how bad you think it is, this is incredible! It actually works! I'm amazed! Can I slow down the speed of the knockback?

@Desour
Copy link
Member

Desour commented May 28, 2019

How good a knockback mod works depends on the server latency.

Knockback should actually just add an impulse (a velocity) to the player and not set the player velocity, teleport the player, give the player an acceleration in a direction or similar stuff.
Imo a much better solution to this would be that add_velocity is made possible for players. This was already suggested before more than once I think. See the issue I linked before.

I still do not understand how disabling player controls is needed. I guess the thought was that currently giving the player a velocity is only possible by attaching him to an object and then the player can't move and that this means that the reason why setting or adding player velocity server side isn't possible lies in the controls.

@tenplus1
Copy link
Contributor Author

tenplus1 commented May 28, 2019

It was said before that using functions like set_velocity and set_acceleration on a player would cause lag due to player controls, so I thought that disabling such controls would help the issue and allow for the player entity to be treated and moved just like a normal entity.

Also, LoneWolfHT - simple but effective knockback feature using raycasting :) nice.

@rubenwardy
Copy link
Member

rubenwardy commented May 28, 2019

This is better described as allowing server-side authority for player entities

But when it comes to controlling player velocity and acceleration on a server directly you don't want to allow it? Sorry but I don't follow that logic.

Citation please, I don't think this has ever been said

@rubenwardy rubenwardy changed the title Player Control Idea... Allow switch to server-side authority of player entities May 28, 2019
@rubenwardy rubenwardy changed the title Allow switch to server-side authority of player entities Allow player entities to be switched to server-side authority May 28, 2019
@Desour
Copy link
Member

Desour commented May 28, 2019

It was said before that using functions like set_velocity and set_acceleration on a player would cause lag due to player controls

Afaik, with this is meant that the player has a velocity that is gotten with ssm, then the ssm adds a velocity and sets the velocity, until it's sent, the player has local on its client another velocity that would be gotten, then the new velocity is not the velocity added.

Example
P = player
--> = velocity arrow

First the player is moving forwards:
P--->

The client sends this velocity.

The server mod calculates a new velocity by adding a constant one to the current player velocity:
measured_velocity + constant_velocity = new_velocity
---> + |  = \
       |      \
       |        \
       v          _|

The server sends the new velocity.

The player now changed it's velocity (with the help of control) to:
P
|
|
v

The client now receives the sent velocity and sets it to the player:

P
  \
    \
      \
        _|

But this velocity is not what the ssm wanted to achieve.
The wanted velocity is this:
current_velocity + constant_velocity = correct_new_velocity
| + | = |
|   |   |
v   |   |
    v   |
        |
        |
        v

Such problems don't appear with add_velocity.

@IhrFussel
Copy link

IhrFussel commented May 28, 2019

Citation please, I don't think this has ever been said

It was long long ago when I read about that on IRC ... I cannot find relevant logs right now and I also don't remember if those people actually were core devs, so I edited my comment.

@paramat paramat added @ Server / Client / Env. Feature request Issues that request the addition or enhancement of a feature @ Client / Controls / Input labels May 28, 2019
@paramat
Copy link
Contributor

paramat commented May 28, 2019

I also don't understand the viewpoint of some that servers should never have full control over players.

Celeron55 would agree with you, his rough quote was something like: 'The design of MT is that servers have all possible control'.

And I do not think that player control should be disabled while being "knocked" back.

I agree.

Knockback should actually just add an impulse (a velocity) to the player.

I agree, just an instantaneous added velocity is needed. After all, players can use controls to move around during falling or jumping.

However, this feature request may be useful, and it's fine for a server to override player controls.

@TS440S
Copy link

TS440S commented May 28, 2019

Shouldn't knockback be calculated by the client? I mean if its all server side then it will be slower and glitchier, right? Maybe the client gets word that your player was punched, and because the client already has the position of the puncher it can calculate the KB based on that and send position updates to the server.

@tenplus1
Copy link
Contributor Author

Having the client do the movement would be ideal, hopefully without the need of a csm mod.

@LoneWolfHT
Copy link
Contributor

set_velocity would be useful for resetting a player's velocity.
I've had times where I needed to teleport a falling player somewhere on the ground but they died of fall damage every time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client / Controls / Input Feature request Issues that request the addition or enhancement of a feature @ Server / Client / Env.
Projects
None yet
Development

No branches or pull requests

7 participants