Original Post
I'm creating a multiplayer over-the-internet tactical game. In combat, the attacker deals a random amount of damage to the target.
How should I code it to be certain that the amount of damage dealt will be the same on both computers? That is, that there won't be any out-of-sync errors.
I think of two possibilities:
1. Have the attacker generate a random number and send that number over.
2. At the beginning of the game, have the host send his random generator seed to all other computers so that they generate the same numbers.
Are there any other options? Is the second option possible at all? Which option is most often used/preferred?
I use C#/.NET and the Random class.
Thank you in advance,
Petr
How should I code it to be certain that the amount of damage dealt will be the same on both computers? That is, that there won't be any out-of-sync errors.
I think of two possibilities:
1. Have the attacker generate a random number and send that number over.
2. At the beginning of the game, have the host send his random generator seed to all other computers so that they generate the same numbers.
Are there any other options? Is the second option possible at all? Which option is most often used/preferred?
I use C#/.NET and the Random class.
Thank you in advance,
Petr