/*************************************************************************** * 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. * * * * 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. * ***************************************************************************/ /*************************************************************************** * God Wars Mud copyright (C) 1994, 1995, 1996 by Richard Woolcock * * * * Legend of Chrystancia copyright (C) 1999, 2000, 2001 by Matthew Little * * This mud is NOT to be copied in whole or in part, or to be run without * * the permission of Matthew Little. Nobody else has permission to * * authorise the use of this code. * ***************************************************************************/ #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" /*int clan_table_search args( (CHAR_DATA *ch) );*/ /*void format_string_spaces args ( (char *argument,int spaces) );*/ void artifact_table_write () { int art_pos; FILE *fp; if ((fp = fopen (ART_LIST, "w")) == NULL) perror (LOGIN_FILE); for (art_pos = 0; art_pos < MAX_ART; art_pos++) { fprintf (fp, "%d %s~\n", artifact_table[art_pos].object_vnum, artifact_table[art_pos].player_name); } fflush (fp); fclose (fp); return; } void artifact_table_read () { int art_pos; FILE *fp; if ((fp = fopen (ART_LIST, "r")) != NULL) { for (art_pos = 0; art_pos < MAX_ART; art_pos++) { artifact_table[art_pos].object_vnum = fread_number (fp); artifact_table[art_pos].player_name = fread_string (fp); } } else { bug ("Cannot Open ARTIFACT Table:- Loading Default Table", 0); return; } fflush (fp); fclose (fp); return; } void do_show_artifacts (CHAR_DATA * ch, char *argument) { char buf[MAX_STRING_LENGTH]; OBJ_INDEX_DATA *pObjIndex; int art_pos; for (art_pos = 0; art_pos < MAX_ART; art_pos++) { if ((pObjIndex = get_obj_index (artifact_table[art_pos].object_vnum)) == NULL) continue; if (strlen (artifact_table[art_pos].player_name) < 3 || !str_cmp ((artifact_table[art_pos].player_name), "none")) { sprintf (buf, "%s, which has not yet been discovered.\n\r", pObjIndex->short_descr); } else { sprintf (buf, "%s, which has been discovered by %s.\n\r", pObjIndex->short_descr, artifact_table[art_pos].player_name); } buf[0] = UPPER (buf[0]); send_to_char (buf, ch); } } struct artifact_type artifact_table[MAX_ART] = { {"none", 25}, {"none", 26}, {"none", 27}, {"none", 28}, {"none", 29}, {"none", 30}, {"none", 31}, {"none", 32}, {"none", 33}, {"none", 34}, {"none", 35}, {"none", 36}, {"none", 37}, {"none", 38}, {"none", 39}, {"none", 40}, {"none", 41}, {"none", 42}, {"none", 43}, {"none", 44}, {"none", 45}, {"none", 46}, {"none", 47}, {"none", 29500}, {"none", 29501}, {"none", 29502}, {"none", 29503}, {"none", 29504}, {"none", 29505}, {"none", 29506}, {"none", 29507}, {"none", 29508}, {"none", 29509}, {"none", 29510}, {"none", 29511}, {"none", 29512}, {"none", 29513}, {"none", 29514}, {"none", 29515}, {"none", 29516}, {"none", 29517}, {"none", 29518}, {"none", 29519}, {"none", 29520}, {"none", 29521} }; // This identifies which position in the artifact_table a given artifact holds. -- Serenity int find_arti_pos (int vnum) { int loop_var = 0; for (loop_var = 0; loop_var < MAX_ART; loop_var++) { if (artifact_table[loop_var].object_vnum == vnum) return loop_var; } return -1; } // This identifies whether a given artifact IS part of the artifact table and is // therefore an Artifact. - Serenity bool OBJ_ARTIFACT (OBJ_DATA * obj) { if (find_arti_pos (obj->pIndexData->vnum) > -1) return TRUE; return FALSE; } // Now to determine if a given artifact is in fact TRULY the one we are looking for bool IS_ARTIFACT (OBJ_DATA * obj, int arti_vnum) { if (OBJ_ARTIFACT (obj) == FALSE) return FALSE; if (obj->pIndexData->vnum == arti_vnum) return TRUE; return FALSE; } bool ANY_ARTIFACT (OBJ_DATA * obj1, OBJ_DATA * obj2, OBJ_DATA * obj3, OBJ_DATA * obj4, int arti_vnum) { bool FLAG1 = TRUE; bool FLAG2 = TRUE; bool FLAG3 = TRUE; bool FLAG4 = TRUE; if ((obj1 == NULL) || (OBJ_ARTIFACT (obj1) == FALSE)) FLAG1 = FALSE; if ((obj2 == NULL) || (OBJ_ARTIFACT (obj2) == FALSE)) FLAG2 = FALSE; if ((obj3 == NULL) || (OBJ_ARTIFACT (obj3) == FALSE)) FLAG3 = FALSE; if ((obj4 == NULL) || (OBJ_ARTIFACT (obj4) == FALSE)) FLAG4 = FALSE; if ((!FLAG1) && (!FLAG2) && (!FLAG3) && (!FLAG4)) return FALSE; // All 4 were either null or not artifacts if ((obj1 != NULL) && (IS_ARTIFACT (obj1, arti_vnum))) return TRUE; // Object 1 is Arti Looked For if ((obj2 != NULL) && (IS_ARTIFACT (obj2, arti_vnum))) return TRUE; // Object 2 is Arti Looked For if ((obj3 != NULL) && (IS_ARTIFACT (obj3, arti_vnum))) return TRUE; // Object 3 is Arti Looked For if ((obj4 != NULL) && (IS_ARTIFACT (obj4, arti_vnum))) return TRUE; // Object 4 is Arti Looked For return FALSE; // Guess nothing matched } bool WORN_ARTIFACT (CHAR_DATA * ch, int arti_vnum) { bool FLAG = FALSE; OBJ_DATA *obj; OBJ_DATA *obj_next; for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if (obj->wear_loc == WEAR_NONE) continue; if ((obj == NULL) || (OBJ_ARTIFACT (obj) == FALSE)) continue; if (IS_ARTIFACT (obj, arti_vnum)) // Is this the artifact looked for? FLAG = TRUE; if (FLAG) return TRUE; // Positive arti identification } if (!FLAG) return FALSE; // Everything was either Null or not artifacts return FALSE; // Guess nothing matched } OBJ_DATA *get_artifact (CHAR_DATA * ch, int arti_vnum) { bool FLAG = FALSE; OBJ_DATA *obj; OBJ_DATA *obj_next; for (obj = ch->carrying; obj != NULL; obj = obj_next) { obj_next = obj->next_content; if (obj->wear_loc == WEAR_NONE) continue; if ((obj == NULL) || (OBJ_ARTIFACT (obj) == FALSE)) continue; if (IS_ARTIFACT (obj, arti_vnum)) // Is this the artifact looked for? FLAG = TRUE; if (FLAG) return obj; // Positive arti identification } if (!FLAG) return NULL; // Everything was either Null or not artifacts return NULL; // Guess nothing matched }