Originally Posted by
Juix
First off, I would not suggest having the client message the database for player info. This will always be a slow process. You should load all relevant player info into the game server when they log in, then save the changes when they log off (periodically as well, if you want). The server should handle most things, and just tell the client what to display. You will most likely want different systems for ally projectiles and enemy projectiles (unless it's some pvp server, then it's a whole different ball game). For ally projectiles you really have no reason to verify anything on the client side, as long as the server is sending correct info, just display it as best as you can. Ally projectiles have no effect in the game other than visuals, so it's okay if they are a bit off on the position/angle. Enemy projectiles (that are fully hit checked) are a beast to deal with, I'll can provide a write up on them if you want, but I'll pass on that for now.
Your projectile network flow should look like this:
Player Shoot -> Server -> Batching? -> Broadcast to allies
Player Shoot
Only angle info sent. The server assigns it's global id, but the shooter never needs to know his global shot id
Instead, the shooter should keep his own local projectile id counter and use that to send info regarding the shot, usually used by hit packets
The projectile object can use the player data acquired at login to determine the type of projectile shot.
Send the angle info to the server
Server
The server should receive the angle info, then create a projectile object with a unique id attached to it. The server also needs to keep track of the shooter's local id and it's equivalent global id, a simple dictionary should work.
Batching
This part is optional, but better for performance.
The server can add the projectile object to a queue system that is cleared each game tick, 20 per second usually works and feels best.
Broadcast to allies
The server should broadcast the projectile to allies (or list of projectiles if you batched the projectiles).
I would avoid sending the projectile to it's original shooter, because it is unnecessary. You should only be sending angle information paired with the player id that shot it.
Server Info
The server should update players with info about changes to other player's equips, so the other players can correctly display their ally's projectiles.
You usually send all character info when two players first meet, then send updating info as they stay in sight.
Client processing
The client should process allies projectile angle data by using previously sent ally info to determine what type and amount of projectiles should be displayed. If there is a slight desync and you receive a projectile object for an ally that has no weapon equipped, then just ignore that projectile. Remember, ally projectiles are not needed to be 100% accurate.
Let me know if you have any questions, good luck on your source!