/*************************************************************************** * This code was written by Morglum AKA Dave Spink * * E-mail Morglum@another.co.uk * * ALL following code is Copyright 2000 Morglum * ***************************************************************************/ #if defined(macintosh) #include <types.h> #else #include <sys/types.h> #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "merc.h" /* Locals */ FILE * popen args( ( const char *command, const char *type ) ); int pclose args( ( FILE *stream ) ); char * fgetf args( ( char *s, int n, register FILE *iop ) ); void syspipe args( ( CHAR_DATA *ch, char *argument ) ); #define LOG_DIR "../log/" void do_makepreg ( CHAR_DATA *ch, char *argument ) { CHAR_DATA *mother; CHAR_DATA *father; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; if (IS_NPC( ch ) ) return; argument = one_argument( argument, arg1 ); argument = one_argument(argument, arg2 ); if ( arg1[0] == '\0' || arg2[0] == '\0' ) { send_to_char( "Syntax: makepreg [mother] [father]\n\r", ch ); return; } if (( mother = get_char_world( ch, arg1 ) ) == NULL ) { send_to_char( "Mother is not here.\n\r", ch ); return; } if ( ( father = get_char_world( ch, arg2 ) ) == NULL ) { send_to_char( "Father is not here.\n\r", ch ); return; } if ( IS_NPC( mother ) || IS_NPC( father ) ) { send_to_char( "Not on NPC's.\n\r", ch ); return; } if ( IS_EXTRA( mother, EXTRA_PREGNANT ) ) { send_to_char( "They are already pregnant.\n\r", ch ); return; } make_preg( mother, father ); send_to_char( "You are now pregnant.\n\r", mother ); send_to_char( "You are going to be a father.\n\r", father ); if ( ch != mother && ch != father ) send_to_char( "Done.\n\r", ch ); return; } void do_apply ( CHAR_DATA *ch, char *argument ) { char arg1[MAX_INPUT_LENGTH]; argument = one_argument( argument, arg1 ); if (IS_NPC(ch)) send_to_char("Only Players can be Quest Trusted.\n\r",ch); if ( arg1[0] == '\0' ) { send_to_char( "Usage: APPLY QUEST\n\r", ch ); return; } if (!str_cmp( arg1, "quest" )) { if (IS_EXTRA(ch, EXTRA_TRUSTED)) { send_to_char("You are already Quest Trusted\n\r",ch); return; } send_to_char("Your application for Questing Trust has been recieved\n\r",ch); send_to_char("and is being processed.....\n\r\n\r",ch); if ( ( ch->pcdata->score[SCORE_NUM_QUEST] >= 10) && (ch->pcdata->score[SCORE_QUEST] >= 500)) { send_to_char("You have been blessed with Questing Trust.\n\r",ch); SET_BIT(ch->extra, EXTRA_TRUSTED); return; } else { send_to_char("Your Application has been Denied!\n\r",ch); send_to_char("You need to complete 10 quests,\n\r",ch); send_to_char("Must have 500 qp on hand.\n\r",ch); return; } } } void do_selfrestore( CHAR_DATA *ch, char *argument ) { if (IS_NPC(ch)) return; if (ch->in_room == NULL || ch->in_room->vnum != 3054) { send_to_char("You can only get a restore at the Temple Altar of Midgaard.\n\r",ch); return; } if ( ch->exp < 20000) { send_to_char("You need 20,000 xp to restore self.\n\r", ch); return; } ch->exp -= 20000; do_restore(ch,"self"); send_to_char("God answers you, you are restored.\n\r",ch); return; } void do_addlag(CHAR_DATA *ch, char *argument) { CHAR_DATA *victim; char arg1[MAX_STRING_LENGTH]; int x; argument = one_argument(argument, arg1); if (arg1[0] == '\0') { send_to_char("Addlag to who?", ch); return; } if ((victim = get_char_world(ch, arg1)) == NULL) { send_to_char("They're not here.", ch); return; } if ((x = atoi(argument)) <= 0) { send_to_char("That makes a LOT of sense, ya lag yourself *DUH*.", ch); return; } if (x > 100) { send_to_char("There's a limit to cruel and unusual punishment", ch); return; } send_to_char("Somebody REALLY dosen't like you", victim); WAIT_STATE(victim, x); send_to_char("That ought to show that nerdy bitch...", ch); return; } DO_COM( do_renamep ) { char arg[MIL]; char buf[MSL]; char new_name[MIL]; DESCRIPTOR_DATA *d; CHAR_DATA *victim; OBJ_DATA *obj; argument = one_argument( argument, arg ); argument = one_argument( argument, new_name ); if ( IS_NPC( ch ) ) return; if ( ( victim = get_char_world( ch, arg ) ) == NULL ) { send_to_char( "Rename who?\n\r", ch ); return; } if ( new_name[0] == '\0' ) { send_to_char( "Rename them to what?\n\r", ch ); return; } if ( IS_NPC( victim ) ) { send_to_char( "Use mset instead.\n\r", ch ); return; } if ( victim->desc == NULL || victim->desc->connected != CON_PLAYING ) { send_to_char( "They are not avaliable for a rename at the moment.\n\r", ch ); return; } if ( IS_IMMORTAL( victim ) ) { send_to_char( "You are unable to rename Gods!\n\r",ch); return; } if ( char_exists( FILE_PLAYER, new_name ) ) { send_to_char( "There is already a player saved by that name.\n\r", ch ); return; } for ( d = descriptor_list ; d != NULL ; d = d->next ) { if ( d->character != NULL && victim->desc != d ) { if ( !IS_NPC( d->character ) && strlen( d->character->name ) > 0 && !str_cmp( d->character->name, new_name ) ) { send_to_char( "There is already a player with that name.\n\r", ch ); return; } } } if ( !check_parse_name( new_name ) ) { send_to_char( "That is an illegal new name!\n\r", ch ); return; } for ( obj = object_list ; obj != NULL ; obj = obj->next ) { if ( strlen( obj->questowner ) < 3 ) continue; if ( str_cmp( victim->name, obj->questowner ) ) continue; FILL_STRING( obj->questowner, capitalize( new_name ) ); } sprintf( buf, "%s%s", PLAYER_DIR, capitalize( victim->name ) ); free_string( victim->name ); victim->name = str_dup( capitalize( new_name ) ); unlink( buf ); do_autosave( victim, "" ); sprintf( buf, "You have been renamed to %s.\n\r", capitalize( new_name ) ); send_to_char( buf, victim ); send_to_char( "Rename complete.\n\r", ch ); return; } void do_resetarea(CHAR_DATA *ch, char *argument) { send_to_char("You patiently twiddle your thumbs, waiting for the reset.\n\r",ch); send_to_char("Oh fuck this, you MAKE it reset!\n\r",ch); area_update(); } // Delete players who want to be deleted. // Also check their password for authentication - Morglum. DO_COM ( do_delete ) { char pfile[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH]; char *pArg; int i; // Grab the first word, case sensitive { pArg = arg; while (*argument == ' ') argument++; while (*argument != '\0') { if (*argument == ' ') { argument++; break; } *pArg++ = *argument++; } *pArg = '\0'; } if ( arg[0] == '\0' ) { send_to_char( "Syntax: delete [password]\n\r", ch ); send_to_char( " If you self delete, you will #rNOT#n get reimbursed.\n\r", ch); send_to_char( " Use this command very carefully.\n\r", ch); sprintf(log_buf, "%s is contemplating deletion.", ch->name); return; } if (strcmp(arg, ch->pcdata->pwd) && strcmp(crypt(arg, ch->pcdata->pwd), ch->pcdata->pwd)) { send_to_char("Wrong password.\n\r", ch); sprintf(arg, "%s tried to delete with the wrong pwd.", ch->name); log_string(arg); return; } if (ch->vampgen == 2 || IS_SET(ch->act, PLR_DEMON) || ch->level >= LEVEL_ARCHMAGE || ch->level >= LEVEL_IMMORTAL ) { send_to_char("Don't be stupid, you're a leader.\n\r", ch); return; } else { send_to_char("Character deleted.\n\r", ch); } // Get name while ch is still valid sprintf(arg, "%s has destroyed %sself.", ch->name, (ch->sex -1) ? "her" : "him"); log_string(arg); do_info(ch, arg); sprintf(pfile, "%s%s", PLAYER_DIR, capitalize(ch->name)); do_quit(ch, ""); ch = NULL; // Doesn't HAVE to be limited to 99... but more would be stupid for (i = 0; i < 99; i++) { sprintf(arg, "ls %s.d%d", pfile, i); if (system(arg) != 0) break; } // Move pfile to pfile.d* sprintf(arg, "mv %s %s.d%d", pfile, pfile, i); if (system(arg) != 0) { sprintf(pfile, "System returned non-zero from: %s", arg); log_string(pfile); } return; } DO_COM( do_pstat ) { char arg[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; argument = one_argument( argument, arg ); if ( arg[0] == '\0' ) { send_to_char("Pstat whom?\n\r", ch ); return; } if ( ( victim = get_char_world( ch, arg ) ) == NULL ) { send_to_char("They aren't here.\n\r", ch ); return; } if ( !IS_NPC( victim ) && IS_SET( victim->act, PLR_GODLESS ) && get_trust( ch ) < NO_GODLESS ) { send_to_char( "You failed.\n\r", ch ); return; } sprintf( buf, "Name : %s.\n\r", IS_NPC( victim ) ? victim->short_descr : victim->name ); send_to_char( buf, ch ); sprintf( buf, "Sex : %s. Room : %d. Align : %d. Primal : %d. Quest : %d.\n\r", victim->sex == SEX_MALE ? "Male" : victim->sex == SEX_FEMALE ? "Female" : "None", victim->in_room == NULL ? 0 : victim->in_room->vnum, victim->alignment, victim->practice, IS_NPC( victim ) ? 0 : victim->pcdata->quest ); send_to_char( buf, ch ); sprintf( buf, "Level : %d. Trust : %d. Gold : %d. Exp : %d.\n\r", victim->level, victim->trust, victim->gold, victim->exp ); send_to_char( buf, ch ); sprintf( buf, "Hit : %d. Dam : %d. AC : %d. Position : %s. Wimpy : %d.\n\r", char_hitroll( victim ), char_damroll( victim ), char_ac( victim ), capitalize( get_position_name( victim->position ) ), victim->wimpy ); send_to_char( buf, ch ); sprintf( buf, "HP %d/%d. Mana %d/%d. Move %d/%d.\n\r", victim->hit, victim->max_hit, victim->mana, victim->max_mana, victim->move, victim->max_move ); send_to_char( buf, ch ); sprintf( buf, "Fighting : %s. (%d)\n\r", victim->fighting ? victim->fighting->name : "(None)", victim->fighting ? victim->fighting->level : 0 ); send_to_char( buf, ch ); sprintf( buf, "Pkill : %d. Pdeath : %d. Mkill : %d. Mdeath : %d.\n\r", IS_NPC( victim ) ? 0 : victim->pkill, IS_NPC( victim ) ? 0 : victim->pdeath, IS_NPC( victim ) ? 0 : victim->mkill, IS_NPC( victim ) ? 0 : victim->mdeath ); send_to_char( buf, ch ); sprintf( buf, "TotExp : %12d. TotMobLev : %10d. TotQuestPoints : %10d.\n\r", IS_NPC( victim ) ? 0 : victim->pcdata->score[SCORE_TOTAL_XP], IS_NPC( victim ) ? 0 : victim->pcdata->score[SCORE_TOTAL_LEVEL], IS_NPC( victim ) ? 0 : victim->pcdata->score[SCORE_QUEST] ); send_to_char( buf, ch ); sprintf( buf, "HighExp : %12d. HighMobLev : %10d. TotQuests : %10d.\n\r", IS_NPC( victim ) ? 0 : victim->pcdata->score[SCORE_HIGH_XP], IS_NPC( victim ) ? 0 : victim->pcdata->score[SCORE_HIGH_LEVEL], IS_NPC( victim ) ? 0 : victim->pcdata->score[SCORE_NUM_QUEST] ); send_to_char( buf, ch ); if ( !IS_NPC( victim ) ) { sprintf( buf, "Paradox : %d.\n\r", victim->paradox[0]); send_to_char( buf, ch ); } if ( !IS_NPC( victim ) ) { sprintf( buf, "%-7s : %4d.", "Unarmed", victim->wpn[0] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 1 ) ), victim->wpn[1] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 2 ) ), victim->wpn[2] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 3 ) ), victim->wpn[3] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.\n\r", capitalize( get_type_weapon( 4 ) ), victim->wpn[4] ); send_to_char( buf, ch ); sprintf( buf, "%-7s : %4d.", capitalize( get_type_weapon( 5 ) ), victim->wpn[5] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 6 ) ), victim->wpn[6] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 7 ) ), victim->wpn[7] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 8 ) ), victim->wpn[8] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.\n\r", capitalize( get_type_weapon( 9 ) ), victim->wpn[9] ); send_to_char( buf, ch ); sprintf( buf, "%-7s : %4d.", capitalize( get_type_weapon( 10 ) ), victim->wpn[10] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.", capitalize( get_type_weapon( 11 ) ), victim->wpn[11] ); send_to_char( buf, ch ); sprintf( buf, " %-7s : %4d.\n\r", capitalize( get_type_weapon( 12 ) ), victim->wpn[12] ); send_to_char( buf, ch ); sprintf( buf, "%-8s : %3d. %-8s : %3d. %-8s : %3d. %-8s : %3d. %-8s : %3d.\n\r", "Purple", victim->spl[PURPLE_MAGIC], "Red", victim->spl[RED_MAGIC], "Blue", victim->spl[BLUE_MAGIC], "Green", victim->spl[GREEN_MAGIC], "Yellow", victim->spl[YELLOW_MAGIC] ); send_to_char( buf, ch ); sprintf( buf, "%-8s : %3d. %-8s : %3d. %-8s : %3d. %-8s : %3d. %-8s : %3d.\n\r", "Viper", victim->stance[STANCE_VIPER], "Crane", victim->stance[STANCE_CRANE], "Crab", victim->stance[STANCE_CRAB], "Mongoose", victim->stance[STANCE_MONGOOSE], "Bull", victim->stance[STANCE_BULL] ); send_to_char( buf, ch ); sprintf( buf, "%-8s : %3d. %-8s : %3d. %-8s : %3d. %-8s : %-3d. %-8s : %3d.\n\r", "Mantis", victim->stance[STANCE_MANTIS], "Dragon", victim->stance[STANCE_DRAGON], "Tiger", victim->stance[STANCE_TIGER], "Monkey", victim->stance[STANCE_MONKEY], "Swallow", victim->stance[STANCE_SWALLOW] ); send_to_char( buf, ch ); sprintf( buf, "Super Stance Names : %s\n\r", victim->stance[11] > 0 ? victim->pcdata->stancelist : "(None)" ); send_to_char( buf, ch ); sprintf( buf, "SS1 : %3d. SS2 : %3d. SS3 : %3d. SS4 : %3d. SS5 : %3d.\n\r", victim->stance[11], victim->stance[12], victim->stance[13], victim->stance[14], victim->stance[15] ); send_to_char( buf, ch ); } sprintf( buf, "Act : %s\n\r", IS_NPC( victim ) ? act_bit_name( victim->act ) : plr_bit_name( victim->act ) ); send_to_char( buf, ch ); if ( !IS_NPC( victim ) ) { sprintf( buf, "Mod : %s\n\r", victim->pcdata->bodymods <= 0 ? "(None)" : mod_bit_name( victim->pcdata->bodymods ) ); send_to_char( buf, ch ); } sprintf( buf, "Extra : %s\n\r", victim->extra <= 0 ? "(None)" : extra_plr_bit_name( victim->extra ) ); send_to_char( buf, ch ); sprintf( buf, "More : %s\n\r", victim->more <= 0 ? "(None)" : more_bit_name( victim->more ) ); send_to_char( buf, ch ); sprintf( buf, "ItemAff : %s\n\r", victim->itemaffect <= 0 ? "(None)" : itemaffect_bit_name( victim->itemaffect ) ); send_to_char( buf, ch ); sprintf( buf, "Affected by : %s.\n\r", affect_bit_name( victim->affected_by ) ); send_to_char( buf, ch ); return; } void do_pmort( CHAR_DATA *ch, char *argument) { char arg[MAX_INPUT_LENGTH]; CHAR_DATA *victim; DESCRIPTOR_DATA *d; argument = one_argument(argument, arg); if (arg[0] =='\0') { send_to_char("Mort whom?\n\r", ch); return;} if ( get_trust(ch) >= MAX_LEVEL - 1 && !str_cmp(arg,"all")) { for (d = descriptor_list; d != NULL; d = d->next) { victim = d->character; if (victim == NULL || IS_NPC(victim)) continue; { victim->hit = -10; } } } if ( ( victim = get_char_world( ch, arg ) ) == NULL ) { send_to_char( "They aren't here..\n\r", ch) ; return; } victim->hit = -10; send_to_char("Ok, they're morted!\n\r", ch ); } DO_COM( do_kindness ) { CHAR_DATA *victim; char arg[MIL]; if ( IS_NPC( ch ) ) return; one_argument( argument, arg ); if ( arg[0] == '\0' ) { STC( "Who do has shown such an act of Kindness, that they deserve to regain golconda?\n\r", ch ); return; } if ( ( victim = get_char_world( ch, arg ) ) == NULL ) { STC( "They are not here.\n\r", ch ); return; } if ( IS_NPC( victim ) ) { STC( "Not on NPC's.\n\r", ch ); return; } if ( !IS_VAMPIRE( victim ) ) { STC( "Only vampires can regain golconda.\n\r", ch ); return; } if ( victim->beast < 99 || victim->truebeast < 99 ) { STC( "They are still able to gain golconda.\n\r", ch ); return; } victim->truebeast--; act( "$n has given you the chance to regain golconda.\n\r", ch, NULL, victim, TO_VICT ); STC( "You grant them the ability to regain golconda.\n\r", ch ); return; } void do_pfilescan( CHAR_DATA *ch, char *argument ) { char arg1[MSL]; char buf[MSL]; char strsave[MSL]; FILE *fp; argument = one_argument( argument, arg1 ); if (arg1[0] == '\0') { send_to_char("syntax:\n\r",ch); send_to_char("pscan <all> <Searchstring>\n\r",ch); send_to_char("pscan <Player> <Searchstring> \n\r",ch); return; } if (!str_cmp(arg1,"all")) { if (argument[0] == '\0') { send_to_char("Search for what?\n\r",ch); return; } sprintf(buf, "grep -i \"%s\" %s*", argument, PLAYER_DIR); syspipe( ch, buf ); send_to_char("\n\rSearch Complete.\n\r",ch); return; } else { if (argument[0] == '\0') { send_to_char("Search for what?\n\r",ch); return; } sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( arg1 ) ); if ( ( fp = fopen( strsave, "r" ) ) == NULL ) { send_to_char("\n\rCharacter File Not Found\n\r",ch); return; } else { sprintf(buf, "grep -i \"%s\" %s%s", argument, PLAYER_DIR, capitalize( arg1 )); syspipe( ch, buf ); send_to_char("\n\rSearch Complete.\n\r",ch); fclose( fp ); return; } } return; } void do_logscan( CHAR_DATA *ch, char *argument ) { char arg1[MSL]; char buf[MSL]; char strsave[MSL]; FILE *fp; argument = one_argument( argument, arg1 ); if (arg1[0] == '\0') { send_to_char("syntax:\n\r",ch); send_to_char("lscan list\n\r",ch); send_to_char("lscan <Logfile> <Searchstring> \n\r",ch); return; } if (!str_cmp(arg1,"list")) { sprintf( buf, "ls %s", LOG_DIR); syspipe( ch, buf ); send_to_char("\n\rOK.\n\r",ch); return; } else { if (argument[0] == '\0') { send_to_char("Search for what?\n\r",ch); return; } sprintf( strsave, "%s%s", LOG_DIR, arg1 ); if ( ( fp = fopen( strsave, "r" ) ) == NULL ) { send_to_char("\n\rLog File Not Found.\n\r",ch); return; } else { sprintf(buf, "grep -i \"%s\" %s%s", argument, LOG_DIR, arg1); syspipe(ch,buf); send_to_char("\n\rOK.\n\r",ch); fclose( fp ); return; } } return; } void syspipe( CHAR_DATA *ch, char *argument ) { char buf[5000]; FILE *fp; fp = popen( argument, "r" ); fgetf( buf, 5000, fp ); send_to_char( buf, ch ); // hrmm need to develop an echo that handles the output info in pages... pclose( fp ); return; } char *fgetf( char *s, int n, register FILE *iop ) { register int c; register char *cs; c = '\0'; cs = s; while( --n > 0 && (c = getc(iop)) != EOF) if ((*cs++ = c) == '\0') break; *cs = '\0'; return((c == EOF && cs == s) ? NULL : s); }