Results 1 to 4 of 4
  1. #1
    index.html's Avatar
    Join Date
    Sep 2017
    Gender
    male
    Location
    Genesis 6:7
    Posts
    101
    Reputation
    10
    Thanks
    293

    Working projectile system. Need suggestions.

    This is my own source.

    The past 24 hours I've been working non-stop on the projectile system , and it turned out pretty good , but
    i don't think it's optimized enough.

    Basically it's working like that:

    Player left click > Creates local sprite > Sends angle of bullet and own id to the server.
    The server received the message > The server broadcasts the id of the player ( that shot ) and the angle of bullet to other peers.
    Once a peer receives the message from server , it creates a bullet on the player that shot ( identified by the id server sent ).

    But , each weapon has it's own projectile , so -
    once the PEER receives the message from server , it makes a request to the database and checks the weapon of the player that shot ( by id obv.) .

    This is quite a process , and i think it can be optimized a lot , tell me if there's any way of doing it.

    ( Locally , this process is instant , but when the server is host on a vps , there are small lags , by small i mean really fucking big )
    Current in-game footage

    Also , the position interpolation of the players - i have no fucking idea how to do it.





    Thanks


    Last edited by index.html; 05-28-2018 at 02:53 PM.

  2. The Following User Says Thank You to index.html For This Useful Post:

    3XP0S3D (05-28-2018)

  3. #2
    3XP0S3D's Avatar
    Join Date
    May 2018
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    6
    The lag is most likely because you are checking the database everytime you fire a projectile, that is a very bad idea. In the current realm client they check the projectile id through the client but you will need to add a check to see if people are cheating and spoofing their weapon through the client. This check will obviously need to be server sided.

  4. #3
    Juix's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    249
    Reputation
    59
    Thanks
    3,196
    My Mood
    Tired
    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!

  5. #4
    index.html's Avatar
    Join Date
    Sep 2017
    Gender
    male
    Location
    Genesis 6:7
    Posts
    101
    Reputation
    10
    Thanks
    293
    Quote Originally Posted by Juix View Post
    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!
    Woah man !
    Thanks for helping, alot
    .

Similar Threads

  1. [QUESTION] I can't get Drgns Ultimate Hack Pack to work. I need suggestions
    By paiinkiller in forum Combat Arms Hacks & Cheats
    Replies: 32
    Last Post: 07-12-2009, 10:56 PM
  2. [Need suggestions] Can I sell my CA account??
    By secote in forum Trade Accounts/Keys/Items
    Replies: 4
    Last Post: 04-20-2009, 10:27 AM
  3. [Need suggestions] Can I sell my CA account??
    By secote in forum Combat Arms Hacks & Cheats
    Replies: 19
    Last Post: 04-18-2009, 06:03 PM
  4. Replies: 17
    Last Post: 04-14-2009, 11:18 AM
  5. its not working for me ...(need help)
    By jef1994 in forum Combat Arms Hacks & Cheats
    Replies: 4
    Last Post: 12-04-2008, 07:19 PM