Sign in to follow this  
xsocomx

Combat system.

Recommended Posts

Hello everyone, I am interested to know how online games handle the combat system for example fantasy hack/slash system. How does the server/client handle packets and updates? Well something like this? 1. Client -> Server: Send pID for selected character( target ). 2. Server -> Recv: Packet and get the current player sending that packet and set pID as target. 3. Client -> Server: Attack packet( start attack ) for current player( target add this player to pAttackList( players attacking this target ). 4. Server -> Recv: Packet and set the current character to IsAttacking( true ) and animation to A_ATTACK( animation attack ) and broadcast the animation change to all the players in the InRangeList ( not for NonPlayers ), to change the animation. Server combat update: 1. In the combat AI update function I loop through all the players that have animation set to A_ATTACK and target != NULL && player inRange of target. 2. Calculate the Damage using min,max dmg, absorb, shield, mana_dmg, crit and hit_status and stuffs like that to get the damage made to that user for each attack interval/hit based on animation speed. 3. If The current target is dead respawn it to random waypoints using this target start location and calulate loot, experience and stuffs / num of players in the target pAttackList( players attacking this current target ) and broadcast it to all the current players and set animation to(A_IDLE). Im not good at english and explaining but I hope you guys understand what I mean. And feel free to explain if anyone of you have dome something similar! Thanks! and this was my first post :)

Share this post


Link to post
Share on other sites
Quote:
Original post by xsocomx
4. Server -> Recv: Packet and set the current character to IsAttacking( true ) and animation to A_ATTACK( animation attack ) and broadcast the animation change to all the players in the InRangeList ( not for NonPlayers ), to change the animation.


Having never done anything quite like this I can't be certain, but this step seems unlikely. Animations and the like belong in the view, and I can't think of a reason to ever send view information over the network.

If I were to program something like this, I would probably do it as follows:
Player selects target and chooses attack.
Attack request is sent to server. Server verifies target is valid and all that good stuff, then calculates the result of the attack. This info is relayed back to all clients.
Clients receive the message saying an attack was performed, and update the view as necessary.

Share this post


Link to post
Share on other sites
Like Driv3MeFar said, it's unlikely any animation information would be sent over the network. The server will send IsAttacking for the character and the clients will select the proper animation to render.

Share this post


Link to post
Share on other sites
Driv3MeFar and Kipple Yes thats true, but how about the AI update on the server side... How do I sync the hit perfect?. Let say the hit frame is 150... when the frame reach 150 do the damage server side and send damage done packet to clients in list.

would I send the animation frame on the server with the damage made on target info packet? how sould you do this?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The client just sends an attack message to the server and the server just process it and broadcast an attack message to everyone. Then some time later when the animation is done the server broadcasts the resulting hits and the attack stop message.

Each client will see it a bit differently because they are not in lock step, but in most games it doesn't matter. Some games even allow local hit calculations for the hit graphics but use the server data for health status. This can result in a scenario where the user sees hits but the target's health doesn't change. You can avoid this by using on the server side data, but that will mean having a slight latency between the command and the results showing up. Usually this is masked with the attack animation. When the network delay, the animation delay and the overall ping times are correct, the player will see the result of an attack exactly when the attack animation stops.

Viktor

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this