MdN
From YoYoGames Wiki
Contents |
Definition
MdN is defined as a sum of M results of throwing die with N faces (the result of throwing is obviously a number of points on the top face). The result is a random number in range M to M*N, however its distribution is non-linear. The name means M dice with N faces
Explanation
Role Playing Games often used dice to get character attributes, such as Might or Wizdom, or to get random damage value, etc. In such cases not only a cubic die is used, but also dice with different number of faces. The MdN convenience let instead throw two dice with 4 faces just say throw 2d4
How to calculate in GM
In Game Maker there are 2 functions that have random effect. Their names are random and choose. Using random, we can define script MdN in such way:
#define MdN
// argument0 is M (integer)
// argument1 is N (integer)
{
var res;
res = argument0;
repeat(argument0)
res += floor(random(argument1));
return res;
}
Note that we can not achieve the same result with choose. However, it may be used differently:
... // throw 2d4 damage = choose(1,2,3,4)+choose(1,2,3,4); ...

