r/MultiplayerGameDevs • • 2d ago

Question A question about server requests

Hi, I haven't actually made anything with multiplayer yet but I'm theorizing an approach to an MMORPG combat system. I would like feedback on something I'm stuck on.

The project consists of standalone clients connecting to a dedicated server (server authority model).

Conundrum:

I have a skillbar with skills, these have a manacost, cooldown, range and require a living enemy target.

Whenever a target is selected, the skill icons should be colorized when the skill is castable, and grayed out when one of ita criteria isn't met (mana, range, etc...)

Should I just let the client check if the skill is castable (with predicted variables) to display the correct icon before I'm asking the server for the true state (recheck of criteria) to update my skills icons?

This to minimize requests to the server and optimizing performance of it. This does make server and client both do the same thing though.

And let's say I'm a player with malicious intent. When I change the client's code so the skill has no cooldown, I could theoretically flood the server with requests check the criteria for the skill being castable. (There is no global cooldown mechanic for skills as often used in these type of games).

Is this a valid approach and does the server need another sort of protection against requests being spammed maliciously or should I be going at this in another way?

I do realize I might be overthinking this all, but my brain can't let it go and is turning into swiss cheese. Pls halp ;-;

For clarification:

No, I'm not planning on creating an MMO, simply a combat system that I thought of. Theory sounds fun to me, does it work and is it fun in practice?

Yes this idea can be developed without implementing multiplayer, but it's a great and interesting opportunity to expand my skills and knowledge.

2 Upvotes

12 comments sorted by

3

u/Head_Evening_5697 1d ago

> Is this a valid approach and does the server need another sort of protection against requests being spammed maliciously or should I be going at this in another way?

I think you're thinking about it correctly, except this part.
This question has nothing to do with the rest of your post and simply needs to be answered YES!!

It has nothing to do with condition checking or skill bars or whatever - you need to implement client attribution (via shared hmac secrets for example) and you need to implement rate limiting.

1

u/Malviss 1d ago

First of all, thanks for the feedback. Great to hear that my understanding is not entirely wrong :)

Terminology is a very important step in learning, so you pointing me to rate limiting is gonna help me a ton.
I can now research it in a less roundabout way. (I'm an autodidact)

I've done a quick google for Client Attribution, however I don't grasp its importance/necessity, could I ask you to expand a little?

2

u/Head_Evening_5697 1d ago

Every Packet / TCP Connection needs to be clearly and securely attributed to a client. Typically this is done with some kind of cryptographic scheme (specifically NOT IP address based).

If a client misbehaves by spamming packets, sending an usual amount of invalid packets/illegal operations, the connection gets terminated and I'd (via some means) make this visible in telemetry

1

u/Malviss 1d ago

Ah this makes sense and clears up the importance! My original thought was some sort of IP check but with IP spoofing and maybe even SAT this could lead to problems/security issues.

Looks like I'll have to dig way deeper on this subject! Thanks for clarifying!

2

u/Head_Evening_5697 1d ago

It also just doesn't work (in addition to being insecure as fuck), because one household may play from 2 clients, NATing from the same IP.

3

u/KingAggressive1498 1d ago

the client has all the data it needs to reliably predict the player's own mana and the range from a stationary target as long as there's no server bounceback of the player causing distance to change.

The authoritative server can also track client latency and recent history and use that to be more permissive about what it allows; eg if the client's prediction would have been correct if the target didn't abruptly change direction 30ms ago, it can choose to accept the player response to the client's prediction anyway.

1

u/Malviss 1d ago

Thanks for the feedback!

So if I understand correct it might be interesting to implement a way for the server to accept requests from the client without verifying all criteria by just checking how long ago the last data was sent from (and a minor check for abnormalities/tampering so less server resources are used)?

Multiplayer is still a steep mountain so I want to tread carefully ^^

1

u/KingAggressive1498 1d ago edited 1d ago

no, you need to distrust your players as a starting point or you open yourself up to all sorts of problems.

what you can do in the server is estimate what the client's prediction was within reasonable limits and then decide whether within those predictions the action is valid.

for example, the server might know player X went from standing still to running backwards at 101 ticks, and also reasonably guess that player Y still saw player X standing still at 102 ticks, and thus accept that player Y attempting to use an ability on player X at 103 ticks is not lying about player X being in range and let it happen even though player X is now too far from player Y.

but you still need to CHECK this in the server, or you will leave yourself open to exploits like player X hitting player Y from across the map while facing the opposite direction.

1

u/Malviss 1d ago

Alright this explanation makes it clear where I misunderstood your original message.
I thought you were bringing up a 2nd way for the server to verify client information (by comparing values based on time and if the variable are within plausible margins) without having to go through all calculations itself. In this way reducing load on the server. Dropping the request or executing server side calculations when it is deemed faulty and executing the request without calculations when deemed truthful.

Basically meaning that lying good enough would be able to change the truth.

The idea seemed interesting (not necessarily for this project).

Cheers for taking me through it!

1

u/KingAggressive1498 1d ago edited 1d ago

yep this essentially requires duplicating a subset of the work for each tick you're willing to go back. It does add up to a lot of work for something at scale, and you should also handle physics effects differently. I worked on a toy project fighting game where I treated these as "brush offs" - they did less damage and didn't cause any knockback or break an attack combo, but at least they connected and had an effect.

If you're talking about a magic combat game, maybe fireball still catches the enemy on fire without doing its base damage.

I never got to the point of needing to prevent mechanic abuse, but I have a feeling you want to limit how often you do this or kick players who are getting hits this way too often.

1

u/ParamedicAble225 1d ago

Keep all of the real core game state on the server. A lot of state can be derived on the client side, such as effects like your GUI.

The client should never be sending data to the server that is inappropriate unless somebody is trying to hack your game. The clients only real state is from the server, and every action you do on the client that matters to others/the world

A) clients send as an event to update the ONE server state and then the server sends that out to re-update all of the clients.
B) and as it waits for that server’s response, that’s where client side rendering would come in to do what was expected and if it is wrong, then just rubber band it back. Well rubberbanding shouldn’t happen much if your clients rendering matches what your server will do.

The only checking you need to do on incoming client data is if it fits where your servers state says they are and the event works. By nature, the server will glue everything together by being the only store of truth, and all of the clients are just projections of that. They send tiny events and then get the update back, not the full world, but just the data, and then the clients renters that out into a full complex world. You would never want to send the full world from the server. Like if you sent there is one flower from the server to the clients, you don’t send anything but one flower. And then the client side would handle producing what that looks like what it sounds like how it is projected into space, etc.. server only holds the dimensions and the variables and objects and the rules

1

u/ParamedicAble225 1d ago

The reason your idea about trusting the client more is bad it’s because you never want to trust a client. Any single person could change the code of their clients and cheat everyone else which is client side hacking is. Do you want to make it so no matter what people do to their client it does not change the rules or state of the actual game because it all lives in the server. The server should not depend on anything from the client except events coming in about what the players did so that the actual main state can be updating.