[CODE]

From: Del (caminturn@earthlink.net)
Date: 06/28/01


Just thought there would be a lot of people who would benefit from this idear.

Here is the basics:
Old IF flag has two options 0 and 1

I changed the if flag to a sh_int (prolly could have used an int but oh well)
and added an option 2.
This option allows an obj/mob to load IF the previous command failed.

If you have percentages in this would give you some serious fun with
alternate or similar mobs/objects loading.

For stock it would not benefit ya much (unless ya do some tricky
loading, if first loads don't load second, if second doesn't load
then load third. Or if max items/mobs reached then ya can start
loading other types.. or some idea like that.

I was suprised how easy this was and that I have not seen this idea
come across the list!
Anyways enough boring you! here is the code!

George, how do I send it to you so you can put it on developer site?

(lets hope it doesn't get rejected or chopped!)

diff -rub /home/del/src/orig/db.c /home/del/src/db.c
--- /home/del/src/orig/db.c     Tue Jun 26 22:43:39 2001
+++ /home/del/src/db.c  Thu Jun 28 22:29:30 2001
@@ -2104,8 +2104,10 @@

   for (cmd_no = 0; ZCMD.command != 'S'; cmd_no++) {

-    if (ZCMD.if_flag && !mob_load && !obj_load)
+   if ((ZCMD.if_flag == 1 && !mob_load && !obj_load) ||
+       (ZCMD.if_flag == 2 && (mob_load || obj_load)))
       continue;
+

     if (!ZCMD.if_flag) {
       mob_load = FALSE;
diff -rub /home/del/src/orig/db.h /home/del/src/db.h
--- /home/del/src/orig/db.h     Tue Jun 26 22:43:39 2001
+++ /home/del/src/db.h  Thu Jun 28 20:43:31 2001
@@ -125,7 +125,7 @@
 struct reset_com {
   char command;               /* current command                      */

-  bool if_flag;               /* if TRUE: exe only if preceding exe'd */
+  sh_int if_flag;               /* 0 ignore, 1 previous loads, 2 previous
doesn't load */
   int arg1;                   /*                                      */
   int arg2;                   /* Arguments to the command             */
   int arg3;                   /*                                      */
diff -rub /home/del/src/orig/zedit.c /home/del/src/zedit.c
--- /home/del/src/orig/zedit.c  Tue Jun 26 22:43:39 2001
+++ /home/del/src/zedit.c       Thu Jun 28 22:11:55 2001
@@ -800,8 +800,8 @@
     /* Translate what the command means. */
     switch (MYCMD.command) {
     case 'M':
-      sprintf(buf2, "%sLoad %s [%s%d%s], Chance : %d%% , Max : %d (%s)",
-              MYCMD.if_flag ? " then " : "",
+      sprintf(buf2, "%s%sLoad %s [%s%d%s], Chance : %d%% , Max : %d (%s)",
+              MYCMD.if_flag == 1 ? " then " : "", MYCMD.if_flag == 2 ? "
otherwise " : "",
               mob_proto[MYCMD.arg1].player.short_descr,
               nrm, mob_index[MYCMD.arg1].vnum, grn,
               MYCMD.arg4, MYCMD.arg2,
@@ -809,16 +809,16 @@
              );
       break;
     case 'G':
-      sprintf(buf2, "%sGive it %s [%s%d%s], Chance : %d%%, Max : %d
(mud-limit)",
-              MYCMD.if_flag ? " then " : "",
+      sprintf(buf2, "%s%sGive it %s [%s%d%s], Chance : %d%%, Max : %d
(mud-limit)",
+              MYCMD.if_flag == 1 ? " then " : "", MYCMD.if_flag == 2 ? "
otherwise " : "",
               obj_proto[MYCMD.arg1].short_description,
               nrm, obj_index[MYCMD.arg1].vnum, grn,
               MYCMD.arg3, MYCMD.arg2
              );
       break;
     case 'O':
-      sprintf(buf2, "%sLoad %s [%s%d%s], Chance : %d%%, Max : %d (%s)",
-              MYCMD.if_flag ? " then " : "",
+      sprintf(buf2, "%s%sLoad %s [%s%d%s], Chance : %d%%, Max : %d (%s)",
+              MYCMD.if_flag == 1 ? " then " : "", MYCMD.if_flag == 2 ? "
otherwise " : "",
               obj_proto[MYCMD.arg1].short_description,
               nrm, obj_index[MYCMD.arg1].vnum, grn,
               MYCMD.arg4, MYCMD.arg2,
@@ -826,8 +826,8 @@
              );
       break;
     case 'E':
-      sprintf(buf2, "%sEquip with %s [%s%d%s], %s, Chance : %d%%, Max : %d
(mud-limit)",
-              MYCMD.if_flag ? " then " : "",
+      sprintf(buf2, "%s%sEquip with %s [%s%d%s], %s, Chance : %d%%, Max : %d
(mud-limit)",
+              MYCMD.if_flag == 1 ? " then " : "", MYCMD.if_flag == 2 ? "
otherwise " : "",
               obj_proto[MYCMD.arg1].short_description,
               nrm, obj_index[MYCMD.arg1].vnum, grn,
               equipment_types[MYCMD.arg3],
@@ -835,8 +835,8 @@
              );
       break;
     case 'P':
-      sprintf(buf2, "%sPut %s [%s%d%s] in %s [%s%d%s], Chance : %d%%, Max : %d
(%s)",
-              MYCMD.if_flag ? " then " : "",
+      sprintf(buf2, "%s%sPut %s [%s%d%s] in %s [%s%d%s], Chance : %d%%, Max :
%d (%s)",
+              MYCMD.if_flag == 1 ? " then " : "", MYCMD.if_flag == 2 ? "
otherwise " : "",
               obj_proto[MYCMD.arg1].short_description,
               nrm, obj_index[MYCMD.arg1].vnum, grn,
               obj_proto[MYCMD.arg3].short_description,
@@ -1428,8 +1428,12 @@
    OLC_CMD(d).command = toupper(*arg);
    if (!OLC_CMD(d).command || (strchr("MOPEDGR", OLC_CMD(d).command) == NULL))
{
      SEND_TO_Q("Invalid choice, try again : ", d);
-    } else {
-      send_to_char("Is this command dependent on the success of the previous
one? (y/n)\r\n", d->character);
+    } else if (OLC_CMD(d).command != 'D' && OLC_CMD(d).command != 'R') {
+      send_to_char("Options:\r\n"
+                   " 0 = This command is not dependant on previous
command.\r\n"
+                   " 1 = This command will attempt to load if previous
loads.\r\n"
+                   " 2 = This command will attempt to load if previous does NOT
load.\r\n\r\n"
+                   "enter choice: ", d->character);
        OLC_MODE(d) = ZEDIT_IF_FLAG;
      } else {  /* 'if-flag' not appropriate. */
        OLC_CMD(d).if_flag = 0;
@@ -1441,24 +1445,19 @@

   /*-------------------------------------------------------------------*/
   /* Parse the input for the if flag, and goto next quiz. */
+
   case ZEDIT_IF_FLAG:
-    switch (*arg) {
-    case 'y':
-    case 'Y':
-      OLC_CMD(d).if_flag = 1;
-      break;
-    case 'n':
-    case 'N':
-      OLC_CMD(d).if_flag = 0;
-      break;
-    default:
-      send_to_char("Try again : ", d->character);
-      return;
-    }
-    zedit_disp_arg1(d);
+    pos = atoi(arg);
+    if (!isdigit(*arg) || (pos < 0) || (pos > 2))
+      send_to_char("Try again (0-2) : ", d->character);
+    else {
+      OLC_CMD(d).if_flag = pos;
+      zedit_disp_arg1(d);
+    }
     break;

   /*-------------------------------------------------------------------*/

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST