In addition:
If you are using this as part of a script, where you want to store the damage values of a weapon or spell or whatever, and have it calculate damage at a later point, you can use something like this...

Create a table of your weapons (you can add more weapon data such as weight and speed and size if you want):

Code:
hmake weapons 10
hadd weapons shortsword 1d4
hadd weapons flail 1d8+1


Send your weapon name with /attack:
Code:
alias attack {
  set %damage 0
  set %dice 1
  while (%dice <= $gettok($gettok($hget(weapons,$1).data,1,32),1,100)) {
    set %damage $calc(%damage + $rand(1,$gettok($gettok($gettok($hget(weapons,$1).data,1,32),2,100),1,43)) + $gettok($hget(weapons,$1),2,43))
    inc %dice
  }
  unset %dice
}


Example attack:

Player has the Flail:

/attack flail

%damage = 1 roll of $rand(1,8) + 1