Character *getRandomPerson( const Room *r )
{
if( r->charList.empty() )
return 0;
std::vector< Character* > people( r->charList.begin(), r->charList.end() ); // copy contents of list into new vector
return people[ number_range( 0, people.size() - 1 ) ];
}
CHAR_DATA* rand_mob_from_room( ROOM_INDEX_DATA* r )
{
// make sure we have a room, and that it has people in it
if( r == NULL || r->first_person == NULL )
return NULL;
int count = 0;
CHAR_DATA* ch;
// step 1: get the count
for( ch = r->first_person; ch; ch = ch->next_in_room ) {
count++;
}
// step 2: get a random number
int steps = number_range(0, count-1);
// step 3: make that many steps in the linked list
ch = r->first_person;
while (steps– > 0) {
ch = ch->next_in_room;
}
assert(ch != NULL); // it should never be NULL, so assert it here
return ch;
}
Question is: "Is there a way to pull a random Immortals name for the random sacrifice directly off the wizlist?"
I think this roughly translates, at least in regards to Smaug, to pull a name off a random file in the gods directory. So I ask, is it possible to pull a random name from a random file in a specific directory to return as a string in the sacrifice message? Or for those familiar with Smaug did I miss something when I looked at how the wizlist is made, is there a way to pull a random name from the actual wizlist?
Currently, I have to manually add names to a list inside the sacrifice function, but if I could make it pull based off the wizlist or off a random file, I'd be willing to do so, as it would save me a bit of work every time I hire or fire someone.
This is what it looks like currently:
Any ideas, suggestions, or corrections to my thinking are welcome and appreciated. :P