schmalx

07-19-2007, 11:25 AM

here is the basics of my code

#include <windows.h>

#include <time.h>

int Chance;

int x;

int compress()

{

if (Chance < 500){

x = 1;

}

else if (Chance < 990){

x = 2;

}

else if (Chance < 997){

x = 3;

}

else if (Chance < 998){

x = 4;

}

else if (Chance <999){

x = 5;

}

else if (Chance == 999){

x = 6;

}

return x;

}

int main()

{

srand(GetTickCount());

for( ; ; )

{

Chance = rand() % 1000;

Sleep(rand() % 60000);

switch(x){

case 1:

bla bla bla

break;

case 2:

bla bla bla

break;

case 3:

bla bla

break;

case 4:

bla bla bla

break;

case 1:

bla bla bla

break;

default case:

bla bla bla

break;

}

}

return 0;

}

my question is will it work and for every loop will it come up with a different number.

also is there an easier way to have events and have there be for example

10% chance event 1 happens

10% chance event 2 happens

20% chance event 3 happens

60% chance event 4 happens

any help is appreciated

#include <windows.h>

#include <time.h>

int Chance;

int x;

int compress()

{

if (Chance < 500){

x = 1;

}

else if (Chance < 990){

x = 2;

}

else if (Chance < 997){

x = 3;

}

else if (Chance < 998){

x = 4;

}

else if (Chance <999){

x = 5;

}

else if (Chance == 999){

x = 6;

}

return x;

}

int main()

{

srand(GetTickCount());

for( ; ; )

{

Chance = rand() % 1000;

Sleep(rand() % 60000);

switch(x){

case 1:

bla bla bla

break;

case 2:

bla bla bla

break;

case 3:

bla bla

break;

case 4:

bla bla bla

break;

case 1:

bla bla bla

break;

default case:

bla bla bla

break;

}

}

return 0;

}

my question is will it work and for every loop will it come up with a different number.

also is there an easier way to have events and have there be for example

10% chance event 1 happens

10% chance event 2 happens

20% chance event 3 happens

60% chance event 4 happens

any help is appreciated