Manual:DIL Manual/openroll()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:04, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

openroll()

Function (integer). Rolls an open-ended die: high rolls add another roll, low rolls subtract one.

openroll(dice : integer, end : integer)

Rolls a number from 1 to dice.

  • If it is in the top end numbers (from dice - end + 1 up),
 it rolls again and adds, and goes on while the new roll is also in the top end.
  • If it is below end (1 to end - 1), it rolls again and subtracts, and
 goes on subtracting while that roll is in the top end.
  • Otherwise the result is the roll.

With openroll(100, 5), 96 to 100 (5% of rolls) go on upwards and 1 to 4 (4%) go below 1. There is no upper or lower limit.

Parameters

Name Type Meaning
dice integer The size of the die.
end integer How many numbers at the top make the roll open-ended.

Returns

Integer: the roll. It is 0 unless dice and end are above 0 and end is smaller than dice/2 - 1 (so openroll(20, 10) is always 0).

Notes

  • The game's own skill and spell checks use openroll(100, 5) (spells.zon,
 function.zon).

Example

dilbegin integer contest(att : integer, defence : integer);
code
{
   // above 0 is a success; usually between -50 and +50, now and then far more
   return(openroll(100, 5) + att - defence - 50);
}
dilend

A contest between an attack and a defence value, as the skill checks in function.zon work.

See also