>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >> Notes on the Snippet and Installation Instructions: >> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> After being asked by the immortals and players at eloria to include a travel mage in the new codebase I was helping to develop, I started trying to port the old code to the new codebase, although it worked it wasn't a very "neat" or efficient peice of code, thusly i set about trying to develop a new and better alternative. Here is the result. It is much easier to add new locations to this travel mage than the old one and it occupies a great deal less lines in the source files! If you are going to use this code, please email me and let me know this is just out of interest on my part... and if you want, you can give Eloria.net or even me a mention in your "help travel" files. Or both would be even better :-) Please follow the instructions below as carefully as possible, if you encounter problems then please contact me on nonchaotic@hotmail.com if you are running a ROM or GhostMud then you will need to change the chprintlnf function calls for send_to_char function calls and also reverse the arguments. sprintf (buf, "Play that funky music %s!", ch->name); chprintlnf (ch, buf); would become... sprintf (buf, "Play that funky music %s!\n\r", ch->name); send_to_char (buf, ch); NOTICE: the addition of /n/r on the ROM/GhostMUD version of this command chain. To use this code, make a mobile and give it the ACT_TRAVELMAGE flag and then load it wherever you want it to be. You may wish to add code to stop players killing/sapping/stealing/etc from your travel mage. Thanks for choosing Nivaen Geneis for all your snippeting needs!! Feel free to stop by sometime we can be found at eloria.net port 9000, or surf on in to our website at http://www.eloria.net :-) Regards, Steven Tovey AKA Surlaen of Nivaen Geneis (eloria.net port 9000) P.S. Please send me any improvements to the code you may make. Or any bugs you may find, so I can get around to fixing them! :-) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> A) merc.h 1. Add this to the bottom of the type declarations list. typedef struct travel_data TRAVEL_DATA; 2. Add this somewhere in the file, preferably near the other structure declarations. /* Travel Mage v0.2 by Steven Tovey */ struct travel_data { char keyword; char long_desc; long vnum; long cost; }; 3. Add this to the MAX_ declarations in merc.h #define MAX_TRAVEL_LOCATION 4 4. Add this to the ACT_ declarations in merc.h #define ACT_TRAVELMAGE (##) /* Whatever is free */ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> B) dofun.h 1. Add this to the bottom of the file, or wherever you want in that file, maybe in alhpabetical order. /* Travel Mage v0.2 by Steven Tovey */ COMMAND_FUN (do_travel) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> C) tables.c 1. Add this to the bottom of the file, and fill it with the keyword, locations, vnums and cost you would like your travel mage to use. Please remeber to change the MAX_TRAVEL_LOCATION define in merc.h if you add another location. Else you wont be able to travel there, due to the loop wont find the last few locations! /* Travel Mage v0.2 by Steven Tovey */ const struct travel_data travel_table[] = { { "mota", "Mota Ruins", 3001, 1000 }, { "void", "The Void", 1, 2000 }, { "awesome", "The Awesome Ranch", 79, 10000 }, { NULL, NULL, 0, 0 } }; 2. Add this to the character act table, at the bottom (BUT DONOT PUT IT UNDER THE BLANK/NULL ENTRIES AT THE BOTTOM!!) { "travelmage", ACT_TRAVELMAGE, TRUE }, >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> D) tables.h 1. Add a declaration for the type so that other files can see the table of locations! Just add the following to the bottom of the list in that file. extern const struct travel_data travel_table[]; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> E) act_move.c 1. Add the include for tables.h if you dont already have it. #include "tables.h" 2. Add the following command to the act_move.c module of your mud, after all thats what your doing... moving players ^_^ You may need to replace the do_sayto function calls if you don't have that function in your mud. Else email me if you want me to send it to you. /* Travel Mage v0.2 by Steven Tovey */ CH_CMD (do_travel) { CHAR_DATA *travel_mage; CHAR_DATA *pet; char buf[MAX_STRING_LENGTH]; char arg1[MAX_STRING_LENGTH]; char arg2[MAX_STRING_LENGTH]; argument = one_argument(argument, arg1); argument = one_argument(argument, arg2); travel_mage = NULL; for (travel_mage = ch->in_room->people; travel_mage; travel_mage = travel_mage->next_in_room) { if (IS_NPC(travel_mage) && IS_SET(travel_mage->pIndexData->act, ACT_TRAVELMAGE)) break; } if (!travel_mage) { chprintlnf (ch, "There is no travel mage here."); return; } if (arg1[0] == '\0') { sprintf (buf, "%s I'm sorry, did you want something?", ch->name); do_sayto (travel_mage, buf); return; } if (!strcmp(arg1, "list")) { int i; chprintlnf (ch, "I offer the following locations..."); chprintlnf (ch, " "); chprintlnf (ch, "[Location Name ] [Price ]"); chprintlnf (ch, "---------------------------------------------------"); for (i = 0; i < (MAX_TRAVEL_LOCATION-1); i++) { sprintf (buf, "[%-40s] [%-6ld]", travel_table[i].long_desc, travel_table[i].cost); chprintlnf (ch, buf); } chprintlnf (ch, " "); chprintlnf (ch, "Please type 'travel buy ' and have your gold ready!"); chprintlnf (ch, "For more information type 'help travelmage' and read!"); return; } if (!strcmp(arg1, "buy")) { if (arg2[0] == '\0') { sprintf(buf, "%s You must tell me where you wish to travel to.", ch->name); do_sayto (travel_mage, buf); return; } int j; for (j = 0; j < MAX_TRAVEL_LOCATION; j++) { if (is_name(arg2, travel_table[j].keyword)) { if (ch->gold < travel_table[j].cost) { sprintf(buf, "%s Sorry you dont have enough gold to travel to %s", ch->name, travel_table[j].long_desc); do_sayto (travel_mage, buf); return; } ch->gold -= travel_table[j].cost; act( "$n disappears in a violet fog.", ch, NULL, NULL, TO_ROOM ); sprintf(buf, "{MYou are surrounded by a violet fog.{x"); char_from_room (ch); char_to_room (ch, get_room_index(travel_table[j].vnum)); chprintlnf(ch, buf); pet = ch->pet; if (ch->pet != NULL && ch->pet->in_room == ch->in_room) { char_from_room(pet); char_to_room (pet, get_room_index(travel_table[j].vnum)); act("{M$n disappears in a violet fog.{x", ch, NULL, NULL, TO_ROOM); } do_look (ch, ""); do_say (travel_mage, "Thankyou, come again!"); return; } } sprintf(buf, "%s Sorry, that location is not on the list.", ch->name); do_sayto (travel_mage, buf); return; } >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> F) Add the following to your help.are file, or which ever file you use for help. Please leave the credits in if you modify the help entry. Thanks! Syntax: travel list travel buy Travel list will display a list of available travel locations, and there corresponding prices. The prices are not subjec to any haggling skills that may be implemented. Travel buy, followed by a keyword will buy a travel to this location it will also transport you pet to the same location. Please ensure your pet is in the same room as you and please ensure you have the correct amount of gold before attempting to travel. Travel Mage v0.2 Credits ------------------------ Author : Steven Tovey AKA Surlaen of Nivaen Genesis Copyright : Kevin Eng and The Nivaen Genesis Team 2003 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> G) Make and copyover, don't forget if your using 1st MUD you need to add the command with the online command editor, the commands to do this will be... cmdedit create travel dofun do_travel done asave commands Then your all done!! Hope your players enjoy paying not to walk the lazy beggars!!