JS-RANDOM-CHAR
The randomChar() method can be used to pick a character at random in the current room.
inRoom.randomChar()
The randomChar() method can also be used to pick a character at random who is within N rooms from the current room. For example:
inRoom.randomChar( 30 )
Would return a character picked at random from along all the chars that are no further than 30 rooms way. You can also specify a predicate function to narrow the list of characters that will be considered as a candidate:
function evilBigMobs( o ) {
o.isNPC() && o.isEvil() && o.maxLevel() >= 100;
}
inRoom.randomChar( 20, evilBigMobs );
The previous example picks an evil, level 100 or higher NPC at random that is no further than 20 rooms away.
Do not use big predicate searches frequently as this can be very computationally expensive for the mud. Occassional long searches (like for the initiation of a random quest or for the rare spell) are fine. Short searches, like only 3-4 rooms away are also fine.