/***************************************************** This patch is designed for use with my version of ASCII playerfiles (should work fine with any of my versions). If you are using someone else's version of ASCII pfiles, it'll probably work if you change the pfile directory to what you have. As a matter of fact, it'll probably still work with the stock pfiles. If someone tries to patch it into a MUD with stock pfiles, gimme a mail and tell me if it worked. You MUST have an olc struct defined for this patch to work!! Patch version 1 ******************************************************/ Open interpreter.c and look for these lines: switch (STATE(d)) { /*. OLC states .*/ case CON_OEDIT: oedit_parse(d, arg); break; case CON_REDIT: redit_parse(d, arg); break; case CON_ZEDIT: zedit_parse(d, arg); break; case CON_MEDIT: medit_parse(d, arg); break; case CON_SEDIT: sedit_parse(d, arg); break; After these add: case CON_PEDIT: pedit_parse(d, arg); break; Also add the external define for pedit_parse at the top. Look for void sedit_parse(struct descriptor_data *d, char *arg); and after it add void pedit_parse(struct descriptor_data *d, char *arg); Don't forget to add ACMD(do_pedit); and { "pedit" , POS_DEAD , do_pedit , LVL_IMPL, 0 }, Toss these into olc.h: /*. Submodes of PEDIT connectedness .*/ #define PEDIT_MENU 1 #define PEDIT_DESC_MENU 2 #define PEDIT_DESC 3 #define PEDIT_TITLE 4 #define PEDIT_PASSWD 5 #define PEDIT_NUMERICAL_RESPONSE 6 #define PEDIT_HMV 7 #define PEDIT_HMVMAX 8 #define PEDIT_EXP 9 #define PEDIT_GOLD 10 #define PEDIT_HITDAM 11 #define PEDIT_ATTRIB1 12 #define PEDIT_ATTRIB2 13 #define PEDIT_HWS 14 #define PEDIT_CLA 15 #define PEDIT_CONFIRM_SAVE 16 and in structs.h, look for the last olc mode, probably: #define CON_SEDIT 21 /*. OLC mode - shop edit .*/ After it add: #define CON_PEDIT 22 ^make sure that number is one more than the one above it Now open modify.c and look for these lines: extern void oedit_disp_menu(struct descriptor_data *d); extern void oedit_disp_extradesc_menu(struct descriptor_data *d); extern void redit_disp_menu(struct descriptor_data *d); extern void redit_disp_extradesc_menu(struct descriptor_data *d); extern void redit_disp_exit_menu(struct descriptor_data *d); extern void medit_disp_menu(struct descriptor_data *d); After them, add: extern void pedit_disp_menu(struct descriptor_data *tar); and after these: ((STATE(d) == CON_REDIT) || (STATE(d) == CON_MEDIT) || (STATE(d) == CON_OEDIT) || add: (STATE(d) == CON_PEDIT) || and after this: if (STATE(d) == CON_MEDIT) { medit_disp_menu(d); } add: if (STATE(d) == CON_PEDIT) pedit_disp_menu(d); Then open up makefile and add pedit.obj (or in the case of unix, pedit.o) to the list of object files. Further down add: pedit.obj: pedit.c conf.h sysdep.h structs.h utils.h db.h comm.h interpreter.h \ handler.h spells.h $(CC) -c $(CFLAGS) pedit.c finally, create a new file named pedit.c and paste this into it: /* ************************************************************************ * File: Pedit.c Part of CircleMUD * * Usage: Editing a online/offline player's struct * * Edit interpreter.c to include a 'case CON_PEDIT' and define the * * PEDIT submodes of connectiveness * * Coded by: CoReXS * ************************************************************************ */ #include "conf.h" #include "sysdep.h" #include #include "structs.h" #include "utils.h" #include "comm.h" #include "interpreter.h" #include "handler.h" #include "db.h" #include "spells.h" #include "screen.h" #include "house.h" #include "olc.h" extern const char *genders[]; extern const char *class_abbrevs[]; extern struct char_data *character_list; extern struct descriptor_data *descriptor_list; extern struct obj_data *object_list; void disp_desc(struct descriptor_data *tar) { sprintf(buf, "%s\r\n", tar->olc->mob->player.description); send_to_char(buf, tar->character); send_to_char("1) edit, 2)return to menu: ", tar->character); OLC_MODE(tar) = PEDIT_DESC_MENU; } void pedit_disp_menu(struct descriptor_data *tar) { sprintf(buf, "\r\n\r\n\r\n\r\n" "-- Name: %s Id Number: [%d]\r\n" "1) Description\r\n" "2) Title: %s\r\n" "3) Password: %s\r\n" "4) H, M, V current: %dH, %dM, %dV\r\n" "5) H, M, V max: %dH, %dM, %dV\r\n" "6) EXP: %d\r\n", GET_NAME(tar->olc->mob), mob->mob_specials.attack_type, GET_TITLE(tar->olc->mob), GET_PASSWD(tar->olc->mob), GET_HIT(tar->olc->mob), GET_MANA(tar->olc->mob), GET_MOVE(tar->olc->mob), GET_MAX_HIT(tar->olc->mob), GET_MAX_MANA(tar->olc->mob), GET_MAX_MOVE(tar->olc->mob), GET_EXP(tar->olc->mob)); send_to_char(buf, tar->character); sprintf(buf, "7) Gold: on hand: %d, bank: %d\r\n" "8) Hitroll: %d, Damroll: %d, AC: %d\r\n" "9) Str: %d, Dex: %d, Con: %d\r\n" "A) Int: %d, Wis: %d, Cha: %d\r\n" "B) Height: %d, Weight: %d, Sex: %s\r\n" "C) Class: %s, Level: %d, Align: %d\r\n" "Q) Quit\r\n" "Enter a choice: ", GET_GOLD(tar->olc->mob), GET_BANK_GOLD(tar->olc->mob), GET_HITROLL(tar->olc->mob), GET_DAMROLL(tar->olc->mob), GET_AC(tar->olc->mob), GET_STR(tar->olc->mob), GET_DEX(tar->olc->mob), GET_CON(tar->olc->mob), GET_INT(tar->olc->mob), GET_WIS(tar->olc->mob), GET_CHA(tar->olc->mob), GET_HEIGHT(tar->olc->mob), GET_WEIGHT(tar->olc->mob), genders[GET_SEX(tar->olc->mob)], class_abbrevs[GET_CLASS(tar->olc->mob)], GET_LEVEL(tar->olc->mob), GET_ALIGNMENT(tar->olc->mob)); send_to_char(buf, tar->character); OLC_MODE(tar) = PEDIT_MENU; } ACMD(do_pedit) { FILE *pfile; struct descriptor_data *tar; struct char_data *mob; one_argument(argument, arg); if (!*arg) { send_to_char("Who's playerfile do you wish to read?\r\n", ch); return; } if (ch->desc->original) { send_to_char("You're not allowed to while switched.\r\n", ch); return; } sprintf(buf, "pfiles/%s.pfile", arg); if (!(pfile = fopen(buf, "r"))) { sprintf(buf, "Playerfile for %s not found.\r\n", arg); send_to_char(buf, ch); return; } fclose(pfile); sprintf(buf, "$n begins to edit %s's playerfile.\r\n", arg); act(buf, TRUE, ch, 0, 0, TO_ROOM); sprintf(buf, "%s", GET_NAME(ch)); char_to_store(ch); SET_BIT(PLR_FLAGS(ch), PLR_WRITING); tar = ch->desc; CREATE(tar->olc, struct olc_data, 1); CREATE(mob, struct char_data, 1); init_mobile(mob); GET_MOB_RNUM(mob) = -1; (mob)->player.name = str_dup("mob unfinished"); (mob)->player.short_descr = str_dup("the unfinished mob"); (mob)->player.long_descr = str_dup("An unfinished mob stands here.\r\n"); (mob)->player.description = str_dup("It looks, err, unfinished.\r\n"); OLC_MOB(tar) = mob; store_to_char(arg, OLC_MOB(tar)); mob->mob_specials.attack_type = GET_IDNUM(mob); GET_IDNUM(mob) = -1; STATE(tar) = CON_PEDIT; pedit_disp_menu(tar); } void stop_pedit(struct descriptor_data *tar) { struct char_data *k, *next_char; sprintf(buf, "%s", GET_NAME(tar->olc->mob)); for (k = character_list; k; k = next_char) { next_char = k->next; if (strcmp(GET_NAME(k),buf)==0) { sprintf(buf2, "Pedit: Player %s was found active and was reloaded.", buf); mudlog(buf2, CMP, LVL_GRGOD, TRUE); store_to_char(buf, k); } } REMOVE_BIT(PLR_FLAGS(tar->character), PLR_WRITING); STATE(tar)=CON_PLAYING; act("$n stops using Pedit.", TRUE, tar->character, 0, 0, TO_ROOM); medit_free_mobile(OLC_MOB(tar)); free(tar->olc); } void pedit_parse(struct descriptor_data *tar, char *arg) { int num; int t[5]; if (OLC_MODE(tar) > PEDIT_NUMERICAL_RESPONSE) { if(!*arg || (!isdigit(arg[0]) && ((*arg == '-') && (!isdigit(arg[1]))))) { send_to_char("Field must be numerical, try again : ", tar->character); return; } } switch (OLC_MODE(tar)) { /*-------------------------------------------------------------------*/ case PEDIT_MENU: switch (*arg) { case 'q': case 'Q': send_to_char("Do you wish to save the changes to the playerfile? (y/n) : ", tar->character); OLC_MODE(tar) = PEDIT_CONFIRM_SAVE; return; case '1': send_to_char("Existing Description:\r\n", tar->character); disp_desc(tar); return; case '2': send_to_char("New title: ", tar->character); OLC_MODE(tar) = PEDIT_TITLE; return; case '3': send_to_char("New password: ", tar->character); OLC_MODE(tar) = PEDIT_PASSWD; return; case '4': send_to_char("Enter stats in format: %d %d %d\r\n" "where the numbers are: hit mana move\r\n", tar->character); OLC_MODE(tar) = PEDIT_HMV; return; case '5': send_to_char("Enter stats in format: %d %d %d\r\n" "where the numbers are: maxhit maxmana maxmove\r\n", tar->character); OLC_MODE(tar) = PEDIT_HMVMAX; return; case '6': send_to_char("New exp: ", tar->character); OLC_MODE(tar) = PEDIT_EXP; return; case '7': send_to_char("Enter gold in format: %d %d\r\n" " : goldonhand goldinbank\r\n", tar->character); OLC_MODE(tar) = PEDIT_GOLD; return; case '8': send_to_char("Enter in format: %d %d %d\r\n" " : hitroll damroll, ac\r\n", tar->character); OLC_MODE(tar) = PEDIT_HITDAM; return; case '9': send_to_char("Enter in format: %d %d %d\r\n" " : str dex con\r\n", tar->character); STATE(tar) = CON_PEDIT; OLC_MODE(tar) = PEDIT_ATTRIB1; return; case 'a': case 'A': send_to_char("Enter in format: %d %d %d\r\n" " : int wis cha\r\n", tar->character); STATE(tar) = CON_PEDIT; OLC_MODE(tar) = PEDIT_ATTRIB2; return; case 'b': case 'B': send_to_char("Enter in format: %d %d %d\r\n" " : height weight sex\r\n" "For sex, 0=neutral, 1=male, 2=female\r\n", tar->character); OLC_MODE(tar) = PEDIT_HWS; return; case 'c': case 'C': send_to_char("Enter in format: %d %d %d\r\n" " : class level align\r\n", tar->character); OLC_MODE(tar) = PEDIT_CLA; return; default: pedit_disp_menu(tar); return; } break; /*-------------------------------------------------------------------*/ case PEDIT_DESC_MENU: if (((num = atoi(arg)) != 1) && ((num = atoi(arg)) != 2)) { send_to_char("That'll either have to be 1 or 2.\r\n", tar->character); return; } if (num == 1) { OLC_MODE(tar) = PEDIT_DESC; SEND_TO_Q("Enter player's description: (/s saves /h for help)\r\n\r\n", tar); tar->backstr = NULL; if (tar->olc->mob->player.description) { SEND_TO_Q(tar->olc->mob->player.description, tar); tar->backstr = str_dup(tar->olc->mob->player.description); } tar->str = &tar->olc->mob->player.description; tar->max_str = MAX_MOB_DESC; tar->mail_to = 0; return; } else if (num == 2) OLC_MODE(tar) = PEDIT_MENU; break; /*-------------------------------------------------------------------*/ case PEDIT_DESC: pedit_disp_menu(tar); break; /*-------------------------------------------------------------------*/ case PEDIT_TITLE: if(tar->olc->mob->player.title) free(tar->olc->mob->player.title); strcpy(buf, arg); tar->olc->mob->player.title = str_dup(buf); break; /*-------------------------------------------------------------------*/ case PEDIT_PASSWD: if (strlen(arg) < 3) send_to_char("The given password was too short.\r\n", tar->character); else if (strlen(arg) > MAX_PWD_LENGTH) send_to_char("The given password was too long.\r\n", tar->character); else { strncpy(GET_PASSWD(tar->olc->mob), CRYPT(arg, GET_NAME(tar->olc->mob)), MAX_PWD_LENGTH); *(GET_PASSWD(tar->olc->mob) + MAX_PWD_LENGTH) = '\0'; } break; /*-------------------------------------------------------------------*/ case PEDIT_HMV: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } GET_HIT(tar->olc->mob) = t[0]; GET_MANA(tar->olc->mob) = t[1]; GET_MOVE(tar->olc->mob) = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_HMVMAX: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } GET_MAX_HIT(tar->olc->mob) = t[0]; GET_MAX_MANA(tar->olc->mob) = t[1]; GET_MAX_MOVE(tar->olc->mob) = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_EXP: GET_EXP(tar->olc->mob) = MAX(0, atol(arg)); break; /*-------------------------------------------------------------------*/ case PEDIT_GOLD: if (sscanf(arg,"%d %d\n",t,t+1)!=2) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } GET_GOLD(tar->olc->mob) = t[0]; GET_BANK_GOLD(tar->olc->mob) = t[1]; break; /*-------------------------------------------------------------------*/ case PEDIT_HITDAM: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } GET_HITROLL(tar->olc->mob) = t[0]; GET_DAMROLL(tar->olc->mob) = t[1]; GET_AC(tar->olc->mob) = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_ATTRIB1: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } tar->olc->mob->aff_abils.str = tar->olc->mob->real_abils.str = t[0]; tar->olc->mob->aff_abils.dex = tar->olc->mob->real_abils.dex = t[1]; tar->olc->mob->aff_abils.con = tar->olc->mob->real_abils.con = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_ATTRIB2: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } tar->olc->mob->aff_abils.intel = tar->olc->mob->real_abils.intel = t[0]; tar->olc->mob->aff_abils.wis = tar->olc->mob->real_abils.wis = t[1]; tar->olc->mob->aff_abils.cha = tar->olc->mob->real_abils.cha = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_HWS: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } GET_HEIGHT(tar->olc->mob) = t[0]; GET_WEIGHT(tar->olc->mob) = t[1]; GET_SEX(tar->olc->mob) = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_CLA: if (sscanf(arg,"%d %d %d\n",t,t+1,t+2)!=3) { send_to_char("You were asked nicely to follow the format... now do it!\r\n", tar->character); return; } GET_CLASS(tar->olc->mob) = t[0]; GET_LEVEL(tar->olc->mob) = t[1]; GET_ALIGNMENT(tar->olc->mob) = t[2]; break; /*-------------------------------------------------------------------*/ case PEDIT_CONFIRM_SAVE: switch (*arg) { case 'y': case 'Y': send_to_char("Saving playerfile.\r\n", tar->character); char_to_store(tar->olc->mob); stop_pedit(tar); return; case 'n': case 'N': stop_pedit(tar); return; default: send_to_char("Invalid choice!\r\n", tar->character); send_to_char("Do you wish to save the playerfile? : ", tar->character); return; } break; default: /*. We should never get here .*/ stop_pedit(tar); mudlog("SYSERR: OLC: pedit_parse(): Reached default case!",BRF,LVL_BUILDER,TRUE); break; } pedit_disp_menu(tar); } Recompile... hope it works... have fun with it CoReXS CoReXS@hotmail.com