2

How would you account for an event during which time is very important? Most games use frames and the simulations take place in time steps. What if an event occurred that needed a specific time to take place on?

For example, in a game like DOTA, attack speed is very important. Now, let's say the time-step for this game is 50ms. Two heroes are fighting. HeroA attacks HeroB and lands a "killing blow" at 14ms into the time-step. HeroB attacks HeroA and also lands a "killing blow", only this occurs at 40ms into the time-step. However, neither one of these blows will be simulated until the 50ms time-step. Therefore, at 50ms, both heroes will be killed when really only HeroA should be left standing because he managed to attack first.

Is there some way to account for this?

DangerMcD
  • 21
  • 1
  • 7
  • Prediction. Peer-to-peer games will usually take both results and do its best to figure out which is more likely accurate. You have to figure that even a 50ms timestep (which is enormous for a game), might be less than the latency. Dedicated servers can make this better, because no person has the advantage of being the host, but even then one person may have more latency so that much be taken into account when deciding which event may have actually occurred first rather than which even the server received first. Running prediction code in another thread can help as well. – Nic Foster Jan 20 '12 at 19:39
  • I understand how different network topologies work, so feel free to expand more on what you are saying, but I think you basically just rephrased and even expanded the scope of my original question. Even network commands are sent out at a specified rate with the server keeping track of which commands to execute at which interval. This certainly allows each client simulation to run with a deterministic lock step, but how would the smaller details between time-steps be determined? Or am I misunderstanding your response? – DangerMcD Jan 20 '12 at 20:12
  • Any events that are going to be networked will usually be timestamped. Also the server will try and synchronize a time between clients and itself so that any timestamps from a client are fairly accurate. On the last project I was on the client would send a "I think I killed this guy", and the server would evaluate it to see if that was something likely to occur. It was an MMO, but no PVP, if you add a second player you would probably wait a small amount of time for second message from the other client to see if they also through they killed, or were killed by the other player. – Nic Foster Jan 20 '12 at 20:17
  • So what you're saying is to keep a timestamp on events as they "would occur", not on the frame but in real time, and then on the update loop, if there is a possibility for conflicting events, check the timestamp? Could you give a recommendation as to how to pack the timestamp into memory to provide the least amount of overhead? (Not necessarily for networking) – DangerMcD Jan 20 '12 at 21:12
  • Yes you could probably keep a record of events sorted by timestamp, and so if you got a message from both players saying they struck the killing blow, you can use the timestamp and account for the latency to each client to figure out which likely happened first. -- As for compression we used a PHP port of AMF for some stuff, and RakNet for everything else, I don't know the details of it all though, I didn't set that part up. – Nic Foster Jan 20 '12 at 22:48

1 Answers1

0

I don't know how your game architecture is designed, but if you are able to get the timestamps of your events, you can easily put them into a buffer with another Thread and process them in the time specific order every 50ms.

Sibbo
  • 3,796
  • 2
  • 23
  • 41
  • I had this thought, only without the Thread. The problem I have with this conceptually is that the time stamps would need to be stored per event, although I haven't yet thought of a way that does not involve the storage of time stamps. It just seems like some unnecessary overhead that maybe some simulation method I've yet to stumble upon can account for. – DangerMcD Jan 20 '12 at 19:42