/*************************************************************************** * Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, * * Michael Seifert, Hans Henrik St{rfeldt, Tom Madsen, and Katja Nyboe. * * * * Merc Diku Mud improvments copyright (C) 1992, 1993 by Michael * * Chastain, Michael Quan, and Mitchell Tse. * * * * In order to use any part of this Merc Diku Mud, you must comply with * * both the original Diku license in 'license.doc' as well the Merc * * license in 'license.txt'. In particular, you may not remove either of * * these copyright notices. * * * * Dystopia Mud improvements copyright (C) 2000, 2001 by Brian Graversen * * * * Much time and thought has gone into this software and you are * * benefitting. We hope that you share your changes too. What goes * * around, comes around. * ***************************************************************************/ /*************************************************************************** * _/ _/ * * _/_/_/ _/_/ _/_/_/ _/ _/_/ _/ _/ _/_/_/ * * _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ * * _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ * * _/ _/ _/ _/_/_/ _/ _/_/ _/_/_/ _/_/_/ * *************************************************************************** * Mindcloud Copyright 2001-2003 by Jeff Boschee (Zarius), * * Additional credits are in the help file CODECREDITS * * All Rights Reserved. * ***************************************************************************/ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <time.h> #include <ctype.h> #include "merc.h" bool is_valid_room args( ( int vnum ) ); char * CHAR2 ( long iNum ) { static char csdf [ 256 ]; sprintf( csdf, "%ld", iNum ); return csdf; } void do_loop( CHAR_DATA *ch, char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; int startvnum, endvnum, i; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); if ( arg1[0] == '\0' ) { send_to_char( "#CSyntax: loop <command> <start##> <end##> <params>\n\r", ch ); send_to_char( " Where <command> is a valid command to execute,\n\r", ch ); send_to_char( " <start##> and <end##> are numbers/vnums,\n\r", ch ); send_to_char( " and <params> is a parameter list for <command>.\n\r", ch ); send_to_char( "#GEXAMPLE: LOOP MSHOW 22000 22100#n\n\r", ch ); return; } if ( arg2[0] == '\0' ) { send_to_char( "You must specify a start number/vnum.\n\r", ch ); return; } if ( arg3[0] == '\0' ) { send_to_char( "You must specify an end number/vnum.\n\r", ch ); return; } startvnum = (is_number(arg2) ? atoi(arg2) : 1); endvnum = (is_number(arg3) ? atoi(arg3) : 1); if ( endvnum < 0 ) endvnum = 1; if ( startvnum < 0 ) startvnum = 1; if ( startvnum > endvnum ) { i = endvnum; endvnum = startvnum; startvnum = i; } sprintf( buf, "Beginning loop for %s command, vnums %d to %d (%s).\n\r", arg1, startvnum, endvnum, argument ); send_to_char( buf, ch ); for ( i = startvnum ; i <= endvnum ; i++ ) { sprintf( buf, "%s %d %s", arg1, i, (!str_cmp(arg1,"mstat") || !str_cmp(arg1,"ostat")) ? "\b" : argument ); interpret( ch, buf ); } send_to_char( "Done.\n\r", ch ); return; } char *centerjob (char *fill, const char *txt, int maxlen ) { int Tot; int tofill; int iA; const char *txt2 = txt; static char buf[MSL]; char Lik[MSL]; strcpy(buf,""); tofill = maxlen; tofill -= strlen(txt); tofill += (strlen(txt) - strlen(bash_color(txt))); tofill /= 2; for (Tot = 0, iA = 0; iA < tofill && Tot < maxlen; iA++, Tot++) // xcatf(buf, fill); for ( ; *txt; txt++ ) { sprintf(Lik, "%s%c", buf, *txt); strcpy(buf, Lik); } Tot += strlen(bash_color(txt2)); for (iA = Tot; iA < maxlen; iA++) // xcatf(buf, fill); return buf; } char * bash_color( const char *txt ) { const char *point; char *point2; static char buf[MSL*4]; buf[0] = '\0'; point2 = buf; for (point = txt; *point; point++) { if (*point == '#' && *(point+1) != '\0') { point++; continue; } *point2 = *point; *++point2 = '\0'; } *point2 = '\0'; return buf; } void randomize_object(int vnum) { OBJ_DATA *obj; ROOM_INDEX_DATA *rm = NULL; EXIT_DATA *pexit = NULL; int count = 0; int a, to_room; bool PLACE = 0; while (!rm) { to_room = number_range(500, 90000); if (is_valid_room(to_room)) rm = get_room_index(number_range(500, 90000)); } for (a = 0; a < 6; a++) { if ((pexit = rm->exit[a]) != NULL && pexit->to_room != NULL) count++; } if (rm && count > 0) PLACE = TRUE; if (PLACE){ obj = create_object(get_obj_index(vnum), 0); if (!obj) return; obj_to_room(obj, rm); } else randomize_object(vnum); return; } bool is_valid_room(int vnum) { // Arena if (vnum >= 151 && vnum <= 170) return FALSE; /* * Kingdoms */ // Kingdom 1 if (vnum >= 40300 && vnum <= 40399) return FALSE; // Kingdom 2 if (vnum >= 40400 && vnum <= 40499) return FALSE; // Kingdom 3 if (vnum >= 40500 && vnum <= 40599) return FALSE; // Kingdom 4 if (vnum >= 40600 && vnum <= 40699) return FALSE; // Kingdom 5 if (vnum >= 40700 && vnum <= 40799) return FALSE; // Class HQs if (vnum >= 93300 && vnum <= 93600) return FALSE; return TRUE; } void do_randomload(CHAR_DATA *ch, char *argument) { if (!get_obj_index(atoi(argument))) { stc("That object doesn't exist!\n\r", ch); return; } stc(get_obj_index((atoi(argument)))->short_descr, ch); if(ch->level > 6) { stc(" randomly loaded to a room on the mud.\n\r", ch); } randomize_object(atoi(argument)); return; } void update_exp() { if (pulse_exp > 0) { if (--pulse_exp == 0) { global_exp = FALSE; pulse_exp = -1; do_info(NULL,"#RDouble Exp #0is now #YOFF#n"); } } } void update_dt() { if (pulse_dt > 0) { if (--pulse_dt == 0) { global_dt = FALSE; pulse_dt = -1; do_info(NULL,"#WSuper Training #0now #ROFF#n"); } } } void update_cp() { if (pulse_cp > 0) { if (--pulse_cp == 0) { global_cp = FALSE; pulse_cp = -1; do_info(NULL,"#wDouble Class Points now #ROFF#n"); } } } void update_qp() { if (pulse_qp > 0) { if (--pulse_qp == 0) { global_qp = FALSE; pulse_qp = -1; do_info(NULL,"#wDouble Quest Points now #ROFF#n"); } } }