[CODE] Random Procs

From: Chuck Reed (creed@I-55.COM)
Date: 05/04/98


Ok, if any of you are interested in giving your spec_procs the ability to
be truly random, here's something that will call them every X seconds.

First, you need to add these two functions.  I put em right below
mobile_activity in mobact.c, but I'm sure there is a more suitable place
for em.

void call_obj_sepcs(void)
{
extern struct descriptor_data *descriptor_list;
struct descriptor_data *d;
int j;

for (d = descriptor_list; d; d = d->next) {
   for (j = 0; j < NUM_WEARS; j++)
    if (GET_EQ(d->character, j) && GET_OBJ_SPEC(GET_EQ(d->character, j)) !=
NULL)
      if (GET_OBJ_SPEC(GET_EQ(d->character, j)) (d->character,
GET_EQ(d->character, j), cmd, arg))
         continue;
  }
}

void call_room_specs(void)
{
extern struct descriptor_data *descriptor_list;
struct descriptor_data *d;

for (d = descriptor_list; d; d = d->next) {
   if(GET_ROOM_SPEC(d->character->in_room) != NULL)
     if (GET_ROOM_SPEC(d->character->in_room) (d->character, world +
d->character->in_room, 0, ""))
        continue;
 }
}

Now, add this in structs.h right after the definition of PULSE_MOBILE

#define PULSE_SPEC      (5 RL_SEC)  /* Change this from 5 to whatever you
want. */

Now do the following in comm.c:
 void mobile_activity(void);
+void call_room_specs(void);
+void call_obj_specs(void);
 void string_add(struct descriptor_data *d, char *str);

Find the following code:

if (!(pulse % PULSE_MOBILE))
    mobile_activity();

And add this below it:

if(!(pulse % PULSE_SPEC)) {
   call_room_specs();
   call_obj_specs();
 }

That should be it.  Whenever you want to make a random proc for anything
now, you can simply use the

if(!cmd)
   return FALSE;

code at the top.  If you see any problems with this or ways to make it
better, please gimme a holler.




Chuck Reed     | Q: Who's your favorite Spice Girl? |
creed@i-55.com | A: The dead one.                   |

"Jesus saves . . . . he passes to Moses.  Moses shoots, HE SCORES!"
                                                -Unknown


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST