Re: Oasis percentage load patch

From: Johan Dustler (Johan.Dustler@epk.ericsson.se)
Date: 02/06/97


DOH.
Me smart *chuckle*

Here is the patch.

-Johan
----------

Only in oasis: OasisOLC.README
Only in oasis: OasisOLC.patch
diff -c oasis/olc.h oasis2/olc.h
*** oasis/olc.h	Tue Apr  9 04:37:10 1996
--- oasis2/olc.h	Fri Jan 31 17:40:16 1997
***************
*** 154,164 ****
  #define ZEDIT_ARG1			6
  #define ZEDIT_ARG2			7
  #define ZEDIT_ARG3			8
! #define ZEDIT_ZONE_NAME			9
! #define ZEDIT_ZONE_LIFE			10
! #define ZEDIT_ZONE_TOP			11
! #define ZEDIT_ZONE_RESET		12
! #define ZEDIT_CONFIRM_SAVESTRING	13
  
  
  /*. Submodes of MEDIT connectedness 	.*/
--- 154,165 ----
  #define ZEDIT_ARG1			6
  #define ZEDIT_ARG2			7
  #define ZEDIT_ARG3			8
! #define ZEDIT_ARG4                      9
! #define ZEDIT_ZONE_NAME			10
! #define ZEDIT_ZONE_LIFE			11
! #define ZEDIT_ZONE_TOP			12
! #define ZEDIT_ZONE_RESET		13	
! #define ZEDIT_CONFIRM_SAVESTRING	14
  
  
  /*. Submodes of MEDIT connectedness 	.*/
diff -c oasis/zedit.c oasis2/zedit.c
*** oasis/zedit.c	Tue Apr  9 04:36:57 1996
--- oasis2/zedit.c	Wed Feb  5 16:46:05 1997
***************
*** 350,356 ****
      have an OLC as cool as this ? :> .*/
  
  void zedit_save_to_disk(struct descriptor_data *d)
! { int subcmd, arg1 = -1, arg2 = -1, arg3 = -1;
    char fname[64];
    FILE *zfile;
  
--- 350,356 ----
      have an OLC as cool as this ? :> .*/
  
  void zedit_save_to_disk(struct descriptor_data *d)
! { int subcmd, arg1 = -1, arg2 = -1, arg3 = -1, arg4 = -1;
    char fname[64];
    FILE *zfile;
  
***************
*** 383,418 ****
  	arg1 = mob_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = world[ZCMD.arg3].number;
  	break;
        case 'O':
  	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = world[ZCMD.arg3].number;
  	break;
        case 'G':
   	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
! 	arg3 = -1;
  	break;
        case 'E':
  	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = ZCMD.arg3;
  	break;
        case 'P':
  	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = obj_index[ZCMD.arg3].virtual;
  	break;
        case 'D':
  	arg1 = world[ZCMD.arg1].number;
  	arg2 = ZCMD.arg2;
  	arg3 = ZCMD.arg3;
  	break;
        case 'R':
  	arg1 = world[ZCMD.arg1].number;
  	arg2 = obj_index[ZCMD.arg2].virtual;
  	arg3 = -1;
  	break;
        case '*':
          /*. Invalid commands are replaced with '*' - Ignore them .*/
--- 383,425 ----
  	arg1 = mob_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = world[ZCMD.arg3].number;
+         arg4 = ZCMD.arg4;
  	break;
        case 'O':
  	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = world[ZCMD.arg3].number;
+         arg4 = ZCMD.arg4;
  	break;
        case 'G':
   	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
!         arg3 = ZCMD.arg3;
! 	arg4 = -1;
  	break;
        case 'E':
  	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = ZCMD.arg3;
+         arg4 = ZCMD.arg4;
  	break;
        case 'P':
  	arg1 = obj_index[ZCMD.arg1].virtual;
  	arg2 = ZCMD.arg2;
  	arg3 = obj_index[ZCMD.arg3].virtual;
+         arg4 = ZCMD.arg4;
  	break;
        case 'D':
  	arg1 = world[ZCMD.arg1].number;
  	arg2 = ZCMD.arg2;
  	arg3 = ZCMD.arg3;
+         arg4 = -1;
  	break;
        case 'R':
  	arg1 = world[ZCMD.arg1].number;
  	arg2 = obj_index[ZCMD.arg2].virtual;
  	arg3 = -1;
+         arg4 = -1;
  	break;
        case '*':
          /*. Invalid commands are replaced with '*' - Ignore them .*/
***************
*** 422,429 ****
          mudlog(buf, BRF, LVL_GOD, TRUE);
          continue;
      }
!     fprintf(zfile, "%c %d %d %d %d\n",
! 	ZCMD.command, ZCMD.if_flag, arg1, arg2, arg3);
    }
    fprintf(zfile, "S\n$\n");
    fclose(zfile);
