I have read the discussion about scan command. This is my scan command; if you use it, PLEASE, send me a mail, just tell me if you like it. And if you found any bug, PLEEEEEAASSE!!!! tell me. mailto:leherrer@entelchile.net (I speak spanish, so, some variable names are in my Lingua Materna :) ) --------- Begin Scan Code --------------- #define R_EXIT(n, door) (world[n].dir_option[door]) #define SLIGHT_OK(sub, obj) \ (!IS_AFFECTED(sub, AFF_BLIND) &&\ (IS_LIGHT((obj)->in_room) || IS_AFFECTED((sub), AFF_INFRAVISION))) #define SMORT_CAN_SEE(sub, obj)\ (SLIGHT_OK(sub, obj) && INVIS_OK(sub, obj)) #define SIMM_CAN_SEE(sub, obj) \ (SMORT_CAN_SEE(sub, obj) || PRF_FLAGGED(sub, PRF_HOLYLIGHT)) /* Can subject see character "obj"? */ #define SCAN_SEE(sub, obj) (SELF(sub, obj) || \ ((GET_REAL_LEVEL(sub) >= GET_INVIS_LEV(obj)) && SIMM_CAN_SEE(sub, obj))) /* End of SCAN_SEE */ int ExitOk( int n, int aux, int tf ) { int x, m=n; for (x=0; x<tf; x++ ) { if ((R_EXIT(m, aux)) && (R_EXIT(m,aux)->to_room != NOWHERE) && (!IS_SET(R_EXIT(m, aux)->exit_info, EX_CLOSED))) m = R_EXIT(m, aux)->to_room; else return( FALSE ); } return( TRUE ); } int GetRoomNum( int n, int direction, int tf ) { int x, m=n; for (x=0; x<tf; x++ ) { if ((R_EXIT(m, direction)) && (R_EXIT(m,direction)->to_room != NOWHERE) && (!IS_SET(R_EXIT(m, direction)->exit_info, EX_CLOSED))) m = R_EXIT(m, direction)->to_room; else return( NOWHERE ); } return( m ); } void list_per(struct char_data * i, struct char_data * ch, char * dirr ) { if (IS_NPC(i) && i->player.short_descr ) sprintf(buf, "%s%s%-30s\r\n", buf, dirr, i->player.short_descr ); else sprintf(buf, "%s%s%s%-30s%s\r\n", buf, dirr, CCGRN(ch,C_SPR), i->player.name, CCNRM(ch, C_SPR) ) ; return; } short list_pers(struct char_data * list, struct char_data * ch, char * dirr ) { struct char_data *i; short bandera=0; for (i = list; i; i = i->next_in_room) if (ch != i) if (SCAN_SEE(ch, i)) { bandera=1; list_per( i, ch, dirr ); } return(bandera); } /* This defines the number of rooms that you can see... ten is too much, but... :) */ #define MAX_SCAN 10 ACMD(do_scan) { int door, x; char dirr[80]; short bandera=0; dirr[0] = '\0'; act("$n scans the area.", TRUE, ch, 0, 0, TO_ROOM); { strcpy( buf, "You scan the area:\r\n"); strcpy( dirr, "[Right Here] " ); bandera = list_pers(world[ch->in_room].people, ch, dirr ); for (door = 0; door < NUM_OF_DIRS; door++) for (x=1; x<MAX_SCAN; x++ ) if (ExitOk(ch->in_room, door, x)) { dirr[0] = '\0'; sprintf( dirr, "[%-8s, square %2d] ", x, dirs[door] ); bandera += list_pers( world[GetRoomNum(ch->in_room,door,x)].people, ch, dirr ); if (strlen(buf) > MAX_STRING_LENGTH - 30) { strcat(buf, "*** Truncated ***\r\n" ); door = NUM_OF_DIRS+1; } } if (bandera == 0) sprintf( buf, "%sNobody.\r\n", buf ); } page_string( ch->desc, buf, 1 ); } +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST