I want to have a function that rolls a die, and I have a Switch Conditional call that function.
heres what I tried (theres probably a couple of errors in there)
Code: Select all
/* 1.generate target location
2.roll attack dice
3.roll defense dice
4.result hit: play swing,play late parry, gen damage, play blood,knock down,dead
5.result parry :play half swing , play parry, trade initiative
6.deplete pools, advance round counter.
*/
int D6()
{
return round(random(3.5,2.4));
}
//target location
void target()
{
if (rnd() < 0.5)
{swingType = 0;} //diagonal down
else
{swingType = 1;} //midsection
if (swingType = 0)
{
switch(D6)
{
case 1: (hitLocation = 1); //upper arm shoulder
break;
case 2: (hitLocation = 1); //upper arm shoulder
break;
case 3: (hitLocation = 2); //across chest
break;
case 4: (hitLocation = 3); //neck
break;
case 5: (hitLocation = 4); //face,jaw
break;
case 6: (hitLocation = 5); //skull
break;
}
}
}
It's been about twenty years since I tried to do any programing on this scale, so Im kinda rusty.