Stat Zone Loading/Reset information
Snippet Posted Saturday, September 23rd @ 12:50:50 PM, by Brandon Brown in the Wizard dept.
Dana Luther, "I can't think of how many times I've had to jump into zedit just to peek at what a room would load up on a reset. This is a handy way to get around that chaos. ;)" Really really good idea here. Can't imagine why I never thought of doing something like this.
Note: 's should be replaced with tabs.

I can't think of how many times I've had to jump into zedit just to peek at what a room would load up on a reset. This is a handy way to get around that chaos. ;)

All in act.wizard.c
********************

+/* Check the previous command in the list to determine whether
+ * it was used in the same room or not 
+ */
+bool check_same_room(int zone, int subcmd, room_rnum rnum)
+{
+	sprintf(buf, "subcmd is %d", subcmd);
+   log(buf);
+
+	if (subcmd <= 0)  /* Looks like we're already at the bottom, tough luck */
+   	return FALSE;
+
+	if (ZCMD(zone, (subcmd-1)).if_flag) {  /* Need to go back another command */
+   	if (check_same_room(zone, (subcmd - 1), rnum) != TRUE)
+      	return FALSE; /* Checking previous command found no match to the rnum */
+      else
+      	return TRUE;  /* Found it! */
+ } else {
+  	switch (ZCMD(zone, (subcmd-1)).command){
+			case 'M':   /* Mobile */
+     case 'V':		/* Variable - Used with DG Scripts, omit this case if you don't use them*/
+	    case 'O':		/* Object */
+	      	if (ZCMD(zone, (subcmd-1)).arg3 == rnum)
+            	return TRUE;
+	      	break;
+  	   case 'R':	/* Room */
+	     case 'D':	/* Door */
+	      	if (ZCMD(zone, (subcmd-1)).arg1 == rnum)
+            	return TRUE;
+      		break;
+   	 default: break;
+	   }
+  }
+	 return FALSE;
+}
+
+/* Called from vstat - show the zone reset information for
+ * the specified room
+ */
+void do_zstat_room(struct char_data *ch, zone_rnum rnum)
+{
+  int zone = world[rnum].zone;
+  int subcmd = 0, counter = 0;
+  room_vnum rvnum = GET_ROOM_VNUM(rnum);
+  extern struct char_data *mob_proto;
+  extern struct obj_data *obj_proto;
+  char output[MAX_STRING_LENGTH];
+  bool found;
+
+  sprintbit(zone_table[zone].zone_flags, zone_bits, buf1);
+
+  sprintf(buf,
+    "Zone number : %d [%4d]\r\n"
+    "Zone name   : %s\r\n"
+    "Builders    : %s\r\n"
+    "Zone Flags  : %s\r\n",
+    zone_table[zone].number, rvnum, zone_table[zone].name ? zone_table[zone].name : "",
+    zone_table[zone].builders ? zone_table[zone].builders : "", buf1);
+    send_to_char(buf, ch);
+
+  if (!(ZCMD(zone, subcmd).command)){
+    send_to_char("No zone loading information.\r\n", ch);
+    return;
+  }
+
+  sprintf(output, "--------------------------------------------------\r\n");
+  while ((ZCMD(zone, subcmd).command) && (ZCMD(zone, subcmd).command != 'S')) {
+ 	 found = FALSE;
+    /*
+     * Translate what the command means.
+     */
+
+   /* If this is a "then do this" command, we need to check that the previous
+    * command was issued in this room
+    */
+   if (ZCMD(zone, subcmd).if_flag == TRUE){
+		  if (check_same_room(zone, subcmd, rnum) == FALSE){
+       	subcmd++;
+         continue; /* not this room */
+      }
+    }
+    switch (ZCMD(zone, subcmd).command) {
+    case 'M':
+       if (ZCMD(zone, subcmd).arg3 != rnum)
+       	break; /* not this room */
+      sprintf(buf2, "%sLoad %s [%d], Max : %d",
+              ZCMD(zone, subcmd).if_flag ? " then " : "",
+              mob_proto[ZCMD(zone, subcmd).arg1].player.short_descr,
+              mob_index[ZCMD(zone, subcmd).arg1].vnum, ZCMD(zone, subcmd).arg2);
+      found = TRUE;
+      break;
+    case 'G':
+      sprintf(buf2, "%sGive it %s [%d], Max : %d",
+	      ZCMD(zone, subcmd).if_flag ? " then " : "",
+	      obj_proto[ZCMD(zone, subcmd).arg1].short_description,
+	      obj_index[ZCMD(zone, subcmd).arg1].vnum,
+	      ZCMD(zone, subcmd).arg2);
+      found = TRUE;
+      break;
+    case 'O':
+      if (ZCMD(zone, subcmd).arg3 != rnum)
+      	break; /* not this room */
+      sprintf(buf2, "%sLoad %s [%d], Max : %d",
+	      ZCMD(zone, subcmd).if_flag ? " then " : "",
+	      obj_proto[ZCMD(zone, subcmd).arg1].short_description,
+	      obj_index[ZCMD(zone, subcmd).arg1].vnum,
+	      ZCMD(zone, subcmd).arg2);
+      found = TRUE;
+      break;
+    case 'E':
+     sprintf(buf2, "%sEquip with %s [%d], %s, Max : %d",
+	      ZCMD(zone, subcmd).if_flag ? " then " : "",
+	      obj_proto[ZCMD(zone, subcmd).arg1].short_description,
+	      obj_index[ZCMD(zone, subcmd).arg1].vnum,
+	      equipment_types[ZCMD(zone, subcmd).arg3],
+	      ZCMD(zone, subcmd).arg2);
+
+      found = TRUE;
+      break;
+    case 'P':
+      sprintf(buf2, "%sPut %s [%d] in %s [%d], Max : %d",
+	      ZCMD(zone, subcmd).if_flag ? " then " : "",
+	      obj_proto[ZCMD(zone, subcmd).arg1].short_description,
+	      obj_index[ZCMD(zone, subcmd).arg1].vnum,
+	      obj_proto[ZCMD(zone, subcmd).arg3].short_description,
+	      obj_index[ZCMD(zone, subcmd).arg3].vnum,
+	      ZCMD(zone, subcmd).arg2);
+      found = TRUE;
+      break;
+    case 'R':
+       if (ZCMD(zone, subcmd).arg1 != rnum)
+         break; // not this room
+       sprintf(buf2, "%sRemove %s [%d] from room.",
+	      ZCMD(zone, subcmd).if_flag ? " then " : "",
+	      obj_proto[ZCMD(zone, subcmd).arg2].short_description,
+	      obj_index[ZCMD(zone, subcmd).arg2].vnum);
+      found = TRUE;
+      break;
+    case 'D':
+       if (ZCMD(zone, subcmd).arg1 != rnum)
+       	break; /* not this room */
+     sprintf(buf2, "%sSet door %s as %s.",
+	      ZCMD(zone, subcmd).if_flag ? " then " : "",
+	      dirs[ZCMD(zone, subcmd).arg2],
+	      ZCMD(zone, subcmd).arg3 ? ((ZCMD(zone, subcmd).arg3 == 1) ? ((ZCMD(zone, subcmd).arg3 == 2) ? "hidden" : "closed") : "locked") : "open");
+      found = TRUE;
+      break;
+    case 'T': /* Omit this case if the latest version of DGScripts is not installed */
+      sprintf(buf2, "%sAttach trigger %s [%d] to %s",
+        ZCMD(zone, subcmd).if_flag ? " then " : "",
+        trig_index[real_trigger(ZCMD(zone, subcmd).arg2)]->proto->name,
+        ZCMD(zone, subcmd).arg2,
+        ((ZCMD(zone, subcmd).arg1 == MOB_TRIGGER) ? "mobile" :
+          ((ZCMD(zone, subcmd).arg1 == OBJ_TRIGGER) ? "object" :
+            ((ZCMD(zone, subcmd).arg1 == WLD_TRIGGER)? "room" : "????"))));
+      found = TRUE;
+      break;
+    case 'V':  /* Omit this case if the latest version of DGScripts is not installed */
+      if (ZCMD(zone, subcmd).arg1 != WLD_TRIGGER)
+      	break; /* not a world trigger then it doesn't concern us. */
+      if (ZCMD(zone, subcmd).arg3 != rnum)
+      	break; /* not this room */
+      sprintf(buf2, "%sAssign global %s:%d to %s = %s",
+        ZCMD(zone, subcmd).if_flag ? " then " : "",
+        ZCMD(zone, subcmd).sarg1, ZCMD(zone, subcmd).arg2,
+        ((ZCMD(zone, subcmd).arg1 == MOB_TRIGGER) ? "mobile" :
+          ((ZCMD(zone, subcmd).arg1 == OBJ_TRIGGER) ? "object" :
+            ((ZCMD(zone, subcmd).arg1 == WLD_TRIGGER)? "room" : "????"))),
+        ZCMD(zone, subcmd).sarg2);
+      found = TRUE;
+      break;
+    default: /* Catch all */
+      sprintf(buf2, "");
+      found = TRUE;
+      break;
+    }
+    /*
+     * Build the display buffer for this command.  
+     * Only show things that apply to this room.
+     */
+    if (found == TRUE){  
+	    sprintf(buf1, "%d - %s\r\n", counter++, buf2);
+   	 strcat(output, buf1);
+    }
+    subcmd++;
+  }
+  send_to_char(output, ch);
+
+}
+

