void medit_parse(struct descriptor_data *d, char *arg) { int i = -1, j; char *oldtext = NULL; if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) { i = atoi(arg); if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) { write_to_output(d, "Try again : "); return; } } else { /* String response. */ if (!genolc_checkstring(d, arg)) return; } switch (OLC_MODE(d)) { case MEDIT_CONFIRM_SAVESTRING: /* Ensure mob has MOB_ISNPC set. */ SET_BIT_AR(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC); switch (*arg) { case 'y': case 'Y': /* Save the mob in memory and to disk. */ medit_save_internally(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d)); if (CONFIG_OLC_SAVE) { medit_save_to_disk(zone_table[real_zone_by_thing(OLC_NUM(d))].number); write_to_output(d, "Mobile saved to disk.\r\n"); } else write_to_output(d, "Mobile saved to memory.\r\n"); cleanup_olc(d, CLEANUP_ALL); return; case 'n': case 'N': /* If not saving, we must free the script_proto list. We do so by * assigning it to the edited mob and letting free_mobile in * cleanup_olc handle it. */ OLC_MOB(d)->proto_script = OLC_SCRIPT(d); cleanup_olc(d, CLEANUP_ALL); return; default: write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Do you wish to save your changes? : "); return; } break; case MEDIT_MAIN_MENU: i = 0; switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Anything been changed? */ write_to_output(d, "Do you wish to save your changes? : "); OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = MEDIT_SEX; medit_disp_sex(d); return; case '2': OLC_MODE(d) = MEDIT_KEYWORD; i--; break; case '3': OLC_MODE(d) = MEDIT_S_DESC; i--; break; case '4': OLC_MODE(d) = MEDIT_L_DESC; i--; break; case '5': OLC_MODE(d) = MEDIT_D_DESC; send_editor_help(d); write_to_output(d, "Enter mob description:\r\n\r\n"); if (OLC_MOB(d)->player.description) { write_to_output(d, "%s", OLC_MOB(d)->player.description); oldtext = strdup(OLC_MOB(d)->player.description); } string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext); OLC_VAL(d) = 1; return; case '6': OLC_MODE(d) = MEDIT_POS; medit_disp_positions(d); return; case '7': OLC_MODE(d) = MEDIT_DEFAULT_POS; medit_disp_positions(d); return; case '8': OLC_MODE(d) = MEDIT_ATTACK; medit_disp_attack_types(d); return; case '9': OLC_MODE(d) = MEDIT_STATS_MENU; medit_disp_stats_menu(d); return; case 'a': case 'A': OLC_MODE(d) = MEDIT_NPC_FLAGS; medit_disp_mob_flags(d); return; case 'b': case 'B': OLC_MODE(d) = MEDIT_AFF_FLAGS; medit_disp_aff_flags(d); return; case 'w': case 'W': write_to_output(d, "Copy what mob? "); OLC_MODE(d) = MEDIT_COPY; return; case 'x': case 'X': write_to_output(d, "Are you sure you want to delete this mobile? "); OLC_MODE(d) = MEDIT_DELETE; return; case 's': case 'S': OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU; dg_script_menu(d); return; default: medit_disp_menu(d); return; } if (i == 0) break; else if (i == 1) write_to_output(d, "\r\nEnter new value : "); else if (i == -1) write_to_output(d, "\r\nEnter new text :\r\n] "); else write_to_output(d, "Oops...\r\n"); return; case MEDIT_STATS_MENU: i=0; switch(*arg) { case 'q': case 'Q': medit_disp_menu(d); return; case '1': /* Edit level */ OLC_MODE(d) = MEDIT_LEVEL; i++; break; case '2': /* Autoroll stats */ medit_autoroll_stats(d); medit_disp_stats_menu(d); OLC_VAL(d) = TRUE; return; case '3': OLC_MODE(d) = MEDIT_NUM_HP_DICE; i++; break; case '4': OLC_MODE(d) = MEDIT_SIZE_HP_DICE; i++; break; case '5': OLC_MODE(d) = MEDIT_ADD_HP; i++; break; case '6': OLC_MODE(d) = MEDIT_NDD; i++; break; case '7': OLC_MODE(d) = MEDIT_SDD; i++; break; case '8': OLC_MODE(d) = MEDIT_DAMROLL; i++; break; case 'a': case 'A': OLC_MODE(d) = MEDIT_AC; i++; break; case 'b': case 'B': OLC_MODE(d) = MEDIT_EXP; i++; break; case 'c': case 'C': OLC_MODE(d) = MEDIT_GOLD; i++; break; case 'd': case 'D': OLC_MODE(d) = MEDIT_HITROLL; i++; break; case 'e': case 'E': OLC_MODE(d) = MEDIT_ALIGNMENT; i++; break; case 'f': case 'F': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_STR; i++; break; case 'g': case 'G': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_INT; i++; break; case 'h': case 'H': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_WIS; i++; break; case 'i': case 'I': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_DEX; i++; break; case 'j': case 'J': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_CON; i++; break; case 'k': case 'K': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_CHA; i++; break; case 'l': case 'L': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_PARA; i++; break; case 'm': case 'M': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_ROD; i++; break; case 'n': case 'N': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_PETRI; i++; break; case 'o': case 'O': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_BREATH; i++; break; case 'p': case 'P': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_SPELL; i++; break; default: medit_disp_stats_menu(d); return; } if (i == 0) break; else if (i == 1) write_to_output(d, "\r\nEnter new value : "); else if (i == -1) write_to_output(d, "\r\nEnter new text :\r\n] "); else write_to_output(d, "Oops...\r\n"); return; case OLC_SCRIPT_EDIT: if (dg_script_edit_parse(d, arg)) return; break; case MEDIT_KEYWORD: smash_tilde(arg); if (GET_ALIAS(OLC_MOB(d))) free(GET_ALIAS(OLC_MOB(d))); GET_ALIAS(OLC_MOB(d)) = str_udup(arg); break; case MEDIT_S_DESC: smash_tilde(arg); if (GET_SDESC(OLC_MOB(d))) free(GET_SDESC(OLC_MOB(d))); GET_SDESC(OLC_MOB(d)) = str_udup(arg); break; case MEDIT_L_DESC: smash_tilde(arg); if (GET_LDESC(OLC_MOB(d))) free(GET_LDESC(OLC_MOB(d))); if (arg && *arg) { char buf[MAX_INPUT_LENGTH]; snprintf(buf, sizeof(buf), "%s\r\n", arg); GET_LDESC(OLC_MOB(d)) = strdup(buf); } else GET_LDESC(OLC_MOB(d)) = strdup("undefined"); break; case MEDIT_D_DESC: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: medit_parse(): Reached D_DESC case!"); write_to_output(d, "Oops...\r\n"); break; case MEDIT_NPC_FLAGS: if ((i = atoi(arg)) <= 0) break; else if ( (j = medit_get_mob_flag_by_number(i)) == -1) { write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Enter mob flags (0 to quit) :"); return; } else if (j <= NUM_MOB_FLAGS) { TOGGLE_BIT_AR(MOB_FLAGS(OLC_MOB(d)), (j)); } medit_disp_mob_flags(d); return; case MEDIT_AFF_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_AFF_FLAGS) TOGGLE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), i); /* Remove unwanted bits right away. */ REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_CHARM); REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_POISON); REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_GROUP); REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_SLEEP); medit_disp_aff_flags(d); return; /* Numerical responses. */ case MEDIT_SEX: GET_SEX(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_GENDERS - 1); break; case MEDIT_HITROLL: GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_DAMROLL: GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_NDD: GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_SDD: GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_NUM_HP_DICE: GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_SIZE_HP_DICE: GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_ADD_HP: GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_AC: GET_AC(OLC_MOB(d)) = LIMIT(i, -200, 200); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_EXP: GET_EXP(OLC_MOB(d)) = LIMIT(i, 0, MAX_MOB_EXP); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_GOLD: GET_GOLD(OLC_MOB(d)) = LIMIT(i, 0, MAX_MOB_GOLD); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_STR: GET_STR(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_INT: GET_INT(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_WIS: GET_WIS(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_DEX: GET_DEX(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_CON: GET_CON(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_CHA: GET_CHA(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_PARA: GET_SAVE(OLC_MOB(d), SAVING_PARA) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_ROD: GET_SAVE(OLC_MOB(d), SAVING_ROD) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_PETRI: GET_SAVE(OLC_MOB(d), SAVING_PETRI) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_BREATH: GET_SAVE(OLC_MOB(d), SAVING_BREATH) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_SPELL: GET_SAVE(OLC_MOB(d), SAVING_SPELL) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_POS: GET_POS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_POSITIONS - 1); break; case MEDIT_DEFAULT_POS: GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_POSITIONS - 1); break; case MEDIT_ATTACK: GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1); break; case MEDIT_LEVEL: GET_LEVEL(OLC_MOB(d)) = LIMIT(i, 1, LVL_IMPL); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_ALIGNMENT: GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_COPY: if ((i = real_mobile(atoi(arg))) != NOWHERE) { medit_setup_existing(d, i); } else write_to_output(d, "That mob does not exist.\r\n"); break; case MEDIT_DELETE: if (*arg == 'y' || *arg == 'Y') { if (delete_mobile(GET_MOB_RNUM(OLC_MOB(d))) != NOBODY) write_to_output(d, "Mobile deleted.\r\n"); else write_to_output(d, "Couldn't delete the mobile!\r\n"); cleanup_olc(d, CLEANUP_ALL); return; } else if (*arg == 'n' || *arg == 'N') { medit_disp_menu(d); OLC_MODE(d) = MEDIT_MAIN_MENU; return; } else write_to_output(d, "Please answer 'Y' or 'N': "); break; default: /* We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: medit_parse(): Reached default case!"); write_to_output(d, "Oops...\r\n"); break; } /* END OF CASE If we get here, we have probably changed something, and now want to return to main menu. Use OLC_VAL as a 'has changed' flag */ OLC_VAL(d) = TRUE; medit_disp_menu(d); }
void medit_parse(struct descriptor_data *d, char *arg) { int i = -1; char *oldtext = NULL; if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) { i = atoi(arg); if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) { SEND_TO_Q("Field must be numerical, try again : ", d); return; } } else { /* String response. */ if (!genolc_checkstring(d, arg)) return; } switch (OLC_MODE(d)) { /*-------------------------------------------------------------------*/ case MEDIT_CONFIRM_SAVESTRING: /* * Ensure mob has MOB_ISNPC set or things will go pear shaped. */ SET_BIT(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC); switch (*arg) { case 'y': case 'Y': /* * Save the mob in memory and to disk. */ SEND_TO_Q("Saving mobile to memory.\r\n", d); medit_save_internally(d); sprintf(buf, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE); /* FALL THROUGH */ case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); return; default: SEND_TO_Q("Invalid choice!\r\n", d); SEND_TO_Q("Do you wish to save the mobile? : ", d); return; } break; /*-------------------------------------------------------------------*/ case MEDIT_MAIN_MENU: i = 0; switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Anything been changed? */ SEND_TO_Q("Do you wish to save the changes to the mobile? (y//n) : ", d); OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = MEDIT_SEX; medit_disp_sex(d); return; case '2': OLC_MODE(d) = MEDIT_ALIAS; i--; break; case '3': OLC_MODE(d) = MEDIT_S_DESC; i--; break; case '4': OLC_MODE(d) = MEDIT_L_DESC; i--; break; case '5': OLC_MODE(d) = MEDIT_D_DESC; send_editor_help(d); SEND_TO_Q("Enter mob description:\r\n\r\n", d); if (OLC_MOB(d)->player.description) { SEND_TO_Q(OLC_MOB(d)->player.description, d); oldtext = str_dup(OLC_MOB(d)->player.description); } string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext); OLC_VAL(d) = 1; return; case '6': OLC_MODE(d) = MEDIT_LEVEL; i++; break; case '7': OLC_MODE(d) = MEDIT_ALIGNMENT; i++; break; case '8': OLC_MODE(d) = MEDIT_HITROLL; i++; break; case '9': OLC_MODE(d) = MEDIT_DAMROLL; i++; break; case 'a': case 'A': OLC_MODE(d) = MEDIT_NDD; i++; break; case 'b': case 'B': OLC_MODE(d) = MEDIT_SDD; i++; break; case 'c': case 'C': OLC_MODE(d) = MEDIT_NUM_HP_DICE; i++; break; case 'd': case 'D': OLC_MODE(d) = MEDIT_SIZE_HP_DICE; i++; break; case 'e': case 'E': OLC_MODE(d) = MEDIT_ADD_HP; i++; break; case 'f': case 'F': OLC_MODE(d) = MEDIT_AC; i++; break; case 'g': case 'G': OLC_MODE(d) = MEDIT_EXP; i++; break; case 'h': case 'H': OLC_MODE(d) = MEDIT_GOLD; i++; break; case 'i': case 'I': OLC_MODE(d) = MEDIT_POS; medit_disp_positions(d); return; case 'j': case 'J': OLC_MODE(d) = MEDIT_DEFAULT_POS; medit_disp_positions(d); return; case 'k': case 'K': OLC_MODE(d) = MEDIT_ATTACK; medit_disp_attack_types(d); return; case 'l': case 'L': OLC_MODE(d) = MEDIT_NPC_FLAGS; medit_disp_mob_flags(d); return; case 'm': case 'M': OLC_MODE(d) = MEDIT_AFF_FLAGS; medit_disp_aff_flags(d); return; case 'n': case 'N': OLC_MODE(d) = MEDIT_CLASS; medit_disp_class_flags(d); return; case 'r': case 'R': OLC_MODE(d) = MEDIT_RACE; medit_disp_race_flags(d); return; case 's': case 'S': OLC_MODE(d) = MEDIT_MSIZE; medit_disp_size_flags(d); return; case 'w': case 'W': OLC_MODE(d) = MEDIT_WEIGHT; send_to_char("Please enter the mobiles weight in pounds: ", d->character); return; #if CONFIG_OASIS_MPROG case 'p': case 'P': OLC_MODE(d) = MEDIT_MPROG; medit_disp_mprog(d); return; #endif default: medit_disp_menu(d); return; } if (i == 0) break; else if (i == 1) SEND_TO_Q("\r\nEnter new value : ", d); else if (i == -1) SEND_TO_Q("\r\nEnter new text :\r\n] ", d); else SEND_TO_Q("Oops...\r\n", d); return; /*-------------------------------------------------------------------*/ case MEDIT_ALIAS: if (GET_ALIAS(OLC_MOB(d))) free(GET_ALIAS(OLC_MOB(d))); GET_ALIAS(OLC_MOB(d)) = str_udup(arg); break; /*-------------------------------------------------------------------*/ case MEDIT_S_DESC: if (GET_SDESC(OLC_MOB(d))) free(GET_SDESC(OLC_MOB(d))); GET_SDESC(OLC_MOB(d)) = str_udup(arg); break; /*-------------------------------------------------------------------*/ case MEDIT_L_DESC: if (GET_LDESC(OLC_MOB(d))) free(GET_LDESC(OLC_MOB(d))); if (arg && *arg) { strcpy(buf, arg); strcat(buf, "\r\n"); GET_LDESC(OLC_MOB(d)) = str_dup(buf); } else GET_LDESC(OLC_MOB(d)) = str_dup("undefined"); break; /*-------------------------------------------------------------------*/ case MEDIT_D_DESC: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached D_DESC case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; /*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG_COMLIST: /* * We should never get here, but if we do, bail out. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached MPROG_COMLIST case!", BRF, LVL_BUILDER, TRUE); break; #endif /*-------------------------------------------------------------------*/ case MEDIT_NPC_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_MOB_FLAGS) TOGGLE_BIT(MOB_FLAGS(OLC_MOB(d)), 1 << (i - 1)); medit_disp_mob_flags(d); return; /*-------------------------------------------------------------------*/ case MEDIT_AFF_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_AFF_FLAGS) TOGGLE_BIT(AFF_FLAGS(OLC_MOB(d)), 1 << (i - 1)); medit_disp_aff_flags(d); return; /*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG: if ((i = atoi(arg)) == 0) medit_disp_menu(d); else if (i == OLC_MTOTAL(d)) { struct mob_prog_data *temp; CREATE(temp, struct mob_prog_data, 1); temp->next = OLC_MPROGL(d); temp->type = -1; temp->arglist = NULL; temp->comlist = NULL; OLC_MPROG(d) = temp; OLC_MPROGL(d) = temp; OLC_MODE(d) = MEDIT_CHANGE_MPROG; medit_change_mprog (d); } else if (i < OLC_MTOTAL(d)) { struct mob_prog_data *temp; int x = 1; for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next) x++; OLC_MPROG(d) = temp; OLC_MODE(d) = MEDIT_CHANGE_MPROG; medit_change_mprog (d); } else if (i == (OLC_MTOTAL(d) + 1)) { SEND_TO_Q("Which mob prog do you want to purge? ", d); OLC_MODE(d) = MEDIT_PURGE_MPROG; } else medit_disp_menu(d); return; case MEDIT_PURGE_MPROG: if ((i = atoi(arg)) > 0 && i < OLC_MTOTAL(d)) { struct mob_prog_data *temp; int x = 1; for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next) x++; OLC_MPROG(d) = temp; REMOVE_FROM_LIST(OLC_MPROG(d), OLC_MPROGL(d), next); free(OLC_MPROG(d)->arglist); free(OLC_MPROG(d)->comlist); free(OLC_MPROG(d)); OLC_MPROG(d) = NULL; OLC_VAL(d) = 1; } medit_disp_mprog(d); return; case MEDIT_CHANGE_MPROG: if ((i = atoi(arg)) == 1) medit_disp_mprog_types(d); else if (i == 2) { SEND_TO_Q("Enter new arg list: ", d); OLC_MODE(d) = MEDIT_MPROG_ARGS; } else if (i == 3) { SEND_TO_Q("Enter new mob prog commands:\r\n", d); /* * Pass control to modify.c for typing. */ OLC_MODE(d) = MEDIT_MPROG_COMLIST; if (OLC_MPROG(d)->comlist) { SEND_TO_Q(OLC_MPROG(d)->comlist, d); oldtext = str_dup(OLC_MPROG(d)->comlist); } string_write(d, &OLC_MPROG(d)->comlist, MAX_STRING_LENGTH, 0, oldtext); OLC_VAL(d) = 1; } else medit_disp_mprog(d); return; #endif /*-------------------------------------------------------------------*/ /* * Numerical responses. */ #if CONFIG_OASIS_MPROG case MEDIT_MPROG_TYPE: /* * This calculation may be off by one too many powers of 2? * Someone who actually uses MobProgs will have to check. */ OLC_MPROG(d)->type = (1 << LIMIT(atoi(arg), 0, NUM_PROGS - 1)); OLC_VAL(d) = 1; medit_change_mprog(d); return; case MEDIT_MPROG_ARGS: OLC_MPROG(d)->arglist = str_dup(arg); OLC_VAL(d) = 1; medit_change_mprog(d); return; #endif case MEDIT_SEX: GET_SEX(OLC_MOB(d)) = LIMIT(i, 0, NUM_GENDERS - 1); break; case MEDIT_HITROLL: GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); break; case MEDIT_DAMROLL: GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); break; case MEDIT_NDD: GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30); break; case MEDIT_SDD: GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127); break; case MEDIT_NUM_HP_DICE: GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30); break; case MEDIT_SIZE_HP_DICE: GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000); break; case MEDIT_ADD_HP: GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000); break; case MEDIT_AC: GET_AC(OLC_MOB(d)) = LIMIT(i, 10, 200); break; case MEDIT_EXP: GET_EXP(OLC_MOB(d)) = MAX(i, 0); break; case MEDIT_GOLD: add_money_to_char(OLC_MOB(d), MAX(i, 0), COPPER_COINS); break; case MEDIT_POS: GET_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1); break; case MEDIT_DEFAULT_POS: GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1); break; case MEDIT_ATTACK: GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1); break; case MEDIT_LEVEL: GET_LEVEL(OLC_MOB(d)) = i; break; case MEDIT_ALIGNMENT: GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000); break; case MEDIT_CLASS: GET_CLASS(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_CLASS, atoi(arg))); break; case MEDIT_RACE: GET_RACE(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_RACE, atoi(arg))); // INT, WIS, STR, DEX, CON, CHA GET_INT(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][0]; GET_WIS(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][1]; GET_STR(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][2]; GET_DEX(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][3]; GET_CON(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][4]; GET_CHA(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][5]; GET_HIT(OLC_MOB(d)) = mob_hp[i][0]; GET_MANA(OLC_MOB(d)) = mob_hp[i][2]; GET_MOVE(OLC_MOB(d)) = mob_hp[i][3]; break; case MEDIT_WEIGHT: GET_MOB_WEIGHT(OLC_MOB(d)) = LIMIT(i, 1, 1000); break; case MEDIT_MSIZE: GET_MOB_SIZE(OLC_MOB(d)) = atoi(arg); break; /*-------------------------------------------------------------------*/ default: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; }