--- 429,436 ----
          mudlog(buf, BRF, LVL_GOD, TRUE);
          continue;
      }
!     fprintf(zfile, "%c %d %d %d %d %d\n",
! 	ZCMD.command, ZCMD.if_flag, arg1, arg2, arg3, arg4);
    }
    fprintf(zfile, "S\n$\n");
    fclose(zfile);
***************
*** 581,626 ****
    { /*. Translate what the command means .*/
      switch(MYCMD.command)
      { case'M':
!         sprintf(buf2, "%sLoad %s [%s%d%s], Max : %d",
                  MYCMD.if_flag ? " then " : "",
  		mob_proto[MYCMD.arg1].player.short_descr,
                  cyn, mob_index[MYCMD.arg1].virtual, yel,
! 		MYCMD.arg2
          );
          break;
        case'G':
!         sprintf(buf2, "%sGive it %s [%s%d%s], Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
! 		MYCMD.arg2
          );
          break;
        case'O':
!         sprintf(buf2, "%sLoad %s [%s%d%s], Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
! 		MYCMD.arg2
          );
          break;
        case'E':
!         sprintf(buf2, "%sEquip with %s [%s%d%s], %s, Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
! 		equipment_types[MYCMD.arg3],
  		MYCMD.arg2
          );
          break;
        case'P':
!         sprintf(buf2, "%sPut %s [%s%d%s] in %s [%s%d%s], Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
  		obj_proto[MYCMD.arg3].short_description,
                  cyn, obj_index[MYCMD.arg3].virtual, yel,
! 		MYCMD.arg2
          );
          break;
        case'R':
--- 588,633 ----
    { /*. Translate what the command means .*/
      switch(MYCMD.command)
      { case'M':
!         sprintf(buf2, "%sLoad %s [%s%d%s], Chance %d%% , Max : %d",
                  MYCMD.if_flag ? " then " : "",
  		mob_proto[MYCMD.arg1].player.short_descr,
                  cyn, mob_index[MYCMD.arg1].virtual, yel,
! 		MYCMD.arg4 ? (101 - MYCMD.arg4): 100, MYCMD.arg2
          );
          break;
        case'G':
!         sprintf(buf2, "%sGive it %s [%s%d%s], Chance %d%%, Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
! 		MYCMD.arg3 ? (101 - MYCMD.arg3): 100, MYCMD.arg2
          );
          break;
        case'O':
!         sprintf(buf2, "%sLoad %s [%s%d%s], Chance %d%%, Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
! 		MYCMD.arg4 ? (101 - MYCMD.arg4): 100, MYCMD.arg2
          );
          break;
        case'E':
!         sprintf(buf2, "%sEquip with %s [%s%d%s], %s, Chance %d%%, Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
! 		equipment_types[MYCMD.arg3], MYCMD.arg4 ? (101 - MYCMD.arg4): 100,
  		MYCMD.arg2
          );
          break;
        case'P':
!         sprintf(buf2, "%sPut %s [%s%d%s] in %s [%s%d%s], Chance %d%%, Max : %d",
  		MYCMD.if_flag ? " then " : "",
  		obj_proto[MYCMD.arg1].short_description,
                  cyn, obj_index[MYCMD.arg1].virtual, yel,
  		obj_proto[MYCMD.arg3].short_description,
                  cyn, obj_index[MYCMD.arg3].virtual, yel,
! 		MYCMD.arg4 ? (101 - MYCMD.arg4): 100, MYCMD.arg2
          );
          break;
        case'R':
***************
*** 786,795 ****
                     "2)  Door locked\r\n" 
                     "Enter state of the door : ", d->character);
        break;
      case 'M':
      case 'O':
      case 'R':
-     case 'G':
      default:
        /*. We should never get here .*/
        cleanup_olc(d, CLEANUP_ALL);
--- 793,805 ----
                     "2)  Door locked\r\n" 
                     "Enter state of the door : ", d->character);
        break;
+ 
+     case 'G':
+             send_to_char("Give the percentage chance that this event should happen: ", d->character);
+       break;
      case 'M':
      case 'O':
      case 'R':
      default:
        /*. We should never get here .*/
        cleanup_olc(d, CLEANUP_ALL);
***************
*** 799,804 ****
--- 809,842 ----
    OLC_MODE(d) = ZEDIT_ARG3;
  }
  
+ /*-------------------------------------------------------------------*/
+ /*. Print the appropriate message for the command type for arg4 and set
+     up the input catch clause .*/
+ 
+ void zedit_disp_arg4(struct descriptor_data *d)
+ {
+   switch(OLC_CMD(d).command)
+   {
+     case 'E':
+     case 'M':
+     case 'O':
+     case 'P':
+       send_to_char("Give the percentage chance that this event should happen: ", d->character);
+       break;
+ 
+     case 'G':
+     case 'D':
+     case 'R':
+     default:
+       /*. We should never get here .*/
+       cleanup_olc(d, CLEANUP_ALL);
+       mudlog("SYSERR: OLC: zedit_disp_arg3(): Help!", BRF, LVL_GOD, TRUE);
+       return;
+   }
+   OLC_MODE(d) = ZEDIT_ARG4;
+ }
+ 
+ 
      
      
  /**************************************************************************
***************
*** 1028,1038 ****
        case 'O':
          OLC_CMD(d).arg2 = atoi(arg);
          OLC_CMD(d).arg3 = real_room(OLC_NUM(d));
!         zedit_disp_menu(d);
          break;
        case 'G':
          OLC_CMD(d).arg2 = atoi(arg);
!         zedit_disp_menu(d);
          break; 
        case 'P':
        case 'E':
--- 1066,1076 ----
        case 'O':
          OLC_CMD(d).arg2 = atoi(arg);
          OLC_CMD(d).arg3 = real_room(OLC_NUM(d));
!         zedit_disp_arg4(d);
          break;
        case 'G':
          OLC_CMD(d).arg2 = atoi(arg);
!         zedit_disp_arg3(d);
          break; 
        case 'P':
        case 'E':
***************
*** 1085,1091 ****
            send_to_char("Try again : ", d->character);
          else
          { OLC_CMD(d).arg3 = pos;
!           zedit_disp_menu(d);
          }
          break;
        case 'P':
--- 1123,1129 ----
            send_to_char("Try again : ", d->character);
          else
          { OLC_CMD(d).arg3 = pos;
!           zedit_disp_arg4(d);
          }
          break;
        case 'P':
***************
*** 1092,1098 ****
          pos = real_object(atoi(arg));
          if (pos >= 0)
          { OLC_CMD(d).arg3 = pos;
!           zedit_disp_menu(d);
          } else
            send_to_char("That object does not exist, try again : ", d->character);
          break;
--- 1130,1136 ----
          pos = real_object(atoi(arg));
          if (pos >= 0)
          { OLC_CMD(d).arg3 = pos;
!           zedit_disp_arg4(d);
          } else
            send_to_char("That object does not exist, try again : ", d->character);
          break;
***************
*** 1105,1113 ****
            zedit_disp_menu(d);
          }
          break;
        case 'M':
        case 'O':
-       case 'G':
        case 'R':
        default:
          /*. We should never get here .*/
--- 1143,1163 ----
            zedit_disp_menu(d);
          }
          break;
