Re: Mobile-loading question (solution patch)

From: Sammy (samedi@ticnet.com)
Date: 03/27/00


From: AxL <axl@MINDWARP.PLYMOUTH.EDU>
Sent: Monday, March 27, 2000 9:21 AM

It just occurred to me that there's a better way to get mobs to reset in a
predictable way.  The included patch will solve the problem mentioned in AxL's
email.  It will also fix the problem of lower-numbered zones hijacking higher
zones' mobs (but not objects).  This code guarantees that each "M" reset
command will spawn exactly one mob, and then will be deactivated until that
mob dies, whether it's a sentinel, or wanders halfway across the mud.  The one
obvious drawback is that since it ignores the max_in_world option of the reset
command, it isn't possible to set up a zone that would normally be able to
load more and more mobs when the originals aren't killed.  That can be fixed
if necessary.  There may also be problems caused by using OLC on the reset
commands of a zone that is actively resetting.  I recommend a policy of
turning the resets off until the zone is finished (always have, actually).

If the patch is confusing, I'll be happy to explain what it's doing in detail.
If this works out ok and is useful, I can whip up a similar patch for objects.

Sam


diff -u oldsrc/db.c newresets/db.c
--- oldsrc/db.c Mon Mar 27 14:17:18 2000
+++ newresets/db.c Mon Mar 27 14:18:40 2000
@@ -1436,6 +1436,9 @@
       exit(1);
     }
     ZCMD.line = line_num;
+
+ ZCMD.instance = NULL;
+
     cmd_no++;
   }

@@ -1752,8 +1755,11 @@
       break;

     case 'M':   /* read a mobile */
-      if (mob_index[ZCMD.arg1].number < ZCMD.arg2) {
+ /*     if (mob_index[ZCMD.arg1].number < ZCMD.arg2) {  *old line* */
+  if(!ZCMD.instance) { /* new check ignores max_in_world */
  mob = read_mobile(ZCMD.arg1, REAL);
+ ZCMD.instance = mob;
+ mob->reset = &ZCMD;
  char_to_room(mob, ZCMD.arg3);
  last_cmd = 1;
       } else
@@ -2464,6 +2470,8 @@
   GET_AC(ch) = 100;  /* Basic Armor */
   if (ch->points.max_mana < 100)
     ch->points.max_mana = 100;
+
+  ch->reset = NULL;  /* pointer to reset command (mob use only) */
 }


diff -u oldsrc/db.h newresets/db.h
--- oldsrc/db.h Mon Mar 27 14:17:22 2000
+++ newresets/db.h Mon Mar 27 14:18:44 2000
@@ -136,6 +136,7 @@
    int arg2;  /* Arguments to the command             */
    int arg3;  /*                                      */
    int line;  /* line number this command appears on  */
+   struct char_data *instance; /* Loaded instance of this mob reset command
*/

    /*
  *  Commands:              *
Only in newresets: handler.c
Only in oldsrc: handler.h
diff -u oldsrc/structs.h newresets/structs.h
--- oldsrc/structs.h Mon Mar 27 14:17:07 2000
+++ newresets/structs.h Mon Mar 27 14:18:26 2000
@@ -874,6 +874,8 @@
    room_rnum was_in_room;   /* location for linkdead people  */
    int wait;     /* wait for how many loops   */

+   struct reset_com *reset; /* The reset command that loaded me (mob only) */
+
    struct char_player_data player;       /* Normal data                   */
    struct char_ability_data real_abils;  /* Abilities without modifiers   */
    struct char_ability_data aff_abils;  /* Abils with spells/stones/etc  */


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



This archive was generated by hypermail 2b30 : 04/10/01 PDT