ACMD(do_vstat)
{
  struct char_data *mob;
  struct obj_data *obj;
  mob_vnum number;	/* or obj_vnum ... */
  mob_rnum r_num;	/* or obj_rnum ... */

  two_arguments(argument, buf, buf2);

  if (!*buf || !*buf2 || !isdigit(*buf2)) {
!   send_to_char("Usage: vstat { obj | mob | room } \r\n", ch);
    return;
  }
  if ((number = atoi(buf2)) < 0) {
    send_to_char("A NEGATIVE number??\r\n", ch);
    return;
  }
  if (is_abbrev(buf, "mob")) {
    if ((r_num = real_mobile(number)) < 0) {
      send_to_char("There is no monster with that number.\r\n", ch);
      return;
    }
    mob = read_mobile(r_num, REAL);
    char_to_room(mob, 0);
    do_stat_character(ch, mob);
    extract_char(mob);
  } else if (is_abbrev(buf, "obj")) {
    if ((r_num = real_object(number)) < 0) {
      send_to_char("There is no object with that number.\r\n", ch);
      return;
    }
    obj = read_object(r_num, REAL);
    do_stat_object(ch, obj);
    extract_obj(obj);
+ } else if (is_abbrev(buf, "room")){
+   if ((r_num = real_room(number)) < 0) {
+     send_to_char("That room does not exist.\r\n", ch);
+     return;
+   }
+   do_zstat_room(ch, r_num);
  } else
!    send_to_char("That'll have to be either 'obj' or 'mob' or 'room'.\r\n", ch);
}

<< safe_command_interpreter | Reply | Flattened >>

 


Related Links
  Dana Luther
Related Articles
More by bbrown
 
 

Quick Links
 
The CircleMUD FAQ
The CircleMUD home page
Alex's Snippets
Wintermute Snippets
CircleMUD Bug Reporting or Help
CircleMUD List Archives
CircleMUD Resources
Death Gate's Scripts
(Author of C conversion)
Sammy's code site
Erwin S. Andreasen's page
(Author of mudFTP and other goodies)
Death's Gate Scripting site
Help for CircleMUD in Windows
The OasisOLC Maintenance Effort
George's Random Stuff
Imaginary Realities
MUD Dictionary