Re: Dynamic Spec Assignment

From: George (greerga@CIRCLEMUD.ORG)
Date: 01/10/98


On Sat, 10 Jan 1998, Jeff Almeida wrote:

>I wasnt able to get a response on this, is it impossible to do?

No, actually sounds easy.

>I am looking to assign a spec process after the mud is up and running.  For

WARNING! Mailer code, untested, not compiled, and probably missing a ).

ACMD(do_assign)
{
  int i;
  struct char_data *mob;
  struct {
    const char *name;
    SPECIAL(*func);
  } special_p[] = {
    { "fido",           fido },
    { "janitor",        janitor },
    { "cityguard",      cityguard },
    { "puff",           puff },
    { "\n",             NULL }
  };

  skip_spaces(&argument);
  two_argument(argument, buf1, buf2);

  /*
   * Find the correct entry in the table.
   */
  for (i = 0; special_p[i].name != '\n'; i++)
    if (!str_cmp(buf1, special_p[i].name))
      break;
  if (special_p[i].name == '\n') {
    send_to_char("That special procedure was not found.\r\n", ch);
    return;
  }

  /*
   * Ok, now we need the mob to tag.  You could also see if the person
   * put in a number here for the VNUM of the mob.
   */
  if ((mob = get_char_vis(ch, buf2)) == NULL) {
    send_to_char(NOPERSON, ch);
    return;
  }
  /* Sanity check if you like. */
  mob_index[mob->nr].func = special_p[i].func;
  send_to_char(OK, ch);
}

>Can a MOB have two spec_proc's?

Shopkeepers do, but that is a special arrangement.

--
George Greer  -  Me@Null.net   | Genius may have its limitations, but stupidity
http://www.van.ml.org/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | 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