![]() |
Thankyou Octocat. I known how random.next works, but I chose to go with the RNGCryptoServiceProvider rather than the Random class because I feel it gives me "better" random numbers. Anyone using the script is welcome to replace the NextInt routine with the random class as suggested.
|
My variant with RNGCryptoServiceProvider :)
- Code slightly reduced and refactored - Added minutes randomization - Fixed maxValue problem (random.Next always return value by 1 less then the specified maximum) Code:
using System; |
OK, I see what you've done. One declaration of var provider = new RNGCryptoServiceProvider(); Much better Thankyou.
1. I've moved the Random Class declaration outside the randomisemission routine so it can also be used in the randomisation of mission selection etc. (see below). But this construct produces an error CS1519: Invalid token '(' in class, struct, or interface member declaration on the provider.GetBytes(buffer); line. pehaps you can help? code removed by author 2. Multiplayer implimentation This script randomised the [MAIN] section of the mission file OK in single-player mode, but fails in multi-player(server) mode. I have in mind some pseudo code such as: Randomise [MAIN] on server battle start; save [MAIN] section file on the server side; as players connect reload the saved [MAIN] section file from server side so they get the same mission parameters in multi-player mode. |
Yes, because dynamic type resolution "var x = " works in functions only, and calls like "provider.GetBytes(buffer)" too.
In your case better to use constructor, to bury inside all temporary instances like "buffer" and "provider", when they perform their task. For example: Code:
using System; |
| All times are GMT. The time now is 11:31 PM. |
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.