nesting issues
Posted: Thu Jun 09, 2011 3:36 am
Ive tried this a couple ways now and it acts strangely either way
i have a key press doing this
when swing type 0 comes up it gives location values from swing 1s case.
did the same thing with nested ifs.
Code: Select all
int roll(int sides)
{
return (rnd()*sides)+1;
}
void attackType()
{
switch(roll(2))
{
case 1:(swingType = 0);
break;
case 2:(swingType = 1);
break;
}
}
void location()
{
switch(swingType)
{
case 0: switch(roll(6))
{
case 1:
break;
case 2: (hitLocation = 14);
break;
case 3: (hitLocation = 9);
break;
case 4: (hitLocation = 11);
break;
case 5: (hitLocation = 12);
break;
case 6: (hitLocation = 13);
break;
}
break;
case 1: switch(roll(6))
{
case 1: (hitLocation = 6);
break;
case 2: (hitLocation = 8);
break;
case 3: (hitLocation = 9);
break;
case 4: (hitLocation = 15);
break;
case 5: (hitLocation = 16);
break;
case 6: (hitLocation = 17);
break;
}
break;
}
}
i have a key press doing this
Code: Select all
attackType();
location();
trace("swing"+intToStr(swingType));
trace("location"+intToStr(hitLocation));
when swing type 0 comes up it gives location values from swing 1s case.
did the same thing with nested ifs.