/* ************************************************************************ * File: reports.c * * Usage: Misc. functions for on-line status reports * * * ***************************************************************************/ /* (comments to raymond@brokersys.com) These are several functions created to assist me in taking inventory of new areas and spot-checking my own work. There are several functions in here, but only do_wlist needs to be added to the command interpreter. The functions in this file seem a little fragmented since I am still trying to decide exactly what I personally want to display. After the function list I have included a paragraph that can be added to your Wizhelp file. Main function ACMD (do_wlist) sub functions: void do_olist (struct char_data *ch, char *input); List all objs in specified zone. If no arg, it defaults to your current zone. It includes type; for Armor/worn, it shows where and AC; for weapons it shows damage dice and +dam applies. calls: void list_object_zone (struct char_data *ch, int whichzone); int get_weapon_dam (struct obj_data *o); int get_armor_ac (struct obj_data *o); void do_mlist (struct char_data *ch, char *input); List all mobs in specified zone, plus their levels. If no arg, it defaults to your current zone. calls: void list_mob_zone (struct char_data *ch, int whichzone); void list_wands_staves (struct char_data *ch, char *input); void list_scrolls_potions (struct char_data *ch, char *input); List each specified item, giving spell and charge information For Help File: WLIST (World list) Options Wlist obj | mob Wlist S (scrolls) Wlist P (potions) Wlist T (staves) Wlist W (wands) Wlist # (wear position) Wlist o | m This will list all of the mobs or objects available to you, whether loaded in the game or not. If no zone is specified, you will see all mobs/objects in your current zone. Both will display the vnum and short description. For a mob, you'll be given its level. For objects, you'll see the wear position. Also, Armor will show normal and magical AC, and weapons will include damage dice and +damroll apply. If you specify a zone that has no objects because it is the second half of another zone, objects from the earlier zone will be displayed. Wlist S | P | W | T This will list all the magical items available in the game. All four will give the vnum and short description. Wand and sTaff will include the spell it casts and the number of charges it holds. Potion and Scroll will list all the spells of the item. Wlist # N | ? This will list all items which can be worn in a specific position. To see a list of the positions available, use WLIST # ?, then replace the ? with the proper number. Ex: WLIST # ? (List shows WRIST is position 14) WLIST # 14 (displays all wrist-wear in game) # */ #include "conf.h" #include "sysdep.h" #include "structs.h" #include "utils.h" #include "comm.h" #include "interpreter.h" #include "handler.h" #include "db.h" #include "spells.h" #include "screen.h" #include "constants.h" #include "olc.h" /*to avoid repeating NUM_ITEM_WEARS*/ /* external vars */ //extern FILE *player_fl; extern struct room_data *world; extern struct char_data *character_list; extern struct obj_data *object_list; extern struct obj_data *obj_proto; extern struct descriptor_data *descriptor_list; extern struct index_data *mob_index; extern struct index_data *obj_index; extern struct zone_data *zone_table; extern struct char_data *mob_proto; extern zone_rnum top_of_zone_table; extern int circle_shutdown, circle_reboot; extern int circle_restrict; extern mob_rnum top_of_mobt; extern obj_rnum top_of_objt; extern room_rnum top_of_world; extern const char *wear_bits[]; /* local functions */ int get_weapon_dam (struct obj_data *o); int get_armor_ac (struct obj_data *o); void list_object_zone (struct char_data *ch, int whichzone); void list_mob_zone (struct char_data *ch, int whichzone); void do_olist (struct char_data *ch, char *input); void do_mlist (struct char_data *ch, char *input); void do_rlist (struct char_data *ch, char *input); void list_wands_staves (struct char_data *ch, char *input); void list_scrolls_potions (struct char_data *ch, char *input); void do_list_wear (struct char_data *ch, char *input); void list_room_zone (struct char_data *ch, int whichzone) { int i=0; int j=0; room_vnum first_z_room=0; /*vnum of first obj in zone list*/ room_vnum last_z_room=0; /*vnum of last obj in zone list */ int char_zone = ((GET_ROOM_VNUM(ch->in_room))/100); /*initialize to current zone */ buf[0]='\0'; if (whichzone > (-1)) char_zone = whichzone; /*see if specific zone was passed as arg*/ while (j!= char_zone) { first_z_room++; j=(world[i].number/100); i++; /*some zones have 100+ rooms but not 100+ items/objs. To find the needed objs/objects, * search backwards for previous zone.*/ if (j>char_zone) { if (char_zone>0) { char_zone--; first_z_room=0; i=0; j=0; } else { log("SYSERR: rlist looked for a zone < 0"); return; } } } first_z_room --; last_z_room=first_z_room; while (j == char_zone) { j=(world[i].number/100); last_z_room++; i++; } if (first_z_room<0) first_z_room ++; for (i=first_z_room;idesc,buf,1); return; } void do_rlist (struct char_data *ch, char *input) { int i=0; if (!(*input)) list_room_zone(ch,(-1)); else { skip_spaces(&input); if (is_number(input)) list_room_zone(ch,atoi(input)); else list_room_zone(ch,((GET_ROOM_VNUM(ch->in_room)) / 100)); } return; } int get_weapon_dam (struct obj_data *o) { int i = 0; for (i;iaffected[i].location == APPLY_DAMROLL) { return (o->affected[i].modifier); } return (0); } int get_armor_ac (struct obj_data *o) { int i = 0; for (i;iaffected[i].location == APPLY_AC) { return (o->affected[i].modifier); } return (0); } void list_object_zone (struct char_data *ch, int whichzone) { int i=0; int j=0; obj_vnum first_z_obj=0; /*vnum of first obj in zone list*/ obj_vnum last_z_obj=0; /*vnum of last obj in zone list */ int char_zone = ((GET_ROOM_VNUM(ch->in_room))/100); /*initialize to current zone */ buf[0]='\0'; if (whichzone > (-1)) char_zone = whichzone; /*see if specific zone was passed as arg*/ while (j!= char_zone) { first_z_obj++; j=(GET_OBJ_VNUM(&obj_proto[i])/100); i++; /*some zones have 100+ rooms but not 100+ items/objs. To find the needed objs/objects, * search backwards for previous zones w/them.*/ if (j>char_zone) { if (char_zone>0) { char_zone--; first_z_obj=0; i=0; j=0; } else { log("SYSERR: olist looked for a zone < 0"); return; } } } first_z_obj --; last_z_obj=first_z_obj; while (j == char_zone) { j=(GET_OBJ_VNUM(&obj_proto[i])/100); last_z_obj++; i++; } if (first_z_obj<0) first_z_obj ++; for (i=first_z_obj;idesc,buf,1); return; } void do_olist (struct char_data *ch, char *input) { int i=0; if (!(*input)) list_object_zone(ch,(-1)); else { skip_spaces(&input); if (is_number(input)) list_object_zone(ch,atoi(input)); else list_object_zone(ch,((GET_ROOM_VNUM(ch->in_room)) / 100)); } return; } void list_mob_zone (struct char_data *ch, int whichzone) { int i=0; int j=0; mob_vnum first_z_mob=0; /*vnum of first mob in zone list*/ mob_vnum last_z_mob=0; /*vnum of last mob in zone list */ int char_zone = ((GET_ROOM_VNUM(ch->in_room))/100); /*initialize to current zone */ buf[0]='\0'; if (whichzone > (-1)) char_zone = whichzone; /*see if specific zone was passed as arg*/ while (j!= char_zone) { first_z_mob++; j=(GET_MOB_VNUM(&mob_proto[i])/100); i++; /*some zones have 100+ rooms but not 100+ items/mobs. To find the needed mobs/objects, * search backwards for previous zonew/them.*/ if (j>char_zone) { if (char_zone>0) { char_zone--; first_z_mob=0; i=0; j=0; } else { log("SYSERR: mlist looked for a zone < 0"); return; } } } first_z_mob --; last_z_mob=first_z_mob; while (j == char_zone) { j=(GET_MOB_VNUM(&mob_proto[i])/100); last_z_mob++; i++; } if (first_z_mob<0) first_z_mob ++; for (i=first_z_mob;idesc,buf,1); return; } void do_mlist (struct char_data *ch, char *input) { if (!(*input)) list_mob_zone(ch,(-1)); else { skip_spaces(&input); if (is_number(input)) list_mob_zone(ch,atoi(input)); else list_mob_zone(ch,((GET_ROOM_VNUM(ch->in_room)) / 100)); } return; } void list_wands_staves (struct char_data *ch, char *input) { int type=0; int i=0; int j=0; int k=0; skip_spaces(&input); switch (input[0]) { case 'T': case 't': type = ITEM_STAFF; break; case 'W': case 'w': type = ITEM_WAND; break; default: { sprintf(buf,"SYSERR: Default reached in list_scrolls_potions (arg = %s)", input); log(buf); return; } } /*switch...*/ buf[0]='\0'; for (i=0;idesc, buf, 1); } void list_scrolls_potions (struct char_data *ch, char *input) { int type=0; int i=0; int j=0; int k=0; skip_spaces(&input); switch (input[0]) { case 'S': case 's': type = ITEM_SCROLL; break; case 'P': case 'p': type = ITEM_POTION; break; default : sprintf(buf,"SYSERR: Default reached in list_scrolls_potions (arg = %s)", input); log (buf); return; } /*switch...*/ buf[0]='\0'; for (i=0;idesc, buf, 1); } void do_list_wear (struct char_data *ch, char *input) { char j = atoi(input); int i=0; if (input[0] == '?') { j=0; send_to_char ("Wear positions:\r\n", ch); for (i = 0; i < NUM_ITEM_WEARS; i++) { sprintf(buf, "(%2d) %-20.20s %s", i + 1, wear_bits[i], !(++j % 2) ? "\r\n" : ""); send_to_char(buf, ch); } send_to_char("\r\nIf you choose TAKE, you will be shown item that are !Take\r\n",ch); return; } buf[0]='\0'; j--; /*to be used with NAMES array*/ if (j==0) /*Show ony !Take items for this option*/ { for (i=0;idesc, buf, 1); return; } for (i=0;idesc, buf, 1); } ACMD (do_wlist) { char *message="Usage: wlist < o | m | s | t | w | p | b | r | # (?)> \r\nType HELP WLIST for details\r\n"; two_arguments(argument, buf, buf2); if (!*buf) { send_to_char(message,ch); return; } switch (buf[0]) { case 'O': case 'o': do_olist(ch, buf2); break; case 'M': case 'm': do_mlist(ch, buf2); break; case 'T': case 't': case 'W': case 'w': list_wands_staves(ch,buf); break; case 'P': case 'p': case 'S': case 's': list_scrolls_potions(ch,buf); break; case 'R': case 'r': do_rlist(ch,buf2); break; case '#': do_list_wear(ch, buf2); break; default: send_to_char (message, ch); break; } /*switch...*/ return; }