Many unimportant RNG calls use Rand or Rnd instead of Rnd2

Issue #5431 wontfix
John Snail created an issue

These may be the root cause of seed inconsistencies.

To reduce the chances of more instances popping up, I suggest making the RNG parameters in methods such as GetRandomElement mandatory the next time mods must be broken.

Below are some RNG calls that should be using Rnd2 instead. Let me know if you guys need help finding them all!

  • GameObject.Die, which calls GetRandomElement to randomise the death sound
  • GetRandomAlchemistSaying
  • Potentially most Get... methods in Gender and PronounSet
  • GetRandomConcreteBodyPart, which is used by descriptions, dialogue, etc.
  • Grammar.Weirdify
  • All text filters (Bird, Fish, Frog, etc.)
  • Pettable.Pet, which calls GetRandomElement to randomise the response text
  • SurroundOnStep.HandleEvent; the rainbow particles call GetRandomRainbowColor and Stat.Random
  • Chat.HandleEvent (GetRandomElement)
  • Chat.PerformChat (GetRandomElement)
  • PetFrondzie.taunt, which calls GetRandomElement to randomise the taunt text
  • Campfire.Cook (GetRandomElement)

Comments (4)

  1. Brian Bucklew repo owner

    The fact that the RNGs are all reseeded before any zone generation in general mean these calls to get random don’t actually effect zone generation determinism all that much in practice.

    What’s really problematic is non-local changes in state having follow on effects in prng between seedings; That is, sometimes a different zone adjacency has been generated and so it creates a stair somewhere which effects the rest of rng, or perhaps this time the medicine names need to be rolled (This would be a bug but it happens) and it happens deep in a population table result, etc

  2. John Snail reporter

    Ah, I didn’t see that when looking through the source. Though, if I understood correctly, wouldn’t fixing these RNG calls help narrow down causes of that issue without taking much time?

  3. Log in to comment