[CODE SNIPPET] New zone command: force mobile

From: Andrey Fidrya (andrey@ALEX-UA.COM)
Date: 03/25/98


Hi, All!

This snippet adds new ZONE file command: F (forces mob to perform action)
Syntax:
F <if_flag> action to be performed by mobile

Useful in situations like:
  M 0 9501 1 9550       * Horse
  M 0 9502 1 9550       * Knight
    F 1 mount horse

Or:
  M 0 9503 1 9550       * Evil beast
    F 1 emote appeared in the middle of room!

The code part:

1. Open "db.h" and look for:
struct reset_com {
  [ some text ]
   int  arg1;           /*                                      */
   int  arg2;           /* Arguments to the command             */
   int  arg3;       /*                                      */
  ----- Right after "int arg3", add this line:
   char *sarg;      /* String argument                      */

2. Open "db.c". Around line 1240 look for:
    if (ZCMD.command == 'S' || ZCMD.command == '$') {
      ZCMD.command = 'S';
      break;
    }
    error = 0;
  ----- And add this piece of code right after it:
    if (ZCMD.command == 'F')  /* force mobile command */ {
      skip_spaces(&ptr);
      if (*ptr) {
        tmp = *ptr;
        ptr++;
        skip_spaces(&ptr);
        ZCMD.sarg = str_dup(ptr);
      } else
        error = 1;
    } else
  -----
  ----- Now look for:
    case '*':                   /* ignore command */
      last_cmd = 0;
      break;
  ----- And add this piece of code below:
    case 'F':           /* force mobile to do action */
      if (!mob) {
        ZONE_ERROR("attempt to force-command a non-existant mob");
        break;
      }
      command_interpreter(mob, ZCMD.sarg);
      break;
  -----

  Done.
  You can now use the "F" command in your zone files.

  If this snippet was useful to you, please add:
  Andrey Fidrya // RMUD (rmud.techno.ru:4000 ; rus lang only)
  to your MUD's credits file. Thanks.

 Andrey (andrey@alex-ua.com)
    aka Zmey//RMUD


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