Random function: Helpo-pleaso
Hullo again, well im a bit of a noob when it comes 2 scripting; i was jus wonderin though, can any of youse tell me what to write for a random function ie when dink kills slayer there is a 1 in 15 chance of it leaving a str potion OR when dink walks into screen 37, there is a 3 in 22 chance of their being 1,2 or 3 boncas.
From the old dinkc reference:
"int random(max, plus_this);
Random(10,1) would return a number between 1 and 10. Random(5,0) would return a number from 0 to 4. Simular to how C does it."
Check out some of the original Dink source files (e.g. s2-wand.c has a lot of randomization going on) for real examples of how to do it.
"int random(max, plus_this);
Random(10,1) would return a number between 1 and 10. Random(5,0) would return a number from 0 to 4. Simular to how C does it."
Check out some of the original Dink source files (e.g. s2-wand.c has a lot of randomization going on) for real examples of how to do it.
In slayer's die procedure:
int &rand = random(15, 1);
if (&rand == 1)
//^doesn't have to be 1, anything up to 15.
{
//make potion
}
Following attached to screen (or a sprite):
void main (void)
{
int &rand = random(22, 1);
if (&rand <= 3)
{
&rand = random(3, 1);
if (&rand >= 2)
{
if (&rand == 3)
{
//create 1 bonca here
}
//create 1 bonca here
}
//create 1 bonca here
}
kill_this_task();
}
I think this is what you meant? So there is a 19 in 22 chance of there being no boncas.
Edit: The line &rand = random(3, 1); is unecessary, take it out if you like.
int &rand = random(15, 1);
if (&rand == 1)
//^doesn't have to be 1, anything up to 15.
{
//make potion
}
Following attached to screen (or a sprite):
void main (void)
{
int &rand = random(22, 1);
if (&rand <= 3)
{
&rand = random(3, 1);
if (&rand >= 2)
{
if (&rand == 3)
{
//create 1 bonca here
}
//create 1 bonca here
}
//create 1 bonca here
}
kill_this_task();
}
I think this is what you meant? So there is a 19 in 22 chance of there being no boncas.
Edit: The line &rand = random(3, 1); is unecessary, take it out if you like.









