m_dice.c

lima-1.0b5/lib/std/modules/m_dice.c · 477 B

From the archive lima-1.0b5+driver.tar.gz

Download the archive   « Back to the archive contents

/* Do not remove the headers from this file! see /USAGE for more info. */

//:MODULE
// This module handles all dice rolling functions

//:FUNCTION roll_dice
// Roll x number of dice with y sides. 
// Not all gaming systems use just the total of the dice, so each result is 
// returned in an array.
int array roll_dice(int num_dice, int num_sides)
{
  int i;
  int array results=({});

  for(i=0;i<num_dice;i++) {
    results+=({random(num_sides)+1});
  }
  return results;
}

Site Stats

Snippets: 1791
Codebases: 571