Hmm. First off. You are better off using regular expressions for this:
^ A Maze of Twisty Passages\s{30}(-|NW)\s{5,6}(-|N)\s(5,6)(-|NE)$
and
^ WARNING: You are in a CHAOTIC PLAYER KILLING room.\s{5}(-|SW)\s{5,6}(-|S)\s{5,6}(-|SE)$
An explaination:
^ and $ - I often call these spoof proofers. Why? Because ^ makes certain that the line starts with that character, you don't have to worry about some moron doing:
[OOC] Fred: I'm seeing A Maze of Twisty Passages - N -
and have it confuse your trigger. Same with $, which specifies that the 'end' of the line must be at a specific location, though in this case you could probably leave it off.
\s in a regular expression specifies a space. It is followed by *, +, ? or {min,max}.
The first two types are equivalent to {1,}, the ? is {0,1}. ;)
In the first trigger for example we use {30} to tell it to look for 30 spaces. You could make it {30,} to mean at least 30 or {,30} would mean anything less than 31. Since know (or assume) it will always be 30, we only give it that number, which means both 'min' and 'max' are 30. Then later we use \s{5,6}. This allows the number of spaces to shrink from the normal 6 to 5 whenever NW is found. We do the same for the last exit. With the second of the three triggers you are using, this is not needed, since there is no big spaces or changes in size that happen if the exit is there or not, but we do use the same tactic on the last trigger.
Now as for the wildcards. In regular expressions you need to place () around anything you want to pass as a wildcard. In this case we are testing for - or a direction. That is what | does in there. ;) Note that in some cases this is a problem, since () is required when using | to check multiple possibilities, but if you only want to test for them, but not pass them on, you are out of luck. In this case you are lucky, since you are not just testing for something, but actually using the result.
Here is an example of when it is annoying:
Match = "^[(newbie|gossip|sales)]: .*"
SendTo = "Notepad"
In this case you don't care what chat channel is being sent to the notepad, you are sending all three there anyway, but the channel name is passed as the first wildcard. In a complex trigger this can get quite annoying, since you may be testing 6-7 different things that may use more than one possible word, but only want to actually use the 3rd and 5th items. Definitely something to be careful of since if you use the wrong wildcard from such a mess you might spend a lot of time trying to figure out what isn't working with your script, only to realize you are using the wrong values... I've done it a few times. lol
Now for movement.. This is a more complex issue. You will probably need to trigger on whatever you mud uses as a prompt. This is so you can test for the hermit being in the room 'before' the client has the chance to use the room exits to move at random. My suggestion is to have the hermit being found disable the prompt trigger, you can then use your death message to enable this trigger. This will make sure that the random move stuff only happens when dead and ends when you want it to. ;)
Now for the script:
I assume you already have the stuff to set your binary bits and that you 'mean' stored in one variable, not several -
sub RandMove (tname, output, wilds)
a = 0
do
'Gives a binary number from 2^0 to 2^7.
'This 'should' be the same range as your binary. ;)
b = 2^int(rnd * 8)
'This is where you store your directions. Call it what
'ever you are already using instead. If using a global
'script variable, then skip this and use that instead
'of c in the following code.
c = getvariable("ValidDirs")
for d = 7 to 0 step -1
e = 2^d 'Get the next biggest binary value.
if c >= e then 'Test to see if it is even a 'possible' direction.
if b = e then 'See if the random direction is also the valid on we found.
a = -1 'If yes, then exit this mess.
exit for
end if
c = c - e
end if
until a = -1
'Use whatever the last direction tested was to determine how to move.
'You should rearrange the following to match the way you set up your booleans.
'Also, if 0, 1, 2, etc. does not work then try using "0", "1", "2", etc. ;)
select case d
case 0
send "northwest"
case 1
send "north"
case 2
send "northeast"
case 3
send "east"
case 4
send "southeast"
case 5
send "south"
case 6
send "southwest"
case 7
send "west"
end select
setvariable "ValidDirs", 0 'Clear directions, since we moved and they are now invalid.
end sub
Note.. If you are using an array or multiple boolean variable, then this is a bit different, but you can use stuff like this instead to build the type I used:
Match = <Your first line here>
RegEx = "y"
SendTo "Script"
Send = "
if %1 = "NW" then
setvariable "ValidDirs", getvariable("ValidDirs") + 1
end if
if %2 = "N" then
setvariable "ValidDirs", getvariable("ValidDirs") + 2
end if
if %3 = "NE" then
setvariable "ValidDirs", getvariable("ValidDirs") + 4
end if
Match = <Your second line here>
RegEx = "y"
SendTo "Script"
Send = "
if %1 = "W" then
setvariable "ValidDirs", getvariable("ValidDirs") + 128
end if
if %2 = "E" then
setvariable "ValidDirs", getvariable("ValidDirs") + 8
end if
Match = <Your last line here>
RegEx = "y"
SendTo "Script"
Send = "
if %1 = "SE" then
setvariable "ValidDirs", getvariable("ValidDirs") + 16
end if
if %2 = "S" then
setvariable "ValidDirs", getvariable("ValidDirs") + 32
end if
if %3 = "SW" then
setvariable "ValidDirs", getvariable("ValidDirs") + 64
end if
|