/* * This will allow for your players to back themselves up, with or without equipment. * There are some checks and immortals don't have to pay the cost for either. * * --Vorlin, 6/30/03 */ 1) Make a directory called backup. (If in the area or src directory, do mkdir ../backup) 2) merc.h A: Find ------- #define BAN_FILE "ban.txt" Insert below ------------ #define BACKUP_DIR "../backup/" /* Backup directory for do_backup */ B: Find ------- void save_char_obj args((CHAR_DATA *ch)); Replace with ------------ void save_char_obj args((CHAR_DATA * ch, bool backup, bool save_other)); 3) act_info.c Add the following at the end. This is the core do_backup function. void do_backup(CHAR_DATA * ch, char *argument) { char buf[MSL], arg[MIL]; int cost = 0, base_cost = 500, full_cost = 1000; bool save_eq = FALSE; if (IS_NPC(ch) || IS_SWITCHED(ch) || IS_AFFECTED(ch, AFF_CHARM)) { send_to_char ("NPCs, switched immortals, or being charmed prevent backups from occuring.\n\r", ch); return; } one_argument(argument, arg); /* * noeq = 500 cost and save_eq = FALSE * all = 1000 cost and save_eq = TRUE * other = print usage and bail */ if (!str_cmp(arg, "noeq")) { cost = base_cost; save_eq = FALSE; } else if (!str_cmp(arg, "all")) { cost = full_cost; save_eq = TRUE; } else { send_to_char("Usage: backup all/noeq\n\r", ch); send_to_char ("Understand that if a backup exists, it will be overwritten.\n\r", ch); return; } if (ch->gold - cost < 0 && !IS_IMMORTAL(ch)) { sprintf(buf, "You need %ld more gold to backup your pfile.\n\r", cost - ch->gold); send_to_char(buf, ch); return; } /* * At this point, gold is taken out, flags are set, and the backup occurs. * No cost for immortals. */ if (!IS_IMMORTAL(ch)) { ch->gold -= cost; sprintf(buf, "Checks successful, removing `#%d`` gold for cost.\n\r", cost); send_to_char(buf, ch); WAIT_STATE(ch, PULSE_PER_SECOND * 5); } /* * Save the char through save_char_obj with the flags set */ save_char_obj(ch, TRUE, save_eq); sprintf(buf, "Character saved as %s `!%s`` equipment/etc.\n\r", ch->name, save_eq == TRUE ? "with" : "without"); send_to_char(buf, ch); log_string(buf); return; } 4) save.c A: Find ------- void save_char_obj(CHAR_DATA * ch) Replace with ------------ void save_char_obj(CHAR_DATA * ch, bool backup, bool save_other) B: Inside save_char_obj, find ----------------------------- sprintf(strsave, "%s%s",PLAYER_DIR, capitalize(ch->name)); Replace with ------------ /* Backup status? */ sprintf(strsave, "%s%s", backup == FALSE ? PLAYER_DIR : BACKUP_DIR, capitalize(ch->name)); C: Inside save_char_obj, further down, find ------------------------------------------- if (ch->carrying != NULL) Replace with ------------ if (ch->carrying != NULL && save_other == TRUE) D: Inside save_char_obj, further down, find ------------------------------------------- /* save the pets */ if (ch->pet != NULL && ch->pet->in_room == ch->in_room) Replace with: ------------- /* save the pets */ if (ch->pet != NULL && ch->pet->in_room == ch->in_room && save_other == TRUE) 5) interp.c Find ---- {"areas", do_areas, POS_DEAD, 0, LOG_NORMAL, 1}, Insert below ------------ {"backup", do_backup, POS_DEAD, 0, LOG_ALWAYS, 1}, 6) interp.h At the end of interp.h, add --------------------------- DECLARE_DO_FUN(do_backup); // Backups 7) The most tedious part of this entire snippet is now here, where you must find every occurence of save_char_obj (act_comm.c, act_info.c, act_wiz.c, comm.c, fight.c, save.c, update.c mainly) and change them from the old version to the following: save_char_obj(ch, FALSE, FALSE); The reason for all these being FALSE, FALSE, is because if the boolean backup is TRUE, only then do you care whether or not the boolean save_other is TRUE or FALSE. Only in do_backup should you have the boolean backup set to TRUE. You can hack apart do_slay, do_deny, and other punishable wiz commands so that mortals automatically have a backup made w/o eq or whatnot, but I'll leave that discretion to whoever might put this in their mud. If you do want to have automatic backups of a char after any command, just put the following: save_char_obj(<victim>, TRUE, <TRUE for w/ eq, FALSE for w/o eq>); At this point, you now have a do_backup function available for everyone to use, given the gold cost of 500 w/o equipment, 1000 with equipment, has variable checks in it so charmed people can't backup, npcs can't do it, etc etc... I'm going to be doing a restore function soon that'll check said backup directory and pull a char, if available, back to the player dir. Let me know if anything might be missed or can be fixed. I think I got most of it but I could be wrong. --Vorlin vorlin@tampabay.rr.com 6/30/03