Help with the random function

Started by thealexv2, Sat 07/08/2010 10:09:46

Previous topic - Next topic

thealexv2

whenever my main character is attacked by the villain i want a 50% chance that the character will live or die. i have been able to do this but there is a problem. the random function gives me  5 possibilites instead of 2. i am not sure what i am doing wrong.  The first view is the death animation and the second is the hurt. my script is this:
int i;
i = random(1);
if (i == 0) player.lockview(13); 
player.animate(0, 7, eonce,enoblock, eforwards);
wait(50);
display("Lily is dead");
resetroom(1);
if (i == 1) player.lockview(15);
please respond, and thanks for reading

Matti

What are the five possibilities ??

Does this piece of code run more than once, unintentionally?

Wyz

Use brackets like:

Code: ags

int i = random(1); 
if (i == 0)
{
	player.lockview(13);  
	player.animate(0, 7, eonce,enoblock, eforwards); 
	wait(50); 
	display("Lily is dead"); 
	resetroom(1); 
}
else
	player.lockview(15); 
Life is like an adventure without the pixel hunts.

Matti

Ah, right. I must be tired.

*drinks some more coffee*

SMF spam blocked by CleanTalk