Author Topic: OP2 Scenario Project for C#  (Read 1632 times)

Offline TechCor

  • Newbie
  • *
  • Posts: 34
Re: OP2 Scenario Project for C#
« Reply #75 on: April 15, 2019, 02:48:18 AM »
Hmm. I went back and checked, and Tethys::GetRand works fine. Must have been really bad luck the handful of times I used it. Like flipping heads 15 times in a row... I have no idea.

Offline lordpalandus

  • Hero Member
  • *****
  • Posts: 755
Re: OP2 Scenario Project for C#
« Reply #76 on: April 15, 2019, 10:58:16 AM »
I use random number generation a lot in the video game I'm making, so some possible reasons it is returning 0:

1. You improperly set up the array / vector, so it is using an empty array/vector. Random number of 0 between the size of the array/vector would be 0, so it will always return 0.

2. It is choosing a random number as a float, and converted into an int. If the random number was 0.9, in floats that is nearly 1, but when converted to int it becomes 0. Some round up, some round down.

3. Some random number generators, like the one I use, utilizes different streams. If your random number generator requires a specific stream, that could be the issue.

Otherwise:

We will need to see what code you are trying to execute to provide more detailed assistance. Just because there is no syntax error, doesn't mean there isn't some unintentional logic error. Without the code in question, it is really hard to say.
Currently working on Cataclysm of Chaos, Remade.
Link to OPU page = http://forum.outpost2.net/index.php/topic,6073.0.html

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2152
    • LairWorks Entertainment
Re: OP2 Scenario Project for C#
« Reply #77 on: April 17, 2019, 09:38:41 PM »
Gonna go out on a limb and assume the core code is just using a really shit PRNG. Haven't looked too far into it but I'd suggest using literally any other PRNG than whatever OP2's engine provides (unless for some reason mission DLL's must use that function as Hooman has suggested).
« Last Edit: April 17, 2019, 09:40:27 PM by leeor_net »