A set of convenience functions with a random theme!
A minimalist demo is included.
<function name="ShowRandomEvent" parameters="region">
Prints a random message to screen.
This should be sent an object with an attribute "event_list"
that is a string list. A string will be selected at random from
this list.
Optionally, the object can have an atribute "event_prob" that
is an integer; in that case a message is only displayed occasionally,
specifically "event_prob" times out of 100.
Personally, I have all my rooms divided up into regions, so each
room is inside a region object, and I set "event_list" and "event_prob"
on the region object. Then, in the description for the room I can use this:
ShowRandomEvent(this.parent)
"this" refers to the current object, i.e., the room, and its parent is the
region.
Note that you have to ensure the object you send to ShowRandomEvent has suitable
attributes. currently Quest 5 has no way to test for a StringList attribute.
<function name="RandomString" parameters="my_list" type="string">
Returns a random string from the given string list.
<function name="PercentageChance" parameters="prob" type="boolean">
Returns true or false at random, with true occuring prob times
out of 100.
<function name="RollDice" parameters="dice, ac" type="int">
Given the classic DnD notation, dice are rolled and the result returned.
The input string must conform to a specific pattern; this is not tested for.
The string must be one of these, where x is one or more digits:
xdx
xdx+x
For example:
1d6 Roll a normal six-sided die
5d20+5 Roll five twenty sided dice and add 5 to the result.
<function name="RollDamage" parameters="dice, ac" type="int">
As RollDice (using the same notation for dice), but the AC (armour
class) is deducted from eac dice roll.