/* ----------------------------------------------------------------------- The following snippet was written by Gary McNickle (dharvest) for Rom 2.4 specific MUDs and is released into the public domain. My thanks to the originators of Diku, and Rom, as well as to all those others who have released code for this mud base. Goes to show that the freeware idea can actually work. ;) In any case, all I ask is that you credit this code properly, and perhaps drop me a line letting me know it's being used. from: gary@dharvest.com website: http://www.dharvest.com or http://www.dharvest.com/resource.html (rom related) Send any comments, flames, bug-reports, suggestions, requests, etc... to the above email address. ----------------------------------------------------------------------- */ /****************************** DO_PETNAME ****************************** Petname allows your players to rename their pets, change the pets long and short descriptions as well as thier "look" description. This data is saved to the players pfile so it's restored when the quit and log back on later. Also, changing the pet information for one character does not affect other pets of the same type owned by other players. known bugs: none todo list: hrm... installation instructions: Note, on my mud, I have a define called "ANSI_KEY" it looks like this; #define ANSI_KEY '`' and is used as a constant anywhere I may need it. This code uses it, but you dont necessarily have to define it on your mud, if you would rather, just replace any mention of ANSI_KEY with whatever character your mud uses for color. (ie: '{' or '#' to quote some popular ones) 1: add "do_petname" to interp. files 2: cut the "do_petname" function out of the bottom of this file and add to (or create if need be) "dharvest.c". Be sure "dharvest.o" is added to your makefile. 3: add included help information (at bottom, after "do_petname" function) to an appropriate help file. (be sure it's included in area.lst) 4: in "merc.h" under function prototypes, add; /* dharvest.c */ void do_petname args ( (CHAR_DATA *ch, char *argument) ); also, if you do not use OLC, or do not otherwise have the file "string.c" that contains the OLC string editor, add the following define to merc.h #define OldDesc 1 5: add petname.hlp file to your help.hlp 6: be sure to let your mudlets know about the new command. 7: compile and test. ;) /******************************* DO_PETNAME ****************************/ /* dharvest.c These functions written and copywrite (c) 1997, by Gary McNickle for use with ROM MUD v2.4+ All rights reserved by author. You are granted limited liscense to use this code, as long as this credit message is not changed. Feel free to modify to suit your specific mud (colors, options, etc) but please give credit where it's due. [gary@dharvest.com / http://www.dharvest.com] */ #if defined(macintosh) #include <types.h> #include <time.h> #else #include <sys/types.h> #include <sys/time.h> #endif #include <stdio.h> #include <string.h> #include <stdlib.h> #include "merc.h" /** Function: do_petname * Descr : renames pets, also allows changing of short/long and * descritpion variables. * Returns : (void) * Syntax : petname ([name|short|long|desc]) (argument) * Written : v1.1 1/98 * Author : Gary McNickle <gary@dharvest.com> */ void do_petname(CHAR_DATA *ch, char *argument) { char buf[MAX_STRING_LENGTH]; char command[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH]; /* smash all tilde's right away. */ smash_tilde(argument); if ( ch->pet == NULL ) { send_to_char("You dont have a pet!\n\r", ch); return; } if ( ch->in_room != ch->pet->in_room ) { send_to_char("Kinda hard for your pet to learn his new name\n\r",ch); send_to_char("if he's not even with you! *boggle*\n\r", ch); return; } argument = one_argument(argument, command); if ( command[0] == '\0' || argument[0] == '\0' ) { send_to_char( "\n\rsyntax: petname [name|short|long|desc] <argument>\n\r",ch); send_to_char( "\n\r example: \"petname name fido\n\r", ch); send_to_char( " \"petname short is hungry!\"\n\r",ch); send_to_char("\n\rTry using color in the descriptions!\n\r\n\r", ch); send_to_char( "See \"help petname\" and \"help color\" for more information.\n\r",ch); return; } /* syntax */ if ( !str_prefix(command, "name") ) { if ( argument[0] == ANSI_KEY ) /* ack! */ { argument++; argument++; /* on WoT, our color codes are all one character long, so we only have to delete two characters here, the symbol that tells us "convert this to color" and the color code itself. you may have to modify this to suit your mud */ } argument = one_argument(argument, arg2); free_string(ch->pet->name); ch->pet->name = capitalize( str_dup(arg2) ); sprintf(buf, "Your pet has been renamed to: %s\n\r", ch->pet->name); send_to_char(buf, ch); } /* name */ else if ( !str_prefix(command, "short") ) { if ( argument[0] == '\0' ) return; free_string(ch->pet->short_descr); /* short description should not have an "\n\r" appended to it. */ ch->pet->short_descr = str_dup(argument); sprintf(buf, "%s's short description set to: \n\r%s\n\r", ch->pet->name, ch->pet->short_descr); send_to_char(buf, ch); } /* short */ else if ( !str_prefix(command, "long") ) { if ( argument[0] == '\0' ) return; free_string(ch->pet->long_descr); /* long descr needs "\n\r" appended to it. */ sprintf(buf, "%s\n\r", argument); ch->pet->long_descr = str_dup(buf); sprintf(buf, "%s's long description set to: \n\r%s\n\r", ch->pet->name, ch->pet->long_descr); send_to_char(buf, ch); } /* long */ else if ( !str_prefix(command, "description") ) { #if defined (OldDesc) do_description(ch, argument); #else if ( argument[0] == '\0' ) { string_append( ch, &ch->pet->description ); return; } #endif } /* desc */ else do_help(ch, "petname"); return; } /* end of do_petname */