+       case 'G':
+         pos = atoi(arg);
+         if (pos == 100) {
+           OLC_CMD(d).arg3 = 0;
+           zedit_disp_menu(d);
+         }
+         else if (pos > 0 && pos < 100) {
+           OLC_CMD(d).arg3 = 101 - pos;
+           zedit_disp_menu(d);
+         }
+         else
+           send_to_char("Give a number between 1 and 100. Try again: ", d->character);
+         break;
        case 'M':
        case 'O':
        case 'R':
        default:
          /*. We should never get here .*/
***************
*** 1116,1122 ****
          break;
      }
      break;
!   
  /*-------------------------------------------------------------------*/
    case ZEDIT_ZONE_NAME:
      /*. Add new name and return to main menu .*/
--- 1166,1207 ----
          break;
      }
      break;
! 
! /*-------------------------------------------------------------------*/
!   case ZEDIT_ARG4:
!     /*. Parse the input for arg4, and go back to main menu. */
!     if (!isdigit(*arg)) {
!       send_to_char("Must be a numeric value, try again : ", d->character
! );
!       return;
!     }
!     switch(OLC_CMD(d).command)
!     { case 'E':
!       case 'M':
!       case 'O':
!       case 'P':
!         pos = atoi(arg);
!           if (pos == 100) {
!             OLC_CMD(d).arg4 = 0;
!             zedit_disp_menu(d);
!           }
!           else if (pos > 0 && pos < 100) {
!             OLC_CMD(d).arg4 = 101 - pos;
!             zedit_disp_menu(d);
!           }
!           else
!             send_to_char("Give a number between 1 and 100. Try again: ", d->character);
!         break;
!       case 'R':
!       case 'D':
!       default:
!         /*. We should never get here .*/
!         cleanup_olc(d, CLEANUP_ALL);
!         mudlog("SYSERR: OLC: zedit_parse(): case ARG3: Ack!", BRF, LVL_GOD, TRUE);
!         break;
!     }
!     break; 
! 
  /*-------------------------------------------------------------------*/
    case ZEDIT_ZONE_NAME:
      /*. Add new name and return to main menu .*/
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST