/*************************************************************************** * 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. * * * * Envy Diku Mud improvements copyright (C) 1994 by Michael Quan, David * * Love, Guilherme 'Willie' Arnold, and Mitchell Tse. * * * * EnvyMud 2.0 improvements copyright (C) 1995 by Michael Quan and * * Mitchell Tse. * * * * In order to use any part of this Envy Diku Mud, you must comply with * * the original Diku license in 'license.doc', the Merc license in * * 'license.txt', as well as the Envy license in 'license.nvy'. * * In particular, you may not remove either of these copyright notices. * * * * 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. * ***************************************************************************/ #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 "merc.h" // Code to show the fraglist is in act_info.c, this file is just for the // processing of the fraglist. FRAG_DATA fraglist; // Code to check if someone just fragged. // Will also have to add to race, class, and guild frag tables in // addition to the master frag table. This does not update any // lists yet and instead only updates the totals. - Veygoth void check_frag( CHAR_DATA *ch, CHAR_DATA *victim ) { // NPC's don't participate in fragging, can't frag yourself, // have to be within 10 levels, no same side frags, no frags // from races not participating in racewars, have to be level // 20 to frag, and have to be a valid class. if( IS_NPC( ch )) return; if( IS_NPC( victim )) return; if( ch == victim ) return; if( race_table[victim->race].racewar_side == RACEWAR_NONE ) return; if( race_table[victim->race].racewar_side == race_table[ch->race].racewar_side ) return; if( IS_IMMORTAL( ch )) return; if( IS_IMMORTAL( victim )) return; if( victim->level < 20 ) return; if( (ch->level - victim->level) > 10 ) return; if( ch->class == CLASS_NONE || victim->class == CLASS_NONE ) return; ch->pcdata->frags++; fraglist.total_race_frags[ch->race]++; fraglist.total_class_frags[ch->class]++; fraglist.total_side_frags[race_table[ch->race].racewar_side]++; if( ch->pcdata->clan ) ch->pcdata->clan->frags++; victim->pcdata->frags--; fraglist.total_race_frags[victim->race]--; fraglist.total_class_frags[victim->class]--; fraglist.total_side_frags[race_table[victim->race].racewar_side]--; if( victim->pcdata->clan ) victim->pcdata->clan->frags--; send_to_char( "&+WYou gain a frag!&n\n\r", ch ); send_to_char( "&+WYou lose a frag!&n\n\r", victim ); save_fraglist(); return; } void load_fraglist( ) { FILE *fp; char strsave[MAX_INPUT_LENGTH]; int races; int classes; int sides; int stat; int count; sprintf( strsave, "%s%s", SYSTEM_DIR, FRAG_FILE ); if( !( fp = fopen( strsave, "r" ) ) ) { bug( "Error opening frag file! Fraglist left blank.", 0 ); return; } log_string( "Loading fraglist" ); sides = fread_number( fp, &stat ); races = fread_number( fp, &stat ); classes = fread_number( fp, &stat ); for( count = 0; count < sides; count++ ) { if( count >= MAX_RACEWAR_SIDE ) break; fraglist.total_side_frags[count] = fread_number( fp, &stat ); } for( count = 0; count < races; count++ ) { if( count >= MAX_PC_RACE ) break; fraglist.total_race_frags[count] = fread_number( fp, &stat ); } for( count = 0; count < classes; count++ ) { if( count >= MAX_CLASS ) break; fraglist.total_class_frags[count] = fread_number( fp, &stat ); } fclose( fp ); fpReserve = fopen( NULL_FILE, "r" ); return; } void save_fraglist( ) { FILE *fp; char strsave[MAX_INPUT_LENGTH]; int count; sprintf( strsave, "%s%s", SYSTEM_DIR, FRAG_FILE ); if( !( fp = fopen( strsave, "w" ) ) ) { bug( "Error opening frag file! Fraglist not written.", 0 ); return; } // Print the current maxes so it doesen't bomb out if we change // the number of races/classes - Veygoth fprintf( fp, "%d\n", MAX_RACEWAR_SIDE ); fprintf( fp, "%d\n", MAX_PC_RACE ); fprintf( fp, "%d\n", MAX_CLASS ); for( count = 0; count < MAX_RACEWAR_SIDE; count++ ) { fprintf( fp, "%d ", fraglist.total_side_frags[count] ); } fprintf( fp, "\n" ); for( count = 0; count < MAX_PC_RACE; count++ ) { fprintf( fp, "%d ", fraglist.total_race_frags[count] ); } fprintf( fp, "\n" ); for( count = 0; count < MAX_CLASS; count++ ) { fprintf( fp, "%d ", fraglist.total_class_frags[count] ); } fprintf( fp, "\n" ); fclose( fp ); fpReserve = fopen( NULL_FILE, "r" ); return; }