Richter2005-03-15 06:29:52
Is there a way to do a random thing? For example, whenever a spectre puts up a shield, I want to either say "fool" (I made that emote!), laugh, or spit on the ground in disgust. Of course, I don't want to do one of those EVERY time a spectre shields.
Ideas?
Ideas?
Terenas2005-03-15 07:37:10
QUOTE(Richter @ Mar 15 2005, 06:29 AM)
Is there a way to do a random thing? For example, whenever a spectre puts up a shield, I want to either say "fool" (I made that emote!), laugh, or spit on the ground in disgust. Of course, I don't want to do one of those EVERY time a spectre shields.
Ideas?
Ideas?
73478
Yup, from Zmud's help file.
QUOTE
random
Syntax: %random(i,j)
return a random integer >= I and <= J. If J is omitted, then I specifies the maximum value, and 0 is used as the minimum value.
Examples:
#VAR dirList {n|e|s|w|ne|se|sw|nw|u|d}
#20 {%item(@dirList,%random(5,8))}
sends 20 randomized diagonal directions to the mud.
#VAR dType 12
#VAR dNum 6
#VAR dOffset 22
#VAR sum @dOffset
#LOOP @dNUM {#ADD sum %random(1,@dType)}
#SAY @sum
displays the sum of 6 rolls with a 12-sided die plus an offset of 22
Note: The 'short version' of this example is
#SAY %dice(6d12+22)
Syntax: %random(i,j)
return a random integer >= I and <= J. If J is omitted, then I specifies the maximum value, and 0 is used as the minimum value.
Examples:
#VAR dirList {n|e|s|w|ne|se|sw|nw|u|d}
#20 {%item(@dirList,%random(5,8))}
sends 20 randomized diagonal directions to the mud.
#VAR dType 12
#VAR dNum 6
#VAR dOffset 22
#VAR sum @dOffset
#LOOP @dNUM {#ADD sum %random(1,@dType)}
#SAY @sum
displays the sum of 6 rolls with a 12-sided die plus an offset of 22
Note: The 'short version' of this example is
#SAY %dice(6d12+22)
Daganev2005-03-15 07:40:07
There is also a case you can do, which is easier to code and understand... let me look up the help file...
I've used cased before when I want to give random greetings to novices, so it doesn't look like I'm using a trigger or an alias.
QUOTE
CASE
Syntax: #CA index command1
Allows you to select a command from a list to be executed. The index parameter determines the command to execute from the list given by command1..commandn. If index is greater then the number of commands, it wraps around. For example, if there are four commands and you ask for the fifth, the first is returned. This allows you to use the predefined variable %random to select a random command.
If the index is negative, results are undefined.
CASE examples
#CASE 2 {first command} {second command} {third command}
sends the string second command to the MUD
#CASE @joincmd {join} {rescue}
if the variable @joincmd is 1 (or 3,5,7...) the string join is returned, otherwise the string rescue is returned.
#CASE %random {Hello} {Hi there} {Hiya} {Hi}
returns a random string from the given list to the MUD.
case
Syntax: %case(i,s1,s2,s3...)
if I=1, return s1, if I=2, return s2, etc.
Example:
#VAR Greeting %case(%random(1,4),"Hi","Hello","Hiya","Hail")
Assigns a random greeting to the Greeting variable
Syntax: #CA index command1
Allows you to select a command from a list to be executed. The index parameter determines the command to execute from the list given by command1..commandn. If index is greater then the number of commands, it wraps around. For example, if there are four commands and you ask for the fifth, the first is returned. This allows you to use the predefined variable %random to select a random command.
If the index is negative, results are undefined.
CASE examples
#CASE 2 {first command} {second command} {third command}
sends the string second command to the MUD
#CASE @joincmd {join} {rescue}
if the variable @joincmd is 1 (or 3,5,7...) the string join is returned, otherwise the string rescue is returned.
#CASE %random {Hello} {Hi there} {Hiya} {Hi}
returns a random string from the given list to the MUD.
case
Syntax: %case(i,s1,s2,s3...)
if I=1, return s1, if I=2, return s2, etc.
Example:
#VAR Greeting %case(%random(1,4),"Hi","Hello","Hiya","Hail")
Assigns a random greeting to the Greeting variable
I've used cased before when I want to give random greetings to novices, so it doesn't look like I'm using a trigger or an alias.
Richter2005-03-15 07:49:41
Above -my- head.
Unknown2005-03-15 08:01:34
CODE
#TRIGGER {pattern to match} {#CASE %random( 1, 5) {fool} {laugh} {spit}}
That trigger will:
3/5 of the time do one of those random emotes.
2/5 of the time do nothing.
Just change the second argument in the %random() (in this case the 5), to change the chances of doing something.
Unknown2005-03-15 14:14:53
Actually, Zaltan, the #case command wraps around, so basically it uses the "mod" function to grab the remainder and find the true index. This means that doing %random() is pretty much the same as %random(1,5), though it may execute that third option less than the first two.
Thorgal2005-03-15 15:17:02
#trigger {Spectre puts up shield.} {#case %random {say to spectre Fool!} {say to spectre Wuss!} {say to spectre Pansy} {say to spectre ya blubbering jar of ectoplasm!}}
Asarnil2005-03-15 15:32:19
and if you want it to randomly do nothing, then add a couple of {#noop} arguments into it too.
Summer2005-03-15 15:33:19
QUOTE(daganev @ Mar 15 2005, 03:40 PM)
I've used cased before when I want to give random greetings to novices, so it doesn't look like I'm using a trigger or an alias.
73506
Now we know... And I thought you were different!
